summaryrefslogtreecommitdiffstats
path: root/common/src/main/webapp/usageguide/appserver/node_modules/mongoose
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-08-07 11:39:39 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-08-07 11:39:39 +0800
commit21d72c4a80fe2937d0c4ddd20624b27adbcd989b (patch)
treee5013ee12f74f8452e01cbff16e7b0158bc456cb /common/src/main/webapp/usageguide/appserver/node_modules/mongoose
parentf533e73e2ae32e010b16abdcf7985abaf31ab843 (diff)
Upload the ESR GUI seed code
Issue-ID: AAI-68 Change-Id: Ia50ce0570c2fabecd77199d4e8454f56fe587c4e Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/mongoose')
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintignore3
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintrc.yml31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.npmignore16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.travis.yml15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/CONTRIBUTING.md56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/History.md3328
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/README.md322
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js103
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js77
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js100
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js84
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js100
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js134
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js103
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js109
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js124
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js138
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js106
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js94
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js79
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js71
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js119
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/index.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/ES6Promise.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/aggregate.js685
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browser.js126
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browserDocument.js103
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/cast.js248
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/collection.js210
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connection.js854
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connectionstate.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document.js2615
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.web.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/SPEC.md4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/ReadPreference.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/binary.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/index.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/objectid.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.web.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js267
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js386
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/browserMissingSchema.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/cast.js60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/disconnected.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/divergentArray.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/messages.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/missingSchema.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/objectExpected.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/overwriteModel.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/strict.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validation.js63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validator.js81
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/version.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/index.js818
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/internal.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/model.js3414
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise.js314
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise_provider.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/query.js3413
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querycursor.js314
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/queryhelpers.js78
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querystream.js367
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema.js1768
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/array.js314
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/boolean.js103
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/buffer.js188
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/date.js296
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/documentarray.js313
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/embedded.js177
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/index.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/mixed.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/number.js290
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/objectid.js207
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/bitwise.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/geospatial.js100
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/helpers.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/string.js516
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schematype.js931
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/common.js87
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/setDefaultsOnInsert.js96
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/updateValidators.js100
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/statemachine.js178
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/array.js778
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/buffer.js273
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/documentarray.js256
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/embedded.js347
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/index.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/objectid.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/subdocument.js152
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/utils.js868
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/virtualtype.js103
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/CHANGELOG.md219
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/LICENSE19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/README.md12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/apply.js62
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEach.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEachSeries.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/asyncify.js93
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/auto.js285
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/autoInject.js167
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/bower.json17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/cargo.js95
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/compose.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concat.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concatSeries.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/constant.js65
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detect.js61
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectLimit.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectSeries.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dir.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.js5427
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.min.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doDuring.js60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doUntil.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doWhilst.js54
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/during.js71
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/each.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachLimit.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOf.js105
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfLimit.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfSeries.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachSeries.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/ensureAsync.js69
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/every.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everyLimit.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everySeries.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filter.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterLimit.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterSeries.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/forever.js61
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/index.js505
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/DoublyLinkedList.js63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/applyEach.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/breakLoop.js9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/concat.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/consoleFunc.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/createTester.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doLimit.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallel.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallelLimit.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doSeries.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/eachOfLimit.js71
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/filter.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/findGetResult.js10
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/getIterator.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/initialParams.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/iterator.js58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/map.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/notId.js10
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/once.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/onlyOnce.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/parallel.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/queue.js184
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/reject.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/setImmediate.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/withoutIndex.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/log.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/map.js54
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapLimit.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapSeries.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValues.js63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesLimit.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesSeries.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/memoize.js95
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/nextTick.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/LICENSE47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/README.md39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_DataView.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Hash.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LazyWrapper.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_ListCache.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LodashWrapper.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Map.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_MapCache.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Promise.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Set.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_SetCache.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Stack.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Symbol.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Uint8Array.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_WeakMap.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addMapEntry.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addSetEntry.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_apply.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayAggregator.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEach.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEachRight.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEvery.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayFilter.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludes.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludesWith.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayLikeKeys.js49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayMap.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayPush.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduce.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduceRight.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySample.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySampleSize.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayShuffle.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySome.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiSize.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiToArray.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiWords.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignInDefaults.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignMergeValue.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignValue.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assocIndexOf.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAggregator.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssign.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignIn.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignValue.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAt.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClamp.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClone.js153
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConforms.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConformsTo.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseCreate.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDelay.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDifference.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEach.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEachRight.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEvery.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseExtremum.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFill.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFilter.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindIndex.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindKey.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFlatten.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFor.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwn.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwnRight.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForRight.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFunctions.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGet.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetAllKeys.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetTag.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGt.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHas.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHasIn.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInRange.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOf.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOfWith.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIntersection.js74
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInverter.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInvoke.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArguments.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArrayBuffer.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsDate.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqual.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqualDeep.js88
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMap.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMatch.js62
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNaN.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNative.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsRegExp.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsSet.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsTypedArray.js60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIteratee.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeys.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeysIn.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLodash.js10
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLt.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMap.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatches.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatchesProperty.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMean.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMerge.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMergeDeep.js93
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseNth.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseOrderBy.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePick.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePickBy.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseProperty.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyDeep.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyOf.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAll.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAt.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRandom.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRange.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseReduce.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRepeat.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRest.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSample.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSampleSize.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSet.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetData.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetToString.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseShuffle.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSlice.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSome.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortBy.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndex.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndexBy.js64
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedUniq.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSum.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseTimes.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToNumber.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToPairs.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToString.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnary.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUniq.js72
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnset.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUpdate.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseValues.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWhile.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWrapperValue.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseXor.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseZipObject.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cacheHas.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castArrayLikeObject.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castFunction.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castPath.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castRest.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castSlice.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsEndIndex.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsStartIndex.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneArrayBuffer.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneBuffer.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneDataView.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneMap.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneRegExp.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSet.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSymbol.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneTypedArray.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareAscending.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareMultiple.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgs.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgsRight.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyArray.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyObject.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbols.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbolsIn.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_coreJsData.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_countHolders.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAggregator.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAssigner.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseEach.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseFor.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBind.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCaseFirst.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCompounder.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCtor.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCurry.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFind.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFlow.js82
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createHybrid.js92
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createInverter.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createMathOperation.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createOver.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPadding.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPartial.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRange.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRecurry.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRelationalOperation.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRound.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createSet.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createToPairs.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createWrap.js106
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_deburrLetter.js71
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_defineProperty.js11
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalArrays.js83
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalByTag.js112
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalObjects.js89
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeHtmlChar.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeStringChar.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_flatRest.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_freeGlobal.js4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeys.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeysIn.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getData.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getFuncName.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getHolder.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMapData.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMatchData.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getNative.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getPrototype.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getRawTag.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbols.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbolsIn.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getTag.js58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getValue.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getView.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getWrapDetails.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasPath.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicode.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicodeWord.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashClear.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashDelete.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashGet.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashHas.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashSet.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneArray.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneByTag.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneObject.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_insertWrapDetails.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isFlattenable.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIndex.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIterateeCall.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKey.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKeyable.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isLaziable.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMaskable.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMasked.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isPrototype.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isStrictComparable.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_iteratorToArray.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyClone.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyReverse.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyValue.js73
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheClear.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheDelete.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheGet.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheHas.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheSet.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheClear.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheDelete.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheGet.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheHas.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheSet.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapToArray.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_matchesStrictComparable.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_memoizeCapped.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeData.js90
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeDefaults.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_metaMap.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeCreate.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeys.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeysIn.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nodeUtil.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_objectToString.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overArg.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overRest.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_parent.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEscape.js4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEvaluate.js4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reInterpolate.js4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_realNames.js4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reorder.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_replaceHolders.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_root.js9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheAdd.js19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheHas.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setData.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToArray.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToPairs.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToString.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setWrapToString.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shortOut.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shuffleSelf.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackClear.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackDelete.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackGet.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackHas.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackSet.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictIndexOf.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictLastIndexOf.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringSize.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToArray.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToPath.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toKey.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toSource.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unescapeHtmlChar.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeSize.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeToArray.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeWords.js69
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_updateWrapDetails.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_wrapperClone.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/add.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/after.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/array.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ary.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assign.js58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignIn.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignInWith.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignWith.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/at.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/attempt.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/before.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bind.js57
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindAll.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindKey.js68
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/camelCase.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/capitalize.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/castArray.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ceil.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chain.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chunk.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clamp.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clone.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeep.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeepWith.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneWith.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/collection.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/commit.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/compact.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/concat.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cond.js60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conforms.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conformsTo.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/constant.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.js3839
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.min.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/countBy.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/create.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curry.js57
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curryRight.js54
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/date.js3
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/debounce.js188
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/deburr.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultTo.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaults.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultsDeep.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defer.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/delay.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/difference.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceBy.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceWith.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/divide.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/drop.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRight.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRightWhile.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropWhile.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/each.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eachRight.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/endsWith.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entries.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entriesIn.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eq.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escape.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escapeRegExp.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/every.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extend.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extendWith.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fill.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/filter.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/find.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findIndex.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findKey.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLast.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastIndex.js59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastKey.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/first.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMap.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDeep.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDepth.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatten.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDeep.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDepth.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flip.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/floor.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flow.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flowRight.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEach.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEachRight.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forIn.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forInRight.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwn.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwnRight.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/F.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/T.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/__.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_baseConvert.js567
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_convertBrowser.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_falseOptions.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_mapping.js367
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_util.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/add.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/after.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/all.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/allPass.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/always.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/any.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/anyPass.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/apply.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/array.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ary.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assign.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAllWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAllWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assoc.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assocPath.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/at.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/attempt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/before.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bind.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindKey.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/camelCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/capitalize.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/castArray.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ceil.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chain.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chunk.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clamp.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clone.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeepWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/collection.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/commit.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compact.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/complement.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compose.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/concat.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cond.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conforms.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conformsTo.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/constant.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/contains.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/convert.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/countBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/create.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curry.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryN.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRightN.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/date.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/debounce.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/deburr.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultTo.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaults.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeepAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defer.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/delay.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/difference.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissoc.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissocPath.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/divide.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/drop.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLast.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLastWhile.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRightWhile.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropWhile.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/each.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eachRight.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/endsWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entries.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entriesIn.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eq.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/equals.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escape.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escapeRegExp.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/every.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extend.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAll.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAllWith.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendWith.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fill.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/filter.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/find.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndex.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndexFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findKey.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLast.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndex.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndexFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastKey.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/first.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDeep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDepth.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatten.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDeep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDepth.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flip.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/floor.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flow.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flowRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEach.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEachRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forInRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwnRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fromPairs.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/function.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functions.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functionsIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/get.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/getOr.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/groupBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gte.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/has.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/hasIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/head.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identical.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identity.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/inRange.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includes.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includesFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexBy.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOfFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/init.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/initial.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersection.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invert.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertObj.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invoke.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgs.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgsMap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeMap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArguments.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArray.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayBuffer.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLike.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLikeObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBoolean.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBuffer.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isDate.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isElement.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEmpty.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqual.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqualWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isError.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFinite.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFunction.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isInteger.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isLength.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatch.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatchWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNaN.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNative.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNil.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNull.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNumber.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObjectLike.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isPlainObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isRegExp.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSafeInteger.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSet.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isString.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSymbol.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isTypedArray.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isUndefined.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakMap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakSet.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/iteratee.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/join.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/juxt.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/kebabCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keyBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keys.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keysIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lang.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/last.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOfFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerFirst.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lte.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/map.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapKeys.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapValues.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matches.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matchesProperty.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/math.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/max.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/maxBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mean.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/meanBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/memoize.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/merge.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAllWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/method.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/methodOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/min.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/minBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mixin.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/multiply.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nAry.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/negate.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/next.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/noop.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/now.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nth.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nthArg.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/number.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/object.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omit.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitAll.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/once.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/orderBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/over.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overArgs.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overEvery.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overSome.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pad.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padChars.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsEnd.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsStart.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padEnd.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padStart.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/parseInt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partial.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partialRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partition.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/path.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathEq.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathOr.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/paths.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pick.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickAll.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pipe.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/placeholder.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/plant.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pluck.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/prop.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propEq.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propOr.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/property.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propertyOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/props.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pull.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/random.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/range.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStepRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rearg.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduce.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduceRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/remove.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/repeat.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/replace.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rest.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/restFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/result.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reverse.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/round.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sample.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sampleSize.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/seq.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/set.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/setWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/shuffle.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/size.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/slice.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/snakeCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/some.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndex.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndex.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniq.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniqBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/split.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spread.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spreadFrom.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startsWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/string.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubArray.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubFalse.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubString.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubTrue.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/subtract.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sum.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sumBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifference.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceBy.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceWith.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tail.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/take.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLast.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLastWhile.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRight.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRightWhile.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeWhile.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/template.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/templateSettings.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/throttle.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/thru.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/times.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toArray.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toFinite.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toInteger.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toIterator.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toJSON.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLength.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLower.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toNumber.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairs.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairsIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPath.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPlainObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toSafeInteger.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toString.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toUpper.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/transform.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trim.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimChars.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsEnd.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsStart.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimEnd.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimStart.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/truncate.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unapply.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unary.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unescape.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/union.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniq.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqueId.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unnest.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unset.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzip.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzipWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/update.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/updateWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperCase.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperFirst.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/useWith.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/util.js2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/value.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valueOf.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/values.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valuesIn.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/where.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/whereEq.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/without.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/words.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrap.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperAt.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperChain.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperLodash.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperReverse.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperValue.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xor.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorBy.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zip.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipAll.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObj.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObject.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObjectDeep.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipWith.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fromPairs.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/function.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functions.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functionsIn.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/get.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/groupBy.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gt.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gte.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/has.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/hasIn.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/head.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/identity.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/inRange.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/includes.js53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/index.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/indexOf.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/initial.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersection.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionBy.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionWith.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invert.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invertBy.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invoke.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invokeMap.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArguments.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArray.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayBuffer.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLike.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLikeObject.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBoolean.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBuffer.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isDate.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isElement.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEmpty.js77
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqual.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqualWith.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isError.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFinite.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFunction.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isInteger.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isLength.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMap.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatch.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatchWith.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNaN.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNative.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNil.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNull.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNumber.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObject.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObjectLike.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isPlainObject.js62
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isRegExp.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSafeInteger.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSet.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isString.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSymbol.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isTypedArray.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isUndefined.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakMap.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakSet.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/iteratee.js53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/join.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/kebabCase.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keyBy.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keys.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keysIn.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lang.js58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/last.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lastIndexOf.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.js17065
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.min.js136
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerCase.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerFirst.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lt.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lte.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/map.js53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapKeys.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapValues.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matches.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matchesProperty.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/math.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/max.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/maxBy.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mean.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/meanBy.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/memoize.js73
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/merge.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mergeWith.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/method.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/methodOf.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/min.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/minBy.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mixin.js74
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/multiply.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/negate.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/next.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/noop.js17
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/now.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nth.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nthArg.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/number.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/object.js49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omit.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omitBy.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/once.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/orderBy.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/over.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overArgs.js61
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overEvery.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overSome.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/package.json70
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pad.js49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padEnd.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padStart.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/parseInt.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partial.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partialRight.js49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partition.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pick.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pickBy.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/plant.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/property.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/propertyOf.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pull.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAll.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllBy.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllWith.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAt.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/random.js82
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/range.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rangeRight.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rearg.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduce.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduceRight.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reject.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/remove.js53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/repeat.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/replace.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rest.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/result.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reverse.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/round.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sample.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sampleSize.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/seq.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/set.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/setWith.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/shuffle.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/size.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/slice.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/snakeCase.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/some.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortBy.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndex.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexBy.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexOf.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndex.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexBy.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexOf.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniq.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniqBy.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/split.js52
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/spread.js63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startCase.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startsWith.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/string.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubArray.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubFalse.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubObject.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubString.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubTrue.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/subtract.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sum.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sumBy.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tail.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/take.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRight.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRightWhile.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeWhile.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tap.js29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/template.js238
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/templateSettings.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/throttle.js69
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/thru.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/times.js51
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toArray.js58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toFinite.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toInteger.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toIterator.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toJSON.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLength.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLower.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toNumber.js66
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairs.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairsIn.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPath.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPlainObject.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toSafeInteger.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toString.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toUpper.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/transform.js65
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trim.js49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimEnd.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimStart.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/truncate.js111
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unary.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unescape.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/union.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionBy.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionWith.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniq.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqBy.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqWith.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqueId.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unset.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzip.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzipWith.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/update.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/updateWith.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperCase.js27
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperFirst.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/util.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/value.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valueOf.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/values.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valuesIn.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/without.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/words.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrap.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperAt.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperChain.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperLodash.js147
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperReverse.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperValue.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xor.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorBy.js39
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorWith.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zip.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObject.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObjectDeep.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipWith.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/package.json121
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallel.js87
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallelLimit.js41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/priorityQueue.js99
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/queue.js120
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/race.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduce.js73
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduceRight.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflect.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflectAll.js104
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reject.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectLimit.js36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectSeries.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retry.js152
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retryable.js56
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/seq.js79
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/series.js85
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/setImmediate.js45
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/some.js52
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someLimit.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someSeries.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/sortBy.js85
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timeout.js85
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/times.js50
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesLimit.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesSeries.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/transform.js85
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/unmemoize.js25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/until.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/waterfall.js114
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/whilst.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/HISTORY.md179
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/LICENSE.md201
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/README.md95
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/bson.js1574
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/faster_bson.js429
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/bower.json25
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/bson.js4843
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/package.json8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/deserializer_bak.js357
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/binary.js347
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/bson.js327
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/code.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/db_ref.js32
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/decimal128.js728
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/double.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/float_parser.js121
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/index.js90
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/int_32.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/long.js856
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/map.js126
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/max_key.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/min_key.js14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/objectid.js343
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/calculate_size.js152
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/deserializer.js653
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/serializer.js991
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/regexp.js30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/symbol.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/timestamp.js856
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/package.json81
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/tools/gleak.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/Makefile9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/README.md369
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.alt.js134
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.js188
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/package.json70
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/test.js786
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.npmignore28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.travis.yml9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/LICENSE202
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/Makefile5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/README.md379
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/docs.js37
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/gulpfile.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/index.js312
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/package.json63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/examples.test.js339
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/post.test.js155
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/pre.test.js256
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/wrap.test.js347
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/.coveralls.yml1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/HISTORY.md1547
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/LICENSE201
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/Makefile11
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/README.md415
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/boot_auth.js52
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/conf.json73
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/index.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/insert_bench.js231
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/admin.js581
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js444
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/apm.js613
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js440
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js539
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js542
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/collection.js3360
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js320
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/cursor.js1182
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/db.js1886
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js399
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js366
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js525
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js233
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js1956
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/metadata.js64
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js328
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongos.js509
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/read_preference.js131
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/replset.js559
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/server.js507
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js191
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js406
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/utils.js313
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/CHANGELOG.md65
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/LICENSE19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/README.md74
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.js959
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.min.js9
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise.umd.js18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/-internal.js273
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/asap.js119
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/enumerator.js118
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/polyfill.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise.js384
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/all.js52
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/race.js86
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/reject.js46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/resolve.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/then.js34
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/utils.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/package.json95
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/.coveralls.yml1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/HISTORY.md559
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/LICENSE201
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/Makefile11
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/README.md228
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/TESTING.md18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/conf.json59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/connect_test.js72
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/gssapi.js266
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js185
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/plain.js170
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js345
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/sspi.js255
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/x509.js165
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/command_result.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/commands.js555
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js568
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/logger.js229
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js1220
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/utils.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js699
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/tools/smoke_plugin.js59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/mongos.js1112
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/read_preference.js119
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js1365
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset_state.js948
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js842
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/shared.js225
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js569
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js332
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js541
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/commands.js357
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/shared.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.npmignore33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.travis.yml6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/LICENSE201
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/README.md2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/index.js109
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver.cmd7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/index.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/license21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/package.json63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/readme.md58
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/LICENSE15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/README.md350
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/bin/semver133
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/package.json59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/range.bnf16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/semver.js1203
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/package.json68
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/test/require_optional_tests.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/package.json74
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/simple_2_document_limit_toArray.dat11000
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test.js71
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test1.js72
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.npmignore8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.travis.yml49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/LICENSE18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/README.md36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/stream.md2015
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/duplex.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_duplex.js75
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_passthrough.js26
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_readable.js937
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_transform.js180
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_writable.js526
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/internal/streams/BufferList.js64
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/index.js108
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/license.md19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/package.json49
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/readme.md21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/LICENSE19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/README.md3
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/float.patch604
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/lib/util.js107
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/package.json59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/test.js68
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/LICENSE16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/README.md42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits.js7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits_browser.js23
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/package.json63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.npmignore1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.travis.yml4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/Makefile6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/README.md60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/component.json19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/index.js5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/package.json70
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/test.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/.travis.yml12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/index.js43
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/license.md19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/package.json48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/readme.md18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/test.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/LICENSE20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/README.md7
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/index.js221
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/package.json53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/History.md16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/LICENSE24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/README.md53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/browser.js67
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/node.js6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/package.json53
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/package.json90
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/passthrough.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/readable.js16
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/transform.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/writable.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/package.json90
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.travis.yml4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/History.md30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/Makefile8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/README.md278
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.js109
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.log0
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.out69
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/component.json8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/index.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/lib/index.js215
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/package.json48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/test/index.js1790
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.npmignore4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.travis.yml5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/History.md80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/README.md224
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/lib/promise.js445
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/package.json65
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.domain.test.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.test.js554
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promises.Aplus.js15
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.npmignore3
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.travis.yml8
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/History.md265
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/Makefile22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/README.md1219
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/collection.js42
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/index.js13
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/node.js108
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/env.js22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/mquery.js2728
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/permissions.js88
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/utils.js342
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/LICENSE21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/README.md679
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/changelog.md1723
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.js4887
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.min.js31
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/any.js21
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/assert.js55
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/async.js150
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bind.js72
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bluebird.js11
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/call_get.js123
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/cancel.js48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/captured_trace.js493
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/catch_filter.js66
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/context.js38
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/debuggability.js162
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/direct_resolve.js63
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/each.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/errors.js111
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/es5.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/filter.js12
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/finally.js98
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/generators.js136
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/join.js107
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/map.js133
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/method.js44
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/nodeify.js59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/progress.js76
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise.js754
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_array.js142
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_resolver.js123
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promisify.js307
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/props.js79
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/queue.js90
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/race.js47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/reduce.js148
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/schedule.js35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/settle.js40
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/some.js125
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/synchronous_inspection.js94
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/thenables.js84
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/timers.js64
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/using.js213
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/util.js321
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/package.json100
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.jshintrc3
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.npmignore6
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/History.md195
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Makefile36
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Readme.md188
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/bower.json28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/browser.js168
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/component.json19
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/debug.js197
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/node.js209
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/package.json73
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.travis.yml4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/History.md30
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/Makefile5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/README.md62
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/bench.js95
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/component.json14
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/index.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/lib/sliced.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/package.json47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/test/index.js80
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/package.json72
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/browser.js0
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/mongo.js0
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/node.js28
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/env.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/index.js2857
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/utils.test.js143
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/.npmignore5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/History.md66
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/LICENSE20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/README.md35
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/index.js125
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/package.json48
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.travis.yml4
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/History.md59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/Makefile5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/README.md46
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/index.js1
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/lib/index.js241
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/package.json60
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/test/index.js328
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.npmignore2
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.travis.yml5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/History.md5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/Makefile5
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/README.md18
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/index.js20
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/package.json47
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/test/index.js112
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/History.md41
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/LICENSE22
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/README.md62
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/index.js33
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/package.json59
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/package.json135
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/release-items.md29
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/static.js24
-rw-r--r--common/src/main/webapp/usageguide/appserver/node_modules/mongoose/website.js87
1648 files changed, 184057 insertions, 0 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintignore
new file mode 100644
index 0000000..235bdcd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintignore
@@ -0,0 +1,3 @@
+docs/
+bin/
+test/triage/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintrc.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintrc.yml
new file mode 100644
index 0000000..013d2ec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.eslintrc.yml
@@ -0,0 +1,31 @@
+extends: 'eslint:recommended'
+
+env:
+ node: true
+ mocha: true
+
+rules:
+ comma-style: error
+ consistent-this:
+ - error
+ - _this
+ indent:
+ - error
+ - 2
+ - SwitchCase: 1
+ VariableDeclarator: 2
+ keyword-spacing: error
+ no-console: off
+ no-multi-spaces: error
+ no-spaced-func: error
+ no-trailing-spaces: error
+ quotes:
+ - error
+ - single
+ semi: error
+ space-before-blocks: error
+ space-before-function-paren:
+ - error
+ - never
+ space-infix-ops: error
+ space-unary-ops: error
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.npmignore
new file mode 100644
index 0000000..377d63f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.npmignore
@@ -0,0 +1,16 @@
+lib-cov
+**.swp
+*.sw*
+*.orig
+.DS_Store
+node_modules/
+benchmarks/
+docs/
+test/
+Makefile
+CNAME
+index.html
+index.jade
+bin/
+karma.*.js
+format_deps.js
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.travis.yml
new file mode 100644
index 0000000..23b799d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/.travis.yml
@@ -0,0 +1,15 @@
+language: node_js
+sudo: false
+node_js:
+ - "7"
+ - "6"
+ - "5"
+ - "4"
+ - "0.12"
+ - "0.10"
+ - "iojs"
+before_script:
+ - wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.11.tgz
+ - tar -zxvf mongodb-linux-x86_64-2.6.11.tgz
+ - mkdir -p ./data/db
+ - ./mongodb-linux-x86_64-2.6.11/bin/mongod --fork --nopreallocj --dbpath ./data/db --syslog --port 27017
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/CONTRIBUTING.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/CONTRIBUTING.md
new file mode 100644
index 0000000..904aeef
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/CONTRIBUTING.md
@@ -0,0 +1,56 @@
+## Contributing to Mongoose
+
+If you have a question about Mongoose (not a bug report) please post it to either [StackOverflow](http://stackoverflow.com/questions/tagged/mongoose), or on [Gitter](https://gitter.im/Automattic/mongoose?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+### Reporting bugs
+
+- Before opening a new issue, look for existing [issues](https://github.com/Automattic/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/Automattic/mongoose/issues/new).
+ - Please post any relevant code samples, preferably a standalone script that
+ reproduces your issue. Do **not** describe your issue in prose, show your
+ code.
+ - If the bug involves an error, please post the stack trace.
+ - Please post the version of mongoose and mongodb that you're using.
+ - Please write bug reports in JavaScript (ES5 or ES2015), not coffeescript, typescript, etc.
+
+### Requesting new features
+
+- Before opening a new issue, look for existing [issues](https://github.com/learnboost/mongoose/issues) to avoid duplication. If the issue does not yet exist, [create one](https://github.com/learnboost/mongoose/issues/new).
+- Please describe a use case for it
+- it would be ideal to include test cases as well
+
+### Fixing bugs / Adding features
+
+- Before starting to write code, look for existing [issues](https://github.com/learnboost/mongoose/issues). That way you avoid working on something that might not be of interest or that has been addressed already in a different branch. You can create a new issue [here](https://github.com/learnboost/mongoose/issues/new).
+ - _The source of this project is written in javascript, not coffeescript, therefore your bug reports should be written in javascript_.
+- Fork the [repo](https://github.com/Automattic/mongoose) _or_ for small documentation changes, navigate to the source on github and click the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.
+- Follow the general coding style of the rest of the project:
+ - 2 space tabs
+ - no trailing whitespace
+ - inline documentation for new methods, class members, etc.
+ - 1 space between conditionals, no space before function parenthesis
+ - `if (..) {`
+ - `for (..) {`
+ - `while (..) {`
+ - `function(err) {`
+- Write tests and make sure they pass (tests are in the [test](https://github.com/Automattic/mongoose/tree/master/test) directory).
+
+### Running the tests
+- Open a terminal and navigate to the root of the project
+- execute `npm install` to install the necessary dependencies
+- start a mongodb instance on port 27017 if one isn't running already. `mongod --dbpath <path to store data> --port 27017`
+- execute `npm test` to run the tests (we're using [mocha](http://mochajs.org/))
+ - or to execute a single test `npm test -- -g 'some regexp that matches the test description'`
+ - any mocha flags can be specified with `-- <mocha flags here>`
+ - For example, you can use `npm test -- -R spec` to use the spec reporter, rather than the dot reporter (by default, the test output looks like a bunch of dots)
+
+### Documentation
+
+To contribute to the [API documentation](http://mongoosejs.com/docs/api.html) just make your changes to the inline documentation of the appropriate [source code](https://github.com/Automattic/mongoose/tree/master/lib) in the master branch and submit a [pull request](https://help.github.com/articles/using-pull-requests/). You might also use the github [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.
+
+To contribute to the [guide](http://mongoosejs.com/docs/guide.html) or [quick start](http://mongoosejs.com/docs/index.html) docs, make your changes to the appropriate `.jade` files in the [docs](https://github.com/Automattic/mongoose/tree/master/docs) directory of the master branch and submit a pull request. Again, the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button might work for you here.
+
+If you'd like to preview your documentation changes, first commit your changes to your local master branch, then execute `make docs` from the project root, which switches to the gh-pages branch, merges from the master branch and builds all the static pages for you. Now execute `node static.js` from the project root which will launch a local webserver where you can browse the documentation site locally. If all looks good, submit a [pull request](https://help.github.com/articles/using-pull-requests/) to the master branch with your changes.
+
+### Plugins website
+
+The [plugins](http://plugins.mongoosejs.io/) site is also an [open source project](https://github.com/vkarpov15/mongooseplugins) that you can get involved with. Feel free to fork and improve it as well!
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/History.md
new file mode 100644
index 0000000..98cce2e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/History.md
@@ -0,0 +1,3328 @@
+4.7.1 / 2016-11-30
+==================
+ * fix(schema): throw error if you use prototype as a schema path #4746
+ * fix(schema): throw helpful error if you define a virtual with the same path as a real path #4744
+ * fix(connection): make createConnection not throw rejected promises #4742
+ * fix(populate): allow specifiying options in model schema #4741
+ * fix(document): handle selected nested elements with defaults #4739
+ * fix(query): add model to cast error if possible #4729
+ * fix(query): handle timestamps with overwrite #4054
+
+4.7.0 / 2016-11-23
+==================
+ * docs: clean up schematypes #4732 [kidlj](https://github.com/kidlj)
+ * perf: only get stack when necessary with VersionError #4726 [Sebmaster](https://github.com/Sebmaster)
+ * fix(query): ensure correct casting when setting array element #4724
+ * fix(connection): ensure db name gets set when you pass 4 params #4721
+ * fix: prevent TypeError in node v7 #4719 #4706
+ * feat(document): support .set() on virtual subpaths #4716
+ * feat(populate): support populate virtuals on nested schemas #4715
+ * feat(querycursor): support transform option and .map() #4714 #4705 [cblanc](https://github.com/cblanc)
+ * fix(document): dont set defaults on not-selected nested paths #4707
+ * fix(populate): don't throw if empty string passed to populate #4702
+ * feat(model): add `loadClass()` function for importing schema from ES6 class #4668 [rockmacaca](https://github.com/rockmacaca)
+
+4.6.8 / 2016-11-14
+==================
+ * fix(querycursor): clear stack when iterating onto next doc #4697
+ * fix: handle null keys in validation error #4693 #4689 [arciisine](https://github.com/arciisine)
+ * fix(populate): handle pre init middleware correctly with populate virtuals #4683
+ * fix(connection): ensure consistent return value for open and openSet #4659
+ * fix(schema): handle falsy defaults for arrays #4620
+
+4.6.7 / 2016-11-10
+==================
+ * fix(document): only invalidate in subdoc if using update validators #4681
+ * fix(document): don't create subdocs when excluded in projection #4669
+ * fix(document): ensure single embedded schema validator runs with correct context #4663
+ * fix(document): make sure to depopulate top level for sharding #4658
+ * fix(connection): throw more helpful error when .model() called incorrectly #4652
+ * fix(populate): throw more descriptive error when trying to populate a virtual that doesn't have proper options #4602
+ * fix(document): ensure subtype gets set properly when saving with a buffer id #4506
+ * fix(query): handle setDefaultsOnInsert with defaults on doc arrays #4456
+ * fix(drivers): make debug output better by calling toBSON() #4356
+
+4.6.6 / 2016-11-03
+==================
+ * chore: upgrade deps #4674 [TrejGun](https://github.com/TrejGun)
+ * chore: run tests on node v7 #4673 [TrejGun](https://github.com/TrejGun)
+ * perf: make setDefaultsOnInsert more efficient if upsert is off #4672 [CamHenlin](https://github.com/CamHenlin)
+ * fix(populate): ensure document array is returned #4656
+ * fix(query): cast doc arrays with positionals correctly for update #4655
+ * fix(document): ensure single nested doc validators run with correct context #4654
+ * fix: handle reconnect failed error in new version of driver #4653 [loris](https://github.com/loris)
+ * fix(populate): if setting a populated doc, take its id #4632
+ * fix(populate): handle populated virtuals in init #4618
+
+4.6.5 / 2016-10-23
+==================
+ * docs: fix grammar issues #4642 #4640 #4639 [silvermanj7](https://github.com/silvermanj7)
+ * fix(populate): filter out nonexistant values for dynref #4637
+ * fix(query): handle $type as a schematype operator #4632
+ * fix(schema): better handling for uppercase: false and lowercase: false #4622
+ * fix(query): don't run transforms on updateForExec() #4621
+ * fix(query): handle id = 0 in findById #4610
+ * fix(query): handle buffers in mergeClone #4609
+ * fix(document): handle undefined with conditional validator for validateSync #4607
+ * fix: upgrade to mongodb driver 2.2.11 #4581
+ * docs(schematypes): clarify schema.path() #4518
+ * fix(query): ensure path is defined before checking in timestamps #4514
+ * fix(model): set version key in upsert #4505
+ * fix(document): never depopulate top-level doc #3057
+ * refactor: ensure sync for setting non-capped collections #2690
+
+4.6.4 / 2016-10-16
+==================
+ * fix(query): cast $not correctly #4616 #4592 [prssn](https://github.com/prssn)
+ * fix: address issue with caching global plugins #4608 #4601 [TrejGun](https://github.com/TrejGun)
+ * fix(model): make sure to depopulate in insertMany #4590
+ * fix(model): buffer autoIndex if bufferCommands disabled #4589
+ * fix(populate): copy ids array before modifying #4585
+ * feat(schema): add retainKeyOrder prop #4542
+ * fix(document): return isModified true for children of direct modified paths #4528
+ * fix(connection): add dropDatabase() helper #4490
+ * fix(model): add usePushEach option for schemas #4455
+ * docs(connections): add some warnings about buffering #4413
+ * fix: add ability to set promise implementation in browser #4395
+
+4.6.3 / 2016-10-05
+==================
+ * fix(document): ensure single nested docs get initialized correctly when setting nested paths #4578
+ * fix: turn off transforms when writing nested docs to db #4574
+ * fix(document): don't set single nested subdocs to null when removing parent doc #4566
+ * fix(model): ensure versionKey gets set in insertMany #4561
+ * fix(schema): handle typeKey in arrays #4548
+ * feat(schema): set $implicitlyCreated on schema if created by interpretAsType #4443
+
+4.6.2 / 2016-09-30
+==================
+ * chore: upgrade to async 2.0.1 internally #4579 [billouboq](https://github.com/billouboq)
+ * fix(types): ensure nested single doc schema errors reach update validators #4557 #4519
+ * fix(connection): handle rs names with leading numbers (muri 1.1.1) #4556
+ * fix(model): don't throw if method name conflicts with Object.prototype prop #4551
+ * docs: fix broken link #4544 [VFedyk](https://github.com/VFedyk)
+ * fix: allow overwriting model on mongoose singleton #4541 [Nainterceptor](https://github.com/Nainterceptor)
+ * fix(document): don't use init: true when building doc defaults #4540
+ * fix(connection): use replSet option if replset not specified #4535
+ * fix(query): cast $not objects #4495
+
+4.6.1 / 2016-09-20
+==================
+ * fix(query): improve handling of $not with $elemMatch #4531 #3719 [timbowhite](https://github.com/timbowhite)
+ * fix: upgrade mongodb -> 2.2.10 #4517
+ * chore: fix webpack build issue #4512 [saiichihashimoto](https://github.com/saiichihashimoto)
+ * fix(query): emit error on next tick when exec callback errors #4500
+ * test: improve test case #4496 [isayme](https://github.com/isayme)
+ * fix(schema): use same check for array types and top-level types #4493
+ * style: fix indentation in docs #4489 [dhurlburtusa](https://github.com/dhurlburtusa)
+ * fix(schema): expose original object passed to constructor #4486
+ * fix(query): handle findOneAndUpdate with array of arrays #4484 #4470 [fedotov](https://github.com/fedotov)
+ * feat(document): add $ignore to make a path ignored #4480
+ * fix(query): properly handle setting single embedded in update #4475 #4466 #4465
+ * fix(updateValidators): handle single nested schema subpaths correctly #4479
+ * fix(model): throw handy error when method name conflicts with property name #4475
+ * fix(schema): handle .set() with array field #4472
+ * fix(query): check nested path when avoiding double-validating Mixed #4441
+ * fix(schema): handle calling path.trim() with no args correctly #4042
+
+4.6.0 / 2016-09-02
+==================
+ * docs(document): clarify the findById and findByIdAndUpdate examples #4471 [mdcanham](https://github.com/mdcanham)
+ * docs(schematypes): add details re: options #4452
+ * docs(middleware): add docs for insertMany hooks #4451
+ * fix(schema): create new array when copying from existing object to preserve change tracking #4449
+ * docs: fix typo in index.jade #4448
+ * fix(query): allow array for populate options #4446
+ * fix(model): create should not cause unhandle reject promise #4439
+ * fix: upgrade to mongodb driver 2.2.9 #4363 #4341 #4311 (see [comments here](https://github.com/mongodb/js-bson/commit/aa0b54597a0af28cce3530d2144af708e4b66bf0#commitcomment-18850498) if you use node 0.10)
+
+4.5.10 / 2016-08-23
+===================
+ * docs: fix typo on documents.jade #4444 [Gabri3l](https://github.com/Gabri3l)
+ * chore: upgrade mocha to 3.0.2 #4437 [TrejGun](https://github.com/TrejGun)
+ * fix: subdocuments causing error with parent timestamp on update #4434 [dyang108](https://github.com/dyang108)
+ * fix(query): don't crash if timestamps on and update doesn't have a path #4425 #4424 #4418
+ * fix(query): ensure single nested subdoc is hydrated when running update validators #4420
+ * fix(query): cast non-$geometry operators for $geoWithin #4419
+ * docs: update contributor count #4415 [AdamZaczek](https://github.com/AdamZaczek)
+ * docs: add more clarification re: the index event #4410
+ * fix(document): only skip modifying subdoc path if parent is direct modified #4405
+ * fix(schema): throw cast error if provided date invalid #4404
+ * feat(error): use util.inspect() so CastError never prints "[object Object]" #4398
+ * fix(model): dont error if the discriminator key is unchanged #4387
+ * fix(query): don't throw unhandled rejection with bluebird when using cbs #4379
+
+4.5.9 / 2016-08-14
+==================
+ * docs: add mixed schema doc for Object literal #4400 [Kikobeats](https://github.com/Kikobeats)
+ * fix(query): cast $geoWithin and convert mongoose objects to POJOs before casting #4392
+ * fix(schematype): dont cast defaults without parent doc #4390
+ * fix(query): disallow passing empty string to findOne() #4378
+ * fix(document): set single nested doc isNew correctly #4369
+ * fix(types): checks field name correctly with nested arrays and populate #4365
+ * fix(drivers): make debug output copy-pastable into mongodb shell #4352
+ * fix(services): run update validators on nested paths #4332
+ * fix(model): handle typeKey with discriminators #4339
+ * fix(query): apply timestamps to child schemas when explicitly specified in update #4049
+ * fix(schema): set prefix as nested path with add() #1730
+
+4.5.8 / 2016-08-01
+==================
+ * fix(model): make changing the discriminator key cause a cast error #4374
+ * fix(query): pass projection fields to cursor #4371 #4342 [Corei13](https://github.com/Corei13)
+ * fix(document): support multiple paths for isModified #4370 [adambuczynski](https://github.com/adambuczynski)
+ * fix(querycursor): always cast fields before returning cursor #4355
+ * fix(query): support projection as alias for fields in findOneAndUpdate #4315
+ * fix(schema): treat index false + unique false as no index #4304
+ * fix(types): dont mark single nested subpath as modified if whole doc already modified #4224
+
+4.5.7 / 2016-07-25
+==================
+ * fix(document): ensure no unhandled rejections if callback specified for save #4364
+
+4.5.6 / 2016-07-23
+==================
+ * fix(schema): don't overwrite createdAt if it isn't selected #4351 [tusbar](https://github.com/tusbar)
+ * docs(api): fix link to populate() and add a new one from depopulate() #4345 [Delapouite](https://github.com/Delapouite)
+ * fix(types): ownerDocument() works properly with single nested docs #4344 [vichle](https://github.com/vichle)
+ * fix(populate): dont use findOne when justOne option set #4329
+ * fix(document): dont trigger .then() deprecated warning when calling doc.remove() #4291
+ * docs(connection): add promiseLibrary option #4280
+ * fix(plugins): apply global plugins to subschemas #4271
+ * fix(model): ensure `ensureIndex()` never calls back in the same tick #4246
+ * docs(schema): improve post hook docs on schema #4238
+
+4.5.5 / 2016-07-18
+==================
+ * fix(document): handle setting root to empty obj if minimize false #4337
+ * fix: downgrade to mongodb 2.1.18 #4335 #4334 #4328 #4323
+ * perf(types): remove defineProperty usage in documentarray #4333
+ * fix(query): correctly pass model in .toConstructor() #4318
+ * fix(services): avoid double-validating mixed types with update validators #4305
+ * docs(middleware): add docs describing error handling middleware #4229
+ * fix(types): throw correct error when invalidating doc array #3602
+
+4.5.4 / 2016-07-11
+==================
+ * fix(types): fix removing embedded documents #4309 [RoCat](https://github.com/RoCat)
+ * docs: various docs improvements #4302 #4294 [simonxca](https://github.com/simonxca)
+ * fix: upgrade mongodb -> 2.1.21 #4295 #4202 [RoCat](https://github.com/RoCat)
+ * fix(populate): convert single result to array for virtual populate because of lean #4288
+ * fix(populate): handle empty results for populate virtuals properly #4285 #4284
+ * fix(query): dont cast $inc to number if type is long #4283
+ * fix(types): allow setting single nested doc to null #4281
+ * fix(populate): handle deeply nested virtual populate #4278
+ * fix(document): allow setting empty obj if strict mode is false #4274
+ * fix(aggregate): allow passing obj to .unwind() #4239
+ * docs(document): add return statements to transform examples #1963
+
+4.5.3 / 2016-06-30
+==================
+ * fix(query): pass correct options to QueryCursor #4277 #4266
+ * fix(querycursor): handle lean option correctly #4276 [gchudnov](https://github.com/gchudnov)
+ * fix(document): fix error handling when no error occurred #4275
+ * fix(error): use strict mode for version error #4272
+ * docs(populate): fix crashing compilation for populate.jade #4267
+ * fix(populate): support `justOne` option for populate virtuals #4263
+ * fix(populate): ensure model param gets used for populate virtuals #4261 #4243
+ * fix(querycursor): add ability to properly close the cursor #4258
+ * docs(model): correct link to Document #4250
+ * docs(populate): correct path for refPath populate #4240
+ * fix(document): support validator.isEmail as validator #4064
+
+4.5.2 / 2016-06-24
+==================
+ * fix(connection): add checks for collection presence for `onOpen` and `onClose` #4259 [nodkz](https://github.com/nodkz)
+ * fix(cast): allow strings for $type operator #4256
+ * fix(querycursor): support lean() #4255 [pyramation](https://github.com/pyramation)
+ * fix(aggregate): allow setting noCursorTimeout option #4241
+ * fix(document): handle undefined for Array.pull #4222 [Sebmaster](https://github.com/Sebmaster)
+ * fix(connection): ensure promise.catch() catches initial connection error #4135
+ * fix(document): show additional context for VersionError #2633
+
+4.5.1 / 2016-06-18
+==================
+ * fix(model): ensure wrapped insertMany() returns a promise #4237
+ * fix(populate): dont overwrite populateVirtuals when populating multiple paths #4234
+ * docs(model): clarify relationship between create() and save() #4233
+ * fix(types): handle option param in subdoc remove() #4231 [tdebarochez](https://github.com/tdebarochez)
+ * fix(document): dedupe modified paths #4226 #4223 [adambuczynski](https://github.com/adambuczynski)
+ * fix(model): don't modify user-provided options object #4221
+ * fix(document): handle setting nested path to empty object #4218 #4182
+ * fix(document): clean subpaths when removing single nested #4216
+ * fix(document): don't force transform on subdocs with inspect #4213
+ * fix(error): allow setting .messages object #4207
+
+4.5.0 / 2016-06-13
+==================
+ * feat(query): added Query.prototype.catch() #4215 #4173 [adambuczynski](https://github.com/adambuczynski)
+ * feat(query): add Query.prototype.cursor() as a .stream() alternative #4117 #3637 #1907
+ * feat(document): add markUnmodified() function #4092 [vincentcr](https://github.com/vincentcr)
+ * feat(aggregate): convert aggregate object to a thenable #3995 #3946 [megagon](https://github.com/megagon)
+ * perf(types): remove defineProperties call for array (**Note:** Because of this, a mongoose array will no longer `assert.deepEqual()` a plain old JS array) #3886
+ * feat(model): add hooks for insertMany() #3846
+ * feat(schema): add support for custom query methods #3740 #2372
+ * feat(drivers): emit error on 'serverClosed' because that means that reconnect failed #3615
+ * feat(model): emit error event when callback throws exception #3499
+ * feat(model): inherit options from discriminator base schema #3414 #1818
+ * feat(populate): expose mongoose-populate-virtuals inspired populate API #2562
+ * feat(document): trigger remove hooks on subdocs when removing parent #2348
+ * feat(schema): add support for express-style error handling middleware #2284
+ * fix(model): disallow setting discriminator key #2041
+ * feat(schema): add support for nested arrays #1361
+
+4.4.20 / 2016-06-05
+===================
+ * docs: clarify command buffering when using driver directly #4195
+ * fix(promise): correct broken mpromise .catch() #4189
+ * fix(document): clean modified subpaths when set path to empty obj #4182
+ * fix(query): support minDistance with query casting and `.near()` #4179
+ * fix(model): remove unnecessary .save() promise #4177
+ * fix(schema): cast all valid ObjectId strings to object ids #3365
+ * docs: remove unclear "unsafe" term in query docs #3282
+
+4.4.19 / 2016-05-21
+===================
+ * fix(model): handle insertMany if timestamps not set #4171
+
+4.4.18 / 2016-05-21
+===================
+ * docs: add missing period #4170 [gitname](https://github.com/gitname)
+ * docs: change build badge to svg #4158 [a0viedo](https://github.com/a0viedo)
+ * fix(model): update timestamps when setting `createdAt` #4155
+ * fix(utils): make sure to require in document properly #4152
+ * fix(model): throw overwrite error when discriminator name conflicts #4148
+
+4.4.17 / 2016-05-13
+===================
+ * docs: remove repetition in QueryStream docs #4147 [hugoabonizio](https://github.com/hugoabonizio)
+ * fix(document): dont double-validate doc array elements #4145
+ * fix(document): call required function with correct scope #4142 [JedWatson](https://github.com/JedWatson)
+
+4.4.16 / 2016-05-09
+===================
+ * refactor(document): use function reference #4133 [dciccale](https://github.com/dciccale)
+ * docs(querystream): clarify `destroy()` and close event #4126 [AnthonyCC](https://github.com/AnthonyCC)
+ * test: make before hook fail fast if it can't connect #4121
+ * docs: add description of CastError constructor params #4120
+ * fix(schematype): ensure single embedded defaults have $parent #4115
+ * fix(document): mark nested paths for validation #4111
+ * fix(schema): make sure element is always a subdoc in doc array validation #3816
+
+4.4.15 / 2016-05-06
+===================
+ * fix(schema): support overwriting array default #4109
+ * fix(populate): assign values when resolving each populate #4104
+ * fix(aggregate): dont send async option to server #4101
+ * fix(model): ensure isNew set to false after insertMany #4099
+ * fix(connection): emit on error if listeners and no callback #4098
+ * fix(document): treat required fn that returns false as required: false #4094
+
+4.4.14 / 2016-04-27
+===================
+ * fix: upgrade mongodb -> 2.1.18 #4102
+ * feat(connection): allow setting mongos as a uri query param #4093 #4035 [burtonjc](https://github.com/burtonjc)
+ * fix(populate): make sure to use correct assignment order for each model #4073
+ * fix(schema): add complete set of geospatial operators for single embedded subdocs #4014
+
+3.8.40 / 2016-04-24
+===================
+ * upgraded; mquery -> 1.10.0 #3989
+
+4.4.13 / 2016-04-21
+===================
+ * docs: add docs favicons #4082 [robertjustjones](https://github.com/robertjustjones)
+ * docs(model): correct Model.remove() return value #4075 [Jokero](https://github.com/Jokero)
+ * fix(query): add $geoWithin query casting for single embedded docs #4044
+ * fix(schema): handle setting trim option to falsy #4042
+ * fix(query): handle setDefaultsOnInsert with empty update #3835
+
+4.4.12 / 2016-04-08
+===================
+ * docs(query): document context option for update and findOneAndUpdate #4055
+ * docs(query): correct link to $geoWithin docs #4050
+ * fix(project): upgrade to mongodb driver 2.1.16 #4048 [schmalliso](https://github.com/schmalliso)
+ * docs(validation): fix validation docs #4028
+ * fix(types): improve .id() check for document arrays #4011
+ * fix(query): remove premature return when using $rename #3171
+ * docs(connection): clarify relationship between models and connections #2157
+
+4.4.11 / 2016-04-03
+===================
+ * fix: upgrade to mongodb driver 2.1.14 #4036 #4030 #3945
+ * fix(connection): allow connecting with { mongos: true } to handle query params #4032 [burtonjc](https://github.com/burtonjc)
+ * docs(connection): add autoIndex example #4026 [tilleps](https://github.com/tilleps)
+ * fix(query): handle passRawResult option when zero results #4023
+ * fix(populate): clone options before modifying #4022
+ * docs: add missing whitespace #4019 [chenxsan](https://github.com/chenxsan)
+ * chore: upgrade to ESLint 2.4.0 #4015 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fix(types): single nested subdocs get ids by default #4008
+ * chore(project): add dependency status badge #4007 [Maheshkumar-Kakade](http://github.com/Maheshkumar-Kakade)
+ * fix: make sure timestamps don't trigger unnecessary updates #4005 #3991 [tommarien](https://github.com/tommarien)
+ * fix(document): inspect inherits schema options #4001
+ * fix(populate): don't mark populated path as modified if setting to object w/ same id #3992
+ * fix(document): support kind argument to invalidate #3965
+
+4.4.10 / 2016-03-24
+===================
+ * fix(document): copy isNew when copying a document #3982
+ * fix(document): don't override defaults with undefined keys #3981
+ * fix(populate): merge multiple deep populate options for the same path #3974
+
+4.4.9 / 2016-03-22
+==================
+ * fix: upgrade mongodb -> 2.1.10 re https://jira.mongodb.org/browse/NODE-679 #4010
+ * docs: add syntax highlighting for acquit examples #3975
+
+4.4.8 / 2016-03-18
+==================
+ * docs(aggregate): clarify promises #3990 [megagon](https://github.com/megagon)
+ * fix: upgrade mquery -> 1.10 #3988 [matskiv](https://github.com/matskiv)
+ * feat(connection): 'all' event for repl sets #3986 [xizhibei](https://github.com/xizhibei)
+ * docs(types): clarify Array.pull #3985 [seriousManual](https://github.com/seriousManual)
+ * feat(query): support array syntax for .sort() via mquery 1.9 #3980
+ * fix(populate): support > 3 level nested populate #3973
+ * fix: MongooseThenable exposes connection correctly #3972
+ * docs(connection): add note about reconnectTries and reconnectInterval #3969
+ * feat(document): invalidate returns the new validationError #3964
+ * fix(query): .eq() as shorthand for .equals #3953 [Fonger](https://github.com/Fonger)
+ * docs(connection): clarify connection string vs passed options #3941
+ * docs(query): select option for findOneAndUpdate #3933
+ * fix(error): ValidationError.properties no longer enumerable #3925
+ * docs(validation): clarify how required validators work with nested schemas #3915
+ * fix: upgrade mongodb driver -> 2.1.8 to make partial index errors more sane #3864
+
+4.4.7 / 2016-03-11
+==================
+ * fix(query): stop infinite recursion caused by merging a mongoose buffer #3961
+ * fix(populate): handle deep populate array -> array #3954
+ * fix(schema): allow setting timestamps with .set() #3952 #3951 #3907 [Fonger](https://github.com/Fonger)
+ * fix: MongooseThenable doesn't overwrite constructors #3940
+ * fix(schema): don't cast boolean to date #3935
+ * fix(drivers): support sslValidate in connection string #3929
+ * fix(types): correct markModified() for single nested subdocs #3910
+ * fix(drivers): catch and report any errors that occur in driver methods #3906
+ * fix(populate): get subpopulate model correctly when array under nested #3904
+ * fix(document): allow fields named 'pre' and 'post' #3902
+ * docs(query): clarify runValidators and setDefaultsOnInsert options #3892
+ * docs(validation): show how to use custom required messages in schema #2616
+
+4.4.6 / 2016-03-02
+==================
+ * fix: upgrade mongodb driver to 2.1.7 #3938
+ * docs: fix plugins link #3917 #3909 [fbertone](https://github.com/fbertone)
+ * fix(query): sort+select with count works #3914
+ * fix(query): improve mergeUpdate's ability to handle nested docs #3890
+
+4.4.5 / 2016-02-24
+==================
+ * fix(query): ability to select a length field (upgrade to mquery 1.7.0) #3903
+ * fix: include nested CastError as reason for array CastError #3897 [kotarou3](https://github.com/kotarou3)
+ * fix(schema): check for doc existence before taking fields #3889
+ * feat(schema): useNestedStrict option to take nested strict mode for update #3883
+ * docs(validation): clarify relationship between required and checkRequired #3822
+ * docs(populate): dynamic reference docs #3809
+ * docs: expand dropdown when clicking on file name #3807
+ * docs: plugins.mongoosejs.io is up #3127
+ * fix(schema): ability to add a virtual with same name as removed path #2398
+
+4.4.4 / 2016-02-17
+==================
+ * fix(schema): handle field selection when casting single nested subdocs #3880
+ * fix(populate): populating using base model with multiple child models in result #3878
+ * fix: ability to properly use return value of `mongoose.connect()` #3874
+ * fix(populate): dont hydrate populated subdoc if lean option set #3873
+ * fix(connection): dont re-auth if already connected with useDb #3871
+ * docs: cover how to set underlying driver's promise lib #3869
+ * fix(document): handle conflicting names in validation errors with subdocs #3867
+ * fix(populate): set undefined instead of null consistently when populate couldn't find results #3859
+ * docs: link to `execPopulate()` in `doc.populate()` docs #3836
+ * docs(plugin): link to the `mongoose.plugin()` function #3732
+
+4.4.3 / 2016-02-09
+==================
+ * fix: upgrade to mongodb 2.1.6 to remove kerberos log output #3861 #3860 [cartuchogl](https://github.com/cartuchogl)
+ * fix: require('mongoose') is no longer a pseudo-promise #3856
+ * fix(query): update casting for single nested docs #3820
+ * fix(populate): deep populating multiple paths with same options #3808
+ * docs(middleware): clarify save/validate hook order #1149
+
+4.4.2 / 2016-02-05
+==================
+ * fix(aggregate): handle calling .cursor() with no options #3855
+ * fix: upgrade mongodb driver to 2.1.5 for GridFS memory leak fix #3854
+ * docs: fix schematype.html conflict #3853 #3850 #3843
+ * fix(model): bluebird unhandled rejection with ensureIndexes() on init #3837
+ * docs: autoIndex option for createConnection #3805
+
+4.4.1 / 2016-02-03
+==================
+ * fix: linting broke some cases where we use `== null` as shorthand #3852
+ * docs: fix up schematype.html conflict #3848 #3843 [mynameiscoffey](https://github.com/mynameiscoffey)
+ * fix: backwards breaking change with `.connect()` return value #3847
+ * docs: downgrade dox and highlight.js to fix docs build #3845
+ * docs: clean up typo #3842 [Flash-](https://github.com/Flash-)
+ * fix(document): storeShard handles undefined values #3841
+ * chore: more linting #3838 [TrejGun](https://github.com/TrejGun)
+ * fix(schema): handle `text: true` as a way to declare a text index #3824
+
+4.4.0 / 2016-02-02
+==================
+ * docs: fix expireAfterSeconds index option name #3831 [Flash-](https://github.com/Flash-)
+ * chore: run lint after test #3829 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * chore: use power-assert instead of assert #3828 [TrejGun](https://github.com/TrejGun)
+ * chore: stricter lint #3827 [TrejGun](https://github.com/TrejGun)
+ * feat(types): casting moment to date #3813 [TrejGun](https://github.com/TrejGun)
+ * chore: comma-last lint for test folder #3810 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fix: upgrade async mpath, mpromise, muri, and sliced #3801 [TrejGun](https://github.com/TrejGun)
+ * fix(query): geo queries now return proper ES2015 promises #3800 [TrejGun](https://github.com/TrejGun)
+ * perf(types): use `Object.defineProperties()` for array #3799 [TrejGun](https://github.com/TrejGun)
+ * fix(model): mapReduce, ensureIndexes, remove, and save properly return ES2015 promises #3795 #3628 #3595 [TrejGun](https://github.com/TrejGun)
+ * docs: fixed dates in History.md #3791 [Jokero](https://github.com/Jokero)
+ * feat: connect, open, openSet, and disconnect return ES2015 promises #3790 #3622 [TrejGun](https://github.com/TrejGun)
+ * feat: custom type for int32 via mongoose-int32 npm package #3652 #3102
+ * feat: basic custom schema type API #995
+ * feat(model): `insertMany()` for more performant bulk inserts #723
+
+4.3.7 / 2016-01-23
+==================
+ * docs: grammar fix in timestamps docs #3786 [zclancy](https://github.com/zclancy)
+ * fix(document): setting nested populated docs #3783 [slamuu](https://github.com/slamuu)
+ * fix(document): don't call post save hooks twice for pushed docs #3780
+ * fix(model): handle `_id=0` correctly #3776
+ * docs(middleware): async post hooks #3770
+ * docs: remove confusing sentence #3765 [marcusmellis89](https://github.com/marcusmellis89)
+
+3.8.39 / 2016-01-15
+===================
+ * fixed; casting a number to a buffer #3764
+ * fixed; enumerating virtual property with nested objects #3743 [kusold](https://github.com/kusold)
+
+4.3.6 / 2016-01-15
+==================
+ * fix(types): casting a number to a buffer #3764
+ * fix: add "listener" to reserved keywords #3759
+ * chore: upgrade uglify #3757 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fix: broken execPopulate() in 4.3.5 #3755 #3753
+ * fix: ability to remove() a single embedded doc #3754
+ * style: comma-last in test folder #3751 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * docs: clarify versionKey option #3747
+ * fix: improve colorization for arrays #3744 [TrejGun](https://github.com/TrejGun)
+ * fix: webpack build #3713
+
+4.3.5 / 2016-01-09
+==================
+ * fix(query): throw when 4th parameter to update not a function #3741 [kasselTrankos](https://github.com/kasselTrankos)
+ * fix(document): separate error type for setting an object to a primitive #3735
+ * fix(populate): Model.populate returns ES6 promise #3734
+ * fix(drivers): re-register event handlers after manual reconnect #3729
+ * docs: broken links #3727
+ * fix(validation): update validators run array validation #3724
+ * docs: clarify the need to use markModified with in-place date ops #3722
+ * fix(document): mark correct path as populated when manually populating array #3721
+ * fix(aggregate): support for array pipeline argument to append #3718 [dbkup](https://github.com/dbkup)
+ * docs: clarify `.connect()` callback #3705
+ * fix(schema): properly validate nested single nested docs #3702
+ * fix(types): handle setting documentarray of wrong type #3701
+ * docs: broken links #3700
+ * fix(drivers): debug output properly displays '0' #3689
+
+3.8.38 / 2016-01-07
+===================
+ * fixed; aggregate.append an array #3730 [dbkup](https://github.com/dbkup)
+
+4.3.4 / 2015-12-23
+==================
+ * fix: upgrade mongodb driver to 2.1.2 for repl set error #3712 [sansmischevia](https://github.com/sansmischevia)
+ * docs: validation docs typo #3709 [ivanmaeder](https://github.com/ivanmaeder)
+ * style: remove unused variables #3708 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fix(schema): duck-typing for schemas #3703 [mgcrea](https://github.com/mgcrea)
+ * docs: connection sample code issue #3697
+ * fix(schema): duck-typing for schemas #3693 [mgcrea](https://github.com/mgcrea)
+ * docs: clarify id schema option #3638
+
+4.3.3 / 2015-12-18
+==================
+ * fix(connection): properly support 'replSet' as well as 'replset' #3688 [taxilian](https://github.com/taxilian)
+ * fix(document): single nested doc pre hooks called before nested doc array #3687 [aliatsis](https://github.com/aliatsis)
+
+4.3.2 / 2015-12-17
+==================
+ * fix(document): .set() into single nested schemas #3686
+ * fix(connection): support 'replSet' as well as 'replset' option #3685
+ * fix(document): bluebird unhandled rejection when validating doc arrays #3681
+ * fix(document): hooks for doc arrays in single nested schemas #3680
+ * fix(document): post hooks for single nested schemas #3679
+ * fix: remove unused npm module #3674 [sybarite](https://github.com/sybarite)
+ * fix(model): don't swallow exceptions in nested doc save callback #3671
+ * docs: update keepAlive info #3667 [ChrisZieba](https://github.com/ChrisZieba)
+ * fix(document): strict 'throw' throws a specific mongoose error #3662
+ * fix: flakey test #3332
+ * fix(query): more robust check for RegExp #2969
+
+4.3.1 / 2015-12-11
+==================
+ * feat(aggregate): `.sample()` helper #3665
+ * fix(query): bitwise query operators with buffers #3663
+ * docs(migration): clarify `new` option and findByIdAndUpdate #3661
+
+4.3.0 / 2015-12-09
+==================
+ * feat(query): support for mongodb 3.2 bitwise query operators #3660
+ * style: use comma-last style consistently #3657 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * feat: upgrade mongodb driver to 2.1.0 for full MongoDB 3.2 support #3656
+ * feat(aggregate): `.lookup()` helper #3532
+
+4.2.10 / 2015-12-08
+===================
+ * fixed; upgraded marked #3653 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * docs; cross-db populate #3648
+ * docs; update mocha URL #3646 [ojhaujjwal](https://github.com/ojhaujjwal)
+ * fixed; call close callback asynchronously #3645
+ * docs; virtuals.html issue #3644 [Psarna94](https://github.com/Psarna94)
+ * fixed; single embedded doc casting on init #3642
+ * docs; validation docs improvements #3640
+
+4.2.9 / 2015-12-02
+==================
+ * docs; defaults docs #3625
+ * fix; nested numeric keys causing an embedded document crash #3623
+ * fix; apply path getters before virtual getters #3618
+ * fix; casting for arrays in single nested schemas #3616
+
+4.2.8 / 2015-11-25
+==================
+ * docs; clean up README links #3612 [ReadmeCritic](https://github.com/ReadmeCritic)
+ * fix; ESLint improvements #3605 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fix; assigning single nested subdocs #3601
+ * docs; describe custom logging functions in `mongoose.set()` docs #3557
+
+4.2.7 / 2015-11-20
+==================
+ * fixed; readPreference connection string option #3600
+ * fixed; pulling from manually populated arrays #3598 #3579
+ * docs; FAQ about OverwriteModelError #3597 [stcruy](https://github.com/stcruy)
+ * fixed; setting single embedded schemas to null #3596
+ * fixed; indexes for single embedded schemas #3594
+ * docs; clarify projection for `findOne()` #3593 [gunar](https://github.com/gunar)
+ * fixed; .ownerDocument() method on single embedded schemas #3589
+ * fixed; properly throw casterror for query on single embedded schema #3580
+ * upgraded; mongodb driver -> 2.0.49 for reconnect issue fix #3481
+
+4.2.6 / 2015-11-16
+==================
+ * fixed; ability to manually populate an array #3575
+ * docs; clarify `isAsync` parameter to hooks #3573
+ * fixed; use captureStackTrace if possible instead #3571
+ * fixed; crash with buffer and update validators #3565 [johnpeb](https://github.com/johnpeb)
+ * fixed; update casting with operators overwrite: true #3564
+ * fixed; validation with single embedded docs #3562
+ * fixed; inline docs inherit parents $type key #3560
+ * docs; bad grammar in populate docs #3559 [amaurymedeiros](https://github.com/amaurymedeiros)
+ * fixed; properly handle populate option for find() #2321
+
+3.8.37 / 2015-11-16
+===================
+ * fixed; use retainKeyOrder for cloning update op #3572
+
+4.2.5 / 2015-11-09
+==================
+ * fixed; handle setting fields in pre update hooks with exec #3549
+ * upgraded; ESLint #3547 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; bluebird unhandled rejections with cast errors and .exec #3543
+ * fixed; min/max validators handling undefined #3539
+ * fixed; standalone mongos connections #3537
+ * fixed; call `.toObject()` when setting a single nested doc #3535
+ * fixed; single nested docs now have methods #3534
+ * fixed; single nested docs with .create() #3533 #3521 [tusbar](https://github.com/tusbar)
+ * docs; deep populate docs #3528
+ * fixed; deep populate schema ref handling #3507
+ * upgraded; mongodb driver -> 2.0.48 for sort overflow issue #3493
+ * docs; clarify default ids for discriminators #3482
+ * fixed; properly support .update(doc) #3221
+
+4.2.4 / 2015-11-02
+==================
+ * fixed; upgraded `ms` package for security vulnerability #3524 [fhemberger](https://github.com/fhemberger)
+ * fixed; ESlint rules #3517 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * docs; typo in aggregation docs #3513 [rafakato](https://github.com/rafakato)
+ * fixed; add `dontThrowCastError` option to .update() for promises #3512
+ * fixed; don't double-cast buffers in node 4.x #3510 #3496
+ * fixed; population with single embedded schemas #3501
+ * fixed; pre('set') hooks work properly #3479
+ * docs; promises guide #3441
+
+4.2.3 / 2015-10-26
+==================
+ * docs; remove unreferenced function in middleware.jade #3506
+ * fixed; handling auth with no username/password #3500 #3498 #3484 [mleanos](https://github.com/mleanos)
+ * fixed; more ESlint rules #3491 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; swallowing exceptions in save callback #3478
+ * docs; fixed broken links in subdocs guide #3477
+ * fixed; casting booleans to numbers #3475
+ * fixed; report CastError for subdoc arrays in findOneAndUpdate #3468
+ * fixed; geoNear returns ES6 promise #3458
+
+4.2.2 / 2015-10-22
+==================
+ * fixed; go back to old pluralization code #3490
+
+4.2.1 / 2015-10-22
+==================
+ * fixed; pluralization issues #3492 [ChristianMurphy](https://github.com/ChristianMurphy)
+
+4.2.0 / 2015-10-22
+==================
+ * added; support for skipVersioning for document arrays #3467 [chazmo03](https://github.com/chazmo03)
+ * added; ability to customize schema 'type' key #3459 #3245
+ * fixed; writeConcern for index builds #3455
+ * added; emit event when individual index build starts #3440 [objectiveSee](https://github.com/objectiveSee)
+ * added; 'context' option for update validators #3430
+ * refactor; pluralization now in separate pluralize-mongoose npm module #3415 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * added; customizable error validation messages #3406 [geronime](https://github.com/geronime)
+ * added; support for passing 'minimize' option to update #3381
+ * added; ability to customize debug logging format #3261
+ * added; baseModelName property for discriminator models #3202
+ * added; 'emitIndexErrors' option #3174
+ * added; 'async' option for aggregation cursor to support buffering #3160
+ * added; ability to skip validation for individual save() calls #2981
+ * added; single embedded schema support #2689 #585
+ * added; depopulate function #2509
+
+4.1.12 / 2015-10-19
+===================
+ * docs; use readPreference instead of slaveOk for Query.setOptions docs #3471 [buunguyen](https://github.com/buunguyen)
+ * fixed; more helpful error when regexp contains null bytes #3456
+ * fixed; x509 auth issue #3454 [NoxHarmonium](https://github.com/NoxHarmonium)
+
+3.8.36 / 2015-10-18
+===================
+ * fixed; Make array props non-enumerable #3461 [boblauer](https://github.com/boblauer)
+
+4.1.11 / 2015-10-12
+===================
+ * fixed; update timestamps for update() if they're enabled #3450 [isayme](https://github.com/isayme)
+ * fixed; unit test error on node 0.10 #3449 [isayme](https://github.com/isayme)
+ * docs; timestamp option docs #3448 [isayme](https://github.com/isayme)
+ * docs; fix unexpected indent #3443 [isayme](https://github.com/isayme)
+ * fixed; use ES6 promises for Model.prototype.remove() #3442
+ * fixed; don't use unused 'safe' option for index builds #3439
+ * fixed; elemMatch casting bug #3437 #3435 [DefinitelyCarter](https://github.com/DefinitelyCarter)
+ * docs; schema.index docs #3434
+ * fixed; exceptions in save() callback getting swallowed on mongodb 2.4 #3371
+
+4.1.10 / 2015-10-05
+===================
+ * docs; improve virtuals docs to explain virtuals schema option #3433 [zoyaH](https://github.com/zoyaH)
+ * docs; MongoDB server version compatibility guide #3427
+ * docs; clarify that findById and findByIdAndUpdate fire hooks #3422
+ * docs; clean up Model.save() docs #3420
+ * fixed; properly handle projection with just id #3407 #3412
+ * fixed; infinite loop when database document is corrupted #3405
+ * docs; clarify remove middleware #3388
+
+4.1.9 / 2015-09-28
+==================
+ * docs; minlength and maxlength string validation docs #3368 #3413 [cosmosgenius](https://github.com/cosmosgenius)
+ * fixed; linting for infix operators #3397 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; proper casting for $all #3394
+ * fixed; unhandled rejection warnings with .create() #3391
+ * docs; clarify update validators on paths that aren't explicitly set #3386
+ * docs; custom validator examples #2778
+
+4.1.8 / 2015-09-21
+==================
+ * docs; fixed typo in example #3390 [kmctown](https://github.com/kmctown)
+ * fixed; error in toObject() #3387 [guumaster](https://github.com/guumaster)
+ * fixed; handling for casting null dates #3383 [alexmingoia](https://github.com/alexmingoia)
+ * fixed; passing composite ids to `findByIdAndUpdate` #3380
+ * fixed; linting #3376 #3375 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; added NodeJS v4 to Travis #3374 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; casting $elemMatch inside of $not #3373 [gaguirre](https://github.com/gaguirre)
+ * fixed; handle case where $slice is 0 #3369
+ * fixed; avoid running getters if path is populated #3357
+ * fixed; cast documents to objects when setting to a nested path #3346
+
+4.1.7 / 2015-09-14
+==================
+ * docs; typos in SchemaType documentation #3367 [jasson15](https://github.com/jasson15)
+ * fixed; MONGOOSE_DRIVER_PATH env variable again #3360
+ * docs; added validateSync docs #3353
+ * fixed; set findOne op synchronously in query #3344
+ * fixed; handling for `.pull()` on a documentarray without an id #3341
+ * fixed; use natural order for cloning update conditions #3338
+ * fixed; issue with strict mode casting for mixed type updates #3337
+
+4.1.6 / 2015-09-08
+==================
+ * fixed; MONGOOSE_DRIVER_PATH env variable #3345 [g13013](https://github.com/g13013)
+ * docs; global autoIndex option #3335 [albertorestifo](https://github.com/albertorestifo)
+ * docs; model documentation typos #3330
+ * fixed; report reason for CastError #3320
+ * fixed; .populate() no longer returns true after re-assigning #3308
+ * fixed; discriminators with aggregation geoNear #3304
+ * docs; discriminator docs #2743
+
+4.1.5 / 2015-09-01
+==================
+ * fixed; document.remove() removing all docs #3326 #3325
+ * fixed; connect() checks for rs_name in options #3299
+ * docs; examples for schema.set() #3288
+ * fixed; checkKeys issue with bluebird #3286 [gregthegeek](https://github.com/gregthegeek)
+
+4.1.4 / 2015-08-31
+==================
+ * fixed; ability to set strict: false for update #3305
+ * fixed; .create() properly uses ES6 promises #3297
+ * fixed; pre hooks on nested subdocs #3291 #3284 [aliatsis](https://github.com/aliatsis)
+ * docs; remove unclear text in .remove() docs #3282
+ * fixed; pre hooks called twice for 3rd-level nested doc #3281
+ * fixed; nested transforms #3279
+ * upgraded; mquery -> 1.6.3 #3278 #3272
+ * fixed; don't swallow callback errors by default #3273 #3222
+ * fixed; properly get nested paths from nested schemas #3265
+ * fixed; remove() with id undefined deleting all docs #3260 [thanpolas](https://github.com/thanpolas)
+ * fixed; handling for non-numeric projections #3256
+ * fixed; findById with id undefined returning first doc #3255
+ * fixed; use retainKeyOrder for update #3215
+ * added; passRawResult option to findOneAndUpdate for backwards compat #3173
+
+4.1.3 / 2015-08-16
+==================
+ * fixed; getUpdate() in pre update hooks #3520 [gregthegeek](https://github.com/gregthegeek)
+ * fixed; handleArray() ensures arg is an array #3238 [jloveridge](https://github.com/jloveridge)
+ * fixed; refresh required path cache when recreating docs #3199
+ * fixed; $ operator on unwind aggregation helper #3197
+ * fixed; findOneAndUpdate() properly returns raw result as third arg to callback #3173
+ * fixed; querystream with dynamic refs #3108
+
+3.8.35 / 2015-08-14
+===================
+ * fixed; handling for minimize on nested objects #2930
+ * fixed; don't crash when schema.path.options undefined #1824
+
+4.1.2 / 2015-08-10
+==================
+ * fixed; better handling for Jade templates #3241 [kbadk](https://github.com/kbadk)
+ * added; ESlint trailing spaces #3234 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * added; ESlint #3191 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; properly emit event on disconnect #3183
+ * fixed; copy options properly using Query.toConstructor() #3176
+ * fixed; setMaxListeners() issue in browser build #3170
+ * fixed; node driver -> 2.0.40 to not store undefined keys as null #3169
+ * fixed; update validators handle positional operator #3167
+ * fixed; handle $all + $elemMatch query casting #3163
+ * fixed; post save hooks don't swallow extra args #3155
+ * docs; spelling mistake in index.jade #3154
+ * fixed; don't crash when toObject() has no fields #3130
+ * fixed; apply toObject() recursively for find and update queries #3086 [naoina](https://github.com/naoina)
+
+4.1.1 / 2015-08-03
+==================
+ * fixed; aggregate exec() crash with no callback #3212 #3198 [jpgarcia](https://github.com/jpgarcia)
+ * fixed; pre init hooks now properly synchronous #3207 [burtonjc](https://github.com/burtonjc)
+ * fixed; updateValidators doesn't flatten dates #3206 #3194 [victorkohl](https://github.com/victorkohl)
+ * fixed; default fields don't make document dirty between saves #3205 [burtonjc](https://github.com/burtonjc)
+ * fixed; save passes 0 as numAffected rather than undefined when no change #3195 [burtonjc](https://github.com/burtonjc)
+ * fixed; better handling for positional operator in update #3185
+ * fixed; use Travis containers #3181 [ChristianMurphy](https://github.com/ChristianMurphy)
+ * fixed; leaked variable #3180 [ChristianMurphy](https://github.com/ChristianMurphy)
+
+4.1.0 / 2015-07-24
+==================
+ * added; `schema.queue()` now public #3193
+ * added; raw result as third parameter to findOneAndX callback #3173
+ * added; ability to run validateSync() on only certain fields #3153
+ * added; subPopulate #3103 [timbur](https://github.com/timbur)
+ * added; $isDefault function on documents #3077
+ * added; additional properties for built-in validator messages #3063 [KLicheR](https://github.com/KLicheR)
+ * added; getQuery() and getUpdate() functions for Query #3013
+ * added; export DocumentProvider #2996
+ * added; ability to remove path from schema #2993 [JohnnyEstilles](https://github.com/JohnnyEstilles)
+ * added; .explain() helper for aggregate #2714
+ * added; ability to specify which ES6-compatible promises library mongoose uses #2688
+ * added; export Aggregate #1910
+
+4.0.8 / 2015-07-20
+==================
+ * fixed; assignment with document arrays #3178 [rosston](https://github.com/rosston)
+ * docs; remove duplicate paragraph #3164 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * docs; improve findOneAndXYZ parameter descriptions #3159 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * docs; add findOneAndRemove to list of supported middleware #3158
+ * docs; clarify ensureIndex #3156
+ * fixed; refuse to save/remove document without id #3118
+ * fixed; hooks next() no longer accidentally returns promise #3104
+ * fixed; strict mode for findOneAndUpdate #2947
+ * added; .min.js.gz file for browser component #2806
+
+3.8.34 / 2015-07-20
+===================
+ * fixed; allow using $rename #3171
+ * fixed; no longer modifies update arguments #3008
+
+4.0.7 / 2015-07-11
+==================
+ * fixed; documentarray id method when using object id #3157 [siboulet](https://github.com/siboulet)
+ * docs; improve findById docs #3147
+ * fixed; update validators handle null properly #3136 [odeke-em](https://github.com/odeke-em)
+ * docs; jsdoc syntax errors #3128 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * docs; fix typo #3126 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * docs; proper formatting in queries.jade #3121 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * docs; correct example for string maxlength validator #3111 [rhmeeuwisse](https://github.com/rhmeeuwisse)
+ * fixed; setDefaultsOnInsert with arrays #3107
+ * docs; LearnBoost -> Automattic in package.json #3099
+ * docs; pre update hook example #3094 [danpe](https://github.com/danpe)
+ * docs; clarify query middleware example #3051
+ * fixed; ValidationErrors in strict mode #3046
+ * fixed; set findOneAndUpdate properties before hooks run #3024
+
+3.8.33 / 2015-07-10
+===================
+ * upgraded; node driver -> 1.4.38
+ * fixed; dont crash when `match` validator undefined
+
+4.0.6 / 2015-06-21
+==================
+ * upgraded; node driver -> 2.0.34 #3087
+ * fixed; apply setters on addToSet, etc #3067 [victorkohl](https://github.com/victorkohl)
+ * fixed; missing semicolons #3065 [sokolikp](https://github.com/sokolikp)
+ * fixed; proper handling for async doc hooks #3062 [gregthegeek](https://github.com/gregthegeek)
+ * fixed; dont set failed populate field to null if other docs are successfully populated #3055 [eloytoro](https://github.com/eloytoro)
+ * fixed; setDefaultsOnInsert with document arrays #3034 [taxilian](https://github.com/taxilian)
+ * fixed; setters fired on array items #3032
+ * fixed; stop validateSync() on first error #3025 [victorkohl](https://github.com/victorkohl)
+ * docs; improve query docs #3016
+ * fixed; always exclude _id when its deselected #3010
+ * fixed; enum validator kind property #3009
+ * fixed; mquery collection names #3005
+ * docs; clarify mongos option #3000
+ * docs; clarify that query builder has a .then() #2995
+ * fixed; race condition in dynamic ref #2992
+
+3.8.31 / 2015-06-20
+===================
+ * fixed; properly handle text search with discriminators and $meta #2166
+
+4.0.5 / 2015-06-05
+==================
+ * fixed; ObjectIds and buffers when mongodb driver is a sibling dependency #3050 #3048 #3040 #3031 #3020 #2988 #2951
+ * fixed; warn user when 'increment' is used in schema #3039
+ * fixed; setDefaultsOnInsert with array in schema #3035
+ * fixed; dont use default Object toString to cast to string #3030
+ * added; npm badge #3020 [odeke-em](https://github.com/odeke-em)
+ * fixed; proper handling for calling .set() with a subdoc #2782
+ * fixed; dont throw cast error when using $rename on non-string path #1845
+
+3.8.30 / 2015-06-05
+===================
+ * fixed; enable users to set all options with tailable() #2883
+
+4.0.4 / 2015-05-28
+==================
+ * docs; findAndModify new parameter correct default value #3012 [JonForest](https://github.com/JonForest)
+ * docs; clarify pluralization rules #2999 [anonmily](https://github.com/anonmily)
+ * fix; discriminators with schema methods #2978
+ * fix; make `isModified` a schema reserved keyword #2975
+ * fix; properly fire setters when initializing path with object #2943
+ * fix; can use `setDefaultsOnInsert` without specifying `runValidators` #2938
+ * fix; always set validation errors `kind` property #2885
+ * upgraded; node driver -> 2.0.33 #2865
+
+3.8.29 / 2015-05-27
+===================
+ * fixed; Handle JSON.stringify properly for nested docs #2990
+
+4.0.3 / 2015-05-13
+==================
+ * upgraded; mquery -> 1.5.1 #2983
+ * docs; clarify context for query middleware #2974
+ * docs; fix missing type -> kind rename in History.md #2961
+ * fixed; broken ReadPreference include on Heroku #2957
+ * docs; correct form for cursor aggregate option #2955
+ * fixed; sync post hooks now properly called after function #2949 #2925
+ * fixed; fix sub-doc validate() function #2929
+ * upgraded; node driver -> 2.0.30 #2926
+ * docs; retainKeyOrder for save() #2924
+ * docs; fix broken class names #2913
+ * fixed; error when using node-clone on a doc #2909
+ * fixed; no more hard references to bson #2908 #2906
+ * fixed; dont overwrite array values #2907 [naoina](https://github.com/naoina)
+ * fixed; use readPreference=primary for findOneAndUpdate #2899 #2823
+ * docs; clarify that update validators only run on $set and $unset #2889
+ * fixed; set kind consistently for built-in validators #2885
+ * docs; single field populated documents #2884
+ * fixed; nested objects are now enumerable #2880 [toblerpwn](https://github.com/toblerpwn)
+ * fixed; properly populate field when ref, lean, stream used together #2841
+ * docs; fixed migration guide jade error #2807
+
+3.8.28 / 2015-05-12
+===================
+ * fixed; proper handling for toJSON options #2910
+ * fixed; dont attach virtuals to embedded docs in update() #2046
+
+4.0.2 / 2015-04-23
+==================
+ * fixed; error thrown when calling .validate() on subdoc not in an array #2902
+ * fixed; rename define() to play nice with webpack #2900 [jspears](https://github.com/jspears)
+ * fixed; pre validate called twice with discriminators #2892
+ * fixed; .inspect() on mongoose.Types #2875
+ * docs; correct callback params for Model.update #2872
+ * fixed; setDefaultsOnInsert now works when runValidators not specified #2870
+ * fixed; Document now wraps EventEmitter.addListener #2867
+ * fixed; call non-hook functions in schema queue #2856
+ * fixed; statics can be mocked out for tests #2848 [ninelb](https://github.com/ninelb)
+ * upgraded; mquery 1.4.0 for bluebird bug fix #2846
+ * fixed; required validators run first #2843
+ * docs; improved docs for new option to findAndMody #2838
+ * docs; populate example now uses correct field #2837 [swilliams](https://github.com/swilliams)
+ * fixed; pre validate changes causing VersionError #2835
+ * fixed; get path from correct place when setting CastError #2832
+ * docs; improve docs for Model.update() function signature #2827 [irnc](https://github.com/irnc)
+ * fixed; populating discriminators #2825 [chetverikov](https://github.com/chetverikov)
+ * fixed; discriminators with nested schemas #2821
+ * fixed; CastErrors with embedded docs #2819
+ * fixed; post save hook context #2816
+ * docs; 3.8.x -> 4.x migration guide #2807
+ * fixed; proper _distinct copying for query #2765 [cdelauder](https://github.com/cdelauder)
+
+3.8.27 / 2015-04-22
+===================
+ * fixed; dont duplicate db calls on Q.ninvoke() #2864
+ * fixed; Model.find arguments naming in docs #2828
+ * fixed; Support ipv6 in connection strings #2298
+
+3.8.26 / 2015-04-07
+===================
+ * fixed; TypeError when setting date to undefined #2833
+ * fixed; handle CastError properly in distinct() with no callback #2786
+ * fixed; broken links in queries docs #2779
+ * fixed; dont mark buffer as modified when setting type initially #2738
+ * fixed; dont crash when using slice with populate #1934
+
+4.0.1 / 2015-03-28
+==================
+ * fixed; properly handle empty cast doc in update() with promises #2796
+ * fixed; unstable warning #2794
+ * fixed; findAndModify docs now show new option is false by default #2793
+
+4.0.0 / 2015-03-25
+==================
+ * fixed; on-the-fly schema docs typo #2783 [artiifix](https://github.com/artiifix)
+ * fixed; cast error validation handling #2775 #2766 #2678
+ * fixed; discriminators with populate() #2773 #2719 [chetverikov](https://github.com/chetverikov)
+ * fixed; increment now a reserved path #2709
+ * fixed; avoid sending duplicate object ids in populate() #2683
+ * upgraded; mongodb to 2.0.24 to properly emit reconnect event multiple times #2656
+
+4.0.0-rc4 / 2015-03-14
+======================
+ * fixed; toObject virtuals schema option handled properly #2751
+ * fixed; update validators work on document arrays #2733
+ * fixed; check for cast errors on $set #2729
+ * fixed; instance field set for all schema types #2727 [csdco](https://github.com/csdco)
+ * fixed; dont run other validators if required fails #2725
+ * fixed; custom getters execute on ref paths #2610
+ * fixed; save defaults if they were set when doc was loaded from db #2558
+ * fixed; pre validate now runs before pre save #2462
+ * fixed; no longer throws errors with --use_strict #2281
+
+3.8.25 / 2015-03-13
+===================
+ * fixed; debug output reverses order of aggregation keys #2759
+ * fixed; $eq is a valid query selector in 3.0 #2752
+ * fixed; upgraded node driver to 1.4.32 for handling non-numeric poolSize #2682
+ * fixed; update() with overwrite sets _id for nested docs #2658
+ * fixed; casting for operators in $elemMatch #2199
+
+4.0.0-rc3 / 2015-02-28
+======================
+ * fixed; update() pre hooks run before validators #2706
+ * fixed; setters not called on arrays of refs #2698 [brandom](https://github.com/brandom)
+ * fixed; use node driver 2.0.18 for nodejs 0.12 support #2685
+ * fixed; comments reference file that no longer exists #2681
+ * fixed; populated() returns _id of manually populated doc #2678
+ * added; ability to exclude version key in toObject() #2675
+ * fixed; dont allow setting nested path to a string #2592
+ * fixed; can cast objects with _id field to ObjectIds #2581
+ * fixed; on-the-fly schema getters #2360
+ * added; strict option for findOneAndUpdate() #1967
+
+3.8.24 / 2015-02-25
+===================
+ * fixed; properly apply child schema transforms #2691
+ * fixed; make copy of findOneAndUpdate options before modifying #2687
+ * fixed; apply defaults when parent path is selected #2670 #2629
+ * fixed; properly get ref property for nested paths #2665
+ * fixed; node driver makes copy of authenticate options before modifying them #2619
+ * fixed; dont block process exit when auth fails #2599
+ * fixed; remove redundant clone in update() #2537
+
+4.0.0-rc2 / 2015-02-10
+======================
+ * added; io.js to travis build
+ * removed; browser build dependencies not installed by default
+ * added; dynamic refpaths #2640 [chetverikov](https://github.com/chetverikov)
+ * fixed; dont call child schema transforms on parent #2639 [chetverikov](https://github.com/chetverikov)
+ * fixed; get rid of remove option if new is set in findAndModify #2598
+ * fixed; aggregate all document array validation errors #2589
+ * fixed; custom setters called when setting value to undefined #1892
+
+3.8.23 / 2015-02-06
+===================
+ * fixed; unset opts.remove when upsert is true #2519
+ * fixed; array saved as object when path is object in array #2442
+ * fixed; inline transforms #2440
+ * fixed; check for callback in count() #2204
+ * fixed; documentation for selecting fields #1534
+
+4.0.0-rc1 / 2015-02-01
+======================
+ * fixed; use driver 2.0.14
+ * changed; use transform: true by default #2245
+
+4.0.0-rc0 / 2015-01-31
+===================
+ * fixed; wrong order for distinct() params #2628
+ * fixed; handling no query argument to remove() #2627
+ * fixed; createModel and discriminators #2623 [ashaffer](https://github.com/ashaffer)
+ * added; pre('count') middleware #2621
+ * fixed; double validation calls on document arrays #2618
+ * added; validate() catches cast errors #2611
+ * fixed; respect replicaSet parameter in connection string #2609
+ * added; can explicitly exclude paths from versioning #2576 [csabapalfi](https://github.com/csabapalfi)
+ * upgraded; driver to 2.0.15 #2552
+ * fixed; save() handles errors more gracefully in ES6 #2371
+ * fixed; undefined is now a valid argument to findOneAndUpdate #2272
+ * changed; `new` option to findAndModify ops is false by default #2262
+
+3.8.22 / 2015-01-24
+===================
+ * upgraded; node-mongodb-native to 1.4.28 #2587 [Climax777](https://github.com/Climax777)
+ * added; additional documentation for validators #2449
+ * fixed; stack overflow when creating massive arrays #2423
+ * fixed; undefined is a valid id for queries #2411
+ * fixed; properly create nested schema index when same schema used twice #2322
+ * added; link to plugin generator in docs #2085 [huei90](https://github.com/huei90)
+ * fixed; optional arguments documentation for findOne() #1971 [nachinius](https://github.com/nachinius)
+
+3.9.7 / 2014-12-19
+===================
+ * added; proper cursors for aggregate #2539 [changyy](https://github.com/changyy)
+ * added; min/max built-in validators for dates #2531 [bshamblen](https://github.com/bshamblen)
+ * fixed; save and validate are now reserved keywords #2380
+ * added; basic documentation for browser component #2256
+ * added; find and findOne hooks (query middleware) #2138
+ * fixed; throw a DivergentArrayError when saving positional operator queries #2031
+ * added; ability to use options as a document property #1416
+ * fixed; document no longer inherits from event emitter and so domain and _events are no longer reserved #1351
+ * removed; setProfiling #1349
+
+3.8.21 / 2014-12-18
+===================
+ * fixed; syntax in index.jade #2517 [elderbas](https://github.com/elderbas)
+ * fixed; writable statics #2510 #2528
+ * fixed; overwrite and explicit $set casting #2515
+
+3.9.6 / 2014-12-05
+===================
+ * added; correctly run validators on each element of array when entire array is modified #661 #1227
+ * added; castErrors in validation #1013 [jondavidjohn](https://github.com/jondavidjohn)
+ * added; specify text indexes in schema fields #1401 [sr527](https://github.com/sr527)
+ * added; ability to set field with validators to undefined #1594 [alabid](https://github.com/alabid)
+ * added; .create() returns an array when passed an array #1746 [alabid](https://github.com/alabid)
+ * added; test suite and docs for use with co and yield #2177 #2474
+ * fixed; subdocument toObject() transforms #2447 [chmanie](https://github.com/chmanie)
+ * fixed; Model.create() with save errors #2484
+ * added; pass options to .save() and .remove() #2494 [jondavidjohn](https://github.com/jondavidjohn)
+
+3.8.20 / 2014-12-01
+===================
+ * fixed; recursive readPref #2490 [kjvalencik](https://github.com/kjvalencik)
+ * fixed; make sure to copy parameters to update() before modifying #2406 [alabid](https://github.com/alabid)
+ * fixed; unclear documentation about query callbacks #2319
+ * fixed; setting a schema-less field to an empty object #2314 [alabid](https://github.com/alabid)
+ * fixed; registering statics and methods for discriminators #2167 [alabid](https://github.com/alabid)
+
+3.9.5 / 2014-11-10
+===================
+ * added; ability to disable autoIndex on a per-connection basis #1875 [sr527](https://github.com/sr527)
+ * fixed; `geoNear()` no longer enforces legacy coordinate pairs - supports GeoJSON #1987 [alabid](https://github.com/alabid)
+ * fixed; browser component works when minified with mangled variable names #2302
+ * fixed; `doc.errors` now cleared before `validate()` called #2302
+ * added; `execPopulate()` function to make `doc.populate()` compatible with promises #2317
+ * fixed; `count()` no longer throws an error when used with `sort()` #2374
+ * fixed; `save()` no longer recursively calls `save()` on populated fields #2418
+
+3.8.19 / 2014-11-09
+===================
+ * fixed; make sure to not override subdoc _ids on find #2276 [alabid](https://github.com/alabid)
+ * fixed; exception when comparing two documents when one lacks _id #2333 [slawo](https://github.com/slawo)
+ * fixed; getters for properties with non-strict schemas #2439 [alabid](https://github.com/alabid)
+ * fixed; inconsistent URI format in docs #2414 [sr527](https://github.com/sr527)
+
+3.9.4 / 2014-10-25
+==================
+ * fixed; statics no longer can be overwritten #2343 [nkcmr](https://github.com/chetverikov)
+ * added; ability to set single populated paths to documents #1530
+ * added; setDefaultsOnInsert and runValidator options for findOneAndUpdate() #860
+
+3.8.18 / 2014-10-22
+==================
+ * fixed; Dont use all toObject options in save #2340 [chetverikov](https://github.com/chetverikov)
+
+3.9.3 / 2014-10-01
+=================
+ * added; support for virtuals that return objects #2294
+ * added; ability to manually hydrate POJOs into mongoose objects #2292
+ * added; setDefaultsOnInsert and runValidator options for update() #860
+
+3.8.17 / 2014-09-29
+==================
+ * fixed; use schema options retainKeyOrder in save() #2274
+ * fixed; fix skip in populate when limit is set #2252
+ * fixed; fix stack overflow when passing MongooseArray to findAndModify #2214
+ * fixed; optimize .length usage in populate #2289
+
+3.9.2 / 2014-09-08
+==================
+ * added; test coverage for browser component #2255
+ * added; in-order execution of validators #2243
+ * added; custom fields for validators #2132
+ * removed; exception thrown when find() used with count() #1950
+
+3.8.16 / 2014-09-08
+==================
+ * fixed; properly remove modified array paths if array has been overwritten #1638
+ * fixed; key check errors #1884
+ * fixed; make sure populate on an array always returns a Mongoose array #2214
+ * fixed; SSL connections with node 0.11 #2234
+ * fixed; return sensible strings for promise errors #2239
+
+3.9.1 / 2014-08-17
+==================
+ * added; alpha version of browser-side schema validation #2254
+ * added; support passing a function to schemas `required` field #2247
+ * added; support for setting updatedAt and createdAt timestamps #2227
+ * added; document.validate() returns a promise #2131
+
+3.8.15 / 2014-08-17
+==================
+ * fixed; Replica set connection string example in docs #2246
+ * fixed; bubble up parseError event #2229
+ * fixed; removed buggy populate cache #2176
+ * fixed; dont $inc versionKey if its being $set #1933
+ * fixed; cast $or and $and in $pull #1932
+ * fixed; properly cast to schema in stream() #1862
+ * fixed; memory leak in nested objects #1565 #2211 [devongovett](https://github.com/devongovett)
+
+3.8.14 / 2014-07-26
+==================
+ * fixed; stringifying MongooseArray shows nested arrays #2002
+ * fixed; use populated doc schema in toObject and toJSON by default #2035
+ * fixed; dont crash on arrays containing null #2140
+ * fixed; model.update w/ upsert has same return values on .exec and promise #2143
+ * fixed; better handling for populate limit with multiple documents #2151
+ * fixed; dont prevent users from adding weights to text index #2183
+ * fixed; helper for aggregation cursor #2187
+ * updated; node-mongodb-native to 1.4.7
+
+3.8.13 / 2014-07-15
+==================
+ * fixed; memory leak with isNew events #2159
+ * fixed; docs for overwrite option for update() #2144
+ * fixed; storeShard() handles dates properly #2127
+ * fixed; sub-doc changes not getting persisted to db after save #2082
+ * fixed; populate with _id: 0 actually removes _id instead of setting to undefined #2123
+ * fixed; save versionKey on findOneAndUpdate w/ upsert #2122
+ * fixed; fix typo in 2.8 docs #2120 [shakirullahi](https://github.com/shakirullahi)
+ * fixed; support maxTimeMs #2102 [yuukinajima](https://github.com/yuukinajima)
+ * fixed; support $currentDate #2019
+ * fixed; $addToSet handles objects without _ids properly #1973
+ * fixed; dont crash on invalid nearSphere query #1874
+
+3.8.12 / 2014-05-30
+==================
+ * fixed; single-server reconnect event fires #1672
+ * fixed; sub-docs not saved when pushed into populated array #1794
+ * fixed; .set() sometimes converts embedded docs to pojos #1954 [archangel-irk](https://github.com/archangel-irk)
+ * fixed; sub-doc changes not getting persisted to db after save #2082
+ * fixed; custom getter might cause mongoose to mistakenly think a path is dirty #2100 [pgherveou](https://github.com/pgherveou)
+ * fixed; chainable helper for allowDiskUse option in aggregation #2114
+
+3.9.0 (unstable) / 2014-05-22
+==================
+ * changed; added `domain` to reserved keywords #1338 #2052 [antoinepairet](https://github.com/antoinepairet)
+ * added; asynchronous post hooks #1977 #2081 [chopachom](https://github.com/chopachom) [JasonGhent](https://github.com/JasonGhent)
+ * added; using model for population, cross-db populate [mihai-chiorean](https://github.com/mihai-chiorean)
+ * added; can define a type for schema validators
+ * added; `doc.remove()` returns a promise #1619 [refack](https://github.com/refack)
+ * added; internal promises for hooks, pre-save hooks run in parallel #1732 [refack](https://github.com/refack)
+ * fixed; geoSearch hanging when no results returned #1846 [ghartnett](https://github.com/ghartnett)
+ * fixed; do not set .type property on ValidationError, use .kind instead #1323
+
+3.8.11 / 2014-05-22
+==================
+ * updated; node-mongodb-native to 1.4.5
+ * reverted; #2052, fixes #2097
+
+3.8.10 / 2014-05-20
+==================
+
+ * updated; node-mongodb-native to 1.4.4
+ * fixed; _.isEqual false negatives bug in js-bson #2070
+ * fixed; missing check for schema.options #2014
+ * fixed; missing support for $position #2024
+ * fixed; options object corruption #2049
+ * fixed; improvements to virtuals docs #2055
+ * fixed; added `domain` to reserved keywords #2052 #1338
+
+3.8.9 / 2014-05-08
+==================
+
+ * updated; mquery to 0.7.0
+ * updated; node-mongodb-native to 1.4.3
+ * fixed; $near failing against MongoDB 2.6
+ * fixed; relying on .options() to determine if collection exists
+ * fixed; $out aggregate helper
+ * fixed; all test failures against MongoDB 2.6.1, with caveat #2065
+
+3.8.8 / 2014-02-22
+==================
+
+ * fixed; saving Buffers #1914
+ * updated; expose connection states for user-land #1926 [yorkie](https://github.com/yorkie)
+ * updated; mquery to 0.5.3
+ * updated; added get / set to reserved path list #1903 [tstrimple](https://github.com/tstrimple)
+ * docs; README code highlighting, syntax fixes #1930 [IonicaBizau](https://github.com/IonicaBizau)
+ * docs; fixes link in the doc at #1925 [kapeels](https://github.com/kapeels)
+ * docs; add a missed word 'hook' for the description of the post-hook api #1924 [ipoval](https://github.com/ipoval)
+
+3.8.7 / 2014-02-09
+==================
+
+ * fixed; sending safe/read options in Query#exec #1895
+ * fixed; findOneAnd..() with sort #1887
+
+3.8.6 / 2014-01-30
+==================
+
+ * fixed; setting readPreferences #1895
+
+3.8.5 / 2014-01-23
+==================
+
+ * fixed; ssl setting when using URI #1882
+ * fixed; findByIdAndUpdate now respects the overwrite option #1809 [owenallenaz](https://github.com/owenallenaz)
+
+3.8.4 / 2014-01-07
+==================
+
+ * updated; mongodb driver to 1.3.23
+ * updated; mquery to 0.4.1
+ * updated; mpromise to 0.4.3
+ * fixed; discriminators now work when selecting fields #1820 [daemon1981](https://github.com/daemon1981)
+ * fixed; geoSearch with no results timeout #1846 [ghartnett](https://github.com/ghartnett)
+ * fixed; infitite recursion in ValidationError #1834 [chetverikov](https://github.com/chetverikov)
+
+3.8.3 / 2013-12-17
+==================
+
+ * fixed; setting empty array with model.update #1838
+ * docs; fix url
+
+3.8.2 / 2013-12-14
+==================
+
+ * fixed; enum validation of multiple values #1778 [heroicyang](https://github.com/heroicyang)
+ * fixed; global var leak #1803
+ * fixed; post remove now fires on subdocs #1810
+ * fixed; no longer set default empty array for geospatial-indexed fields #1668 [shirish87](https://github.com/shirish87)
+ * fixed; model.stream() not hydrating discriminators correctly #1792 [j](https://github.com/j)
+ * docs: Stablility -> Stability [nikmartin](https://github.com/nikmartin)
+ * tests; improve shard error handling
+
+3.8.1 / 2013-11-19
+==================
+
+ * fixed; mishandling of Dates with minimize/getters #1764
+ * fixed; Normalize bugs.email, so `npm` will shut up #1769 [refack](https://github.com/refack)
+ * docs; Improve the grammar where "lets us" was used #1777 [alexyoung](https://github.com/alexyoung)
+ * docs; Fix some grammatical issues in the documentation #1777 [alexyoung](https://github.com/alexyoung)
+ * docs; fix Query api exposure
+ * docs; fix return description
+ * docs; Added Notes on findAndUpdate() #1750 [sstadelman](https://github.com/sstadelman)
+ * docs; Update version number in README #1762 [Fodi69](https://github.com/Fodi69)
+
+3.8.0 / 2013-10-31
+==================
+
+ * updated; warn when using an unstable version
+ * updated; error message returned in doc.save() #1595
+ * updated; mongodb driver to 1.3.19 (fix error swallowing behavior)
+ * updated; mquery to 0.3.2
+ * updated; mocha to 1.12.0
+ * updated; mpromise 0.3.0
+ * updated; sliced 0.0.5
+ * removed; mongoose.Error.DocumentError (never used)
+ * removed; namedscope (undocumented and broken) #679 #642 #455 #379
+ * changed; no longer offically supporting node 0.6.x
+ * changed; query.within getter is now a method -> query.within()
+ * changed; query.intersects getter is now a method -> query.intersects()
+ * added; custom error msgs for built-in validators #747
+ * added; discriminator support #1647 #1003 [j](https://github.com/j)
+ * added; support disabled collection name pluralization #1350 #1707 [refack](https://github.com/refack)
+ * added; support for GeoJSON to Query#near [ebensing](https://github.com/ebensing)
+ * added; stand-alone base query support - query.toConstructor() [ebensing](https://github.com/ebensing)
+ * added; promise support to geoSearch #1614 [ebensing](https://github.com/ebensing)
+ * added; promise support for geoNear #1614 [ebensing](https://github.com/ebensing)
+ * added; connection.useDb() #1124 [ebensing](https://github.com/ebensing)
+ * added; promise support to model.mapReduce()
+ * added; promise support to model.ensureIndexes()
+ * added; promise support to model.populate()
+ * added; benchmarks [ebensing](https://github.com/ebensing)
+ * added; publicly exposed connection states #1585
+ * added; $geoWithin support #1529 $1455 [ebensing](https://github.com/ebensing)
+ * added; query method chain validation
+ * added; model.update `overwrite` option
+ * added; model.geoNear() support #1563 [ebensing](https://github.com/ebensing)
+ * added; model.geoSearch() support #1560 [ebensing](https://github.com/ebensing)
+ * added; MongooseBuffer#subtype()
+ * added; model.create() now returns a promise #1340
+ * added; support for `awaitdata` query option
+ * added; pass the doc to doc.remove() callback #1419 [JoeWagner](https://github.com/JoeWagner)
+ * added; aggregation query builder #1404 [njoyard](https://github.com/njoyard)
+ * fixed; document.toObject when using `minimize` and `getters` options #1607 [JedWatson](https://github.com/JedWatson)
+ * fixed; Mixed types can now be required #1722 [Reggino](https://github.com/Reggino)
+ * fixed; do not pluralize model names not ending with letters #1703 [refack](https://github.com/refack)
+ * fixed; repopulating modified populated paths #1697
+ * fixed; doc.equals() when _id option is set to false #1687
+ * fixed; strict mode warnings #1686
+ * fixed; $near GeoJSON casting #1683
+ * fixed; nearSphere GeoJSON query builder
+ * fixed; population field selection w/ strings #1669
+ * fixed; setters not firing on null values #1445 [ebensing](https://github.com/ebensing)
+ * fixed; handle another versioning edge case #1520
+ * fixed; excluding subdocument fields #1280 [ebensing](https://github.com/ebensing)
+ * fixed; allow array properties to be set to null with findOneAndUpdate [aheuermann](https://github.com/aheuermann)
+ * fixed; subdocuments now use own toJSON opts #1376 [ebensing](https://github.com/ebensing)
+ * fixed; model#geoNear fulfills promise when results empty #1658 [ebensing](https://github.com/ebensing)
+ * fixed; utils.merge no longer overrides props and methods #1655 [j](https://github.com/j)
+ * fixed; subdocuments now use their own transform #1412 [ebensing](https://github.com/ebensing)
+ * fixed; model.remove() removes only what is necessary #1649
+ * fixed; update() now only runs with cb or explicit true #1644
+ * fixed; casting ref docs on creation #1606 [ebensing](https://github.com/ebensing)
+ * fixed; model.update "overwrite" option works as documented
+ * fixed; query#remove() works as documented
+ * fixed; "limit" correctly applies to individual items on population #1490 [ebensing](https://github.com/ebensing)
+ * fixed; issue with positional operator on ref docs #1572 [ebensing](https://github.com/ebensing)
+ * fixed; benchmarks to actually output valid json
+ * deprecated; promise#addBack (use promise#onResolve)
+ * deprecated; promise#complete (use promise#fulfill)
+ * deprecated; promise#addCallback (use promise#onFulFill)
+ * deprecated; promise#addErrback (use promise#onReject)
+ * deprecated; query.nearSphere() (use query.near)
+ * deprecated; query.center() (use query.circle)
+ * deprecated; query.centerSphere() (use query.circle)
+ * deprecated; query#slaveOk (use query#read)
+ * docs; custom validator messages
+ * docs; 10gen -> MongoDB
+ * docs; add Date method caveats #1598
+ * docs; more validation details
+ * docs; state which branch is stable/unstable
+ * docs; mention that middleware does not run on Models
+ * docs; promise.fulfill()
+ * docs; fix readme spelling #1483 [yorchopolis](https://github.com/yorchopolis)
+ * docs; fixed up the README and examples [ebensing](https://github.com/ebensing)
+ * website; add "show code" for properties
+ * website; move "show code" links down
+ * website; update guide
+ * website; add unstable docs
+ * website; many improvements
+ * website; fix copyright #1439
+ * website; server.js -> static.js #1546 [nikmartin](https://github.com/nikmartin)
+ * tests; refactor 1703
+ * tests; add test generator
+ * tests; validate formatMessage() throws
+ * tests; add script for continuously running tests
+ * tests; fixed versioning tests
+ * tests; race conditions in tests
+ * tests; added for nested and/or queries
+ * tests; close some test connections
+ * tests; validate db contents
+ * tests; remove .only
+ * tests; close some test connections
+ * tests; validate db contents
+ * tests; remove .only
+ * tests; replace deprecated method names
+ * tests; convert id to string
+ * tests; fix sharding tests for MongoDB 2.4.5
+ * tests; now 4-5 seconds faster
+ * tests; fix race condition
+ * make; suppress warning msg in test
+ * benchmarks; updated for pull requests
+ * examples; improved and expanded [ebensing](https://github.com/ebensing)
+
+3.7.4 (unstable) / 2013-10-01
+=============================
+
+ * updated; mquery to 0.3.2
+ * removed; mongoose.Error.DocumentError (never used)
+ * added; custom error msgs for built-in validators #747
+ * added; discriminator support #1647 #1003 [j](https://github.com/j)
+ * added; support disabled collection name pluralization #1350 #1707 [refack](https://github.com/refack)
+ * fixed; do not pluralize model names not ending with letters #1703 [refack](https://github.com/refack)
+ * fixed; repopulating modified populated paths #1697
+ * fixed; doc.equals() when _id option is set to false #1687
+ * fixed; strict mode warnings #1686
+ * fixed; $near GeoJSON casting #1683
+ * fixed; nearSphere GeoJSON query builder
+ * fixed; population field selection w/ strings #1669
+ * docs; custom validator messages
+ * docs; 10gen -> MongoDB
+ * docs; add Date method caveats #1598
+ * docs; more validation details
+ * website; add "show code" for properties
+ * website; move "show code" links down
+ * tests; refactor 1703
+ * tests; add test generator
+ * tests; validate formatMessage() throws
+
+3.7.3 (unstable) / 2013-08-22
+=============================
+
+ * updated; warn when using an unstable version
+ * updated; mquery to 0.3.1
+ * updated; mocha to 1.12.0
+ * updated; mongodb driver to 1.3.19 (fix error swallowing behavior)
+ * changed; no longer offically supporting node 0.6.x
+ * added; support for GeoJSON to Query#near [ebensing](https://github.com/ebensing)
+ * added; stand-alone base query support - query.toConstructor() [ebensing](https://github.com/ebensing)
+ * added; promise support to geoSearch #1614 [ebensing](https://github.com/ebensing)
+ * added; promise support for geoNear #1614 [ebensing](https://github.com/ebensing)
+ * fixed; setters not firing on null values #1445 [ebensing](https://github.com/ebensing)
+ * fixed; handle another versioning edge case #1520
+ * fixed; excluding subdocument fields #1280 [ebensing](https://github.com/ebensing)
+ * fixed; allow array properties to be set to null with findOneAndUpdate [aheuermann](https://github.com/aheuermann)
+ * fixed; subdocuments now use own toJSON opts #1376 [ebensing](https://github.com/ebensing)
+ * fixed; model#geoNear fulfills promise when results empty #1658 [ebensing](https://github.com/ebensing)
+ * fixed; utils.merge no longer overrides props and methods #1655 [j](https://github.com/j)
+ * fixed; subdocuments now use their own transform #1412 [ebensing](https://github.com/ebensing)
+ * make; suppress warning msg in test
+ * docs; state which branch is stable/unstable
+ * docs; mention that middleware does not run on Models
+ * tests; add script for continuously running tests
+ * tests; fixed versioning tests
+ * benchmarks; updated for pull requests
+
+3.7.2 (unstable) / 2013-08-15
+==================
+
+ * fixed; model.remove() removes only what is necessary #1649
+ * fixed; update() now only runs with cb or explicit true #1644
+ * tests; race conditions in tests
+ * website; update guide
+
+3.7.1 (unstable) / 2013-08-13
+=============================
+
+ * updated; driver to 1.3.18 (fixes memory leak)
+ * added; connection.useDb() #1124 [ebensing](https://github.com/ebensing)
+ * added; promise support to model.mapReduce()
+ * added; promise support to model.ensureIndexes()
+ * added; promise support to model.populate()
+ * fixed; casting ref docs on creation #1606 [ebensing](https://github.com/ebensing)
+ * fixed; model.update "overwrite" option works as documented
+ * fixed; query#remove() works as documented
+ * fixed; "limit" correctly applies to individual items on population #1490 [ebensing](https://github.com/ebensing)
+ * fixed; issue with positional operator on ref docs #1572 [ebensing](https://github.com/ebensing)
+ * fixed; benchmarks to actually output valid json
+ * tests; added for nested and/or queries
+ * tests; close some test connections
+ * tests; validate db contents
+ * tests; remove .only
+ * tests; close some test connections
+ * tests; validate db contents
+ * tests; remove .only
+ * tests; replace deprecated method names
+ * tests; convert id to string
+ * docs; promise.fulfill()
+
+3.7.0 (unstable) / 2013-08-05
+===================
+
+ * changed; query.within getter is now a method -> query.within()
+ * changed; query.intersects getter is now a method -> query.intersects()
+ * deprecated; promise#addBack (use promise#onResolve)
+ * deprecated; promise#complete (use promise#fulfill)
+ * deprecated; promise#addCallback (use promise#onFulFill)
+ * deprecated; promise#addErrback (use promise#onReject)
+ * deprecated; query.nearSphere() (use query.near)
+ * deprecated; query.center() (use query.circle)
+ * deprecated; query.centerSphere() (use query.circle)
+ * deprecated; query#slaveOk (use query#read)
+ * removed; namedscope (undocumented and broken) #679 #642 #455 #379
+ * added; benchmarks [ebensing](https://github.com/ebensing)
+ * added; publicly exposed connection states #1585
+ * added; $geoWithin support #1529 $1455 [ebensing](https://github.com/ebensing)
+ * added; query method chain validation
+ * added; model.update `overwrite` option
+ * added; model.geoNear() support #1563 [ebensing](https://github.com/ebensing)
+ * added; model.geoSearch() support #1560 [ebensing](https://github.com/ebensing)
+ * added; MongooseBuffer#subtype()
+ * added; model.create() now returns a promise #1340
+ * added; support for `awaitdata` query option
+ * added; pass the doc to doc.remove() callback #1419 [JoeWagner](https://github.com/JoeWagner)
+ * added; aggregation query builder #1404 [njoyard](https://github.com/njoyard)
+ * updated; integrate mquery #1562 [ebensing](https://github.com/ebensing)
+ * updated; error msg in doc.save() #1595
+ * updated; bump driver to 1.3.15
+ * updated; mpromise 0.3.0
+ * updated; sliced 0.0.5
+ * tests; fix sharding tests for MongoDB 2.4.5
+ * tests; now 4-5 seconds faster
+ * tests; fix race condition
+ * docs; fix readme spelling #1483 [yorchopolis](https://github.com/yorchopolis)
+ * docs; fixed up the README and examples [ebensing](https://github.com/ebensing)
+ * website; add unstable docs
+ * website; many improvements
+ * website; fix copyright #1439
+ * website; server.js -> static.js #1546 [nikmartin](https://github.com/nikmartin)
+ * examples; improved and expanded [ebensing](https://github.com/ebensing)
+
+3.6.20 (stable) / 2013-09-23
+===================
+
+ * fixed; repopulating modified populated paths #1697
+ * fixed; doc.equals w/ _id false #1687
+ * fixed; strict mode warning #1686
+ * docs; near/nearSphere
+
+3.6.19 (stable) / 2013-09-04
+==================
+
+ * fixed; population field selection w/ strings #1669
+ * docs; Date method caveats #1598
+
+3.6.18 (stable) / 2013-08-22
+===================
+
+ * updated; warn when using an unstable version of mongoose
+ * updated; mocha to 1.12.0
+ * updated; mongodb driver to 1.3.19 (fix error swallowing behavior)
+ * fixed; setters not firing on null values #1445 [ebensing](https://github.com/ebensing)
+ * fixed; properly exclude subdocument fields #1280 [ebensing](https://github.com/ebensing)
+ * fixed; cast error in findAndModify #1643 [aheuermann](https://github.com/aheuermann)
+ * website; update guide
+ * website; added documentation for safe:false and versioning interaction
+ * docs; mention that middleware dont run on Models
+ * docs; fix indexes link
+ * make; suppress warning msg in test
+ * tests; moar
+
+3.6.17 / 2013-08-13
+===================
+
+ * updated; driver to 1.3.18 (fixes memory leak)
+ * fixed; casting ref docs on creation #1606
+ * docs; query options
+
+3.6.16 / 2013-08-08
+===================
+
+ * added; publicly expose connection states #1585
+ * fixed; limit applies to individual items on population #1490 [ebensing](https://github.com/ebensing)
+ * fixed; positional operator casting in updates #1572 [ebensing](https://github.com/ebensing)
+ * updated; MongoDB driver to 1.3.17
+ * updated; sliced to 0.0.5
+ * website; tweak homepage
+ * tests; fixed + added
+ * docs; fix some examples
+ * docs; multi-mongos support details
+ * docs; auto open browser after starting static server
+
+3.6.15 / 2013-07-16
+==================
+
+ * added; mongos failover support #1037
+ * updated; make schematype return vals return self #1580
+ * docs; add note to model.update #571
+ * docs; document third param to document.save callback #1536
+ * tests; tweek mongos test timeout
+
+3.6.14 / 2013-07-05
+===================
+
+ * updated; driver to 1.3.11
+ * fixed; issue with findOneAndUpdate not returning null on upserts #1533 [ebensing](https://github.com/ebensing)
+ * fixed; missing return statement in SchemaArray#$geoIntersects() #1498 [bsrykt](https://github.com/bsrykt)
+ * fixed; wrong isSelected() behavior #1521 [kyano](https://github.com/kyano)
+ * docs; note about toObject behavior during save()
+ * docs; add callbacks details #1547 [nikmartin](https://github.com/nikmartin)
+
+3.6.13 / 2013-06-27
+===================
+
+ * fixed; calling model.distinct without conditions #1541
+ * fixed; regression in Query#count() #1542
+ * now working on 3.6.13
+
+3.6.12 / 2013-06-25
+===================
+
+ * updated; driver to 1.3.10
+ * updated; clearer capped collection error message #1509 [bitmage](https://github.com/bitmage)
+ * fixed; MongooseBuffer subtype loss during casting #1517 [zedgu](https://github.com/zedgu)
+ * fixed; docArray#id when doc.id is disabled #1492
+ * fixed; docArray#id now supports matches on populated arrays #1492 [pgherveou](https://github.com/pgherveou)
+ * website; fix example
+ * website; improve _id disabling example
+ * website; fix typo #1494 [dejj](https://github.com/dejj)
+ * docs; added a 'Requesting new features' section #1504 [shovon](https://github.com/shovon)
+ * docs; improve subtypes description
+ * docs; clarify _id disabling
+ * docs: display by alphabetical order the methods list #1508 [nicolasleger](https://github.com/nicolasleger)
+ * tests; refactor isSelected checks
+ * tests; remove pointless test
+ * tests; fixed timeouts
+
+3.6.11 / 2013-05-15
+===================
+
+ * updated; driver to 1.3.5
+ * fixed; compat w/ Object.create(null) #1484 #1485
+ * fixed; cloning objects w/ missing constructors
+ * fixed; prevent multiple min number validators #1481 [nrako](https://github.com/nrako)
+ * docs; add doc.increment() example
+ * docs; add $size example
+ * docs; add "distinct" example
+
+3.6.10 / 2013-05-09
+==================
+
+ * update driver to 1.3.3
+ * fixed; increment() works without other changes #1475
+ * website; fix links to posterous
+ * docs; fix link #1472
+
+3.6.9 / 2013-05-02
+==================
+
+ * fixed; depopulation of mixed documents #1471
+ * fixed; use of $options in array #1462
+ * tests; fix race condition
+ * docs; fix default example
+
+3.6.8 / 2013-04-25
+==================
+
+ * updated; driver to 1.3.0
+ * fixed; connection.model should retain options #1458 [vedmalex](https://github.com/vedmalex)
+ * tests; 4-5 seconds faster
+
+3.6.7 / 2013-04-19
+==================
+
+ * fixed; population regression in 3.6.6 #1444
+
+3.6.6 / 2013-04-18
+==================
+
+ * fixed; saving populated new documents #1442
+ * fixed; population regession in 3.6.5 #1441
+ * website; fix copyright #1439
+
+3.6.5 / 2013-04-15
+==================
+
+ * fixed; strict:throw edge case using .set(path, val)
+ * fixed; schema.pathType() on some numbericAlpha paths
+ * fixed; numbericAlpha path versioning
+ * fixed; setting nested mixed paths #1418
+ * fixed; setting nested objects with null prop #1326
+ * fixed; regression in v3.6 population performance #1426 [vedmalex](https://github.com/vedmalex)
+ * fixed; read pref typos #1422 [kyano](https://github.com/kyano)
+ * docs; fix method example
+ * website; update faq
+ * website; add more deep links
+ * website; update poolSize docs
+ * website; add 3.6 release notes
+ * website; note about keepAlive
+
+3.6.4 / 2013-04-03
+==================
+
+ * fixed; +field conflict with $slice #1370
+ * fixed; nested deselection conflict #1333
+ * fixed; RangeError in ValidationError.toString() #1296
+ * fixed; do not save user defined transforms #1415
+ * tests; fix race condition
+
+3.6.3 / 2013-04-02
+==================
+
+ * fixed; setting subdocuments deeply nested fields #1394
+ * fixed; regression: populated streams #1411
+ * docs; mention hooks/validation with findAndModify
+ * docs; mention auth
+ * docs; add more links
+ * examples; add document methods example
+ * website; display "see" links for properties
+ * website; clean up homepage
+
+3.6.2 / 2013-03-29
+==================
+
+ * fixed; corrupted sub-doc array #1408
+ * fixed; document#update returns a Query #1397
+ * docs; readpref strategy
+
+3.6.1 / 2013-03-27
+==================
+
+ * added; populate support to findAndModify varients #1395
+ * added; text index type to schematypes
+ * expose allowed index types as Schema.indexTypes
+ * fixed; use of `setMaxListeners` as path
+ * fixed; regression in node 0.6 on docs with > 10 arrays
+ * fixed; do not alter schema arguments #1364
+ * fixed; subdoc#ownerDocument() #1385
+ * website; change search id
+ * website; add search from google [jackdbernier](https://github.com/jackdbernier)
+ * website; fix link
+ * website; add 3.5.x docs release
+ * website; fix link
+ * docs; fix geometry
+ * docs; hide internal constructor
+ * docs; aggregation does not cast arguments #1399
+ * docs; querystream options
+ * examples; added for population
+
+3.6.0 / 2013-03-18
+==================
+
+ * changed; cast 'true'/'false' to boolean #1282 [mgrach](https://github.com/mgrach)
+ * changed; Buffer arrays can now contain nulls
+ * added; QueryStream transform option
+ * added; support for authSource driver option
+ * added; {mongoose,db}.modelNames()
+ * added; $push w/ $slice,$sort support (MongoDB 2.4)
+ * added; hashed index type (MongoDB 2.4)
+ * added; support for mongodb 2.4 geojson (MongoDB 2.4)
+ * added; value at time of validation error
+ * added; support for object literal schemas
+ * added; bufferCommands schema option
+ * added; allow auth option in connections #1360 [geoah](https://github.com/geoah)
+ * added; performance improvements to populate() [263ece9](https://github.com/LearnBoost/mongoose/commit/263ece9)
+ * added; allow adding uncasted docs to populated arrays and properties #570
+ * added; doc#populated(path) stores original populated _ids
+ * added; lean population #1260
+ * added; query.populate() now accepts an options object
+ * added; document#populate(opts, callback)
+ * added; Model.populate(docs, opts, callback)
+ * added; support for rich nested path population
+ * added; doc.array.remove(value) subdoc with _id value support #1278
+ * added; optionally allow non-strict sets and updates
+ * added; promises/A+ comformancy with [mpromise](https://github.com/aheckmann/mpromise)
+ * added; promise#then
+ * added; promise#end
+ * fixed; use of `model` as doc property
+ * fixed; lean population #1382
+ * fixed; empty object mixed defaults #1380
+ * fixed; populate w/ deselected _id using string syntax
+ * fixed; attempted save of divergent populated arrays #1334 related
+ * fixed; better error msg when attempting toObject as property name
+ * fixed; non population buffer casting from doc
+ * fixed; setting populated paths #570
+ * fixed; casting when added docs to populated arrays #570
+ * fixed; prohibit updating arrays selected with $elemMatch #1334
+ * fixed; pull / set subdoc combination #1303
+ * fixed; multiple bg index creation #1365
+ * fixed; manual reconnection to single mongod
+ * fixed; Constructor / version exposure #1124
+ * fixed; CastError race condition
+ * fixed; no longer swallowing misuse of subdoc#invalidate()
+ * fixed; utils.clone retains RegExp opts
+ * fixed; population of non-schema property
+ * fixed; allow updating versionKey #1265
+ * fixed; add EventEmitter props to reserved paths #1338
+ * fixed; can now deselect populated doc _ids #1331
+ * fixed; properly pass subtype to Binary in MongooseBuffer
+ * fixed; casting _id from document with non-ObjectId _id
+ * fixed; specifying schema type edge case { path: [{type: "String" }] }
+ * fixed; typo in schemdate #1329 [jplock](https://github.com/jplock)
+ * updated; driver to 1.2.14
+ * updated; muri to 0.3.1
+ * updated; mpromise to 0.2.1
+ * updated; mocha 1.8.1
+ * updated; mpath to 0.1.1
+ * deprecated; pluralization will die in 4.x
+ * refactor; rename private methods to something unusable as doc properties
+ * refactor MongooseArray#remove
+ * refactor; move expires index to SchemaDate #1328
+ * refactor; internal document properties #1171 #1184
+ * tests; added
+ * docs; indexes
+ * docs; validation
+ * docs; populate
+ * docs; populate
+ * docs; add note about stream compatibility with node 0.8
+ * docs; fix for private names
+ * docs; Buffer -> mongodb.Binary #1363
+ * docs; auth options
+ * docs; improved
+ * website; update FAQ
+ * website; add more api links
+ * website; add 3.5.x docs to prior releases
+ * website; Change mongoose-types to an active repo [jackdbernier](https://github.com/jackdbernier)
+ * website; compat with node 0.10
+ * website; add news section
+ * website; use T for generic type
+ * benchmark; make adjustable
+
+3.6.0rc1 / 2013-03-12
+======================
+
+ * refactor; rename private methods to something unusable as doc properties
+ * added; {mongoose,db}.modelNames()
+ * added; $push w/ $slice,$sort support (MongoDB 2.4)
+ * added; hashed index type (MongoDB 2.4)
+ * added; support for mongodb 2.4 geojson (MongoDB 2.4)
+ * added; value at time of validation error
+ * added; support for object literal schemas
+ * added; bufferCommands schema option
+ * added; allow auth option in connections #1360 [geoah](https://github.com/geoah)
+ * fixed; lean population #1382
+ * fixed; empty object mixed defaults #1380
+ * fixed; populate w/ deselected _id using string syntax
+ * fixed; attempted save of divergent populated arrays #1334 related
+ * fixed; better error msg when attempting toObject as property name
+ * fixed; non population buffer casting from doc
+ * fixed; setting populated paths #570
+ * fixed; casting when added docs to populated arrays #570
+ * fixed; prohibit updating arrays selected with $elemMatch #1334
+ * fixed; pull / set subdoc combination #1303
+ * fixed; multiple bg index creation #1365
+ * fixed; manual reconnection to single mongod
+ * fixed; Constructor / version exposure #1124
+ * fixed; CastError race condition
+ * fixed; no longer swallowing misuse of subdoc#invalidate()
+ * fixed; utils.clone retains RegExp opts
+ * fixed; population of non-schema property
+ * fixed; allow updating versionKey #1265
+ * fixed; add EventEmitter props to reserved paths #1338
+ * fixed; can now deselect populated doc _ids #1331
+ * updated; muri to 0.3.1
+ * updated; driver to 1.2.12
+ * updated; mpromise to 0.2.1
+ * deprecated; pluralization will die in 4.x
+ * docs; Buffer -> mongodb.Binary #1363
+ * docs; auth options
+ * docs; improved
+ * website; add news section
+ * benchmark; make adjustable
+
+3.6.0rc0 / 2013-02-03
+======================
+
+ * changed; cast 'true'/'false' to boolean #1282 [mgrach](https://github.com/mgrach)
+ * changed; Buffer arrays can now contain nulls
+ * fixed; properly pass subtype to Binary in MongooseBuffer
+ * fixed; casting _id from document with non-ObjectId _id
+ * fixed; specifying schema type edge case { path: [{type: "String" }] }
+ * fixed; typo in schemdate #1329 [jplock](https://github.com/jplock)
+ * refactor; move expires index to SchemaDate #1328
+ * refactor; internal document properties #1171 #1184
+ * added; performance improvements to populate() [263ece9](https://github.com/LearnBoost/mongoose/commit/263ece9)
+ * added; allow adding uncasted docs to populated arrays and properties #570
+ * added; doc#populated(path) stores original populated _ids
+ * added; lean population #1260
+ * added; query.populate() now accepts an options object
+ * added; document#populate(opts, callback)
+ * added; Model.populate(docs, opts, callback)
+ * added; support for rich nested path population
+ * added; doc.array.remove(value) subdoc with _id value support #1278
+ * added; optionally allow non-strict sets and updates
+ * added; promises/A+ comformancy with [mpromise](https://github.com/aheckmann/mpromise)
+ * added; promise#then
+ * added; promise#end
+ * updated; mocha 1.8.1
+ * updated; muri to 0.3.0
+ * updated; mpath to 0.1.1
+ * updated; docs
+
+3.5.16 / 2013-08-13
+===================
+
+ * updated; driver to 1.3.18
+
+3.5.15 / 2013-07-26
+==================
+
+ * updated; sliced to 0.0.5
+ * updated; driver to 1.3.12
+ * fixed; regression in Query#count() due to driver change
+ * tests; fixed timeouts
+ * tests; handle differing test uris
+
+3.5.14 / 2013-05-15
+===================
+
+ * updated; driver to 1.3.5
+ * fixed; compat w/ Object.create(null) #1484 #1485
+ * fixed; cloning objects missing constructors
+ * fixed; prevent multiple min number validators #1481 [nrako](https://github.com/nrako)
+
+3.5.13 / 2013-05-09
+==================
+
+ * update driver to 1.3.3
+ * fixed; use of $options in array #1462
+
+3.5.12 / 2013-04-25
+===================
+
+ * updated; driver to 1.3.0
+ * fixed; connection.model should retain options #1458 [vedmalex](https://github.com/vedmalex)
+ * fixed; read pref typos #1422 [kyano](https://github.com/kyano)
+
+3.5.11 / 2013-04-03
+==================
+
+ * fixed; +field conflict with $slice #1370
+ * fixed; RangeError in ValidationError.toString() #1296
+ * fixed; nested deselection conflict #1333
+ * remove time from Makefile
+
+3.5.10 / 2013-04-02
+==================
+
+ * fixed; setting subdocuments deeply nested fields #1394
+ * fixed; do not alter schema arguments #1364
+
+3.5.9 / 2013-03-15
+==================
+
+ * updated; driver to 1.2.14
+ * added; support for authSource driver option (mongodb 2.4)
+ * added; QueryStream transform option (node 0.10 helper)
+ * fixed; backport for saving required populated buffers
+ * fixed; pull / set subdoc combination #1303
+ * fixed; multiple bg index creation #1365
+ * test; added for saveable required populated buffers
+ * test; added for #1365
+ * test; add authSource test
+
+3.5.8 / 2013-03-12
+==================
+
+ * added; auth option in connection [geoah](https://github.com/geoah)
+ * fixed; CastError race condition
+ * docs; add note about stream compatibility with node 0.8
+
+3.5.7 / 2013-02-22
+==================
+
+ * updated; driver to 1.2.13
+ * updated; muri to 0.3.1 #1347
+ * fixed; utils.clone retains RegExp opts #1355
+ * fixed; deepEquals RegExp support
+ * tests; fix a connection test
+ * website; clean up docs [afshinm](https://github.com/afshinm)
+ * website; update homepage
+ * website; migragtion: emphasize impact of strict docs #1264
+
+3.5.6 / 2013-02-14
+==================
+
+ * updated; driver to 1.2.12
+ * fixed; properly pass Binary subtype
+ * fixed; add EventEmitter props to reserved paths #1338
+ * fixed; use correct node engine version
+ * fixed; display empty docs as {} in log output #953 follow up
+ * improved; "bad $within $box argument" error message
+ * populate; add unscientific benchmark
+ * website; add stack overflow to help section
+ * website; use better code font #1336 [risseraka](https://github.com/risseraka)
+ * website; clarify where help is available
+ * website; fix source code links #1272 [floatingLomas](https://github.com/floatingLomas)
+ * docs; be specific about _id schema option #1103
+ * docs; add ensureIndex error handling example
+ * docs; README
+ * docs; CONTRIBUTING.md
+
+3.5.5 / 2013-01-29
+==================
+
+ * updated; driver to 1.2.11
+ * removed; old node < 0.6x shims
+ * fixed; documents with Buffer _ids equality
+ * fixed; MongooseBuffer properly casts numbers
+ * fixed; reopening closed connection on alt host/port #1287
+ * docs; fixed typo in Readme #1298 [rened](https://github.com/rened)
+ * docs; fixed typo in migration docs [Prinzhorn](https://github.com/Prinzhorn)
+ * docs; fixed incorrect annotation in SchemaNumber#min [bilalq](https://github.com/bilalq)
+ * docs; updated
+
+3.5.4 / 2013-01-07
+==================
+
+ * changed; "_pres" & "_posts" are now reserved pathnames #1261
+ * updated; driver to 1.2.8
+ * fixed; exception when reopening a replica set. #1263 [ethankan](https://github.com/ethankan)
+ * website; updated
+
+3.5.3 / 2012-12-26
+==================
+
+ * added; support for geo object notation #1257
+ * fixed; $within query casting with arrays
+ * fixed; unix domain socket support #1254
+ * updated; driver to 1.2.7
+ * updated; muri to 0.0.5
+
+3.5.2 / 2012-12-17
+==================
+
+ * fixed; using auth with replica sets #1253
+
+3.5.1 / 2012-12-12
+==================
+
+ * fixed; regression when using subdoc with `path` as pathname #1245 [daeq](https://github.com/daeq)
+ * fixed; safer db option checks
+ * updated; driver to 1.2.5
+ * website; add more examples
+ * website; clean up old docs
+ * website; fix prev release urls
+ * docs; clarify streaming with HTTP responses
+
+3.5.0 / 2012-12-10
+==================
+
+ * added; paths to CastErrors #1239
+ * added; support for mongodb connection string spec #1187
+ * added; post validate event
+ * added; Schema#get (to retrieve schema options)
+ * added; VersionError #1071
+ * added; npmignore [hidekiy](https://github.com/hidekiy)
+ * update; driver to 1.2.3
+ * fixed; stackoverflow in setter #1234
+ * fixed; utils.isObject()
+ * fixed; do not clobber user specified driver writeConcern #1227
+ * fixed; always pass current document to post hooks
+ * fixed; throw error when user attempts to overwrite a model
+ * fixed; connection.model only caches on connection #1209
+ * fixed; respect conn.model() creation when matching global model exists #1209
+ * fixed; passing model name + collection name now always honors collection name
+ * fixed; setting virtual field to an empty object #1154
+ * fixed; subclassed MongooseErrors exposure, now available in mongoose.Error.xxxx
+ * fixed; model.remove() ignoring callback when executed twice [daeq](https://github.com/daeq) #1210
+ * docs; add collection option to schema api docs #1222
+ * docs; NOTE about db safe options
+ * docs; add post hooks docs
+ * docs; connection string options
+ * docs; middleware is not executed with Model.remove #1241
+ * docs; {g,s}etter introspection #777
+ * docs; update validation docs
+ * docs; add link to plugins page
+ * docs; clarify error returned by unique indexes #1225
+ * docs; more detail about disabling autoIndex behavior
+ * docs; add homepage section to package (npm docs mongoose)
+ * docs; more detail around collection name pluralization #1193
+ * website; add .important css
+ * website; update models page
+ * website; update getting started
+ * website; update quick start
+
+3.4.0 / 2012-11-10
+==================
+
+ * added; support for generic toJSON/toObject transforms #1160 #1020 #1197
+ * added; doc.set() merge support #1148 [NuORDER](https://github.com/NuORDER)
+ * added; query#add support #1188 [aleclofabbro](https://github.com/aleclofabbro)
+ * changed; adding invalid nested paths to non-objects throws 4216f14
+ * changed; fixed; stop invalid function cloning (internal fix)
+ * fixed; add query $and casting support #1180 [anotheri](https://github.com/anotheri)
+ * fixed; overwriting of query arguments #1176
+ * docs; fix expires examples
+ * docs; transforms
+ * docs; schema `collection` option docs [hermanjunge](https://github.com/hermanjunge)
+ * website; updated
+ * tests; added
+
+3.3.1 / 2012-10-11
+==================
+
+ * fixed; allow goose.connect(uris, dbname, opts) #1144
+ * docs; persist API private checked state across page loads
+
+3.3.0 / 2012-10-10
+==================
+
+ * fixed; passing options as 2nd arg to connect() #1144
+ * fixed; race condition after no-op save #1139
+ * fixed; schema field selection application in findAndModify #1150
+ * fixed; directly setting arrays #1126
+ * updated; driver to 1.1.11
+ * updated; collection pluralization rules [mrickard](https://github.com/mrickard)
+ * tests; added
+ * docs; updated
+
+3.2.2 / 2012-10-08
+==================
+
+ * updated; driver to 1.1.10 #1143
+ * updated; use sliced 0.0.3
+ * fixed; do not recast embedded docs unnecessarily
+ * fixed; expires schema option helper #1132
+ * fixed; built in string setters #1131
+ * fixed; debug output for Dates/ObjectId properties #1129
+ * docs; fixed Javascript syntax error in example [olalonde](https://github.com/olalonde)
+ * docs; fix toJSON example #1137
+ * docs; add ensureIndex production notes
+ * docs; fix spelling
+ * docs; add blogposts about v3
+ * website; updated
+ * removed; undocumented inGroupsOf util
+ * tests; added
+
+3.2.1 / 2012-09-28
+==================
+
+ * fixed; remove query batchSize option default of 1000 https://github.com/learnboost/mongoose/commit/3edaa8651
+ * docs; updated
+ * website; updated
+
+3.2.0 / 2012-09-27
+==================
+
+ * added; direct array index assignment with casting support `doc.array.set(index, value)`
+ * fixed; QueryStream#resume within same tick as pause() #1116
+ * fixed; default value validatation #1109
+ * fixed; array splice() not casting #1123
+ * fixed; default array construction edge case #1108
+ * fixed; query casting for inequalities in arrays #1101 [dpatti](https://github.com/dpatti)
+ * tests; added
+ * website; more documentation
+ * website; fixed layout issue #1111 [SlashmanX](https://github.com/SlashmanX)
+ * website; refactored [guille](https://github.com/guille)
+
+3.1.2 / 2012-09-10
+==================
+
+ * added; ReadPreferrence schema option #1097
+ * updated; driver to 1.1.7
+ * updated; default query batchSize to 1000
+ * fixed; we now cast the mapReduce query option #1095
+ * fixed; $elemMatch+$in with field selection #1091
+ * fixed; properly cast $elemMatch+$in conditions #1100
+ * fixed; default field application of subdocs #1027
+ * fixed; querystream prematurely dying #1092
+ * fixed; querystream never resumes when paused at getMore boundries #1092
+ * fixed; querystream occasionally emits data events after destroy #1092
+ * fixed; remove unnecessary ObjectId creation in querystream
+ * fixed; allow ne(boolean) again #1093
+ * docs; add populate/field selection syntax notes
+ * docs; add toObject/toJSON options detail
+ * docs; `read` schema option
+
+3.1.1 / 2012-08-31
+==================
+
+ * updated; driver to 1.1.6
+
+3.1.0 / 2012-08-29
+==================
+
+ * changed; fixed; directly setting nested objects now overwrites entire object (previously incorrectly merged them)
+ * added; read pref support (mongodb 2.2) 205a709c
+ * added; aggregate support (mongodb 2.2) f3a5bd3d
+ * added; virtual {g,s}etter introspection (#1070)
+ * updated; docs [brettz9](https://github.com/brettz9)
+ * updated; driver to 1.1.5
+ * fixed; retain virtual setter return values (#1069)
+
+3.0.3 / 2012-08-23
+==================
+
+ * fixed; use of nested paths beginning w/ numbers #1062
+ * fixed; query population edge case #1053 #1055 [jfremy](https://github.com/jfremy)
+ * fixed; simultaneous top and sub level array modifications #1073
+ * added; id and _id schema option aliases + tests
+ * improve debug formatting to allow copy/paste logged queries into mongo shell [eknkc](https://github.com/eknkc)
+ * docs
+
+3.0.2 / 2012-08-17
+==================
+
+ * added; missing support for v3 sort/select syntax to findAndModify helpers (#1058)
+ * fixed; replset fullsetup event emission
+ * fixed; reconnected event for replsets
+ * fixed; server reconnection setting discovery
+ * fixed; compat with non-schema path props using positional notation (#1048)
+ * fixed; setter/casting order (#665)
+ * docs; updated
+
+3.0.1 / 2012-08-11
+==================
+
+ * fixed; throw Error on bad validators (1044)
+ * fixed; typo in EmbeddedDocument#parentArray [lackac]
+ * fixed; repair mongoose.SchemaTypes alias
+ * updated; docs
+
+3.0.0 / 2012-08-07
+==================
+
+ * removed; old subdocument#commit method
+ * fixed; setting arrays of matching docs [6924cbc2]
+ * fixed; doc!remove event now emits in save order as save for consistency
+ * fixed; pre-save hooks no longer fire on subdocuments when validation fails
+ * added; subdoc#parent() and subdoc#parentArray() to access subdocument parent objects
+ * added; query#lean() helper
+
+3.0.0rc0 / 2012-08-01
+=====================
+
+ * fixed; allow subdoc literal declarations containing "type" pathname (#993)
+ * fixed; unsetting a default array (#758)
+ * fixed; boolean $in queries (#998)
+ * fixed; allow use of `options` as a pathname (#529)
+ * fixed; `model` is again a permitted schema path name
+ * fixed; field selection option on subdocs (#1022)
+ * fixed; handle another edge case with subdoc saving (#975)
+ * added; emit save err on model if listening
+ * added; MongoDB TTL collection support (#1006)
+ * added; $center options support
+ * added; $nearSphere and $polygon support
+ * updated; driver version to 1.1.2
+
+3.0.0alpha2 / 2012-07-18
+=========================
+
+ * changed; index errors are now emitted on their model and passed to an optional callback (#984)
+ * fixed; specifying index along with sparse/unique option no longer overwrites (#1004)
+ * fixed; never swallow connection errors (#618)
+ * fixed; creating object from model with emded object no longer overwrites defaults [achurkin] (#859)
+ * fixed; stop needless validation of unchanged/unselected fields (#891)
+ * fixed; document#equals behavior of objectids (#974)
+ * fixed; honor the minimize schema option (#978)
+ * fixed; provide helpful error msgs when reserved schema path is used (#928)
+ * fixed; callback to conn#disconnect is optional (#875)
+ * fixed; handle missing protocols in connection urls (#987)
+ * fixed; validate args to query#where (#969)
+ * fixed; saving modified/removed subdocs (#975)
+ * fixed; update with $pull from Mixed array (#735)
+ * fixed; error with null shard key value
+ * fixed; allow unsetting enums (#967)
+ * added; support for manual index creation (#984)
+ * added; support for disabled auto-indexing (#984)
+ * added; support for preserving MongooseArray#sort changes (#752)
+ * added; emit state change events on connection
+ * added; support for specifying BSON subtype in MongooseBuffer#toObject [jcrugzz]
+ * added; support for disabled versioning (#977)
+ * added; implicit "new" support for models and Schemas
+
+3.0.0alpha1 / 2012-06-15
+=========================
+
+ * removed; doc#commit (use doc#markModified)
+ * removed; doc.modified getter (#950)
+ * removed; mongoose{connectSet,createSetConnection}. use connect,createConnection instead
+ * removed; query alias methods 1149804c
+ * removed; MongooseNumber
+ * changed; now creating indexes in background by default
+ * changed; strict mode now enabled by default (#952)
+ * changed; doc#modifiedPaths is now a method (#950)
+ * changed; getters no longer cast (#820); casting happens during set
+ * fixed; no need to pass updateArg to findOneAndUpdate (#931)
+ * fixed: utils.merge bug when merging nested non-objects. [treygriffith]
+ * fixed; strict:throw should produce errors in findAndModify (#963)
+ * fixed; findAndUpdate no longer overwrites document (#962)
+ * fixed; setting default DocumentArrays (#953)
+ * fixed; selection of _id with schema deselection (#954)
+ * fixed; ensure promise#error emits instanceof Error
+ * fixed; CursorStream: No stack overflow on any size result (#929)
+ * fixed; doc#remove now passes safe options
+ * fixed; invalid use of $set during $pop
+ * fixed; array#{$pop,$shift} mirror MongoDB behavior
+ * fixed; no longer test non-required vals in string match (#934)
+ * fixed; edge case with doc#inspect
+ * fixed; setter order (#665)
+ * fixed; setting invalid paths in strict mode (#916)
+ * fixed; handle docs without id in DocumentArray#id method (#897)
+ * fixed; do not save virtuals during model.update (#894)
+ * fixed; sub doc toObject virtuals application (#889)
+ * fixed; MongooseArray#pull of ObjectId (#881)
+ * fixed; handle passing db name with any repl set string
+ * fixed; default application of selected fields (#870)
+ * fixed; subdoc paths reported in validation errors (#725)
+ * fixed; incorrect reported num of affected docs in update ops (#862)
+ * fixed; connection assignment in Model#model (#853)
+ * fixed; stringifying arrays of docs (#852)
+ * fixed; modifying subdoc and parent array works (#842)
+ * fixed; passing undefined to next hook (#785)
+ * fixed; Query#{update,remove}() works without callbacks (#788)
+ * fixed; set/updating nested objects by parent pathname (#843)
+ * fixed; allow null in number arrays (#840)
+ * fixed; isNew on sub doc after insertion error (#837)
+ * fixed; if an insert fails, set isNew back to false [boutell]
+ * fixed; isSelected when only _id is selected (#730)
+ * fixed; setting an unset default value (#742)
+ * fixed; query#sort error messaging (#671)
+ * fixed; support for passing $options with $regex
+ * added; array of object literal notation in schema creates DocumentArrays
+ * added; gt,gte,lt,lte query support for arrays (#902)
+ * added; capped collection support (#938)
+ * added; document versioning support
+ * added; inclusion of deselected schema path (#786)
+ * added; non-atomic array#pop
+ * added; EmbeddedDocument constructor is now exposed in DocArray#create 7cf8beec
+ * added; mapReduce support (#678)
+ * added; support for a configurable minimize option #to{Object,JSON}(option) (#848)
+ * added; support for strict: `throws` [regality]
+ * added; support for named schema types (#795)
+ * added; to{Object,JSON} schema options (#805)
+ * added; findByIdAnd{Update,Remove}()
+ * added; findOneAnd{Update,Remove}()
+ * added; query.setOptions()
+ * added; instance.update() (#794)
+ * added; support specifying model in populate() [DanielBaulig]
+ * added; `lean` query option [gitfy]
+ * added; multi-atomic support to MongooseArray#nonAtomicPush
+ * added; support for $set + other $atomic ops on single array
+ * added; tests
+ * updated; driver to 1.0.2
+ * updated; query.sort() syntax to mirror query.select()
+ * updated; clearer cast error msg for array numbers
+ * updated; docs
+ * updated; doc.clone 3x faster (#950)
+ * updated; only create _id if necessary (#950)
+
+2.7.3 / 2012-08-01
+==================
+
+ * fixed; boolean $in queries (#998)
+ * fixed field selection option on subdocs (#1022)
+
+2.7.2 / 2012-07-18
+==================
+
+ * fixed; callback to conn#disconnect is optional (#875)
+ * fixed; handle missing protocols in connection urls (#987)
+ * fixed; saving modified/removed subdocs (#975)
+ * updated; tests
+
+2.7.1 / 2012-06-26
+===================
+
+ * fixed; sharding: when a document holds a null as a value of the shard key
+ * fixed; update() using $pull on an array of Mixed (gh-735)
+ * deprecated; MongooseNumber#{inc, increment, decrement} methods
+ * tests; now using mocha
+
+2.7.0 / 2012-06-14
+===================
+
+ * added; deprecation warnings to methods being removed in 3.x
+
+2.6.8 / 2012-06-14
+===================
+
+ * fixed; edge case when using 'options' as a path name (#961)
+
+2.6.7 / 2012-06-08
+===================
+
+ * fixed; ensure promise#error always emits instanceof Error
+ * fixed; selection of _id w/ another excluded path (#954)
+ * fixed; setting default DocumentArrays (#953)
+
+2.6.6 / 2012-06-06
+===================
+
+ * fixed; stack overflow in query stream with large result sets (#929)
+ * added; $gt, $gte, $lt, $lte support to arrays (#902)
+ * fixed; pass option `safe` along to doc#remove() calls
+
+2.6.5 / 2012-05-24
+===================
+
+ * fixed; do not save virtuals in Model.update (#894)
+ * added; missing $ prefixed query aliases (going away in 3.x) (#884) [timoxley]
+ * fixed; setting invalid paths in strict mode (#916)
+ * fixed; resetting isNew after insert failure (#837) [boutell]
+
+2.6.4 / 2012-05-15
+===================
+
+ * updated; backport string regex $options to 2.x
+ * updated; use driver 1.0.2 (performance improvements) (#914)
+ * fixed; calling MongooseDocumentArray#id when the doc has no _id (#897)
+
+2.6.3 / 2012-05-03
+===================
+
+ * fixed; repl-set connectivity issues during failover on MongoDB 2.0.1
+ * updated; driver to 1.0.0
+ * fixed; virtuals application of subdocs when using toObject({ virtuals: true }) (#889)
+ * fixed; MongooseArray#pull of ObjectId correctly updates the array itself (#881)
+
+2.6.2 / 2012-04-30
+===================
+
+ * fixed; default field application of selected fields (#870)
+
+2.6.1 / 2012-04-30
+===================
+
+ * fixed; connection assignment in mongoose#model (#853, #877)
+ * fixed; incorrect reported num of affected docs in update ops (#862)
+
+2.6.0 / 2012-04-19
+===================
+
+ * updated; hooks.js to 0.2.1
+ * fixed; issue with passing undefined to a hook callback. thanks to [chrisleishman] for reporting.
+ * fixed; updating/setting nested objects in strict schemas (#843) as reported by [kof]
+ * fixed; Query#{update,remove}() work without callbacks again (#788)
+ * fixed; modifying subdoc along with parent array $atomic op (#842)
+
+2.5.14 / 2012-04-13
+===================
+
+ * fixed; setting an unset default value (#742)
+ * fixed; doc.isSelected(otherpath) when only _id is selected (#730)
+ * updated; docs
+
+2.5.13 / 2012-03-22
+===================
+
+ * fixed; failing validation of unselected required paths (#730,#713)
+ * fixed; emitting connection error when only one listener (#759)
+ * fixed; MongooseArray#splice was not returning values (#784) [chrisleishman]
+
+2.5.12 / 2012-03-21
+===================
+
+ * fixed; honor the `safe` option in all ensureIndex calls
+ * updated; node-mongodb-native driver to 0.9.9-7
+
+2.5.11 / 2012-03-15
+===================
+
+ * added; introspection for getters/setters (#745)
+ * updated; node-mongodb-driver to 0.9.9-5
+ * added; tailable method to Query (#769) [holic]
+ * fixed; Number min/max validation of null (#764) [btamas]
+ * added; more flexible user/password connection options (#738) [KarneAsada]
+
+2.5.10 / 2012-03-06
+===================
+
+ * updated; node-mongodb-native driver to 0.9.9-4
+ * added; Query#comment()
+ * fixed; allow unsetting arrays
+ * fixed; hooking the set method of subdocuments (#746)
+ * fixed; edge case in hooks
+ * fixed; allow $id and $ref in queries (fixes compatibility with mongoose-dbref) (#749) [richtera]
+ * added; default path selection to SchemaTypes
+
+2.5.9 / 2012-02-22
+===================
+
+ * fixed; properly cast nested atomic update operators for sub-documents
+
+2.5.8 / 2012-02-21
+===================
+
+ * added; post 'remove' middleware includes model that was removed (#729) [timoxley]
+
+2.5.7 / 2012-02-09
+===================
+
+ * fixed; RegExp validators on node >= v0.6.x
+
+2.5.6 / 2012-02-09
+===================
+
+ * fixed; emit errors returned from db.collection() on the connection (were being swallowed)
+ * added; can add multiple validators in your schema at once (#718) [diogogmt]
+ * fixed; strict embedded documents (#717)
+ * updated; docs [niemyjski]
+ * added; pass number of affected docs back in model.update/save
+
+2.5.5 / 2012-02-03
+===================
+
+ * fixed; RangeError: maximum call stack exceed error when removing docs with Number _id (#714)
+
+2.5.4 / 2012-02-03
+===================
+
+ * fixed; RangeError: maximum call stack exceed error (#714)
+
+2.5.3 / 2012-02-02
+===================
+
+ * added; doc#isSelected(path)
+ * added; query#equals()
+ * added; beta sharding support
+ * added; more descript error msgs (#700) [obeleh]
+ * added; document.modifiedPaths (#709) [ljharb]
+ * fixed; only functions can be added as getters/setters (#707,704) [ljharb]
+
+2.5.2 / 2012-01-30
+===================
+
+ * fixed; rollback -native driver to 0.9.7-3-5 (was causing timeouts and other replica set weirdness)
+ * deprecated; MongooseNumber (will be moved to a separate repo for 3.x)
+ * added; init event is emitted on schemas
+
+2.5.1 / 2012-01-27
+===================
+
+ * fixed; honor strict schemas in Model.update (#699)
+
+2.5.0 / 2012-01-26
+===================
+
+ * added; doc.toJSON calls toJSON on embedded docs when exists [jerem]
+ * added; populate support for refs of type Buffer (#686) [jerem]
+ * added; $all support for ObjectIds and Dates (#690)
+ * fixed; virtual setter calling on instantiation when strict: true (#682) [hunterloftis]
+ * fixed; doc construction triggering getters (#685)
+ * fixed; MongooseBuffer check in deepEquals (#688)
+ * fixed; range error when using Number _ids with `instance.save()` (#691)
+ * fixed; isNew on embedded docs edge case (#680)
+ * updated; driver to 0.9.8-3
+ * updated; expose `model()` method within static methods
+
+2.4.10 / 2012-01-10
+===================
+
+ * added; optional getter application in .toObject()/.toJSON() (#412)
+ * fixed; nested $operators in $all queries (#670)
+ * added; $nor support (#674)
+ * fixed; bug when adding nested schema (#662) [paulwe]
+
+2.4.9 / 2012-01-04
+===================
+
+ * updated; driver to 0.9.7-3-5 to fix Linux performance degradation on some boxes
+
+2.4.8 / 2011-12-22
+===================
+
+ * updated; bump -native to 0.9.7.2-5
+ * fixed; compatibility with date.js (#646) [chrisleishman]
+ * changed; undocumented schema "lax" option to "strict"
+ * fixed; default value population for strict schemas
+ * updated; the nextTick helper for small performance gain. 1bee2a2
+
+2.4.7 / 2011-12-16
+===================
+
+ * fixed; bug in 2.4.6 with path setting
+ * updated; bump -native to 0.9.7.2-1
+ * added; strict schema option [nw]
+
+2.4.6 / 2011-12-16
+===================
+
+ * fixed; conflicting mods on update bug [sirlantis]
+ * improved; doc.id getter performance
+
+2.4.5 / 2011-12-14
+===================
+
+ * fixed; bad MongooseArray behavior in 2.4.2 - 2.4.4
+
+2.4.4 / 2011-12-14
+===================
+
+ * fixed; MongooseArray#doAtomics throwing after sliced
+
+2.4.3 / 2011-12-14
+===================
+
+ * updated; system.profile schema for MongoDB 2x
+
+2.4.2 / 2011-12-12
+===================
+
+ * fixed; partially populating multiple children of subdocs (#639) [kenpratt]
+ * fixed; allow Update of numbers to null (#640) [jerem]
+
+2.4.1 / 2011-12-02
+===================
+
+ * added; options support for populate() queries
+ * updated; -native driver to 0.9.7-1.4
+
+2.4.0 / 2011-11-29
+===================
+
+ * added; QueryStreams (#614)
+ * added; debug print mode for development
+ * added; $within support to Array queries (#586) [ggoodale]
+ * added; $centerSphere query support
+ * fixed; $within support
+ * added; $unset is now used when setting a path to undefined (#519)
+ * added; query#batchSize support
+ * updated; docs
+ * updated; -native driver to 0.9.7-1.3 (provides Windows support)
+
+2.3.13 / 2011-11-15
+===================
+
+ * fixed; required validation for Refs (#612) [ded]
+ * added; $nearSphere support for Arrays (#610)
+
+2.3.12 / 2011-11-09
+===================
+
+ * fixed; regression, objects passed to Model.update should not be changed (#605)
+ * fixed; regression, empty Model.update should not be executed
+
+2.3.11 / 2011-11-08
+===================
+
+ * fixed; using $elemMatch on arrays of Mixed types (#591)
+ * fixed; allow using $regex when querying Arrays (#599)
+ * fixed; calling Model.update with no atomic keys (#602)
+
+2.3.10 / 2011-11-05
+===================
+
+ * fixed; model.update casting for nested paths works (#542)
+
+2.3.9 / 2011-11-04
+==================
+
+ * fixed; deepEquals check for MongooseArray returned false
+ * fixed; reset modified flags of embedded docs after save [gitfy]
+ * fixed; setting embedded doc with identical values no longer marks modified [gitfy]
+ * updated; -native driver to 0.9.6.23 [mlazarov]
+ * fixed; Model.update casting (#542, #545, #479)
+ * fixed; populated refs no longer fail required validators (#577)
+ * fixed; populating refs of objects with custom ids works
+ * fixed; $pop & $unset work with Model.update (#574)
+ * added; more helpful debugging message for Schema#add (#578)
+ * fixed; accessing .id when no _id exists now returns null (#590)
+
+2.3.8 / 2011-10-26
+==================
+
+ * added; callback to query#findOne is now optional (#581)
+
+2.3.7 / 2011-10-24
+==================
+
+ * fixed; wrapped save/remove callbacks in nextTick to mitigate -native swallowing thrown errors
+
+2.3.6 / 2011-10-21
+==================
+
+ * fixed; exclusion of embedded doc _id from query results (#541)
+
+2.3.5 / 2011-10-19
+==================
+
+ * fixed; calling queries without passing a callback works (#569)
+ * fixed; populate() works with String and Number _ids too (#568)
+
+2.3.4 / 2011-10-18
+==================
+
+ * added; Model.create now accepts an array as a first arg
+ * fixed; calling toObject on a DocumentArray with nulls no longer throws
+ * fixed; calling inspect on a DocumentArray with nulls no longer throws
+ * added; MongooseArray#unshift support
+ * fixed; save hooks now fire on embedded documents [gitfy] (#456)
+ * updated; -native driver to 0.9.6-22
+ * fixed; correctly pass $addToSet op instead of $push
+ * fixed; $addToSet properly detects dates
+ * fixed; $addToSet with multiple items works
+ * updated; better node 0.6 Buffer support
+
+2.3.3 / 2011-10-12
+==================
+
+ * fixed; population conditions in multi-query settings [vedmalex] (#563)
+ * fixed; now compatible with Node v0.5.x
+
+2.3.2 / 2011-10-11
+==================
+
+ * fixed; population of null subdoc properties no longer hangs (#561)
+
+2.3.1 / 2011-10-10
+==================
+
+ * added; support for Query filters to populate() [eneko]
+ * fixed; querying with number no longer crashes mongodb (#555) [jlbyrey]
+ * updated; version of -native driver to 0.9.6-21
+ * fixed; prevent query callbacks that throw errors from corrupting -native connection state
+
+2.3.0 / 2011-10-04
+==================
+
+ * fixed; nulls as default values for Boolean now works as expected
+ * updated; version of -native driver to 0.9.6-20
+
+2.2.4 / 2011-10-03
+==================
+
+ * fixed; populate() works when returned array contains undefined/nulls
+
+2.2.3 / 2011-09-29
+==================
+
+ * updated; version of -native driver to 0.9.6-19
+
+2.2.2 / 2011-09-28
+==================
+
+ * added; $regex support to String [davidandrewcope]
+ * added; support for other contexts like repl etc (#535)
+ * fixed; clear modified state properly after saving
+ * added; $addToSet support to Array
+
+2.2.1 / 2011-09-22
+==================
+
+ * more descript error when casting undefined to string
+ * updated; version of -native driver to 0.9.6-18
+
+2.2.0 / 2011-09-22
+==================
+
+ * fixed; maxListeners warning on schemas with many arrays (#530)
+ * changed; return / apply defaults based on fields selected in query (#423)
+ * fixed; correctly detect Mixed types within schema arrays (#532)
+
+2.1.4 / 2011-09-20
+==================
+
+ * fixed; new private methods that stomped on users code
+ * changed; finished removing old "compat" support which did nothing
+
+2.1.3 / 2011-09-16
+==================
+
+ * updated; version of -native driver to 0.9.6-15
+ * added; emit `error` on connection when open fails [edwardhotchkiss]
+ * added; index support to Buffers (thanks justmoon for helping track this down)
+ * fixed; passing collection name via schema in conn.model() now works (thanks vedmalex for reporting)
+
+2.1.2 / 2011-09-07
+==================
+
+ * fixed; Query#find with no args no longer throws
+
+2.1.1 / 2011-09-07
+==================
+
+ * added; support Model.count(fn)
+ * fixed; compatibility with node >=0.4.0 < 0.4.3
+ * added; pass model.options.safe through with .save() so w:2, wtimeout:5000 options work [andrewjstone]
+ * added; support for $type queries
+ * added; support for Query#or
+ * added; more tests
+ * optimized populate queries
+
+2.1.0 / 2011-09-01
+==================
+
+ * changed; document#validate is a public method
+ * fixed; setting number to same value no longer marks modified (#476) [gitfy]
+ * fixed; Buffers shouldn't have default vals
+ * added; allow specifying collection name in schema (#470) [ixti]
+ * fixed; reset modified paths and atomics after saved (#459)
+ * fixed; set isNew on embedded docs to false after save
+ * fixed; use self to ensure proper scope of options in doOpenSet (#483) [andrewjstone]
+
+2.0.4 / 2011-08-29
+==================
+
+ * Fixed; Only send the depopulated ObjectId instead of the entire doc on save (DBRefs)
+ * Fixed; Properly cast nested array values in Model.update (the data was stored in Mongo incorrectly but recast on document fetch was "fixing" it)
+
+2.0.3 / 2011-08-28
+==================
+
+ * Fixed; manipulating a populated array no longer causes infinite loop in BSON serializer during save (#477)
+ * Fixed; populating an empty array no longer hangs foreeeeeeeever (#481)
+
+2.0.2 / 2011-08-25
+==================
+
+ * Fixed; Maintain query option key order (fixes 'bad hint' error from compound query hints)
+
+2.0.1 / 2011-08-25
+==================
+
+ * Fixed; do not over-write the doc when no valide props exist in Model.update (#473)
+
+2.0.0 / 2011-08-24
+===================
+
+ * Added; support for Buffers [justmoon]
+ * Changed; improved error handling [maelstrom]
+ * Removed: unused utils.erase
+ * Fixed; support for passing other context object into Schemas (#234) [Sija]
+ * Fixed; getters are no longer circular refs to themselves (#366)
+ * Removed; unused compat.js
+ * Fixed; getter/setter scopes are set properly
+ * Changed; made several private properties more obvious by prefixing _
+ * Added; DBRef support [guille]
+ * Changed; removed support for multiple collection names per model
+ * Fixed; no longer applying setters when document returned from db
+ * Changed; default auto_reconnect to true
+ * Changed; Query#bind no longer clones the query
+ * Fixed; Model.update now accepts $pull, $inc and friends (#404)
+ * Added; virtual type option support [nw]
+
+1.8.4 / 2011-08-21
+===================
+
+ * Fixed; validation bug when instantiated with non-schema properties (#464) [jmreidy]
+
+1.8.3 / 2011-08-19
+===================
+
+ * Fixed; regression in connection#open [jshaw86]
+
+1.8.2 / 2011-08-17
+===================
+
+ * fixed; reset connection.readyState after failure [tomseago]
+ * fixed; can now query positionally for non-embedded docs (arrays of numbers/strings etc)
+ * fixed; embedded document query casting
+ * added; support for passing options to node-mongo-native db, server, and replsetserver [tomseago]
+
+1.8.1 / 2011-08-10
+===================
+
+ * fixed; ObjectIds were always marked modified
+ * fixed; can now query using document instances
+ * fixed; can now query/update using documents with subdocs
+
+1.8.0 / 2011-08-04
+===================
+
+ * fixed; can now use $all with String and Number
+ * fixed; can query subdoc array with $ne: null
+ * fixed; instance.subdocs#id now works with custom _ids
+ * fixed; do not apply setters when doc returned from db (change in bad behavior)
+
+1.7.4 / 2011-07-25
+===================
+
+ * fixed; sparse now a valid seperate schema option
+ * fixed; now catching cast errors in queries
+ * fixed; calling new Schema with object created in vm.runInNewContext now works (#384) [Sija]
+ * fixed; String enum was disallowing null
+ * fixed; Find by nested document _id now works (#389)
+
+1.7.3 / 2011-07-16
+===================
+
+ * fixed; MongooseArray#indexOf now works with ObjectIds
+ * fixed; validation scope now set properly (#418)
+ * fixed; added missing colors dependency (#398)
+
+1.7.2 / 2011-07-13
+===================
+
+ * changed; node-mongodb-native driver to v0.9.6.7
+
+1.7.1 / 2011-07-12
+===================
+
+ * changed; roll back node-mongodb-native driver to v0.9.6.4
+
+1.7.0 / 2011-07-12
+===================
+
+ * fixed; collection name misspelling [mathrawka]
+ * fixed; 2nd param is required for ReplSetServers [kevinmarvin]
+ * fixed; MongooseArray behaves properly with Object.keys
+ * changed; node-mongodb-native driver to v0.9.6.6
+ * fixed/changed; Mongodb segfault when passed invalid ObjectId (#407)
+ - This means invalid data passed to the ObjectId constructor will now error
+
+1.6.0 / 2011-07-07
+===================
+
+ * changed; .save() errors are now emitted on the instances db instead of the instance 9782463fc
+ * fixed; errors occurring when creating indexes now properly emit on db
+ * added; $maxDistance support to MongooseArrays
+ * fixed; RegExps now work with $all
+ * changed; node-mongodb-native driver to v0.9.6.4
+ * fixed; model names are now accessible via .modelName
+ * added; Query#slaveOk support
+
+1.5.0 / 2011-06-27
+===================
+
+ * changed; saving without a callback no longer ignores the error (@bnoguchi)
+ * changed; hook-js version bump to 0.1.9
+ * changed; node-mongodb-native version bumped to 0.9.6.1 - When .remove() doesn't
+ return an error, null is no longer passed.
+ * fixed; two memory leaks (@justmoon)
+ * added; sparse index support
+ * added; more ObjectId conditionals (gt, lt, gte, lte) (@phillyqueso)
+ * added; options are now passed in model#remote (@JerryLuke)
+
+1.4.0 / 2011-06-10
+===================
+
+ * bumped hooks-js dependency (fixes issue passing null as first arg to next())
+ * fixed; document#inspect now works properly with nested docs
+ * fixed; 'set' now works as a schema attribute (GH-365)
+ * fixed; _id is now set properly within pre-init hooks (GH-289)
+ * added; Query#distinct / Model#distinct support (GH-155)
+ * fixed; embedded docs now can use instance methods (GH-249)
+ * fixed; can now overwrite strings conflicting with schema type
+
+1.3.7 / 2011-06-03
+===================
+
+ * added MongooseArray#splice support
+ * fixed; 'path' is now a valid Schema pathname
+ * improved hooks (utilizing https://github.com/bnoguchi/hooks-js)
+ * fixed; MongooseArray#$shift now works (never did)
+ * fixed; Document.modified no longer throws
+ * fixed; modifying subdoc property sets modified paths for subdoc and parent doc
+ * fixed; marking subdoc path as modified properly persists the value to the db
+ * fixed; RexExps can again be saved ( #357 )
+
+1.3.6 / 2011-05-18
+===================
+
+ * fixed; corrected casting for queries against array types
+ * added; Document#set now accepts Document instances
+
+1.3.5 / 2011-05-17
+===================
+
+ * fixed; $ne queries work properly with single vals
+ * added; #inspect() methods to improve console.log output
+
+1.3.4 / 2011-05-17
+===================
+
+ * fixed; find by Date works as expected (#336)
+ * added; geospatial 2d index support
+ * added; support for $near (#309)
+ * updated; node-mongodb-native driver
+ * fixed; updating numbers work (#342)
+ * added; better error msg when try to remove an embedded doc without an _id (#307)
+ * added; support for 'on-the-fly' schemas (#227)
+ * changed; virtual id getters can now be skipped
+ * fixed; .index() called on subdoc schema now works as expected
+ * fixed; db.setProfile() now buffers until the db is open (#340)
+
+1.3.3 / 2011-04-27
+===================
+
+ * fixed; corrected query casting on nested mixed types
+
+1.3.2 / 2011-04-27
+===================
+
+ * fixed; query hints now retain key order
+
+1.3.1 / 2011-04-27
+===================
+
+ * fixed; setting a property on an embedded array no longer overwrites entire array (GH-310)
+ * fixed; setting nested properties works when sibling prop is named "type"
+ * fixed; isModified is now much finer grained when .set() is used (GH-323)
+ * fixed; mongoose.model() and connection.model() now return the Model (GH-308, GH-305)
+ * fixed; can now use $gt, $lt, $gte, $lte with String schema types (GH-317)
+ * fixed; .lowercase() -> .toLowerCase() in pluralize()
+ * fixed; updating an embedded document by index works (GH-334)
+ * changed; .save() now passes the instance to the callback (GH-294, GH-264)
+ * added; can now query system.profile and system.indexes collections
+ * added; db.model('system.profile') is now included as a default Schema
+ * added; db.setProfiling(level, ms, callback)
+ * added; Query#hint() support
+ * added; more tests
+ * updated node-mongodb-native to 0.9.3
+
+1.3.0 / 2011-04-19
+===================
+
+ * changed; save() callbacks now fire only once on failed validation
+ * changed; Errors returned from save() callbacks now instances of ValidationError
+ * fixed; MongooseArray#indexOf now works properly
+
+1.2.0 / 2011-04-11
+===================
+
+ * changed; MongooseNumber now casts empty string to null
+
+1.1.25 / 2011-04-08
+===================
+
+ * fixed; post init now fires at proper time
+
+1.1.24 / 2011-04-03
+===================
+
+ * fixed; pushing an array onto an Array works on existing docs
+
+1.1.23 / 2011-04-01
+===================
+
+ * Added Model#model
+
+1.1.22 / 2011-03-31
+===================
+
+ * Fixed; $in queries on mixed types now work
+
+1.1.21 / 2011-03-31
+===================
+
+ * Fixed; setting object root to null/undefined works
+
+1.1.20 / 2011-03-31
+===================
+
+ * Fixed; setting multiple props on null field works
+
+1.1.19 / 2011-03-31
+===================
+
+ * Fixed; no longer using $set on paths to an unexisting fields
+
+1.1.18 / 2011-03-30
+===================
+
+ * Fixed; non-mixed type object setters work after initd from null
+
+1.1.17 / 2011-03-30
+===================
+
+ * Fixed; nested object property access works when root initd with null value
+
+1.1.16 / 2011-03-28
+===================
+
+ * Fixed; empty arrays are now saved
+
+1.1.15 / 2011-03-28
+===================
+
+ * Fixed; `null` and `undefined` are set atomically.
+
+1.1.14 / 2011-03-28
+===================
+
+ * Changed; more forgiving date casting, accepting '' as null.
+
+1.1.13 / 2011-03-26
+===================
+
+ * Fixed setting values as `undefined`.
+
+1.1.12 / 2011-03-26
+===================
+
+ * Fixed; nested objects now convert to JSON properly
+ * Fixed; setting nested objects directly now works
+ * Update node-mongodb-native
+
+1.1.11 / 2011-03-25
+===================
+
+ * Fixed for use of `type` as a key.
+
+1.1.10 / 2011-03-23
+===================
+
+ * Changed; Make sure to only ensure indexes while connected
+
+1.1.9 / 2011-03-2
+==================
+
+ * Fixed; Mixed can now default to empty arrays
+ * Fixed; keys by the name 'type' are now valid
+ * Fixed; null values retrieved from the database are hydrated as null values.
+ * Fixed repeated atomic operations when saving a same document twice.
+
+1.1.8 / 2011-03-23
+==================
+
+ * Fixed 'id' overriding. [bnoguchi]
+
+1.1.7 / 2011-03-22
+==================
+
+ * Fixed RegExp query casting when querying against an Array of Strings [bnoguchi]
+ * Fixed getters/setters for nested virtualsl. [bnoguchi]
+
+1.1.6 / 2011-03-22
+==================
+
+ * Only doValidate when path exists in Schema [aheckmann]
+ * Allow function defaults for Array types [aheckmann]
+ * Fix validation hang [aheckmann]
+ * Fix setting of isRequired of SchemaType [aheckmann]
+ * Fix SchemaType#required(false) filter [aheckmann]
+ * More backwards compatibility [aheckmann]
+ * More tests [aheckmann]
+
+1.1.5 / 2011-03-14
+==================
+
+ * Added support for `uri, db, fn` and `uri, fn` signatures for replica sets.
+ * Improved/extended replica set tests.
+
+1.1.4 / 2011-03-09
+==================
+
+ * Fixed; running an empty Query doesn't throw. [aheckmann]
+ * Changed; Promise#addBack returns promise. [aheckmann]
+ * Added streaming cursor support. [aheckmann]
+ * Changed; Query#update defaults to use$SetOnSave now. [brian]
+ * Added more docs.
+
+1.1.3 / 2011-03-04
+==================
+
+ * Added Promise#resolve [aheckmann]
+ * Fixed backward compatibility with nulls [aheckmann]
+ * Changed; Query#{run,exec} return promises [aheckmann]
+
+1.1.2 / 2011-03-03
+==================
+
+ * Restored Query#exec and added notion of default operation [brian]
+ * Fixed ValidatorError messages [brian]
+
+1.1.1 / 2011-03-01
+==================
+
+ * Added SchemaType String `lowercase`, `uppercase`, `trim`.
+ * Public exports (`Model`, `Document`) and tests.
+ * Added ObjectId casting support for `Document`s.
+
+1.1.0 / 2011-02-25
+==================
+
+ * Added support for replica sets.
+
+1.0.16 / 2011-02-18
+===================
+
+ * Added $nin as another whitelisted $conditional for SchemaArray [brian]
+ * Changed #with to #where [brian]
+ * Added ability to use $in conditional with Array types [brian]
+
+1.0.15 / 2011-02-18
+===================
+
+ * Added `id` virtual getter for documents to easily access the hexString of
+ the `_id`.
+
+1.0.14 / 2011-02-17
+===================
+
+ * Fix for arrays within subdocuments [brian]
+
+1.0.13 / 2011-02-16
+===================
+
+ * Fixed embedded documents saving.
+
+1.0.12 / 2011-02-14
+===================
+
+ * Minor refactorings [brian]
+
+1.0.11 / 2011-02-14
+===================
+
+ * Query refactor and $ne, $slice, $or, $size, $elemMatch, $nin, $exists support [brian]
+ * Named scopes sugar [brian]
+
+1.0.10 / 2011-02-11
+===================
+
+ * Updated node-mongodb-native driver [thanks John Allen]
+
+1.0.9 / 2011-02-09
+==================
+
+ * Fixed single member arrays as defaults [brian]
+
+1.0.8 / 2011-02-09
+==================
+
+ * Fixed for collection-level buffering of commands [gitfy]
+ * Fixed `Document#toJSON` [dalejefferson]
+ * Fixed `Connection` authentication [robrighter]
+ * Fixed clash of accessors in getters/setters [eirikurn]
+ * Improved `Model#save` promise handling
+
+1.0.7 / 2011-02-05
+==================
+
+ * Fixed memory leak warnings for test suite on 0.3
+ * Fixed querying documents that have an array that contain at least one
+ specified member. [brian]
+ * Fixed default value for Array types (fixes GH-210). [brian]
+ * Fixed example code.
+
+1.0.6 / 2011-02-03
+==================
+
+ * Fixed `post` middleware
+ * Fixed; it's now possible to instantiate a model even when one of the paths maps
+ to an undefined value [brian]
+
+1.0.5 / 2011-02-02
+==================
+
+ * Fixed; combo $push and $pushAll auto-converts into a $pushAll [brian]
+ * Fixed; combo $pull and $pullAll auto-converts to a single $pullAll [brian]
+ * Fixed; $pullAll now removes said members from array before save (so it acts just
+ like pushAll) [brian]
+ * Fixed; multiple $pulls and $pushes become a single $pullAll and $pushAll.
+ Moreover, $pull now modifies the array before save to reflect the immediate
+ change [brian]
+ * Added tests for nested shortcut getters [brian]
+ * Added tests that show that Schemas with nested Arrays don't apply defaults
+ [brian]
+
+1.0.4 / 2011-02-02
+==================
+
+ * Added MongooseNumber#toString
+ * Added MongooseNumber unit tests
+
+1.0.3 / 2011-02-02
+==================
+
+ * Make sure safe mode works with Model#save
+ * Changed Schema options: safe mode is now the default
+ * Updated node-mongodb-native to HEAD
+
+1.0.2 / 2011-02-02
+==================
+
+ * Added a Model.create shortcut for creating documents. [brian]
+ * Fixed; we can now instantiate models with hashes that map to at least one
+ null value. [brian]
+ * Fixed Schema with more than 2 nested levels. [brian]
+
+1.0.1 / 2011-02-02
+==================
+
+ * Improved `MongooseNumber`, works almost like the native except for `typeof`
+ not being `'number'`.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/README.md
new file mode 100644
index 0000000..22a778a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/README.md
@@ -0,0 +1,322 @@
+# Mongoose
+
+Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment.
+
+[![Slack Status](http://slack.mongoosejs.io/badge.svg)](http://slack.mongoosejs.io)
+[![Build Status](https://api.travis-ci.org/Automattic/mongoose.svg?branch=master)](https://travis-ci.org/Automattic/mongoose)
+[![NPM version](https://badge.fury.io/js/mongoose.svg)](http://badge.fury.io/js/mongoose)
+[![Dependency Status](https://gemnasium.com/Automattic/mongoose.svg)](https://gemnasium.com/Automattic/mongoose)
+[![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/vkarpov?utm_source=github&utm_medium=button&utm_term=vkarpov&utm_campaign=github)
+
+## Documentation
+
+[mongoosejs.com](http://mongoosejs.com/)
+
+## Support
+
+ - [Stack Overflow](http://stackoverflow.com/questions/tagged/mongoose)
+ - [Bug Reports](https://github.com/Automattic/mongoose/issues/)
+ - [Mongoose Slack Channel](http://slack.mongoosejs.io/)
+ - [Help Forum](http://groups.google.com/group/mongoose-orm)
+ - [MongoDB Support](https://docs.mongodb.org/manual/support/)
+
+## Plugins
+
+Check out the [plugins search site](http://plugins.mongoosejs.io/) to see hundreds of related modules from the community.
+
+Build your own Mongoose plugin through [generator-mongoose-plugin](https://github.com/huei90/generator-mongoose-plugin).
+
+## Contributors
+
+View all 200+ [contributors](https://github.com/Automattic/mongoose/graphs/contributors). Stand up and be counted as a [contributor](https://github.com/Automattic/mongoose/blob/master/CONTRIBUTING.md) too!
+
+## Live Examples
+<a href="http://code.runnable.com/mongoose" target="_blank"><img src="http://i.imgur.com/4yNYDLI.png"></a>
+
+## Installation
+
+First install [node.js](http://nodejs.org/) and [mongodb](https://www.mongodb.org/downloads). Then:
+
+```sh
+$ npm install mongoose
+```
+
+## Stability
+
+The current stable branch is [master](https://github.com/Automattic/mongoose/tree/master). The [3.8.x](https://github.com/Automattic/mongoose/tree/3.8.x) branch contains legacy support for the 3.x release series, which is no longer under active development as of September 2015. The [3.8.x docs](http://mongoosejs.com/docs/3.8.x/) are still available.
+
+## Overview
+
+### Connecting to MongoDB
+
+First, we need to define a connection. If your app uses only one database, you should use `mongoose.connect`. If you need to create additional connections, use `mongoose.createConnection`.
+
+Both `connect` and `createConnection` take a `mongodb://` URI, or the parameters `host, database, port, options`.
+
+```js
+var mongoose = require('mongoose');
+
+mongoose.connect('mongodb://localhost/my_database');
+```
+
+Once connected, the `open` event is fired on the `Connection` instance. If you're using `mongoose.connect`, the `Connection` is `mongoose.connection`. Otherwise, `mongoose.createConnection` return value is a `Connection`.
+
+**Note:** _If the local connection fails then try using 127.0.0.1 instead of localhost. Sometimes issues may arise when the local hostname has been changed._
+
+**Important!** Mongoose buffers all the commands until it's connected to the database. This means that you don't have to wait until it connects to MongoDB in order to define models, run queries, etc.
+
+### Defining a Model
+
+Models are defined through the `Schema` interface.
+
+```js
+var Schema = mongoose.Schema,
+ ObjectId = Schema.ObjectId;
+
+var BlogPost = new Schema({
+ author : ObjectId,
+ title : String,
+ body : String,
+ date : Date
+});
+```
+
+Aside from defining the structure of your documents and the types of data you're storing, a Schema handles the definition of:
+
+* [Validators](http://mongoosejs.com/docs/validation.html) (async and sync)
+* [Defaults](http://mongoosejs.com/docs/api.html#schematype_SchemaType-default)
+* [Getters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-get)
+* [Setters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-set)
+* [Indexes](http://mongoosejs.com/docs/guide.html#indexes)
+* [Middleware](http://mongoosejs.com/docs/middleware.html)
+* [Methods](http://mongoosejs.com/docs/guide.html#methods) definition
+* [Statics](http://mongoosejs.com/docs/guide.html#statics) definition
+* [Plugins](http://mongoosejs.com/docs/plugins.html)
+* [pseudo-JOINs](http://mongoosejs.com/docs/populate.html)
+
+The following example shows some of these features:
+
+```js
+var Comment = new Schema({
+ name: { type: String, default: 'hahaha' },
+ age: { type: Number, min: 18, index: true },
+ bio: { type: String, match: /[a-z]/ },
+ date: { type: Date, default: Date.now },
+ buff: Buffer
+});
+
+// a setter
+Comment.path('name').set(function (v) {
+ return capitalize(v);
+});
+
+// middleware
+Comment.pre('save', function (next) {
+ notify(this.get('email'));
+ next();
+});
+```
+
+Take a look at the example in `examples/schema.js` for an end-to-end example of a typical setup.
+
+### Accessing a Model
+
+Once we define a model through `mongoose.model('ModelName', mySchema)`, we can access it through the same function
+
+```js
+var myModel = mongoose.model('ModelName');
+```
+
+Or just do it all at once
+
+```js
+var MyModel = mongoose.model('ModelName', mySchema);
+```
+
+The first argument is the _singular_ name of the collection your model is for. **Mongoose automatically looks for the _plural_ version of your model name.** For example, if you use
+
+```js
+var MyModel = mongoose.model('Ticket', mySchema);
+```
+
+Then Mongoose will create the model for your __tickets__ collection, not your __ticket__ collection.
+
+Once we have our model, we can then instantiate it, and save it:
+
+```js
+var instance = new MyModel();
+instance.my.key = 'hello';
+instance.save(function (err) {
+ //
+});
+```
+
+Or we can find documents from the same collection
+
+```js
+MyModel.find({}, function (err, docs) {
+ // docs.forEach
+});
+```
+
+You can also `findOne`, `findById`, `update`, etc. For more details check out [the docs](http://mongoosejs.com/docs/queries.html).
+
+**Important!** If you opened a separate connection using `mongoose.createConnection()` but attempt to access the model through `mongoose.model('ModelName')` it will not work as expected since it is not hooked up to an active db connection. In this case access your model through the connection you created:
+
+```js
+var conn = mongoose.createConnection('your connection string'),
+ MyModel = conn.model('ModelName', schema),
+ m = new MyModel;
+m.save(); // works
+```
+
+vs
+
+```js
+var conn = mongoose.createConnection('your connection string'),
+ MyModel = mongoose.model('ModelName', schema),
+ m = new MyModel;
+m.save(); // does not work b/c the default connection object was never connected
+```
+
+### Embedded Documents
+
+In the first example snippet, we defined a key in the Schema that looks like:
+
+```
+comments: [Comment]
+```
+
+Where `Comment` is a `Schema` we created. This means that creating embedded documents is as simple as:
+
+```js
+// retrieve my model
+var BlogPost = mongoose.model('BlogPost');
+
+// create a blog post
+var post = new BlogPost();
+
+// create a comment
+post.comments.push({ title: 'My comment' });
+
+post.save(function (err) {
+ if (!err) console.log('Success!');
+});
+```
+
+The same goes for removing them:
+
+```js
+BlogPost.findById(myId, function (err, post) {
+ if (!err) {
+ post.comments[0].remove();
+ post.save(function (err) {
+ // do something
+ });
+ }
+});
+```
+
+Embedded documents enjoy all the same features as your models. Defaults, validators, middleware. Whenever an error occurs, it's bubbled to the `save()` error callback, so error handling is a snap!
+
+
+### Middleware
+
+See the [docs](http://mongoosejs.com/docs/middleware.html) page.
+
+#### Intercepting and mutating method arguments
+
+You can intercept method arguments via middleware.
+
+For example, this would allow you to broadcast changes about your Documents every time someone `set`s a path in your Document to a new value:
+
+```js
+schema.pre('set', function (next, path, val, typel) {
+ // `this` is the current Document
+ this.emit('set', path, val);
+
+ // Pass control to the next pre
+ next();
+});
+```
+
+Moreover, you can mutate the incoming `method` arguments so that subsequent middleware see different values for those arguments. To do so, just pass the new values to `next`:
+
+```js
+.pre(method, function firstPre (next, methodArg1, methodArg2) {
+ // Mutate methodArg1
+ next("altered-" + methodArg1.toString(), methodArg2);
+});
+
+// pre declaration is chainable
+.pre(method, function secondPre (next, methodArg1, methodArg2) {
+ console.log(methodArg1);
+ // => 'altered-originalValOfMethodArg1'
+
+ console.log(methodArg2);
+ // => 'originalValOfMethodArg2'
+
+ // Passing no arguments to `next` automatically passes along the current argument values
+ // i.e., the following `next()` is equivalent to `next(methodArg1, methodArg2)`
+ // and also equivalent to, with the example method arg
+ // values, `next('altered-originalValOfMethodArg1', 'originalValOfMethodArg2')`
+ next();
+});
+```
+
+#### Schema gotcha
+
+`type`, when used in a schema has special meaning within Mongoose. If your schema requires using `type` as a nested property you must use object notation:
+
+```js
+new Schema({
+ broken: { type: Boolean },
+ asset: {
+ name: String,
+ type: String // uh oh, it broke. asset will be interpreted as String
+ }
+});
+
+new Schema({
+ works: { type: Boolean },
+ asset: {
+ name: String,
+ type: { type: String } // works. asset is an object with a type property
+ }
+});
+```
+
+### Driver Access
+
+Mongoose is built on top of the [official MongoDB Node.js driver](https://github.com/mongodb/node-mongodb-native). Each mongoose model keeps a reference to a [native MongoDB driver collection](http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html). The collection object can be accessed using `YourModel.collection`. However, using the collection object directly bypasses all mongoose features, including hooks, validation, etc. The one
+notable exception that `YourModel.collection` still buffers
+commands. As such, `YourModel.collection.find()` will **not**
+return a cursor.
+
+## API Docs
+
+Find the API docs [here](http://mongoosejs.com/docs/api.html), generated using [dox](https://github.com/tj/dox)
+and [acquit](https://github.com/vkarpov15/acquit).
+
+## License
+
+Copyright (c) 2010 LearnBoost &lt;dev@learnboost.com&gt;
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md
new file mode 100644
index 0000000..cb32898
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/README.md
@@ -0,0 +1,41 @@
+This directory contains runnable sample mongoose programs.
+
+To run:
+
+ - first install [Node.js](http://nodejs.org/)
+ - from the root of the project, execute `npm install -d`
+ - in the example directory, run `npm install -d`
+ - from the command line, execute: `node example.js`, replacing "example.js" with the name of a program.
+
+
+Goal is to show:
+
+- ~~global schemas~~
+- ~~GeoJSON schemas / use (with crs)~~
+- text search (once MongoDB removes the "Experimental/beta" label)
+- ~~lean queries~~
+- ~~statics~~
+- methods and statics on subdocs
+- custom types
+- ~~querybuilder~~
+- ~~promises~~
+- accessing driver collection, db
+- ~~connecting to replica sets~~
+- connecting to sharded clusters
+- enabling a fail fast mode
+- on the fly schemas
+- storing files
+- ~~map reduce~~
+- ~~aggregation~~
+- advanced hooks
+- using $elemMatch to return a subset of an array
+- query casting
+- upserts
+- pagination
+- express + mongoose session handling
+- ~~group by (use aggregation)~~
+- authentication
+- schema migration techniques
+- converting documents to plain objects (show transforms)
+- how to $unset
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js
new file mode 100644
index 0000000..793c8cb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/aggregate.js
@@ -0,0 +1,103 @@
+
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25)),
+ gender: 'Male',
+ likes: ['movies', 'games', 'dogs']
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30)),
+ gender: 'Female',
+ likes: ['movies', 'birds', 'cats']
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21)),
+ gender: 'Male',
+ likes: ['tv', 'games', 'rabbits']
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26)),
+ gender: 'Female',
+ likes: ['books', 'cats', 'dogs']
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000)),
+ gender: 'Male',
+ likes: ['glasses', 'wine', 'the night']
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) throw err;
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handle error
+ }
+
+ // run an aggregate query that will get all of the people who like a given
+ // item. To see the full documentation on ways to use the aggregate
+ // framework, see http://docs.mongodb.org/manual/core/aggregation/
+ Person.aggregate(
+ // select the fields we want to deal with
+ {$project: {name: 1, likes: 1}},
+ // unwind 'likes', which will create a document for each like
+ {$unwind: '$likes'},
+ // group everything by the like and then add each name with that like to
+ // the set for the like
+ {$group: {
+ _id: {likes: '$likes'},
+ likers: {$addToSet: '$name'}
+ }},
+ function(err, result) {
+ if (err) throw err;
+ console.log(result);
+ /* [
+ { _id: { likes: 'the night' }, likers: [ 'alucard' ] },
+ { _id: { likes: 'wine' }, likers: [ 'alucard' ] },
+ { _id: { likes: 'books' }, likers: [ 'lilly' ] },
+ { _id: { likes: 'glasses' }, likers: [ 'alucard' ] },
+ { _id: { likes: 'birds' }, likers: [ 'mary' ] },
+ { _id: { likes: 'rabbits' }, likers: [ 'bob' ] },
+ { _id: { likes: 'cats' }, likers: [ 'lilly', 'mary' ] },
+ { _id: { likes: 'dogs' }, likers: [ 'lilly', 'bill' ] },
+ { _id: { likes: 'tv' }, likers: [ 'bob' ] },
+ { _id: { likes: 'games' }, likers: [ 'bob', 'bill' ] },
+ { _id: { likes: 'movies' }, likers: [ 'mary', 'bill' ] }
+ ] */
+
+ cleanup();
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json
new file mode 100644
index 0000000..53ed2e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "aggregate-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for aggregate example",
+ "main": "aggregate.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js
new file mode 100644
index 0000000..607bb07
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/aggregate/person.js
@@ -0,0 +1,17 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date,
+ gender: String,
+ likes: [String]
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js
new file mode 100644
index 0000000..1f648b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/doc-methods.js
@@ -0,0 +1,77 @@
+
+var mongoose = require('mongoose');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Schema
+ */
+
+var CharacterSchema = Schema({
+ name: {
+ type: String,
+ required: true
+ },
+ health: {
+ type: Number,
+ min: 0,
+ max: 100
+ }
+});
+
+/**
+ * Methods
+ */
+
+CharacterSchema.methods.attack = function() {
+ console.log('%s is attacking', this.name);
+};
+
+/**
+ * Character model
+ */
+
+var Character = mongoose.model('Character', CharacterSchema);
+
+/**
+ * Connect to the database on localhost with
+ * the default port (27017)
+ */
+
+var dbname = 'mongoose-example-doc-methods-' + ((Math.random() * 10000) | 0);
+var uri = 'mongodb://localhost/' + dbname;
+
+console.log('connecting to %s', uri);
+
+mongoose.connect(uri, function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ example();
+});
+
+/**
+ * Use case
+ */
+
+function example() {
+ Character.create({name: 'Link', health: 100}, function(err, link) {
+ if (err) return done(err);
+ console.log('found', link);
+ link.attack(); // 'Link is attacking'
+ done();
+ });
+}
+
+/**
+ * Clean up
+ */
+
+function done(err) {
+ if (err) console.error(err);
+ mongoose.connection.db.dropDatabase(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md
new file mode 100644
index 0000000..7ba07b8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/README.md
@@ -0,0 +1 @@
+Mongoose + Express examples
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md
new file mode 100644
index 0000000..fc709a3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/README.md
@@ -0,0 +1,6 @@
+
+To run:
+
+- Execute `npm install` from this directory
+- Execute `node app.js`
+- Navigate to `localhost:8000`
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js
new file mode 100644
index 0000000..8fb2fee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/app.js
@@ -0,0 +1,17 @@
+
+var express = require('express');
+var mongoose = require('../../../lib');
+
+var uri = 'mongodb://localhost/mongoose-shared-connection';
+global.db = mongoose.createConnection(uri);
+
+var routes = require('./routes');
+
+var app = express();
+app.get('/', routes.home);
+app.get('/insert', routes.insert);
+app.get('/name', routes.modelName);
+
+app.listen(8000, function() {
+ console.log('listening on http://localhost:8000');
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js
new file mode 100644
index 0000000..78f9ff6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/modelA.js
@@ -0,0 +1,5 @@
+var Schema = require('../../../lib').Schema;
+var mySchema = Schema({name: String});
+
+/* global db */
+module.exports = db.model('MyModel', mySchema);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json
new file mode 100644
index 0000000..e326165
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "connection-sharing",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "ERROR: No README.md file found!",
+ "main": "app.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "express": "3.1.1" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js
new file mode 100644
index 0000000..35e4f8f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/express/connection-sharing/routes.js
@@ -0,0 +1,20 @@
+
+var model = require('./modelA');
+
+exports.home = function(req, res, next) {
+ model.find(function(err, docs) {
+ if (err) return next(err);
+ res.send(docs);
+ });
+};
+
+exports.modelName = function(req, res) {
+ res.send('my model name is ' + model.modelName);
+};
+
+exports.insert = function(req, res, next) {
+ model.create({name: 'inserting ' + Date.now()}, function(err, doc) {
+ if (err) return next(err);
+ res.send(doc);
+ });
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js
new file mode 100644
index 0000000..f950dea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONSchema.js
@@ -0,0 +1,22 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ // NOTE : This object must conform *precisely* to the geoJSON specification
+ // you cannot embed a geoJSON doc inside a model or anything like that- IT
+ // MUST BE VANILLA
+ var LocationObject = new Schema({
+ loc: {
+ type: {type: String},
+ coordinates: []
+ }
+ });
+ // define the index
+ LocationObject.index({loc: '2dsphere'});
+
+ mongoose.model('Location', LocationObject);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js
new file mode 100644
index 0000000..8e5dd2b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geoJSONexample.js
@@ -0,0 +1,56 @@
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./geoJSONSchema.js')();
+
+var Location = mongoose.model('Location');
+
+// define some dummy data
+// note: the type can be Point, LineString, or Polygon
+var data = [
+ {loc: {type: 'Point', coordinates: [-20.0, 5.0]}},
+ {loc: {type: 'Point', coordinates: [6.0, 10.0]}},
+ {loc: {type: 'Point', coordinates: [34.0, -50.0]}},
+ {loc: {type: 'Point', coordinates: [-100.0, 70.0]}},
+ {loc: {type: 'Point', coordinates: [38.0, 38.0]}}
+];
+
+
+mongoose.connect('mongodb://localhost/locations', function(err) {
+ if (err) {
+ throw err;
+ }
+
+ Location.on('index', function(err) {
+ if (err) {
+ throw err;
+ }
+ // create all of the dummy locations
+ async.each(data, function(item, cb) {
+ Location.create(item, cb);
+ }, function(err) {
+ if (err) {
+ throw err;
+ }
+ // create the location we want to search for
+ var coords = {type: 'Point', coordinates: [-5, 5]};
+ // search for it
+ Location.find({loc: {$near: coords}}).limit(1).exec(function(err, res) {
+ if (err) {
+ throw err;
+ }
+ console.log('Closest to %s is %s', JSON.stringify(coords), res);
+ cleanup();
+ });
+ });
+ });
+});
+
+function cleanup() {
+ Location.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js
new file mode 100644
index 0000000..3ff8c0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/geospatial.js
@@ -0,0 +1,100 @@
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25)),
+ gender: 'Male',
+ likes: ['movies', 'games', 'dogs'],
+ loc: [0, 0]
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30)),
+ gender: 'Female',
+ likes: ['movies', 'birds', 'cats'],
+ loc: [1, 1]
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21)),
+ gender: 'Male',
+ likes: ['tv', 'games', 'rabbits'],
+ loc: [3, 3]
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26)),
+ gender: 'Female',
+ likes: ['books', 'cats', 'dogs'],
+ loc: [6, 6]
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000)),
+ gender: 'Male',
+ likes: ['glasses', 'wine', 'the night'],
+ loc: [10, 10]
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) {
+ throw err;
+ }
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handler error
+ }
+
+ // let's find the closest person to bob
+ Person.find({name: 'bob'}, function(err, res) {
+ if (err) {
+ throw err;
+ }
+
+ res[0].findClosest(function(err, closest) {
+ if (err) {
+ throw err;
+ }
+
+ console.log('%s is closest to %s', res[0].name, closest);
+
+
+ // we can also just query straight off of the model. For more
+ // information about geospatial queries and indexes, see
+ // http://docs.mongodb.org/manual/applications/geospatial-indexes/
+ var coords = [7, 7];
+ Person.find({loc: {$nearSphere: coords}}).limit(1).exec(function(err, res) {
+ console.log('Closest to %s is %s', coords, res);
+ cleanup();
+ });
+ });
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json
new file mode 100644
index 0000000..75c2a0e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "geospatial-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for geospatial example",
+ "main": "geospatial.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js
new file mode 100644
index 0000000..e816637
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/geospatial/person.js
@@ -0,0 +1,27 @@
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date,
+ gender: String,
+ likes: [String],
+ // define the geospatial field
+ loc: {type: [Number], index: '2d'}
+ });
+
+ // define a method to find the closest person
+ PersonSchema.methods.findClosest = function(cb) {
+ return this.model('Person').find({
+ loc: {$nearSphere: this.loc},
+ name: {$ne: this.name}
+ }).limit(1).exec(cb);
+ };
+
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js
new file mode 100644
index 0000000..af9ff11
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/gs_example.js
@@ -0,0 +1,47 @@
+var mongoose = require('../../lib');
+
+
+// import the global schema, this can be done in any file that needs the model
+require('./person.js')();
+
+// grab the person model object
+var Person = mongoose.model('Person');
+
+// connect to a server to do a quick write / read example
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) {
+ throw err;
+ }
+
+ Person.create({
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25))
+ }, function(err, bill) {
+ if (err) {
+ throw err;
+ }
+ console.log('People added to db: %s', bill.toString());
+ Person.find({}, function(err, people) {
+ if (err) {
+ throw err;
+ }
+
+ people.forEach(function(person) {
+ console.log('People in the db: %s', person.toString());
+ });
+
+ // make sure to clean things up after we're done
+ setTimeout(function() {
+ cleanup();
+ }, 2000);
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js
new file mode 100644
index 0000000..39ae725
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/globalschemas/person.js
@@ -0,0 +1,14 @@
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js
new file mode 100644
index 0000000..763367f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/lean.js
@@ -0,0 +1,84 @@
+
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25)),
+ gender: 'Male',
+ likes: ['movies', 'games', 'dogs']
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30)),
+ gender: 'Female',
+ likes: ['movies', 'birds', 'cats']
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21)),
+ gender: 'Male',
+ likes: ['tv', 'games', 'rabbits']
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26)),
+ gender: 'Female',
+ likes: ['books', 'cats', 'dogs']
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000)),
+ gender: 'Male',
+ likes: ['glasses', 'wine', 'the night']
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) throw err;
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handle error
+ }
+
+ // lean queries return just plain javascript objects, not
+ // MongooseDocuments. This makes them good for high performance read
+ // situations
+
+ // when using .lean() the default is true, but you can explicitly set the
+ // value by passing in a boolean value. IE. .lean(false)
+ var q = Person.find({age: {$lt: 1000}}).sort('age').limit(2).lean();
+ q.exec(function(err, results) {
+ if (err) throw err;
+ console.log('Are the results MongooseDocuments?: %s', results[0] instanceof mongoose.Document);
+
+ console.log(results);
+ cleanup();
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json
new file mode 100644
index 0000000..6ee511d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "lean-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for lean example",
+ "main": "lean.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js
new file mode 100644
index 0000000..b0bd2ed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/lean/person.js
@@ -0,0 +1,16 @@
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date,
+ gender: String,
+ likes: [String]
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js
new file mode 100644
index 0000000..6d67fbf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/mapreduce.js
@@ -0,0 +1,100 @@
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25)),
+ gender: 'Male'
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30)),
+ gender: 'Female'
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21)),
+ gender: 'Male'
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26)),
+ gender: 'Female'
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000)),
+ gender: 'Male'
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) throw err;
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handle error
+ }
+
+ // alright, simple map reduce example. We will find the total ages of each
+ // gender
+
+ // create the options object
+ var o = {};
+
+ o.map = function() {
+ // in this function, 'this' refers to the current document being
+ // processed. Return the (gender, age) tuple using
+ /* global emit */
+ emit(this.gender, this.age);
+ };
+
+ // the reduce function receives the array of ages that are grouped by the
+ // id, which in this case is the gender
+ o.reduce = function(id, ages) {
+ return Array.sum(ages);
+ };
+
+ // other options that can be specified
+
+ // o.query = { age : { $lt : 1000 }}; // the query object
+ // o.limit = 3; // max number of documents
+ // o.keeptemp = true; // default is false, specifies whether to keep temp data
+ // o.finalize = someFunc; // function called after reduce
+ // o.scope = {}; // the scope variable exposed to map/reduce/finalize
+ // o.jsMode = true; // default is false, force execution to stay in JS
+ o.verbose = true; // default is false, provide stats on the job
+ // o.out = {}; // objects to specify where output goes, by default is
+ // returned, but can also be stored in a new collection
+ // see: http://mongoosejs.com/docs/api.html#model_Model.mapReduce
+ Person.mapReduce(o, function(err, results, stats) {
+ console.log('map reduce took %d ms', stats.processtime);
+ console.log(results);
+ cleanup();
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json
new file mode 100644
index 0000000..4240068
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "map-reduce-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for map reduce example",
+ "main": "mapreduce.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js
new file mode 100644
index 0000000..9e2f084
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/mapreduce/person.js
@@ -0,0 +1,16 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date,
+ gender: String
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js
new file mode 100644
index 0000000..fe6de72
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-across-three-collections.js
@@ -0,0 +1,134 @@
+
+var assert = require('assert');
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+var ObjectId = mongoose.Types.ObjectId;
+
+/**
+ * Connect to the db
+ */
+
+var dbname = 'testing_populateAdInfinitum_' + require('../../lib/utils').random();
+mongoose.connect('localhost', dbname);
+mongoose.connection.on('error', function() {
+ console.error('connection error', arguments);
+});
+
+/**
+ * Schemas
+ */
+
+var user = new Schema({
+ name: String,
+ friends: [{
+ type: Schema.ObjectId,
+ ref: 'User'
+ }]
+});
+var User = mongoose.model('User', user);
+
+var blogpost = Schema({
+ title: String,
+ tags: [String],
+ author: {
+ type: Schema.ObjectId,
+ ref: 'User'
+ }
+});
+var BlogPost = mongoose.model('BlogPost', blogpost);
+
+/**
+ * example
+ */
+
+mongoose.connection.on('open', function() {
+ /**
+ * Generate data
+ */
+
+ var userIds = [new ObjectId, new ObjectId, new ObjectId, new ObjectId];
+ var users = [];
+
+ users.push({
+ _id: userIds[0],
+ name: 'mary',
+ friends: [userIds[1], userIds[2], userIds[3]]
+ });
+ users.push({
+ _id: userIds[1],
+ name: 'bob',
+ friends: [userIds[0], userIds[2], userIds[3]]
+ });
+ users.push({
+ _id: userIds[2],
+ name: 'joe',
+ friends: [userIds[0], userIds[1], userIds[3]]
+ });
+ users.push({
+ _id: userIds[3],
+ name: 'sally',
+ friends: [userIds[0], userIds[1], userIds[2]]
+ });
+
+ User.create(users, function(err) {
+ assert.ifError(err);
+
+ var blogposts = [];
+ blogposts.push({
+ title: 'blog 1',
+ tags: ['fun', 'cool'],
+ author: userIds[3]
+ });
+ blogposts.push({
+ title: 'blog 2',
+ tags: ['cool'],
+ author: userIds[1]
+ });
+ blogposts.push({
+ title: 'blog 3',
+ tags: ['fun', 'odd'],
+ author: userIds[2]
+ });
+
+ BlogPost.create(blogposts, function(err) {
+ assert.ifError(err);
+
+ /**
+ * Population
+ */
+
+ BlogPost
+ .find({tags: 'fun'})
+ .lean()
+ .populate('author')
+ .exec(function(err, docs) {
+ assert.ifError(err);
+
+ /**
+ * Populate the populated documents
+ */
+
+ var opts = {
+ path: 'author.friends',
+ select: 'name',
+ options: {limit: 2}
+ };
+
+ BlogPost.populate(docs, opts, function(err, docs) {
+ assert.ifError(err);
+ console.log('populated');
+ var s = require('util').inspect(docs, {depth: null, colors: true});
+ console.log(s);
+ done();
+ });
+ });
+ });
+ });
+});
+
+function done(err) {
+ if (err) console.error(err.stack);
+ mongoose.connection.db.dropDatabase(function() {
+ mongoose.connection.close();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js
new file mode 100644
index 0000000..252cc53
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-basic.js
@@ -0,0 +1,103 @@
+
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Console schema
+ */
+
+var consoleSchema = Schema({
+ name: String,
+ manufacturer: String,
+ released: Date
+});
+var Console = mongoose.model('Console', consoleSchema);
+
+/**
+ * Game schema
+ */
+
+var gameSchema = Schema({
+ name: String,
+ developer: String,
+ released: Date,
+ consoles: [{
+ type: Schema.Types.ObjectId,
+ ref: 'Console'
+ }]
+});
+var Game = mongoose.model('Game', gameSchema);
+
+/**
+ * Connect to the console database on localhost with
+ * the default port (27017)
+ */
+
+mongoose.connect('mongodb://localhost/console', function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ createData();
+});
+
+/**
+ * Data generation
+ */
+
+function createData() {
+ Console.create(
+ {
+ name: 'Nintendo 64',
+ manufacturer: 'Nintendo',
+ released: 'September 29, 1996'
+ },
+ function(err, nintendo64) {
+ if (err) return done(err);
+
+ Game.create({
+ name: 'Legend of Zelda: Ocarina of Time',
+ developer: 'Nintendo',
+ released: new Date('November 21, 1998'),
+ consoles: [nintendo64]
+ },
+ function(err) {
+ if (err) return done(err);
+ example();
+ });
+ }
+ );
+}
+
+/**
+ * Population
+ */
+
+function example() {
+ Game
+ .findOne({name: /^Legend of Zelda/})
+ .populate('consoles')
+ .exec(function(err, ocinara) {
+ if (err) return done(err);
+
+ console.log(
+ '"%s" was released for the %s on %s',
+ ocinara.name,
+ ocinara.consoles[0].name,
+ ocinara.released.toLocaleDateString()
+ );
+
+ done();
+ });
+}
+
+function done(err) {
+ if (err) console.error(err);
+ Console.remove(function() {
+ Game.remove(function() {
+ mongoose.disconnect();
+ });
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js
new file mode 100644
index 0000000..c7eadfe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-existing-doc.js
@@ -0,0 +1,109 @@
+
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Console schema
+ */
+
+var consoleSchema = Schema({
+ name: String,
+ manufacturer: String,
+ released: Date
+});
+var Console = mongoose.model('Console', consoleSchema);
+
+/**
+ * Game schema
+ */
+
+var gameSchema = Schema({
+ name: String,
+ developer: String,
+ released: Date,
+ consoles: [{
+ type: Schema.Types.ObjectId,
+ ref: 'Console'
+ }]
+});
+var Game = mongoose.model('Game', gameSchema);
+
+/**
+ * Connect to the console database on localhost with
+ * the default port (27017)
+ */
+
+mongoose.connect('mongodb://localhost/console', function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ createData();
+});
+
+/**
+ * Data generation
+ */
+
+function createData() {
+ Console.create(
+ {
+ name: 'Nintendo 64',
+ manufacturer: 'Nintendo',
+ released: 'September 29, 1996'
+ },
+ function(err, nintendo64) {
+ if (err) return done(err);
+
+ Game.create({
+ name: 'Legend of Zelda: Ocarina of Time',
+ developer: 'Nintendo',
+ released: new Date('November 21, 1998'),
+ consoles: [nintendo64]
+ },
+ function(err) {
+ if (err) return done(err);
+ example();
+ });
+ }
+ );
+}
+
+/**
+ * Population
+ */
+
+function example() {
+ Game
+ .findOne({name: /^Legend of Zelda/})
+ .exec(function(err, ocinara) {
+ if (err) return done(err);
+
+ console.log('"%s" console _id: %s', ocinara.name, ocinara.consoles[0]);
+
+ // population of existing document
+ ocinara.populate('consoles', function(err) {
+ if (err) return done(err);
+
+ console.log(
+ '"%s" was released for the %s on %s',
+ ocinara.name,
+ ocinara.consoles[0].name,
+ ocinara.released.toLocaleDateString()
+ );
+
+ done();
+ });
+ });
+}
+
+function done(err) {
+ if (err) console.error(err);
+ Console.remove(function() {
+ Game.remove(function() {
+ mongoose.disconnect();
+ });
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js
new file mode 100644
index 0000000..61b4e85
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-of-multiple-existing-docs.js
@@ -0,0 +1,124 @@
+
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Console schema
+ */
+
+var consoleSchema = Schema({
+ name: String,
+ manufacturer: String,
+ released: Date
+});
+var Console = mongoose.model('Console', consoleSchema);
+
+/**
+ * Game schema
+ */
+
+var gameSchema = Schema({
+ name: String,
+ developer: String,
+ released: Date,
+ consoles: [{
+ type: Schema.Types.ObjectId,
+ ref: 'Console'
+ }]
+});
+var Game = mongoose.model('Game', gameSchema);
+
+/**
+ * Connect to the console database on localhost with
+ * the default port (27017)
+ */
+
+mongoose.connect('mongodb://localhost/console', function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ createData();
+});
+
+/**
+ * Data generation
+ */
+
+function createData() {
+ Console.create(
+ {
+ name: 'Nintendo 64',
+ manufacturer: 'Nintendo',
+ released: 'September 29, 1996'
+ },
+ {
+ name: 'Super Nintendo',
+ manufacturer: 'Nintendo',
+ released: 'August 23, 1991'
+ },
+ function(err, nintendo64, superNintendo) {
+ if (err) return done(err);
+
+ Game.create(
+ {
+ name: 'Legend of Zelda: Ocarina of Time',
+ developer: 'Nintendo',
+ released: new Date('November 21, 1998'),
+ consoles: [nintendo64]
+ },
+ {
+ name: 'Mario Kart',
+ developer: 'Nintendo',
+ released: 'September 1, 1992',
+ consoles: [superNintendo]
+ },
+ function(err) {
+ if (err) return done(err);
+ example();
+ }
+ );
+ }
+ );
+}
+
+/**
+ * Population
+ */
+
+function example() {
+ Game
+ .find({})
+ .exec(function(err, games) {
+ if (err) return done(err);
+
+ console.log('found %d games', games.length);
+
+ var options = {path: 'consoles', select: 'name released -_id'};
+ Game.populate(games, options, function(err, games) {
+ if (err) return done(err);
+
+ games.forEach(function(game) {
+ console.log(
+ '"%s" was released for the %s on %s',
+ game.name,
+ game.consoles[0].name,
+ game.released.toLocaleDateString()
+ );
+ });
+
+ done();
+ });
+ });
+}
+
+function done(err) {
+ if (err) console.error(err);
+ Console.remove(function() {
+ Game.remove(function() {
+ mongoose.disconnect();
+ });
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js
new file mode 100644
index 0000000..59cfd1e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-options.js
@@ -0,0 +1,138 @@
+
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Console schema
+ */
+
+var consoleSchema = Schema({
+ name: String,
+ manufacturer: String,
+ released: Date
+});
+var Console = mongoose.model('Console', consoleSchema);
+
+/**
+ * Game schema
+ */
+
+var gameSchema = Schema({
+ name: String,
+ developer: String,
+ released: Date,
+ consoles: [{
+ type: Schema.Types.ObjectId,
+ ref: 'Console'
+ }]
+});
+var Game = mongoose.model('Game', gameSchema);
+
+/**
+ * Connect to the console database on localhost with
+ * the default port (27017)
+ */
+
+mongoose.connect('mongodb://localhost/console', function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ createData();
+});
+
+/**
+ * Data generation
+ */
+
+function createData() {
+ Console.create(
+ {
+ name: 'Nintendo 64',
+ manufacturer: 'Nintendo',
+ released: 'September 29, 1996'
+ },
+ {
+ name: 'Super Nintendo',
+ manufacturer: 'Nintendo',
+ released: 'August 23, 1991'
+ },
+ {
+ name: 'XBOX 360',
+ manufacturer: 'Microsoft',
+ released: 'November 22, 2005'
+ },
+ function(err, nintendo64, superNintendo, xbox360) {
+ if (err) return done(err);
+
+ Game.create(
+ {
+ name: 'Legend of Zelda: Ocarina of Time',
+ developer: 'Nintendo',
+ released: new Date('November 21, 1998'),
+ consoles: [nintendo64]
+ },
+ {
+ name: 'Mario Kart',
+ developer: 'Nintendo',
+ released: 'September 1, 1992',
+ consoles: [superNintendo]
+ },
+ {
+ name: 'Perfect Dark Zero',
+ developer: 'Rare',
+ released: 'November 17, 2005',
+ consoles: [xbox360]
+ },
+ function(err) {
+ if (err) return done(err);
+ example();
+ }
+ );
+ }
+ );
+}
+
+/**
+ * Population
+ */
+
+function example() {
+ Game
+ .find({})
+ .populate({
+ path: 'consoles',
+ match: {manufacturer: 'Nintendo'},
+ select: 'name',
+ options: {comment: 'population'}
+ })
+ .exec(function(err, games) {
+ if (err) return done(err);
+
+ games.forEach(function(game) {
+ console.log(
+ '"%s" was released for the %s on %s',
+ game.name,
+ game.consoles.length ? game.consoles[0].name : '??',
+ game.released.toLocaleDateString()
+ );
+ });
+
+ return done();
+ });
+}
+
+/**
+ * Clean up
+ */
+
+function done(err) {
+ if (err) console.error(err);
+ Console.remove(function() {
+ Game.remove(function() {
+ mongoose.disconnect();
+ });
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js
new file mode 100644
index 0000000..ba849dc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/population/population-plain-objects.js
@@ -0,0 +1,106 @@
+
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+console.log('Running mongoose version %s', mongoose.version);
+
+/**
+ * Console schema
+ */
+
+var consoleSchema = Schema({
+ name: String,
+ manufacturer: String,
+ released: Date
+});
+var Console = mongoose.model('Console', consoleSchema);
+
+/**
+ * Game schema
+ */
+
+var gameSchema = Schema({
+ name: String,
+ developer: String,
+ released: Date,
+ consoles: [{
+ type: Schema.Types.ObjectId,
+ ref: 'Console'
+ }]
+});
+var Game = mongoose.model('Game', gameSchema);
+
+/**
+ * Connect to the console database on localhost with
+ * the default port (27017)
+ */
+
+mongoose.connect('mongodb://localhost/console', function(err) {
+ // if we failed to connect, abort
+ if (err) throw err;
+
+ // we connected ok
+ createData();
+});
+
+/**
+ * Data generation
+ */
+
+function createData() {
+ Console.create(
+ {
+ name: 'Nintendo 64',
+ manufacturer: 'Nintendo',
+ released: 'September 29, 1996'
+ },
+ function(err, nintendo64) {
+ if (err) return done(err);
+
+ Game.create(
+ {
+ name: 'Legend of Zelda: Ocarina of Time',
+ developer: 'Nintendo',
+ released: new Date('November 21, 1998'),
+ consoles: [nintendo64]
+ },
+ function(err) {
+ if (err) return done(err);
+ example();
+ }
+ );
+ }
+ );
+}
+
+/**
+ * Population
+ */
+
+function example() {
+ Game
+ .findOne({name: /^Legend of Zelda/})
+ .populate('consoles')
+ .lean() // just return plain objects, not documents wrapped by mongoose
+ .exec(function(err, ocinara) {
+ if (err) return done(err);
+
+ console.log(
+ '"%s" was released for the %s on %s',
+ ocinara.name,
+ ocinara.consoles[0].name,
+ ocinara.released.toLocaleDateString()
+ );
+
+ done();
+ });
+}
+
+function done(err) {
+ if (err) console.error(err);
+ Console.remove(function() {
+ Game.remove(function() {
+ mongoose.disconnect();
+ });
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json
new file mode 100644
index 0000000..1983250
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "promise-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for promise example",
+ "main": "promise.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js
new file mode 100644
index 0000000..40e2bf1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/person.js
@@ -0,0 +1,15 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js
new file mode 100644
index 0000000..3f17206
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/promises/promise.js
@@ -0,0 +1,94 @@
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25))
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30))
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21))
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26))
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000))
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) {
+ throw err;
+ }
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handle error
+ }
+
+ // create a promise (get one from the query builder)
+ var prom = Person.find({age: {$lt: 1000}}).exec();
+
+ // add a callback on the promise. This will be called on both error and
+ // complete
+ prom.addBack(function() {
+ console.log('completed');
+ });
+
+ // add a callback that is only called on complete (success) events
+ prom.addCallback(function() {
+ console.log('Successful Completion!');
+ });
+
+ // add a callback that is only called on err (rejected) events
+ prom.addErrback(function() {
+ console.log('Fail Boat');
+ });
+
+ // you can chain things just like in the promise/A+ spec
+ // note: each then() is returning a new promise, so the above methods
+ // that we defined will all fire after the initial promise is fulfilled
+ prom.then(function(people) {
+ // just getting the stuff for the next query
+ var ids = people.map(function(p) {
+ return p._id;
+ });
+
+ // return the next promise
+ return Person.find({_id: {$nin: ids}}).exec();
+ }).then(function(oldest) {
+ console.log('Oldest person is: %s', oldest);
+ }).then(cleanup);
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json
new file mode 100644
index 0000000..1a3450a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "query-builder-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for query builder example",
+ "main": "querybuilder.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js
new file mode 100644
index 0000000..40e2bf1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/person.js
@@ -0,0 +1,15 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js
new file mode 100644
index 0000000..6f8645b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/querybuilder/querybuilder.js
@@ -0,0 +1,79 @@
+
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25))
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30))
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21))
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26))
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000))
+ }
+];
+
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) throw err;
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) throw err;
+
+ // when querying data, instead of providing a callback, you can instead
+ // leave that off and get a query object returned
+ var query = Person.find({age: {$lt: 1000}});
+
+ // this allows you to continue applying modifiers to it
+ query.sort('birthday');
+ query.select('name');
+
+ // you can chain them together as well
+ // a full list of methods can be found:
+ // http://mongoosejs.com/docs/api.html#query-js
+ query.where('age').gt(21);
+
+ // finally, when ready to execute the query, call the exec() function
+ query.exec(function(err, results) {
+ if (err) throw err;
+
+ console.log(results);
+
+ cleanup();
+ });
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json
new file mode 100644
index 0000000..927dfd2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "replica-set-example",
+ "private": "true",
+ "version": "0.0.0",
+ "description": "deps for replica set example",
+ "main": "querybuilder.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": { "async": "*" },
+ "repository": "",
+ "author": "",
+ "license": "BSD"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js
new file mode 100644
index 0000000..40e2bf1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/person.js
@@ -0,0 +1,15 @@
+
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date
+ });
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js
new file mode 100644
index 0000000..9ebac1b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/replicasets/replica-sets.js
@@ -0,0 +1,71 @@
+
+// import async to make control flow simplier
+var async = require('async');
+
+// import the rest of the normal stuff
+var mongoose = require('../../lib');
+
+require('./person.js')();
+
+var Person = mongoose.model('Person');
+
+// define some dummy data
+var data = [
+ {
+ name: 'bill',
+ age: 25,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 25))
+ },
+ {
+ name: 'mary',
+ age: 30,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 30))
+ },
+ {
+ name: 'bob',
+ age: 21,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 21))
+ },
+ {
+ name: 'lilly',
+ age: 26,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 26))
+ },
+ {
+ name: 'alucard',
+ age: 1000,
+ birthday: new Date().setFullYear((new Date().getFullYear() - 1000))
+ }
+];
+
+
+// to connect to a replica set, pass in the comma delimited uri and optionally
+// any connection options such as the rs_name.
+var opts = {
+ replSet: {rs_name: 'rs0'}
+};
+mongoose.connect('mongodb://localhost:27018/persons,localhost:27019,localhost:27020', opts, function(err) {
+ if (err) throw err;
+
+ // create all of the dummy people
+ async.each(data, function(item, cb) {
+ Person.create(item, cb);
+ }, function(err) {
+ if (err) {
+ // handle error
+ }
+
+ // create and delete some data
+ var prom = Person.find({age: {$lt: 1000}}).exec();
+
+ prom.then(function(people) {
+ console.log('young people: %s', people);
+ }).then(cleanup);
+ });
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js
new file mode 100644
index 0000000..5bc99ae
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/schema.js
@@ -0,0 +1,119 @@
+/**
+ * Module dependencies.
+ */
+
+var mongoose = require('../../lib'),
+ Schema = mongoose.Schema;
+
+/**
+ * Schema definition
+ */
+
+// recursive embedded-document schema
+
+var Comment = new Schema();
+
+Comment.add({
+ title: {
+ type: String,
+ index: true
+ },
+ date: Date,
+ body: String,
+ comments: [Comment]
+});
+
+var BlogPost = new Schema({
+ title: {
+ type: String,
+ index: true
+ },
+ slug: {
+ type: String,
+ lowercase: true,
+ trim: true
+ },
+ date: Date,
+ buf: Buffer,
+ comments: [Comment],
+ creator: Schema.ObjectId
+});
+
+var Person = new Schema({
+ name: {
+ first: String,
+ last: String
+ },
+ email: {
+ type: String,
+ required: true,
+ index: {
+ unique: true,
+ sparse: true
+ }
+ },
+ alive: Boolean
+});
+
+/**
+ * Accessing a specific schema type by key
+ */
+
+BlogPost.path('date')
+.default(function() {
+ return new Date();
+})
+.set(function(v) {
+ return v === 'now' ? new Date() : v;
+});
+
+/**
+ * Pre hook.
+ */
+
+BlogPost.pre('save', function(next, done) {
+ /* global emailAuthor */
+ emailAuthor(done); // some async function
+ next();
+});
+
+/**
+ * Methods
+ */
+
+BlogPost.methods.findCreator = function(callback) {
+ return this.db.model('Person').findById(this.creator, callback);
+};
+
+BlogPost.statics.findByTitle = function(title, callback) {
+ return this.find({title: title}, callback);
+};
+
+BlogPost.methods.expressiveQuery = function(creator, date, callback) {
+ return this.find('creator', creator).where('date').gte(date).run(callback);
+};
+
+/**
+ * Plugins
+ */
+
+function slugGenerator(options) {
+ options = options || {};
+ var key = options.key || 'title';
+
+ return function slugGenerator(schema) {
+ schema.path(key).set(function(v) {
+ this.slug = v.toLowerCase().replace(/[^a-z0-9]/g, '').replace(/-+/g, '');
+ return v;
+ });
+ };
+}
+
+BlogPost.plugin(slugGenerator());
+
+/**
+ * Define model.
+ */
+
+mongoose.model('BlogPost', BlogPost);
+mongoose.model('Person', Person);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
new file mode 100644
index 0000000..284b478
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/index.js
@@ -0,0 +1,27 @@
+
+// modules
+var mongoose = require('../../../lib');
+var Schema = mongoose.Schema;
+
+// parse json
+var raw = require('./schema.json');
+
+// create a schema
+var timeSignatureSchema = Schema(raw);
+
+// compile the model
+var TimeSignature = mongoose.model('TimeSignatures', timeSignatureSchema);
+
+// create a TimeSignature document
+var threeFour = new TimeSignature({
+ count: 3,
+ unit: 4,
+ description: '3/4',
+ additive: false,
+ created: new Date,
+ links: ['http://en.wikipedia.org/wiki/Time_signature'],
+ user_id: '518d31a0ef32bbfa853a9814'
+});
+
+// print its description
+console.log(threeFour);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
new file mode 100644
index 0000000..5afc626
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/schema/storing-schemas-as-json/schema.json
@@ -0,0 +1,9 @@
+{
+ "count": "number",
+ "unit": "number",
+ "description": "string",
+ "links": ["string"],
+ "created": "date",
+ "additive": "boolean",
+ "user_id": "ObjectId"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js
new file mode 100644
index 0000000..a93b8c6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/person.js
@@ -0,0 +1,20 @@
+// import the necessary modules
+var mongoose = require('../../lib');
+var Schema = mongoose.Schema;
+
+// create an export function to encapsulate the model creation
+module.exports = function() {
+ // define schema
+ var PersonSchema = new Schema({
+ name: String,
+ age: Number,
+ birthday: Date
+ });
+
+ // define a static
+ PersonSchema.statics.findPersonByName = function(name, cb) {
+ this.find({name: new RegExp(name, 'i')}, cb);
+ };
+
+ mongoose.model('Person', PersonSchema);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js
new file mode 100644
index 0000000..610b2aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/examples/statics/statics.js
@@ -0,0 +1,41 @@
+var mongoose = require('../../lib');
+
+
+// import the schema
+require('./person.js')();
+
+// grab the person model object
+var Person = mongoose.model('Person');
+
+// connect to a server to do a quick write / read example
+
+mongoose.connect('mongodb://localhost/persons', function(err) {
+ if (err) {
+ throw err;
+ }
+
+ Person.create({name: 'bill', age: 25, birthday: new Date().setFullYear((new Date().getFullYear() - 25))},
+ function(err, bill) {
+ if (err) {
+ throw err;
+ }
+ console.log('People added to db: %s', bill.toString());
+
+ // using the static
+ Person.findPersonByName('bill', function(err, result) {
+ if (err) {
+ throw err;
+ }
+
+ console.log(result);
+ cleanup();
+ });
+ }
+ );
+});
+
+function cleanup() {
+ Person.remove(function() {
+ mongoose.disconnect();
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/index.js
new file mode 100644
index 0000000..e7e6278
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/index.js
@@ -0,0 +1,7 @@
+
+/**
+ * Export lib/mongoose
+ *
+ */
+
+module.exports = require('./lib/');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/ES6Promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/ES6Promise.js
new file mode 100644
index 0000000..13371ac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/ES6Promise.js
@@ -0,0 +1,26 @@
+/**
+ * ES6 Promise wrapper constructor.
+ *
+ * Promises are returned from executed queries. Example:
+ *
+ * var query = Candy.find({ bar: true });
+ * var promise = query.exec();
+ *
+ * DEPRECATED. Mongoose 5.0 will use native promises by default (or bluebird,
+ * if native promises are not present) but still
+ * support plugging in your own ES6-compatible promises library. Mongoose 5.0
+ * will **not** support mpromise.
+ *
+ * @param {Function} fn a function which will be called when the promise is resolved that accepts `fn(err, ...){}` as signature
+ * @api public
+ */
+
+function ES6Promise() {
+ throw new Error('Can\'t use ES6 promise with mpromise style constructor');
+}
+
+ES6Promise.use = function(Promise) {
+ ES6Promise.ES6 = Promise;
+};
+
+module.exports = ES6Promise;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/aggregate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/aggregate.js
new file mode 100644
index 0000000..bb24e88
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/aggregate.js
@@ -0,0 +1,685 @@
+/*!
+ * Module dependencies
+ */
+
+var util = require('util');
+var utils = require('./utils');
+var PromiseProvider = require('./promise_provider');
+var Query = require('./query');
+var read = Query.prototype.read;
+
+/**
+ * Aggregate constructor used for building aggregation pipelines.
+ *
+ * ####Example:
+ *
+ * new Aggregate();
+ * new Aggregate({ $project: { a: 1, b: 1 } });
+ * new Aggregate({ $project: { a: 1, b: 1 } }, { $skip: 5 });
+ * new Aggregate([{ $project: { a: 1, b: 1 } }, { $skip: 5 }]);
+ *
+ * Returned when calling Model.aggregate().
+ *
+ * ####Example:
+ *
+ * Model
+ * .aggregate({ $match: { age: { $gte: 21 }}})
+ * .unwind('tags')
+ * .exec(callback)
+ *
+ * ####Note:
+ *
+ * - The documents returned are plain javascript objects, not mongoose documents (since any shape of document can be returned).
+ * - Requires MongoDB >= 2.1
+ * - Mongoose does **not** cast pipeline stages. `new Aggregate({ $match: { _id: '00000000000000000000000a' } });` will not work unless `_id` is a string in the database. Use `new Aggregate({ $match: { _id: mongoose.Types.ObjectId('00000000000000000000000a') } });` instead.
+ *
+ * @see MongoDB http://docs.mongodb.org/manual/applications/aggregation/
+ * @see driver http://mongodb.github.com/node-mongodb-native/api-generated/collection.html#aggregate
+ * @param {Object|Array} [ops] aggregation operator(s) or operator array
+ * @api public
+ */
+
+function Aggregate() {
+ this._pipeline = [];
+ this._model = undefined;
+ this.options = undefined;
+
+ if (arguments.length === 1 && util.isArray(arguments[0])) {
+ this.append.apply(this, arguments[0]);
+ } else {
+ this.append.apply(this, arguments);
+ }
+}
+
+/**
+ * Binds this aggregate to a model.
+ *
+ * @param {Model} model the model to which the aggregate is to be bound
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.model = function(model) {
+ this._model = model;
+ return this;
+};
+
+/**
+ * Appends new operators to this aggregate pipeline
+ *
+ * ####Examples:
+ *
+ * aggregate.append({ $project: { field: 1 }}, { $limit: 2 });
+ *
+ * // or pass an array
+ * var pipeline = [{ $match: { daw: 'Logic Audio X' }} ];
+ * aggregate.append(pipeline);
+ *
+ * @param {Object} ops operator(s) to append
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.append = function() {
+ var args = (arguments.length === 1 && util.isArray(arguments[0]))
+ ? arguments[0]
+ : utils.args(arguments);
+
+ if (!args.every(isOperator)) {
+ throw new Error('Arguments must be aggregate pipeline operators');
+ }
+
+ this._pipeline = this._pipeline.concat(args);
+
+ return this;
+};
+
+/**
+ * Appends a new $project operator to this aggregate pipeline.
+ *
+ * Mongoose query [selection syntax](#query_Query-select) is also supported.
+ *
+ * ####Examples:
+ *
+ * // include a, include b, exclude _id
+ * aggregate.project("a b -_id");
+ *
+ * // or you may use object notation, useful when
+ * // you have keys already prefixed with a "-"
+ * aggregate.project({a: 1, b: 1, _id: 0});
+ *
+ * // reshaping documents
+ * aggregate.project({
+ * newField: '$b.nested'
+ * , plusTen: { $add: ['$val', 10]}
+ * , sub: {
+ * name: '$a'
+ * }
+ * })
+ *
+ * // etc
+ * aggregate.project({ salary_k: { $divide: [ "$salary", 1000 ] } });
+ *
+ * @param {Object|String} arg field specification
+ * @see projection http://docs.mongodb.org/manual/reference/aggregation/project/
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.project = function(arg) {
+ var fields = {};
+
+ if (typeof arg === 'object' && !util.isArray(arg)) {
+ Object.keys(arg).forEach(function(field) {
+ fields[field] = arg[field];
+ });
+ } else if (arguments.length === 1 && typeof arg === 'string') {
+ arg.split(/\s+/).forEach(function(field) {
+ if (!field) {
+ return;
+ }
+ var include = field[0] === '-' ? 0 : 1;
+ if (include === 0) {
+ field = field.substring(1);
+ }
+ fields[field] = include;
+ });
+ } else {
+ throw new Error('Invalid project() argument. Must be string or object');
+ }
+
+ return this.append({$project: fields});
+};
+
+/**
+ * Appends a new custom $group operator to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.group({ _id: "$department" });
+ *
+ * @see $group http://docs.mongodb.org/manual/reference/aggregation/group/
+ * @method group
+ * @memberOf Aggregate
+ * @param {Object} arg $group operator contents
+ * @return {Aggregate}
+ * @api public
+ */
+
+/**
+ * Appends a new custom $match operator to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.match({ department: { $in: [ "sales", "engineering" } } });
+ *
+ * @see $match http://docs.mongodb.org/manual/reference/aggregation/match/
+ * @method match
+ * @memberOf Aggregate
+ * @param {Object} arg $match operator contents
+ * @return {Aggregate}
+ * @api public
+ */
+
+/**
+ * Appends a new $skip operator to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.skip(10);
+ *
+ * @see $skip http://docs.mongodb.org/manual/reference/aggregation/skip/
+ * @method skip
+ * @memberOf Aggregate
+ * @param {Number} num number of records to skip before next stage
+ * @return {Aggregate}
+ * @api public
+ */
+
+/**
+ * Appends a new $limit operator to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.limit(10);
+ *
+ * @see $limit http://docs.mongodb.org/manual/reference/aggregation/limit/
+ * @method limit
+ * @memberOf Aggregate
+ * @param {Number} num maximum number of records to pass to the next stage
+ * @return {Aggregate}
+ * @api public
+ */
+
+/**
+ * Appends a new $geoNear operator to this aggregate pipeline.
+ *
+ * ####NOTE:
+ *
+ * **MUST** be used as the first operator in the pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.near({
+ * near: [40.724, -73.997],
+ * distanceField: "dist.calculated", // required
+ * maxDistance: 0.008,
+ * query: { type: "public" },
+ * includeLocs: "dist.location",
+ * uniqueDocs: true,
+ * num: 5
+ * });
+ *
+ * @see $geoNear http://docs.mongodb.org/manual/reference/aggregation/geoNear/
+ * @method near
+ * @memberOf Aggregate
+ * @param {Object} parameters
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.near = function(arg) {
+ var op = {};
+ op.$geoNear = arg;
+ return this.append(op);
+};
+
+/*!
+ * define methods
+ */
+
+'group match skip limit out'.split(' ').forEach(function($operator) {
+ Aggregate.prototype[$operator] = function(arg) {
+ var op = {};
+ op['$' + $operator] = arg;
+ return this.append(op);
+ };
+});
+
+/**
+ * Appends new custom $unwind operator(s) to this aggregate pipeline.
+ *
+ * Note that the `$unwind` operator requires the path name to start with '$'.
+ * Mongoose will prepend '$' if the specified field doesn't start '$'.
+ *
+ * ####Examples:
+ *
+ * aggregate.unwind("tags");
+ * aggregate.unwind("a", "b", "c");
+ *
+ * @see $unwind http://docs.mongodb.org/manual/reference/aggregation/unwind/
+ * @param {String} fields the field(s) to unwind
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.unwind = function() {
+ var args = utils.args(arguments);
+
+ var res = [];
+ for (var i = 0; i < args.length; ++i) {
+ var arg = args[i];
+ if (arg && typeof arg === 'object') {
+ res.push({ $unwind: arg });
+ } else if (typeof arg === 'string') {
+ res.push({
+ $unwind: (arg && arg.charAt(0) === '$') ? arg : '$' + arg
+ });
+ } else {
+ throw new Error('Invalid arg "' + arg + '" to unwind(), ' +
+ 'must be string or object');
+ }
+ }
+
+ return this.append.apply(this, res);
+};
+
+/**
+ * Appends new custom $lookup operator(s) to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.lookup({ from: 'users', localField: 'userId', foreignField: '_id', as: 'users' });
+ *
+ * @see $lookup https://docs.mongodb.org/manual/reference/operator/aggregation/lookup/#pipe._S_lookup
+ * @param {Object} options to $lookup as described in the above link
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.lookup = function(options) {
+ return this.append({$lookup: options});
+};
+
+/**
+ * Appends new custom $sample operator(s) to this aggregate pipeline.
+ *
+ * ####Examples:
+ *
+ * aggregate.sample(3); // Add a pipeline that picks 3 random documents
+ *
+ * @see $sample https://docs.mongodb.org/manual/reference/operator/aggregation/sample/#pipe._S_sample
+ * @param {Number} size number of random documents to pick
+ * @return {Aggregate}
+ * @api public
+ */
+
+Aggregate.prototype.sample = function(size) {
+ return this.append({$sample: {size: size}});
+};
+
+/**
+ * Appends a new $sort operator to this aggregate pipeline.
+ *
+ * If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`.
+ *
+ * If a string is passed, it must be a space delimited list of path names. The sort order of each path is ascending unless the path name is prefixed with `-` which will be treated as descending.
+ *
+ * ####Examples:
+ *
+ * // these are equivalent
+ * aggregate.sort({ field: 'asc', test: -1 });
+ * aggregate.sort('field -test');
+ *
+ * @see $sort http://docs.mongodb.org/manual/reference/aggregation/sort/
+ * @param {Object|String} arg
+ * @return {Aggregate} this
+ * @api public
+ */
+
+Aggregate.prototype.sort = function(arg) {
+ // TODO refactor to reuse the query builder logic
+
+ var sort = {};
+
+ if (arg.constructor.name === 'Object') {
+ var desc = ['desc', 'descending', -1];
+ Object.keys(arg).forEach(function(field) {
+ sort[field] = desc.indexOf(arg[field]) === -1 ? 1 : -1;
+ });
+ } else if (arguments.length === 1 && typeof arg === 'string') {
+ arg.split(/\s+/).forEach(function(field) {
+ if (!field) {
+ return;
+ }
+ var ascend = field[0] === '-' ? -1 : 1;
+ if (ascend === -1) {
+ field = field.substring(1);
+ }
+ sort[field] = ascend;
+ });
+ } else {
+ throw new TypeError('Invalid sort() argument. Must be a string or object.');
+ }
+
+ return this.append({$sort: sort});
+};
+
+/**
+ * Sets the readPreference option for the aggregation query.
+ *
+ * ####Example:
+ *
+ * Model.aggregate(..).read('primaryPreferred').exec(callback)
+ *
+ * @param {String} pref one of the listed preference options or their aliases
+ * @param {Array} [tags] optional tags for this query
+ * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
+ * @see driver http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
+ */
+
+Aggregate.prototype.read = function(pref, tags) {
+ if (!this.options) {
+ this.options = {};
+ }
+ read.call(this, pref, tags);
+ return this;
+};
+
+/**
+ * Execute the aggregation with explain
+ *
+ * ####Example:
+ *
+ * Model.aggregate(..).explain(callback)
+ *
+ * @param {Function} callback
+ * @return {Promise}
+ */
+
+Aggregate.prototype.explain = function(callback) {
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ if (!_this._pipeline.length) {
+ var err = new Error('Aggregate has empty pipeline');
+ if (callback) {
+ callback(err);
+ }
+ reject(err);
+ return;
+ }
+
+ prepareDiscriminatorPipeline(_this);
+
+ _this._model
+ .collection
+ .aggregate(_this._pipeline, _this.options || {})
+ .explain(function(error, result) {
+ if (error) {
+ if (callback) {
+ callback(error);
+ }
+ reject(error);
+ return;
+ }
+
+ if (callback) {
+ callback(null, result);
+ }
+ resolve(result);
+ });
+ });
+};
+
+/**
+ * Sets the allowDiskUse option for the aggregation query (ignored for < 2.6.0)
+ *
+ * ####Example:
+ *
+ * Model.aggregate(..).allowDiskUse(true).exec(callback)
+ *
+ * @param {Boolean} value Should tell server it can use hard drive to store data during aggregation.
+ * @param {Array} [tags] optional tags for this query
+ * @see mongodb http://docs.mongodb.org/manual/reference/command/aggregate/
+ */
+
+Aggregate.prototype.allowDiskUse = function(value) {
+ if (!this.options) {
+ this.options = {};
+ }
+ this.options.allowDiskUse = value;
+ return this;
+};
+
+/**
+ * Sets the cursor option option for the aggregation query (ignored for < 2.6.0).
+ * Note the different syntax below: .exec() returns a cursor object, and no callback
+ * is necessary.
+ *
+ * ####Example:
+ *
+ * var cursor = Model.aggregate(..).cursor({ batchSize: 1000 }).exec();
+ * cursor.each(function(error, doc) {
+ * // use doc
+ * });
+ *
+ * @param {Object} options set the cursor batch size
+ * @see mongodb http://mongodb.github.io/node-mongodb-native/2.0/api/AggregationCursor.html
+ */
+
+Aggregate.prototype.cursor = function(options) {
+ if (!this.options) {
+ this.options = {};
+ }
+ this.options.cursor = options || {};
+ return this;
+};
+
+/**
+ * Adds a [cursor flag](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag)
+ *
+ * ####Example:
+ *
+ * var cursor = Model.aggregate(..).cursor({ batchSize: 1000 }).exec();
+ * cursor.each(function(error, doc) {
+ * // use doc
+ * });
+ *
+ * @param {String} flag
+ * @param {Boolean} value
+ * @see mongodb http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag
+ */
+
+Aggregate.prototype.addCursorFlag = function(flag, value) {
+ if (!this.options) {
+ this.options = {};
+ }
+ this.options[flag] = value;
+ return this;
+};
+
+/**
+ * Executes the aggregate pipeline on the currently bound Model.
+ *
+ * ####Example:
+ *
+ * aggregate.exec(callback);
+ *
+ * // Because a promise is returned, the `callback` is optional.
+ * var promise = aggregate.exec();
+ * promise.then(..);
+ *
+ * @see Promise #promise_Promise
+ * @param {Function} [callback]
+ * @return {Promise}
+ * @api public
+ */
+
+Aggregate.prototype.exec = function(callback) {
+ if (!this._model) {
+ throw new Error('Aggregate not bound to any Model');
+ }
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ var options = utils.clone(this.options);
+
+ if (options && options.cursor) {
+ if (options.cursor.async) {
+ delete options.cursor.async;
+ return new Promise.ES6(function(resolve) {
+ if (!_this._model.collection.buffer) {
+ process.nextTick(function() {
+ var cursor = _this._model.collection.
+ aggregate(_this._pipeline, options || {});
+ resolve(cursor);
+ callback && callback(null, cursor);
+ });
+ return;
+ }
+ _this._model.collection.emitter.once('queue', function() {
+ var cursor = _this._model.collection.
+ aggregate(_this._pipeline, options || {});
+ resolve(cursor);
+ callback && callback(null, cursor);
+ });
+ });
+ }
+ return this._model.collection.
+ aggregate(this._pipeline, this.options || {});
+ }
+
+ return new Promise.ES6(function(resolve, reject) {
+ if (!_this._pipeline.length) {
+ var err = new Error('Aggregate has empty pipeline');
+ if (callback) {
+ callback(err);
+ }
+ reject(err);
+ return;
+ }
+
+ prepareDiscriminatorPipeline(_this);
+
+ _this._model
+ .collection
+ .aggregate(_this._pipeline, _this.options || {}, function(error, result) {
+ if (error) {
+ if (callback) {
+ callback(error);
+ }
+ reject(error);
+ return;
+ }
+
+ if (callback) {
+ callback(null, result);
+ }
+ resolve(result);
+ });
+ });
+};
+
+/**
+ * Provides promise for aggregate.
+ *
+ * ####Example:
+ *
+ * Model.aggregate(..).then(successCallback, errorCallback);
+ *
+ * @see Promise #promise_Promise
+ * @param {Function} [resolve] successCallback
+ * @param {Function} [reject] errorCallback
+ * @return {Promise}
+ */
+Aggregate.prototype.then = function(resolve, reject) {
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ var promise = new Promise.ES6(function(success, error) {
+ _this.exec(function(err, val) {
+ if (err) error(err);
+ else success(val);
+ });
+ });
+ return promise.then(resolve, reject);
+};
+
+/*!
+ * Helpers
+ */
+
+/**
+ * Checks whether an object is likely a pipeline operator
+ *
+ * @param {Object} obj object to check
+ * @return {Boolean}
+ * @api private
+ */
+
+function isOperator(obj) {
+ var k;
+
+ if (typeof obj !== 'object') {
+ return false;
+ }
+
+ k = Object.keys(obj);
+
+ return k.length === 1 && k
+ .some(function(key) {
+ return key[0] === '$';
+ });
+}
+
+/*!
+ * Adds the appropriate `$match` pipeline step to the top of an aggregate's
+ * pipeline, should it's model is a non-root discriminator type. This is
+ * analogous to the `prepareDiscriminatorCriteria` function in `lib/query.js`.
+ *
+ * @param {Aggregate} aggregate Aggregate to prepare
+ */
+
+function prepareDiscriminatorPipeline(aggregate) {
+ var schema = aggregate._model.schema,
+ discriminatorMapping = schema && schema.discriminatorMapping;
+
+ if (discriminatorMapping && !discriminatorMapping.isRoot) {
+ var originalPipeline = aggregate._pipeline,
+ discriminatorKey = discriminatorMapping.key,
+ discriminatorValue = discriminatorMapping.value;
+
+ // If the first pipeline stage is a match and it doesn't specify a `__t`
+ // key, add the discriminator key to it. This allows for potential
+ // aggregation query optimizations not to be disturbed by this feature.
+ if (originalPipeline[0] && originalPipeline[0].$match && !originalPipeline[0].$match[discriminatorKey]) {
+ originalPipeline[0].$match[discriminatorKey] = discriminatorValue;
+ // `originalPipeline` is a ref, so there's no need for
+ // aggregate._pipeline = originalPipeline
+ } else if (originalPipeline[0] && originalPipeline[0].$geoNear) {
+ originalPipeline[0].$geoNear.query =
+ originalPipeline[0].$geoNear.query || {};
+ originalPipeline[0].$geoNear.query[discriminatorKey] = discriminatorValue;
+ } else {
+ var match = {};
+ match[discriminatorKey] = discriminatorValue;
+ aggregate._pipeline = [{$match: match}].concat(originalPipeline);
+ }
+ }
+}
+
+
+/*!
+ * Exports
+ */
+
+module.exports = Aggregate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browser.js
new file mode 100644
index 0000000..a787539
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browser.js
@@ -0,0 +1,126 @@
+/* eslint-env browser */
+
+var PromiseProvider = require('./promise_provider');
+
+/**
+ * The Mongoose [Promise](#promise_Promise) constructor.
+ *
+ * @method Promise
+ * @api public
+ */
+
+Object.defineProperty(exports, 'Promise', {
+ get: function() {
+ return PromiseProvider.get();
+ },
+ set: function(lib) {
+ PromiseProvider.set(lib);
+ }
+});
+
+/**
+ * Storage layer for mongoose promises
+ *
+ * @method PromiseProvider
+ * @api public
+ */
+
+exports.PromiseProvider = PromiseProvider;
+
+/**
+ * The [MongooseError](#error_MongooseError) constructor.
+ *
+ * @method Error
+ * @api public
+ */
+
+exports.Error = require('./error');
+
+/**
+ * The Mongoose [Schema](#schema_Schema) constructor
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var Schema = mongoose.Schema;
+ * var CatSchema = new Schema(..);
+ *
+ * @method Schema
+ * @api public
+ */
+
+exports.Schema = require('./schema');
+
+/**
+ * The various Mongoose Types.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var array = mongoose.Types.Array;
+ *
+ * ####Types:
+ *
+ * - [ObjectId](#types-objectid-js)
+ * - [Buffer](#types-buffer-js)
+ * - [SubDocument](#types-embedded-js)
+ * - [Array](#types-array-js)
+ * - [DocumentArray](#types-documentarray-js)
+ *
+ * Using this exposed access to the `ObjectId` type, we can construct ids on demand.
+ *
+ * var ObjectId = mongoose.Types.ObjectId;
+ * var id1 = new ObjectId;
+ *
+ * @property Types
+ * @api public
+ */
+exports.Types = require('./types');
+
+/**
+ * The Mongoose [VirtualType](#virtualtype_VirtualType) constructor
+ *
+ * @method VirtualType
+ * @api public
+ */
+exports.VirtualType = require('./virtualtype');
+
+/**
+ * The various Mongoose SchemaTypes.
+ *
+ * ####Note:
+ *
+ * _Alias of mongoose.Schema.Types for backwards compatibility._
+ *
+ * @property SchemaTypes
+ * @see Schema.SchemaTypes #schema_Schema.Types
+ * @api public
+ */
+
+exports.SchemaType = require('./schematype.js');
+
+/**
+ * Internal utils
+ *
+ * @property utils
+ * @api private
+ */
+
+exports.utils = require('./utils.js');
+
+/**
+ * The Mongoose browser [Document](#document-js) constructor.
+ *
+ * @method Document
+ * @api public
+ */
+exports.Document = require('./document_provider.js')();
+
+/*!
+ * Module exports.
+ */
+
+if (typeof window !== 'undefined') {
+ window.mongoose = module.exports;
+ window.Buffer = Buffer;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browserDocument.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browserDocument.js
new file mode 100644
index 0000000..6c87d19
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/browserDocument.js
@@ -0,0 +1,103 @@
+/*!
+ * Module dependencies.
+ */
+
+var NodeJSDocument = require('./document'),
+ EventEmitter = require('events').EventEmitter,
+ MongooseError = require('./error'),
+ Schema = require('./schema'),
+ ObjectId = require('./types/objectid'),
+ utils = require('./utils'),
+ ValidationError = MongooseError.ValidationError,
+ InternalCache = require('./internal');
+
+/**
+ * Document constructor.
+ *
+ * @param {Object} obj the values to set
+ * @param {Object} [fields] optional object containing the fields which were selected in the query returning this document and any populated paths data
+ * @param {Boolean} [skipId] bool, should we auto create an ObjectId _id
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `init`: Emitted on a document after it has was retrieved from the db and fully hydrated by Mongoose.
+ * @event `save`: Emitted when the document is successfully saved
+ * @api private
+ */
+
+function Document(obj, schema, fields, skipId, skipInit) {
+ if (!(this instanceof Document)) {
+ return new Document(obj, schema, fields, skipId, skipInit);
+ }
+
+
+ if (utils.isObject(schema) && !schema.instanceOfSchema) {
+ schema = new Schema(schema);
+ }
+
+ // When creating EmbeddedDocument, it already has the schema and he doesn't need the _id
+ schema = this.schema || schema;
+
+ // Generate ObjectId if it is missing, but it requires a scheme
+ if (!this.schema && schema.options._id) {
+ obj = obj || {};
+
+ if (obj._id === undefined) {
+ obj._id = new ObjectId();
+ }
+ }
+
+ if (!schema) {
+ throw new MongooseError.MissingSchemaError();
+ }
+
+ this.$__setSchema(schema);
+
+ this.$__ = new InternalCache;
+ this.$__.emitter = new EventEmitter();
+ this.isNew = true;
+ this.errors = undefined;
+
+ // var schema = this.schema;
+
+ if (typeof fields === 'boolean') {
+ this.$__.strictMode = fields;
+ fields = undefined;
+ } else {
+ this.$__.strictMode = this.schema.options && this.schema.options.strict;
+ this.$__.selected = fields;
+ }
+
+ var required = this.schema.requiredPaths();
+ for (var i = 0; i < required.length; ++i) {
+ this.$__.activePaths.require(required[i]);
+ }
+
+ this.$__.emitter.setMaxListeners(0);
+ this._doc = this.$__buildDoc(obj, fields, skipId);
+
+ if (!skipInit && obj) {
+ this.init(obj);
+ }
+
+ this.$__registerHooksFromSchema();
+
+ // apply methods
+ for (var m in schema.methods) {
+ this[m] = schema.methods[m];
+ }
+ // apply statics
+ for (var s in schema.statics) {
+ this[s] = schema.statics[s];
+ }
+}
+
+/*!
+ * Inherit from the NodeJS document
+ */
+Document.prototype = Object.create(NodeJSDocument.prototype);
+Document.prototype.constructor = Document;
+
+/*!
+ * Module exports.
+ */
+Document.ValidationError = ValidationError;
+module.exports = exports = Document;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/cast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/cast.js
new file mode 100644
index 0000000..6a07196
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/cast.js
@@ -0,0 +1,248 @@
+/*!
+ * Module dependencies.
+ */
+
+var utils = require('./utils');
+var Types = require('./schema/index');
+
+var ALLOWED_GEOWITHIN_GEOJSON_TYPES = ['Polygon', 'MultiPolygon'];
+
+/**
+ * Handles internal casting for queries
+ *
+ * @param {Schema} schema
+ * @param {Object} obj Object to cast
+ * @api private
+ */
+module.exports = function cast(schema, obj) {
+ var paths = Object.keys(obj),
+ i = paths.length,
+ _keys,
+ any$conditionals,
+ schematype,
+ nested,
+ path,
+ type,
+ val;
+
+ while (i--) {
+ path = paths[i];
+ val = obj[path];
+
+ if (path === '$or' || path === '$nor' || path === '$and') {
+ var k = val.length;
+
+ while (k--) {
+ val[k] = cast(schema, val[k]);
+ }
+ } else if (path === '$where') {
+ type = typeof val;
+
+ if (type !== 'string' && type !== 'function') {
+ throw new Error('Must have a string or function for $where');
+ }
+
+ if (type === 'function') {
+ obj[path] = val.toString();
+ }
+
+ continue;
+ } else if (path === '$elemMatch') {
+ val = cast(schema, val);
+ } else {
+ if (!schema) {
+ // no casting for Mixed types
+ continue;
+ }
+
+ schematype = schema.path(path);
+
+ if (!schematype) {
+ // Handle potential embedded array queries
+ var split = path.split('.'),
+ j = split.length,
+ pathFirstHalf,
+ pathLastHalf,
+ remainingConds;
+
+ // Find the part of the var path that is a path of the Schema
+ while (j--) {
+ pathFirstHalf = split.slice(0, j).join('.');
+ schematype = schema.path(pathFirstHalf);
+ if (schematype) {
+ break;
+ }
+ }
+
+ // If a substring of the input path resolves to an actual real path...
+ if (schematype) {
+ // Apply the casting; similar code for $elemMatch in schema/array.js
+ if (schematype.caster && schematype.caster.schema) {
+ remainingConds = {};
+ pathLastHalf = split.slice(j).join('.');
+ remainingConds[pathLastHalf] = val;
+ obj[path] = cast(schematype.caster.schema, remainingConds)[pathLastHalf];
+ } else {
+ obj[path] = val;
+ }
+ continue;
+ }
+
+ if (utils.isObject(val)) {
+ // handle geo schemas that use object notation
+ // { loc: { long: Number, lat: Number }
+
+ var geo = '';
+ if (val.$near) {
+ geo = '$near';
+ } else if (val.$nearSphere) {
+ geo = '$nearSphere';
+ } else if (val.$within) {
+ geo = '$within';
+ } else if (val.$geoIntersects) {
+ geo = '$geoIntersects';
+ } else if (val.$geoWithin) {
+ geo = '$geoWithin';
+ }
+
+ if (!geo) {
+ continue;
+ }
+
+ var numbertype = new Types.Number('__QueryCasting__');
+ var value = val[geo];
+
+ if (val.$maxDistance != null) {
+ val.$maxDistance = numbertype.castForQuery(val.$maxDistance);
+ }
+ if (val.$minDistance != null) {
+ val.$minDistance = numbertype.castForQuery(val.$minDistance);
+ }
+
+ if (geo === '$within') {
+ var withinType = value.$center
+ || value.$centerSphere
+ || value.$box
+ || value.$polygon;
+
+ if (!withinType) {
+ throw new Error('Bad $within paramater: ' + JSON.stringify(val));
+ }
+
+ value = withinType;
+ } else if (geo === '$near' &&
+ typeof value.type === 'string' && Array.isArray(value.coordinates)) {
+ // geojson; cast the coordinates
+ value = value.coordinates;
+ } else if ((geo === '$near' || geo === '$nearSphere' || geo === '$geoIntersects') &&
+ value.$geometry && typeof value.$geometry.type === 'string' &&
+ Array.isArray(value.$geometry.coordinates)) {
+ if (value.$maxDistance != null) {
+ value.$maxDistance = numbertype.castForQuery(value.$maxDistance);
+ }
+ if (value.$minDistance != null) {
+ value.$minDistance = numbertype.castForQuery(value.$minDistance);
+ }
+ if (utils.isMongooseObject(value.$geometry)) {
+ value.$geometry = value.$geometry.toObject({ transform: false });
+ }
+ value = value.$geometry.coordinates;
+ } else if (geo === '$geoWithin') {
+ if (value.$geometry) {
+ if (utils.isMongooseObject(value.$geometry)) {
+ value.$geometry = value.$geometry.toObject({ virtuals: false });
+ }
+ var geoWithinType = value.$geometry.type;
+ if (ALLOWED_GEOWITHIN_GEOJSON_TYPES.indexOf(geoWithinType) === -1) {
+ throw new Error('Invalid geoJSON type for $geoWithin "' +
+ geoWithinType + '", must be "Polygon" or "MultiPolygon"');
+ }
+ value = value.$geometry.coordinates;
+ } else {
+ value = value.$box || value.$polygon || value.$center ||
+ value.$centerSphere;
+ if (utils.isMongooseObject(value)) {
+ value = value.toObject({ virtuals: false });
+ }
+ }
+ }
+
+ _cast(value, numbertype);
+ }
+ } else if (val === null || val === undefined) {
+ obj[path] = null;
+ continue;
+ } else if (val.constructor.name === 'Object') {
+ any$conditionals = Object.keys(val).some(function(k) {
+ return k.charAt(0) === '$' && k !== '$id' && k !== '$ref';
+ });
+
+ if (!any$conditionals) {
+ obj[path] = schematype.castForQuery(val);
+ } else {
+ var ks = Object.keys(val),
+ $cond;
+
+ k = ks.length;
+
+ while (k--) {
+ $cond = ks[k];
+ nested = val[$cond];
+
+ if ($cond === '$exists') {
+ if (typeof nested !== 'boolean') {
+ throw new Error('$exists parameter must be Boolean');
+ }
+ continue;
+ }
+
+ if ($cond === '$not') {
+ if (nested && schematype && !schematype.caster) {
+ _keys = Object.keys(nested);
+ if (_keys.length && _keys[0].charAt(0) === '$') {
+ for (var key in nested) {
+ nested[key] = schematype.castForQuery(key, nested[key]);
+ }
+ } else {
+ val[$cond] = schematype.castForQuery($cond, nested);
+ }
+ continue;
+ }
+ cast(schematype.caster ? schematype.caster.schema : schema, nested);
+ } else {
+ val[$cond] = schematype.castForQuery($cond, nested);
+ }
+ }
+ }
+ } else {
+ obj[path] = schematype.castForQuery(val);
+ }
+ }
+ }
+
+ return obj;
+};
+
+function _cast(val, numbertype) {
+ if (Array.isArray(val)) {
+ val.forEach(function(item, i) {
+ if (Array.isArray(item) || utils.isObject(item)) {
+ return _cast(item, numbertype);
+ }
+ val[i] = numbertype.castForQuery(item);
+ });
+ } else {
+ var nearKeys = Object.keys(val);
+ var nearLen = nearKeys.length;
+ while (nearLen--) {
+ var nkey = nearKeys[nearLen];
+ var item = val[nkey];
+ if (Array.isArray(item) || utils.isObject(item)) {
+ _cast(item, numbertype);
+ val[nkey] = item;
+ } else {
+ val[nkey] = numbertype.castForQuery(item);
+ }
+ }
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/collection.js
new file mode 100644
index 0000000..e550ec2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/collection.js
@@ -0,0 +1,210 @@
+/*!
+ * Module dependencies.
+ */
+
+var EventEmitter = require('events').EventEmitter;
+var STATES = require('./connectionstate');
+
+/**
+ * Abstract Collection constructor
+ *
+ * This is the base class that drivers inherit from and implement.
+ *
+ * @param {String} name name of the collection
+ * @param {Connection} conn A MongooseConnection instance
+ * @param {Object} opts optional collection options
+ * @api public
+ */
+
+function Collection(name, conn, opts) {
+ if (opts === void 0) {
+ opts = {};
+ }
+ if (opts.capped === void 0) {
+ opts.capped = {};
+ }
+
+ opts.bufferCommands = undefined === opts.bufferCommands
+ ? true
+ : opts.bufferCommands;
+
+ if (typeof opts.capped === 'number') {
+ opts.capped = {size: opts.capped};
+ }
+
+ this.opts = opts;
+ this.name = name;
+ this.collectionName = name;
+ this.conn = conn;
+ this.queue = [];
+ this.buffer = this.opts.bufferCommands;
+ this.emitter = new EventEmitter();
+
+ if (STATES.connected === this.conn.readyState) {
+ this.onOpen();
+ }
+}
+
+/**
+ * The collection name
+ *
+ * @api public
+ * @property name
+ */
+
+Collection.prototype.name;
+
+/**
+ * The collection name
+ *
+ * @api public
+ * @property collectionName
+ */
+
+Collection.prototype.collectionName;
+
+/**
+ * The Connection instance
+ *
+ * @api public
+ * @property conn
+ */
+
+Collection.prototype.conn;
+
+/**
+ * Called when the database connects
+ *
+ * @api private
+ */
+
+Collection.prototype.onOpen = function() {
+ this.buffer = false;
+ this.doQueue();
+};
+
+/**
+ * Called when the database disconnects
+ *
+ * @api private
+ */
+
+Collection.prototype.onClose = function() {
+ if (this.opts.bufferCommands) {
+ this.buffer = true;
+ }
+};
+
+/**
+ * Queues a method for later execution when its
+ * database connection opens.
+ *
+ * @param {String} name name of the method to queue
+ * @param {Array} args arguments to pass to the method when executed
+ * @api private
+ */
+
+Collection.prototype.addQueue = function(name, args) {
+ this.queue.push([name, args]);
+ return this;
+};
+
+/**
+ * Executes all queued methods and clears the queue.
+ *
+ * @api private
+ */
+
+Collection.prototype.doQueue = function() {
+ for (var i = 0, l = this.queue.length; i < l; i++) {
+ if (typeof this.queue[i][0] === 'function') {
+ this.queue[i][0].apply(this, this.queue[i][1]);
+ } else {
+ this[this.queue[i][0]].apply(this, this.queue[i][1]);
+ }
+ }
+ this.queue = [];
+ var _this = this;
+ process.nextTick(function() {
+ _this.emitter.emit('queue');
+ });
+ return this;
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.ensureIndex = function() {
+ throw new Error('Collection#ensureIndex unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.findAndModify = function() {
+ throw new Error('Collection#findAndModify unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.findOne = function() {
+ throw new Error('Collection#findOne unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.find = function() {
+ throw new Error('Collection#find unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.insert = function() {
+ throw new Error('Collection#insert unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.save = function() {
+ throw new Error('Collection#save unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.update = function() {
+ throw new Error('Collection#update unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.getIndexes = function() {
+ throw new Error('Collection#getIndexes unimplemented by driver');
+};
+
+/**
+ * Abstract method that drivers must implement.
+ */
+
+Collection.prototype.mapReduce = function() {
+ throw new Error('Collection#mapReduce unimplemented by driver');
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = Collection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connection.js
new file mode 100644
index 0000000..69c470a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connection.js
@@ -0,0 +1,854 @@
+/*!
+ * Module dependencies.
+ */
+
+var utils = require('./utils');
+var EventEmitter = require('events').EventEmitter;
+var driver = global.MONGOOSE_DRIVER_PATH || './drivers/node-mongodb-native';
+var Schema = require('./schema');
+var Collection = require(driver + '/collection');
+var STATES = require('./connectionstate');
+var MongooseError = require('./error');
+var muri = require('muri');
+var PromiseProvider = require('./promise_provider');
+
+/*!
+ * Protocol prefix regexp.
+ *
+ * @api private
+ */
+
+var rgxProtocol = /^(?:.)+:\/\//;
+
+/*!
+ * A list of authentication mechanisms that don't require a password for authentication.
+ * This is used by the authMechanismDoesNotRequirePassword method.
+ *
+ * @api private
+ */
+var authMechanismsWhichDontRequirePassword = [
+ 'MONGODB-X509'
+];
+
+/**
+ * Connection constructor
+ *
+ * For practical reasons, a Connection equals a Db.
+ *
+ * @param {Mongoose} base a mongoose instance
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `connecting`: Emitted when `connection.{open,openSet}()` is executed on this connection.
+ * @event `connected`: Emitted when this connection successfully connects to the db. May be emitted _multiple_ times in `reconnected` scenarios.
+ * @event `open`: Emitted after we `connected` and `onOpen` is executed on all of this connections models.
+ * @event `disconnecting`: Emitted when `connection.close()` was executed.
+ * @event `disconnected`: Emitted after getting disconnected from the db.
+ * @event `close`: Emitted after we `disconnected` and `onClose` executed on all of this connections models.
+ * @event `reconnected`: Emitted after we `connected` and subsequently `disconnected`, followed by successfully another successfull connection.
+ * @event `error`: Emitted when an error occurs on this connection.
+ * @event `fullsetup`: Emitted in a replica-set scenario, when primary and at least one seconaries specified in the connection string are connected.
+ * @event `all`: Emitted in a replica-set scenario, when all nodes specified in the connection string are connected.
+ * @api public
+ */
+
+function Connection(base) {
+ this.base = base;
+ this.collections = {};
+ this.models = {};
+ this.config = {autoIndex: true};
+ this.replica = false;
+ this.hosts = null;
+ this.host = null;
+ this.port = null;
+ this.user = null;
+ this.pass = null;
+ this.name = null;
+ this.options = null;
+ this.otherDbs = [];
+ this._readyState = STATES.disconnected;
+ this._closeCalled = false;
+ this._hasOpened = false;
+}
+
+/*!
+ * Inherit from EventEmitter
+ */
+
+Connection.prototype.__proto__ = EventEmitter.prototype;
+
+/**
+ * Connection ready state
+ *
+ * - 0 = disconnected
+ * - 1 = connected
+ * - 2 = connecting
+ * - 3 = disconnecting
+ *
+ * Each state change emits its associated event name.
+ *
+ * ####Example
+ *
+ * conn.on('connected', callback);
+ * conn.on('disconnected', callback);
+ *
+ * @property readyState
+ * @api public
+ */
+
+Object.defineProperty(Connection.prototype, 'readyState', {
+ get: function() {
+ return this._readyState;
+ },
+ set: function(val) {
+ if (!(val in STATES)) {
+ throw new Error('Invalid connection state: ' + val);
+ }
+
+ if (this._readyState !== val) {
+ this._readyState = val;
+ // loop over the otherDbs on this connection and change their state
+ for (var i = 0; i < this.otherDbs.length; i++) {
+ this.otherDbs[i].readyState = val;
+ }
+
+ if (STATES.connected === val) {
+ this._hasOpened = true;
+ }
+
+ this.emit(STATES[val]);
+ }
+ }
+});
+
+/**
+ * A hash of the collections associated with this connection
+ *
+ * @property collections
+ */
+
+Connection.prototype.collections;
+
+/**
+ * The mongodb.Db instance, set when the connection is opened
+ *
+ * @property db
+ */
+
+Connection.prototype.db;
+
+/**
+ * A hash of the global options that are associated with this connection
+ *
+ * @property config
+ */
+
+Connection.prototype.config;
+
+/**
+ * Opens the connection to MongoDB.
+ *
+ * `options` is a hash with the following possible properties:
+ *
+ * config - passed to the connection config instance
+ * db - passed to the connection db instance
+ * server - passed to the connection server instance(s)
+ * replset - passed to the connection ReplSet instance
+ * user - username for authentication
+ * pass - password for authentication
+ * auth - options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate)
+ *
+ * ####Notes:
+ *
+ * Mongoose forces the db option `forceServerObjectId` false and cannot be overridden.
+ * Mongoose defaults the server `auto_reconnect` options to true which can be overridden.
+ * See the node-mongodb-native driver instance for options that it understands.
+ *
+ * _Options passed take precedence over options included in connection strings._
+ *
+ * @param {String} connection_string mongodb://uri or the host to which you are connecting
+ * @param {String} [database] database name
+ * @param {Number} [port] database port
+ * @param {Object} [options] options
+ * @param {Function} [callback]
+ * @see node-mongodb-native https://github.com/mongodb/node-mongodb-native
+ * @see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate
+ * @api public
+ */
+
+Connection.prototype.open = function(host, database, port, options, callback) {
+ var parsed;
+ var Promise = PromiseProvider.get();
+
+ if (typeof database === 'string') {
+ switch (arguments.length) {
+ case 2:
+ port = 27017;
+ break;
+ case 3:
+ switch (typeof port) {
+ case 'function':
+ callback = port;
+ port = 27017;
+ break;
+ case 'object':
+ options = port;
+ port = 27017;
+ break;
+ }
+ break;
+ case 4:
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ }
+ } else {
+ switch (typeof database) {
+ case 'function':
+ callback = database;
+ database = undefined;
+ break;
+ case 'object':
+ options = database;
+ database = undefined;
+ callback = port;
+ break;
+ }
+
+ if (!rgxProtocol.test(host)) {
+ host = 'mongodb://' + host;
+ }
+
+ try {
+ parsed = muri(host);
+ } catch (err) {
+ this.error(err, callback);
+ return this;
+ }
+
+ database = parsed.db;
+ host = parsed.hosts[0].host || parsed.hosts[0].ipc;
+ port = parsed.hosts[0].port || 27017;
+ }
+
+ this.options = this.parseOptions(options, parsed && parsed.options);
+
+ // make sure we can open
+ if (STATES.disconnected !== this.readyState) {
+ var err = new Error('Trying to open unclosed connection.');
+ err.state = this.readyState;
+ this.error(err, callback);
+ return new Promise.ES6(function(resolve, reject) {
+ reject(err);
+ });
+ }
+
+ if (!host) {
+ this.error(new Error('Missing hostname.'), callback);
+ return new Promise.ES6(function(resolve, reject) {
+ reject(err);
+ });
+ }
+
+ if (!database) {
+ this.error(new Error('Missing database name.'), callback);
+ return new Promise.ES6(function(resolve, reject) {
+ reject(err);
+ });
+ }
+
+ // authentication
+ if (this.optionsProvideAuthenticationData(options)) {
+ this.user = options.user;
+ this.pass = options.pass;
+ } else if (parsed && parsed.auth) {
+ this.user = parsed.auth.user;
+ this.pass = parsed.auth.pass;
+
+ // Check hostname for user/pass
+ } else if (/@/.test(host) && /:/.test(host.split('@')[0])) {
+ host = host.split('@');
+ var auth = host.shift().split(':');
+ host = host.pop();
+ this.user = auth[0];
+ this.pass = auth[1];
+ } else {
+ this.user = this.pass = undefined;
+ }
+
+ // global configuration options
+ if (options && options.config) {
+ this.config.autoIndex = options.config.autoIndex !== false;
+ }
+
+ this.name = database;
+ this.host = host;
+ this.port = port;
+
+ var _this = this;
+ var promise = new Promise.ES6(function(resolve, reject) {
+ _this._open(true, function(error) {
+ callback && callback(error);
+ if (error) {
+ reject(error);
+ if (!callback && !promise.$hasHandler) {
+ _this.emit('error', error);
+ }
+ return;
+ }
+ resolve();
+ });
+ });
+ return promise;
+};
+
+/**
+ * Helper for `dropDatabase()`.
+ *
+ * @param {Function} callback
+ * @return {Promise}
+ * @api public
+ */
+
+Connection.prototype.dropDatabase = function(callback) {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+ var promise = new Promise.ES6(function(resolve, reject) {
+ if (_this.readyState !== STATES.connected) {
+ _this.on('open', function() {
+ _this.db.dropDatabase(function(error) {
+ if (error) {
+ reject(error);
+ } else {
+ resolve();
+ }
+ });
+ });
+ } else {
+ _this.db.dropDatabase(function(error) {
+ if (error) {
+ reject(error);
+ } else {
+ resolve();
+ }
+ });
+ }
+ });
+ if (callback) {
+ promise.then(function() { callback(); }, callback);
+ }
+ return promise;
+};
+
+/**
+ * Opens the connection to a replica set.
+ *
+ * ####Example:
+ *
+ * var db = mongoose.createConnection();
+ * db.openSet("mongodb://user:pwd@localhost:27020,localhost:27021,localhost:27012/mydb");
+ *
+ * The database name and/or auth need only be included in one URI.
+ * The `options` is a hash which is passed to the internal driver connection object.
+ *
+ * Valid `options`
+ *
+ * db - passed to the connection db instance
+ * server - passed to the connection server instance(s)
+ * replset - passed to the connection ReplSetServer instance
+ * user - username for authentication
+ * pass - password for authentication
+ * auth - options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate)
+ * mongos - Boolean - if true, enables High Availability support for mongos
+ *
+ * _Options passed take precedence over options included in connection strings._
+ *
+ * ####Notes:
+ *
+ * _If connecting to multiple mongos servers, set the `mongos` option to true._
+ *
+ * conn.open('mongodb://mongosA:27501,mongosB:27501', { mongos: true }, cb);
+ *
+ * Mongoose forces the db option `forceServerObjectId` false and cannot be overridden.
+ * Mongoose defaults the server `auto_reconnect` options to true which can be overridden.
+ * See the node-mongodb-native driver instance for options that it understands.
+ *
+ * _Options passed take precedence over options included in connection strings._
+ *
+ * @param {String} uris MongoDB connection string
+ * @param {String} [database] database name if not included in `uris`
+ * @param {Object} [options] passed to the internal driver
+ * @param {Function} [callback]
+ * @see node-mongodb-native https://github.com/mongodb/node-mongodb-native
+ * @see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate
+ * @api public
+ */
+
+Connection.prototype.openSet = function(uris, database, options, callback) {
+ if (!rgxProtocol.test(uris)) {
+ uris = 'mongodb://' + uris;
+ }
+
+ var Promise = PromiseProvider.get();
+
+ switch (arguments.length) {
+ case 3:
+ switch (typeof database) {
+ case 'string':
+ this.name = database;
+ break;
+ case 'object':
+ callback = options;
+ options = database;
+ database = null;
+ break;
+ }
+
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ break;
+ case 2:
+ switch (typeof database) {
+ case 'string':
+ this.name = database;
+ break;
+ case 'function':
+ callback = database;
+ database = null;
+ break;
+ case 'object':
+ options = database;
+ database = null;
+ break;
+ }
+ }
+
+ if (typeof database === 'string') {
+ this.name = database;
+ }
+
+ var parsed;
+ try {
+ parsed = muri(uris);
+ } catch (err) {
+ this.error(err, callback);
+ return new Promise.ES6(function(resolve, reject) {
+ reject(err);
+ });
+ }
+
+ if (!this.name) {
+ this.name = parsed.db;
+ }
+
+ this.hosts = parsed.hosts;
+ this.options = this.parseOptions(options, parsed && parsed.options);
+ this.replica = true;
+
+ if (!this.name) {
+ var err = new Error('No database name provided for replica set');
+ this.error(err, callback);
+ return new Promise.ES6(function(resolve, reject) {
+ reject(err);
+ });
+ }
+
+ // authentication
+ if (this.optionsProvideAuthenticationData(options)) {
+ this.user = options.user;
+ this.pass = options.pass;
+ } else if (parsed && parsed.auth) {
+ this.user = parsed.auth.user;
+ this.pass = parsed.auth.pass;
+ } else {
+ this.user = this.pass = undefined;
+ }
+
+ // global configuration options
+ if (options && options.config) {
+ this.config.autoIndex = options.config.autoIndex !== false;
+ }
+
+ var _this = this;
+ var emitted = false;
+ var promise = new Promise.ES6(function(resolve, reject) {
+ _this._open(true, function(error) {
+ callback && callback(error);
+ if (error) {
+ reject(error);
+ if (!callback && !promise.$hasHandler && !emitted) {
+ emitted = true;
+ _this.emit('error', error);
+ }
+ return;
+ }
+ resolve();
+ });
+ });
+ return promise;
+};
+
+/**
+ * error
+ *
+ * Graceful error handling, passes error to callback
+ * if available, else emits error on the connection.
+ *
+ * @param {Error} err
+ * @param {Function} callback optional
+ * @api private
+ */
+
+Connection.prototype.error = function(err, callback) {
+ if (callback) {
+ return callback(err);
+ }
+ this.emit('error', err);
+};
+
+/**
+ * Handles opening the connection with the appropriate method based on connection type.
+ *
+ * @param {Function} callback
+ * @api private
+ */
+
+Connection.prototype._open = function(emit, callback) {
+ this.readyState = STATES.connecting;
+ this._closeCalled = false;
+
+ var _this = this;
+
+ var method = this.replica
+ ? 'doOpenSet'
+ : 'doOpen';
+
+ // open connection
+ this[method](function(err) {
+ if (err) {
+ _this.readyState = STATES.disconnected;
+ if (_this._hasOpened) {
+ if (callback) {
+ callback(err);
+ }
+ } else {
+ _this.error(err, emit && callback);
+ }
+ return;
+ }
+
+ _this.onOpen(callback);
+ });
+};
+
+/**
+ * Called when the connection is opened
+ *
+ * @api private
+ */
+
+Connection.prototype.onOpen = function(callback) {
+ var _this = this;
+
+ function open(err, isAuth) {
+ if (err) {
+ _this.readyState = isAuth ? STATES.unauthorized : STATES.disconnected;
+ _this.error(err, callback);
+ return;
+ }
+
+ _this.readyState = STATES.connected;
+
+ // avoid having the collection subscribe to our event emitter
+ // to prevent 0.3 warning
+ for (var i in _this.collections) {
+ if (utils.object.hasOwnProperty(_this.collections, i)) {
+ _this.collections[i].onOpen();
+ }
+ }
+
+ callback && callback();
+ _this.emit('open');
+ }
+
+ // re-authenticate if we're not already connected #3871
+ if (this._readyState !== STATES.connected && this.shouldAuthenticate()) {
+ _this.db.authenticate(_this.user, _this.pass, _this.options.auth, function(err) {
+ open(err, true);
+ });
+ } else {
+ open();
+ }
+};
+
+/**
+ * Closes the connection
+ *
+ * @param {Function} [callback] optional
+ * @return {Connection} self
+ * @api public
+ */
+
+Connection.prototype.close = function(callback) {
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ _this._close(function(error) {
+ callback && callback(error);
+ if (error) {
+ reject(error);
+ return;
+ }
+ resolve();
+ });
+ });
+};
+
+/**
+ * Handles closing the connection
+ *
+ * @param {Function} callback
+ * @api private
+ */
+Connection.prototype._close = function(callback) {
+ var _this = this;
+ this._closeCalled = true;
+
+ switch (this.readyState) {
+ case 0: // disconnected
+ callback && callback();
+ break;
+
+ case 1: // connected
+ case 4: // unauthorized
+ this.readyState = STATES.disconnecting;
+ this.doClose(function(err) {
+ if (err) {
+ _this.error(err, callback);
+ } else {
+ _this.onClose();
+ callback && callback();
+ }
+ });
+ break;
+
+ case 2: // connecting
+ this.once('open', function() {
+ _this.close(callback);
+ });
+ break;
+
+ case 3: // disconnecting
+ if (!callback) {
+ break;
+ }
+ this.once('close', function() {
+ callback();
+ });
+ break;
+ }
+
+ return this;
+};
+
+/**
+ * Called when the connection closes
+ *
+ * @api private
+ */
+
+Connection.prototype.onClose = function() {
+ this.readyState = STATES.disconnected;
+
+ // avoid having the collection subscribe to our event emitter
+ // to prevent 0.3 warning
+ for (var i in this.collections) {
+ if (utils.object.hasOwnProperty(this.collections, i)) {
+ this.collections[i].onClose();
+ }
+ }
+
+ this.emit('close');
+};
+
+/**
+ * Retrieves a collection, creating it if not cached.
+ *
+ * Not typically needed by applications. Just talk to your collection through your model.
+ *
+ * @param {String} name of the collection
+ * @param {Object} [options] optional collection options
+ * @return {Collection} collection instance
+ * @api public
+ */
+
+Connection.prototype.collection = function(name, options) {
+ if (!(name in this.collections)) {
+ this.collections[name] = new Collection(name, this, options);
+ }
+ return this.collections[name];
+};
+
+/**
+ * Defines or retrieves a model.
+ *
+ * var mongoose = require('mongoose');
+ * var db = mongoose.createConnection(..);
+ * db.model('Venue', new Schema(..));
+ * var Ticket = db.model('Ticket', new Schema(..));
+ * var Venue = db.model('Venue');
+ *
+ * _When no `collection` argument is passed, Mongoose produces a collection name by passing the model `name` to the [utils.toCollectionName](#utils_exports.toCollectionName) method. This method pluralizes the name. If you don't like this behavior, either pass a collection name or set your schemas collection name option._
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ name: String }, { collection: 'actor' });
+ *
+ * // or
+ *
+ * schema.set('collection', 'actor');
+ *
+ * // or
+ *
+ * var collectionName = 'actor'
+ * var M = conn.model('Actor', schema, collectionName)
+ *
+ * @param {String} name the model name
+ * @param {Schema} [schema] a schema. necessary when defining a model
+ * @param {String} [collection] name of mongodb collection (optional) if not given it will be induced from model name
+ * @see Mongoose#model #index_Mongoose-model
+ * @return {Model} The compiled model
+ * @api public
+ */
+
+Connection.prototype.model = function(name, schema, collection) {
+ // collection name discovery
+ if (typeof schema === 'string') {
+ collection = schema;
+ schema = false;
+ }
+
+ if (utils.isObject(schema) && !schema.instanceOfSchema) {
+ schema = new Schema(schema);
+ }
+ if (schema && !schema.instanceOfSchema) {
+ throw new Error('The 2nd parameter to `mongoose.model()` should be a ' +
+ 'schema or a POJO');
+ }
+
+ if (this.models[name] && !collection) {
+ // model exists but we are not subclassing with custom collection
+ if (schema && schema.instanceOfSchema && schema !== this.models[name].schema) {
+ throw new MongooseError.OverwriteModelError(name);
+ }
+ return this.models[name];
+ }
+
+ var opts = {cache: false, connection: this};
+ var model;
+
+ if (schema && schema.instanceOfSchema) {
+ // compile a model
+ model = this.base.model(name, schema, collection, opts);
+
+ // only the first model with this name is cached to allow
+ // for one-offs with custom collection names etc.
+ if (!this.models[name]) {
+ this.models[name] = model;
+ }
+
+ model.init();
+ return model;
+ }
+
+ if (this.models[name] && collection) {
+ // subclassing current model with alternate collection
+ model = this.models[name];
+ schema = model.prototype.schema;
+ var sub = model.__subclass(this, schema, collection);
+ // do not cache the sub model
+ return sub;
+ }
+
+ // lookup model in mongoose module
+ model = this.base.models[name];
+
+ if (!model) {
+ throw new MongooseError.MissingSchemaError(name);
+ }
+
+ if (this === model.prototype.db
+ && (!collection || collection === model.collection.name)) {
+ // model already uses this connection.
+
+ // only the first model with this name is cached to allow
+ // for one-offs with custom collection names etc.
+ if (!this.models[name]) {
+ this.models[name] = model;
+ }
+
+ return model;
+ }
+ this.models[name] = model.__subclass(this, schema, collection);
+ return this.models[name];
+};
+
+/**
+ * Returns an array of model names created on this connection.
+ * @api public
+ * @return {Array}
+ */
+
+Connection.prototype.modelNames = function() {
+ return Object.keys(this.models);
+};
+
+/**
+ * @brief Returns if the connection requires authentication after it is opened. Generally if a
+ * username and password are both provided than authentication is needed, but in some cases a
+ * password is not required.
+ * @api private
+ * @return {Boolean} true if the connection should be authenticated after it is opened, otherwise false.
+ */
+Connection.prototype.shouldAuthenticate = function() {
+ return (this.user !== null && this.user !== void 0) &&
+ ((this.pass !== null || this.pass !== void 0) || this.authMechanismDoesNotRequirePassword());
+};
+
+/**
+ * @brief Returns a boolean value that specifies if the current authentication mechanism needs a
+ * password to authenticate according to the auth objects passed into the open/openSet methods.
+ * @api private
+ * @return {Boolean} true if the authentication mechanism specified in the options object requires
+ * a password, otherwise false.
+ */
+Connection.prototype.authMechanismDoesNotRequirePassword = function() {
+ if (this.options && this.options.auth) {
+ return authMechanismsWhichDontRequirePassword.indexOf(this.options.auth.authMechanism) >= 0;
+ }
+ return true;
+};
+
+/**
+ * @brief Returns a boolean value that specifies if the provided objects object provides enough
+ * data to authenticate with. Generally this is true if the username and password are both specified
+ * but in some authentication methods, a password is not required for authentication so only a username
+ * is required.
+ * @param {Object} [options] the options object passed into the open/openSet methods.
+ * @api private
+ * @return {Boolean} true if the provided options object provides enough data to authenticate with,
+ * otherwise false.
+ */
+Connection.prototype.optionsProvideAuthenticationData = function(options) {
+ return (options) &&
+ (options.user) &&
+ ((options.pass) || this.authMechanismDoesNotRequirePassword());
+};
+
+/*!
+ * Module exports.
+ */
+
+Connection.STATES = STATES;
+module.exports = Connection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connectionstate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connectionstate.js
new file mode 100644
index 0000000..b9d1baf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/connectionstate.js
@@ -0,0 +1,27 @@
+
+/*!
+ * Connection states
+ */
+
+var STATES = module.exports = exports = Object.create(null);
+
+var disconnected = 'disconnected';
+var connected = 'connected';
+var connecting = 'connecting';
+var disconnecting = 'disconnecting';
+var unauthorized = 'unauthorized';
+var uninitialized = 'uninitialized';
+
+STATES[0] = disconnected;
+STATES[1] = connected;
+STATES[2] = connecting;
+STATES[3] = disconnecting;
+STATES[4] = unauthorized;
+STATES[99] = uninitialized;
+
+STATES[disconnected] = 0;
+STATES[connected] = 1;
+STATES[connecting] = 2;
+STATES[disconnecting] = 3;
+STATES[unauthorized] = 4;
+STATES[uninitialized] = 99;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document.js
new file mode 100644
index 0000000..968ad1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document.js
@@ -0,0 +1,2615 @@
+/*!
+ * Module dependencies.
+ */
+
+var EventEmitter = require('events').EventEmitter;
+var MongooseError = require('./error');
+var MixedSchema = require('./schema/mixed');
+var Schema = require('./schema');
+var ObjectExpectedError = require('./error/objectExpected');
+var StrictModeError = require('./error/strict');
+var ValidatorError = require('./schematype').ValidatorError;
+var VersionError = require('./error').VersionError;
+var utils = require('./utils');
+var clone = utils.clone;
+var isMongooseObject = utils.isMongooseObject;
+var inspect = require('util').inspect;
+var ValidationError = MongooseError.ValidationError;
+var InternalCache = require('./internal');
+var deepEqual = utils.deepEqual;
+var hooks = require('hooks-fixed');
+var PromiseProvider = require('./promise_provider');
+var DocumentArray;
+var MongooseArray;
+var Embedded;
+var flatten = require('./services/common').flatten;
+var mpath = require('mpath');
+
+/**
+ * Document constructor.
+ *
+ * @param {Object} obj the values to set
+ * @param {Object} [fields] optional object containing the fields which were selected in the query returning this document and any populated paths data
+ * @param {Boolean} [skipId] bool, should we auto create an ObjectId _id
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `init`: Emitted on a document after it has was retreived from the db and fully hydrated by Mongoose.
+ * @event `save`: Emitted when the document is successfully saved
+ * @api private
+ */
+
+function Document(obj, fields, skipId) {
+ this.$__ = new InternalCache;
+ this.$__.emitter = new EventEmitter();
+ this.isNew = true;
+ this.errors = undefined;
+
+ var schema = this.schema;
+
+ if (typeof fields === 'boolean') {
+ this.$__.strictMode = fields;
+ fields = undefined;
+ } else {
+ this.$__.strictMode = schema.options && schema.options.strict;
+ this.$__.selected = fields;
+ }
+
+ var required = schema.requiredPaths(true);
+ for (var i = 0; i < required.length; ++i) {
+ this.$__.activePaths.require(required[i]);
+ }
+
+ this.$__.emitter.setMaxListeners(0);
+ this._doc = this.$__buildDoc(obj, fields, skipId);
+
+ if (obj) {
+ if (obj instanceof Document) {
+ this.isNew = obj.isNew;
+ }
+ this.set(obj, undefined, true);
+ }
+
+ if (!schema.options.strict && obj) {
+ var _this = this,
+ keys = Object.keys(this._doc);
+
+ keys.forEach(function(key) {
+ if (!(key in schema.tree)) {
+ defineKey(key, null, _this);
+ }
+ });
+ }
+
+ this.$__registerHooksFromSchema();
+}
+
+/*!
+ * Document exposes the NodeJS event emitter API, so you can use
+ * `on`, `once`, etc.
+ */
+utils.each(
+ ['on', 'once', 'emit', 'listeners', 'removeListener', 'setMaxListeners',
+ 'removeAllListeners', 'addListener'],
+ function(emitterFn) {
+ Document.prototype[emitterFn] = function() {
+ return this.$__.emitter[emitterFn].apply(this.$__.emitter, arguments);
+ };
+ });
+
+Document.prototype.constructor = Document;
+
+/**
+ * The documents schema.
+ *
+ * @api public
+ * @property schema
+ */
+
+Document.prototype.schema;
+
+/**
+ * Boolean flag specifying if the document is new.
+ *
+ * @api public
+ * @property isNew
+ */
+
+Document.prototype.isNew;
+
+/**
+ * The string version of this documents _id.
+ *
+ * ####Note:
+ *
+ * This getter exists on all documents by default. The getter can be disabled by setting the `id` [option](/docs/guide.html#id) of its `Schema` to false at construction time.
+ *
+ * new Schema({ name: String }, { id: false });
+ *
+ * @api public
+ * @see Schema options /docs/guide.html#options
+ * @property id
+ */
+
+Document.prototype.id;
+
+/**
+ * Hash containing current validation errors.
+ *
+ * @api public
+ * @property errors
+ */
+
+Document.prototype.errors;
+
+/**
+ * Builds the default doc structure
+ *
+ * @param {Object} obj
+ * @param {Object} [fields]
+ * @param {Boolean} [skipId]
+ * @return {Object}
+ * @api private
+ * @method $__buildDoc
+ * @memberOf Document
+ */
+
+Document.prototype.$__buildDoc = function(obj, fields, skipId) {
+ var doc = {};
+ var exclude = null;
+ var keys;
+ var ki;
+ var _this = this;
+
+ // determine if this doc is a result of a query with
+ // excluded fields
+
+ if (fields && utils.getFunctionName(fields.constructor) === 'Object') {
+ keys = Object.keys(fields);
+ ki = keys.length;
+
+ if (ki === 1 && keys[0] === '_id') {
+ exclude = !!fields[keys[ki]];
+ } else {
+ while (ki--) {
+ if (keys[ki] !== '_id' &&
+ (!fields[keys[ki]] || typeof fields[keys[ki]] !== 'object')) {
+ exclude = !fields[keys[ki]];
+ break;
+ }
+ }
+ }
+ }
+
+ var paths = Object.keys(this.schema.paths);
+ var plen = paths.length;
+ var ii = 0;
+
+ var hasIncludedChildren = {};
+ if (exclude === false && fields) {
+ keys = Object.keys(fields);
+ for (var j = 0; j < keys.length; ++j) {
+ var parts = keys[j].split('.');
+ var c = [];
+ for (var k = 0; k < parts.length; ++k) {
+ c.push(parts[k]);
+ hasIncludedChildren[c.join('.')] = 1;
+ }
+ }
+ }
+
+ for (; ii < plen; ++ii) {
+ var p = paths[ii];
+
+ if (p === '_id') {
+ if (skipId) {
+ continue;
+ }
+ if (obj && '_id' in obj) {
+ continue;
+ }
+ }
+
+ var type = this.schema.paths[p];
+ var path = p.split('.');
+ var len = path.length;
+ var last = len - 1;
+ var curPath = '';
+ var doc_ = doc;
+ var i = 0;
+ var included = false;
+
+ for (; i < len; ++i) {
+ var piece = path[i],
+ def;
+
+ curPath += (!curPath.length ? '' : '.') + piece;
+
+ // support excluding intermediary levels
+ if (exclude === true) {
+ if (curPath in fields) {
+ break;
+ }
+ } else if (exclude === false && fields && !included) {
+ if (curPath in fields) {
+ included = true;
+ } else if (!hasIncludedChildren[curPath]) {
+ break;
+ }
+ }
+
+ if (i === last) {
+ if (fields && exclude !== null) {
+ if (exclude === true) {
+ // apply defaults to all non-excluded fields
+ if (p in fields) {
+ continue;
+ }
+
+ def = type.getDefault(_this, false);
+ if (typeof def !== 'undefined') {
+ doc_[piece] = def;
+ _this.$__.activePaths.default(p);
+ }
+ } else if (included) {
+ // selected field
+ def = type.getDefault(_this, false);
+ if (typeof def !== 'undefined') {
+ doc_[piece] = def;
+ _this.$__.activePaths.default(p);
+ }
+ }
+ } else {
+ def = type.getDefault(_this, false);
+ if (typeof def !== 'undefined') {
+ doc_[piece] = def;
+ _this.$__.activePaths.default(p);
+ }
+ }
+ } else {
+ doc_ = doc_[piece] || (doc_[piece] = {});
+ }
+ }
+ }
+
+ return doc;
+};
+
+/**
+ * Initializes the document without setters or marking anything modified.
+ *
+ * Called internally after a document is returned from mongodb.
+ *
+ * @param {Object} doc document returned by mongo
+ * @param {Function} fn callback
+ * @api public
+ */
+
+Document.prototype.init = function(doc, opts, fn) {
+ // do not prefix this method with $__ since its
+ // used by public hooks
+
+ if (typeof opts === 'function') {
+ fn = opts;
+ opts = null;
+ }
+
+ this.isNew = false;
+
+ // handle docs with populated paths
+ // If doc._id is not null or undefined
+ if (doc._id !== null && doc._id !== undefined &&
+ opts && opts.populated && opts.populated.length) {
+ var id = String(doc._id);
+ for (var i = 0; i < opts.populated.length; ++i) {
+ var item = opts.populated[i];
+ if (item.isVirtual) {
+ this.populated(item.path, utils.getValue(item.path, doc), item);
+ } else {
+ this.populated(item.path, item._docs[id], item);
+ }
+ }
+ }
+
+ init(this, doc, this._doc);
+ this.$__storeShard();
+
+ this.emit('init', this);
+ if (fn) {
+ fn(null);
+ }
+ return this;
+};
+
+/*!
+ * Init helper.
+ *
+ * @param {Object} self document instance
+ * @param {Object} obj raw mongodb doc
+ * @param {Object} doc object we are initializing
+ * @api private
+ */
+
+function init(self, obj, doc, prefix) {
+ prefix = prefix || '';
+
+ var keys = Object.keys(obj);
+ var len = keys.length;
+ var schema;
+ var path;
+ var i;
+ var index = 0;
+
+ if (self.schema.options.retainKeyOrder) {
+ while (index < len) {
+ _init(index++);
+ }
+ } else {
+ while (len--) {
+ _init(len);
+ }
+ }
+
+ function _init(index) {
+ i = keys[index];
+ path = prefix + i;
+ schema = self.schema.path(path);
+
+ if (!schema && utils.isObject(obj[i]) &&
+ (!obj[i].constructor || utils.getFunctionName(obj[i].constructor) === 'Object')) {
+ // assume nested object
+ if (!doc[i]) {
+ doc[i] = {};
+ }
+ init(self, obj[i], doc[i], path + '.');
+ } else {
+ if (obj[i] === null) {
+ doc[i] = null;
+ } else if (obj[i] !== undefined) {
+ if (schema) {
+ try {
+ doc[i] = schema.cast(obj[i], self, true);
+ } catch (e) {
+ self.invalidate(e.path, new ValidatorError({
+ path: e.path,
+ message: e.message,
+ type: 'cast',
+ value: e.value
+ }));
+ }
+ } else {
+ doc[i] = obj[i];
+ }
+ }
+ // mark as hydrated
+ if (!self.isModified(path)) {
+ self.$__.activePaths.init(path);
+ }
+ }
+ }
+}
+
+/**
+ * Stores the current values of the shard keys.
+ *
+ * ####Note:
+ *
+ * _Shard key values do not / are not allowed to change._
+ *
+ * @api private
+ * @method $__storeShard
+ * @memberOf Document
+ */
+
+Document.prototype.$__storeShard = function() {
+ // backwards compat
+ var key = this.schema.options.shardKey || this.schema.options.shardkey;
+ if (!(key && utils.getFunctionName(key.constructor) === 'Object')) {
+ return;
+ }
+
+ var orig = this.$__.shardval = {},
+ paths = Object.keys(key),
+ len = paths.length,
+ val;
+
+ for (var i = 0; i < len; ++i) {
+ val = this.getValue(paths[i]);
+ if (isMongooseObject(val)) {
+ orig[paths[i]] = val.toObject({depopulate: true, _isNested: true});
+ } else if (val !== null && val !== undefined && val.valueOf &&
+ // Explicitly don't take value of dates
+ (!val.constructor || utils.getFunctionName(val.constructor) !== 'Date')) {
+ orig[paths[i]] = val.valueOf();
+ } else {
+ orig[paths[i]] = val;
+ }
+ }
+};
+
+/*!
+ * Set up middleware support
+ */
+
+for (var k in hooks) {
+ if (k === 'pre' || k === 'post') {
+ Document.prototype['$' + k] = Document['$' + k] = hooks[k];
+ } else {
+ Document.prototype[k] = Document[k] = hooks[k];
+ }
+}
+
+/**
+ * Sends an update command with this document `_id` as the query selector.
+ *
+ * ####Example:
+ *
+ * weirdCar.update({$inc: {wheels:1}}, { w: 1 }, callback);
+ *
+ * ####Valid options:
+ *
+ * - same as in [Model.update](#model_Model.update)
+ *
+ * @see Model.update #model_Model.update
+ * @param {Object} doc
+ * @param {Object} options
+ * @param {Function} callback
+ * @return {Query}
+ * @api public
+ */
+
+Document.prototype.update = function update() {
+ var args = utils.args(arguments);
+ args.unshift({_id: this._id});
+ return this.constructor.update.apply(this.constructor, args);
+};
+
+/**
+ * Sets the value of a path, or many paths.
+ *
+ * ####Example:
+ *
+ * // path, value
+ * doc.set(path, value)
+ *
+ * // object
+ * doc.set({
+ * path : value
+ * , path2 : {
+ * path : value
+ * }
+ * })
+ *
+ * // on-the-fly cast to number
+ * doc.set(path, value, Number)
+ *
+ * // on-the-fly cast to string
+ * doc.set(path, value, String)
+ *
+ * // changing strict mode behavior
+ * doc.set(path, value, { strict: false });
+ *
+ * @param {String|Object} path path or object of key/vals to set
+ * @param {Any} val the value to set
+ * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes
+ * @param {Object} [options] optionally specify options that modify the behavior of the set
+ * @api public
+ */
+
+Document.prototype.set = function(path, val, type, options) {
+ if (type && utils.getFunctionName(type.constructor) === 'Object') {
+ options = type;
+ type = undefined;
+ }
+
+ var merge = options && options.merge,
+ adhoc = type && type !== true,
+ constructing = type === true,
+ adhocs;
+
+ var strict = options && 'strict' in options
+ ? options.strict
+ : this.$__.strictMode;
+
+ if (adhoc) {
+ adhocs = this.$__.adhocPaths || (this.$__.adhocPaths = {});
+ adhocs[path] = Schema.interpretAsType(path, type, this.schema.options);
+ }
+
+ if (typeof path !== 'string') {
+ // new Document({ key: val })
+
+ if (path === null || path === void 0) {
+ var _ = path;
+ path = val;
+ val = _;
+ } else {
+ var prefix = val
+ ? val + '.'
+ : '';
+
+ if (path instanceof Document) {
+ if (path.$__isNested) {
+ path = path.toObject();
+ } else {
+ path = path._doc;
+ }
+ }
+
+ var keys = Object.keys(path);
+ var len = keys.length;
+ var i = 0;
+ var pathtype;
+ var key;
+
+ if (len === 0 && !this.schema.options.minimize) {
+ if (val) {
+ this.set(val, {});
+ }
+ return this;
+ }
+
+ if (this.schema.options.retainKeyOrder) {
+ while (i < len) {
+ _handleIndex.call(this, i++);
+ }
+ } else {
+ while (len--) {
+ _handleIndex.call(this, len);
+ }
+ }
+
+ return this;
+ }
+ }
+
+ function _handleIndex(i) {
+ key = keys[i];
+ var pathName = prefix + key;
+ pathtype = this.schema.pathType(pathName);
+
+ if (path[key] !== null
+ && path[key] !== void 0
+ // need to know if plain object - no Buffer, ObjectId, ref, etc
+ && utils.isObject(path[key])
+ && (!path[key].constructor || utils.getFunctionName(path[key].constructor) === 'Object')
+ && pathtype !== 'virtual'
+ && pathtype !== 'real'
+ && !(this.$__path(pathName) instanceof MixedSchema)
+ && !(this.schema.paths[pathName] &&
+ this.schema.paths[pathName].options &&
+ this.schema.paths[pathName].options.ref)) {
+ this.set(path[key], prefix + key, constructing);
+ } else if (strict) {
+ // Don't overwrite defaults with undefined keys (gh-3981)
+ if (constructing && path[key] === void 0 &&
+ this.get(key) !== void 0) {
+ return;
+ }
+
+ if (pathtype === 'real' || pathtype === 'virtual') {
+ // Check for setting single embedded schema to document (gh-3535)
+ if (this.schema.paths[pathName] &&
+ this.schema.paths[pathName].$isSingleNested &&
+ path[key] instanceof Document) {
+ path[key] = path[key].toObject({virtuals: false});
+ }
+ this.set(prefix + key, path[key], constructing);
+ } else if (pathtype === 'nested' && path[key] instanceof Document) {
+ this.set(prefix + key,
+ path[key].toObject({transform: false}), constructing);
+ } else if (strict === 'throw') {
+ if (pathtype === 'nested') {
+ throw new ObjectExpectedError(key, path[key]);
+ } else {
+ throw new StrictModeError(key);
+ }
+ }
+ } else if (path[key] !== void 0) {
+ this.set(prefix + key, path[key], constructing);
+ }
+ }
+
+ // ensure _strict is honored for obj props
+ // docschema = new Schema({ path: { nest: 'string' }})
+ // doc.set('path', obj);
+ var pathType = this.schema.pathType(path);
+ if (pathType === 'nested' && val) {
+ if (utils.isObject(val) &&
+ (!val.constructor || utils.getFunctionName(val.constructor) === 'Object')) {
+ if (!merge) {
+ this.setValue(path, null);
+ cleanModifiedSubpaths(this, path);
+ }
+
+ if (Object.keys(val).length === 0) {
+ this.setValue(path, {});
+ this.markModified(path);
+ cleanModifiedSubpaths(this, path);
+ } else {
+ this.set(val, path, constructing);
+ }
+ return this;
+ }
+ this.invalidate(path, new MongooseError.CastError('Object', val, path));
+ return this;
+ }
+
+ var schema;
+ var parts = path.split('.');
+
+ if (pathType === 'adhocOrUndefined' && strict) {
+ // check for roots that are Mixed types
+ var mixed;
+
+ for (i = 0; i < parts.length; ++i) {
+ var subpath = parts.slice(0, i + 1).join('.');
+ schema = this.schema.path(subpath);
+ if (schema instanceof MixedSchema) {
+ // allow changes to sub paths of mixed types
+ mixed = true;
+ break;
+ }
+
+ // If path is underneath a virtual, bypass everything and just set it.
+ if (i + 1 < parts.length && this.schema.pathType(subpath) === 'virtual') {
+ mpath.set(path, val, this);
+ return this;
+ }
+ }
+
+ if (!mixed) {
+ if (strict === 'throw') {
+ throw new StrictModeError(path);
+ }
+ return this;
+ }
+ } else if (pathType === 'virtual') {
+ schema = this.schema.virtualpath(path);
+ schema.applySetters(val, this);
+ return this;
+ } else {
+ schema = this.$__path(path);
+ }
+
+ var pathToMark;
+
+ // When using the $set operator the path to the field must already exist.
+ // Else mongodb throws: "LEFT_SUBFIELD only supports Object"
+
+ if (parts.length <= 1) {
+ pathToMark = path;
+ } else {
+ for (i = 0; i < parts.length; ++i) {
+ subpath = parts.slice(0, i + 1).join('.');
+ if (this.isDirectModified(subpath) // earlier prefixes that are already
+ // marked as dirty have precedence
+ || this.get(subpath) === null) {
+ pathToMark = subpath;
+ break;
+ }
+ }
+
+ if (!pathToMark) {
+ pathToMark = path;
+ }
+ }
+
+ // if this doc is being constructed we should not trigger getters
+ var priorVal = constructing
+ ? undefined
+ : this.getValue(path);
+
+ if (!schema) {
+ this.$__set(pathToMark, path, constructing, parts, schema, val, priorVal);
+ return this;
+ }
+
+ var shouldSet = true;
+ try {
+ // If the user is trying to set a ref path to a document with
+ // the correct model name, treat it as populated
+ var didPopulate = false;
+ if (schema.options &&
+ schema.options.ref &&
+ val instanceof Document &&
+ schema.options.ref === val.constructor.modelName) {
+ if (this.ownerDocument) {
+ this.ownerDocument().populated(this.$__fullPath(path),
+ val._id, {model: val.constructor});
+ } else {
+ this.populated(path, val._id, {model: val.constructor});
+ }
+ didPopulate = true;
+ }
+
+ var popOpts;
+ if (schema.options &&
+ Array.isArray(schema.options.type) &&
+ schema.options.type.length &&
+ schema.options.type[0].ref &&
+ Array.isArray(val) &&
+ val.length > 0 &&
+ val[0] instanceof Document &&
+ val[0].constructor.modelName &&
+ schema.options.type[0].ref === val[0].constructor.modelName) {
+ if (this.ownerDocument) {
+ popOpts = { model: val[0].constructor };
+ this.ownerDocument().populated(this.$__fullPath(path),
+ val.map(function(v) { return v._id; }), popOpts);
+ } else {
+ popOpts = { model: val[0].constructor };
+ this.populated(path, val.map(function(v) { return v._id; }), popOpts);
+ }
+ didPopulate = true;
+ }
+ val = schema.applySetters(val, this, false, priorVal);
+
+ if (!didPopulate && this.$__.populated) {
+ delete this.$__.populated[path];
+ }
+
+ this.$markValid(path);
+ } catch (e) {
+ this.invalidate(path,
+ new MongooseError.CastError(schema.instance, val, path, e));
+ shouldSet = false;
+ }
+
+ if (shouldSet) {
+ this.$__set(pathToMark, path, constructing, parts, schema, val, priorVal);
+ }
+
+ if (schema.$isSingleNested && this.isDirectModified(path)) {
+ cleanModifiedSubpaths(this, path);
+ }
+
+ return this;
+};
+
+/*!
+ * ignore
+ */
+
+function cleanModifiedSubpaths(doc, path) {
+ var _modifiedPaths = Object.keys(doc.$__.activePaths.states.modify);
+ var _numModifiedPaths = _modifiedPaths.length;
+ for (var j = 0; j < _numModifiedPaths; ++j) {
+ if (_modifiedPaths[j].indexOf(path + '.') === 0) {
+ delete doc.$__.activePaths.states.modify[_modifiedPaths[j]];
+ }
+ }
+}
+
+/**
+ * Determine if we should mark this change as modified.
+ *
+ * @return {Boolean}
+ * @api private
+ * @method $__shouldModify
+ * @memberOf Document
+ */
+
+Document.prototype.$__shouldModify = function(pathToMark, path, constructing, parts, schema, val, priorVal) {
+ if (this.isNew) {
+ return true;
+ }
+
+ if (undefined === val && !this.isSelected(path)) {
+ // when a path is not selected in a query, its initial
+ // value will be undefined.
+ return true;
+ }
+
+ if (undefined === val && path in this.$__.activePaths.states.default) {
+ // we're just unsetting the default value which was never saved
+ return false;
+ }
+
+ // gh-3992: if setting a populated field to a doc, don't mark modified
+ // if they have the same _id
+ if (this.populated(path) &&
+ val instanceof Document &&
+ deepEqual(val._id, priorVal)) {
+ return false;
+ }
+
+ if (!deepEqual(val, priorVal || this.get(path))) {
+ return true;
+ }
+
+ if (!constructing &&
+ val !== null &&
+ val !== undefined &&
+ path in this.$__.activePaths.states.default &&
+ deepEqual(val, schema.getDefault(this, constructing))) {
+ // a path with a default was $unset on the server
+ // and the user is setting it to the same value again
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Handles the actual setting of the value and marking the path modified if appropriate.
+ *
+ * @api private
+ * @method $__set
+ * @memberOf Document
+ */
+
+Document.prototype.$__set = function(pathToMark, path, constructing, parts, schema, val, priorVal) {
+ Embedded = Embedded || require('./types/embedded');
+
+ var shouldModify = this.$__shouldModify(pathToMark, path, constructing, parts,
+ schema, val, priorVal);
+ var _this = this;
+
+ if (shouldModify) {
+ this.markModified(pathToMark, val);
+
+ // handle directly setting arrays (gh-1126)
+ MongooseArray || (MongooseArray = require('./types/array'));
+ if (val && val.isMongooseArray) {
+ val._registerAtomic('$set', val);
+
+ // Small hack for gh-1638: if we're overwriting the entire array, ignore
+ // paths that were modified before the array overwrite
+ this.$__.activePaths.forEach(function(modifiedPath) {
+ if (modifiedPath.indexOf(path + '.') === 0) {
+ _this.$__.activePaths.ignore(modifiedPath);
+ }
+ });
+ }
+ }
+
+ var obj = this._doc;
+ var i = 0;
+ var l = parts.length;
+ var cur = '';
+
+ for (; i < l; i++) {
+ var next = i + 1;
+ var last = next === l;
+ cur += (cur ? '.' + parts[i] : parts[i]);
+
+ if (last) {
+ obj[parts[i]] = val;
+ } else {
+ if (obj[parts[i]] && utils.getFunctionName(obj[parts[i]].constructor) === 'Object') {
+ obj = obj[parts[i]];
+ } else if (obj[parts[i]] && obj[parts[i]] instanceof Embedded) {
+ obj = obj[parts[i]];
+ } else if (obj[parts[i]] && obj[parts[i]].$isSingleNested) {
+ obj = obj[parts[i]];
+ } else if (obj[parts[i]] && Array.isArray(obj[parts[i]])) {
+ obj = obj[parts[i]];
+ } else {
+ this.set(cur, {});
+ obj = obj[parts[i]];
+ }
+ }
+ }
+};
+
+/**
+ * Gets a raw value from a path (no getters)
+ *
+ * @param {String} path
+ * @api private
+ */
+
+Document.prototype.getValue = function(path) {
+ return utils.getValue(path, this._doc);
+};
+
+/**
+ * Sets a raw value for a path (no casting, setters, transformations)
+ *
+ * @param {String} path
+ * @param {Object} value
+ * @api private
+ */
+
+Document.prototype.setValue = function(path, val) {
+ utils.setValue(path, val, this._doc);
+ return this;
+};
+
+/**
+ * Returns the value of a path.
+ *
+ * ####Example
+ *
+ * // path
+ * doc.get('age') // 47
+ *
+ * // dynamic casting to a string
+ * doc.get('age', String) // "47"
+ *
+ * @param {String} path
+ * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for on-the-fly attributes
+ * @api public
+ */
+
+Document.prototype.get = function(path, type) {
+ var adhoc;
+ if (type) {
+ adhoc = Schema.interpretAsType(path, type, this.schema.options);
+ }
+
+ var schema = this.$__path(path) || this.schema.virtualpath(path),
+ pieces = path.split('.'),
+ obj = this._doc;
+
+ for (var i = 0, l = pieces.length; i < l; i++) {
+ obj = obj === null || obj === void 0
+ ? undefined
+ : obj[pieces[i]];
+ }
+
+ if (adhoc) {
+ obj = adhoc.cast(obj);
+ }
+
+ // Check if this path is populated - don't apply getters if it is,
+ // because otherwise its a nested object. See gh-3357
+ if (schema && !this.populated(path)) {
+ obj = schema.applyGetters(obj, this);
+ }
+
+ return obj;
+};
+
+/**
+ * Returns the schematype for the given `path`.
+ *
+ * @param {String} path
+ * @api private
+ * @method $__path
+ * @memberOf Document
+ */
+
+Document.prototype.$__path = function(path) {
+ var adhocs = this.$__.adhocPaths,
+ adhocType = adhocs && adhocs[path];
+
+ if (adhocType) {
+ return adhocType;
+ }
+ return this.schema.path(path);
+};
+
+/**
+ * Marks the path as having pending changes to write to the db.
+ *
+ * _Very helpful when using [Mixed](./schematypes.html#mixed) types._
+ *
+ * ####Example:
+ *
+ * doc.mixed.type = 'changed';
+ * doc.markModified('mixed.type');
+ * doc.save() // changes to mixed.type are now persisted
+ *
+ * @param {String} path the path to mark modified
+ * @api public
+ */
+
+Document.prototype.markModified = function(path) {
+ this.$__.activePaths.modify(path);
+};
+
+/**
+ * Clears the modified state on the specified path.
+ *
+ * ####Example:
+ *
+ * doc.foo = 'bar';
+ * doc.unmarkModified('foo');
+ * doc.save() // changes to foo will not be persisted
+ *
+ * @param {String} path the path to unmark modified
+ * @api public
+ */
+
+Document.prototype.unmarkModified = function(path) {
+ this.$__.activePaths.init(path);
+};
+
+/**
+ * Don't run validation on this path or persist changes to this path.
+ *
+ * ####Example:
+ *
+ * doc.foo = null;
+ * doc.$ignore('foo');
+ * doc.save() // changes to foo will not be persisted and validators won't be run
+ *
+ * @param {String} path the path to ignore
+ * @api public
+ */
+
+Document.prototype.$ignore = function(path) {
+ this.$__.activePaths.ignore(path);
+};
+
+/**
+ * Returns the list of paths that have been modified.
+ *
+ * @return {Array}
+ * @api public
+ */
+
+Document.prototype.modifiedPaths = function() {
+ var directModifiedPaths = Object.keys(this.$__.activePaths.states.modify);
+ return directModifiedPaths.reduce(function(list, path) {
+ var parts = path.split('.');
+ return list.concat(parts.reduce(function(chains, part, i) {
+ return chains.concat(parts.slice(0, i).concat(part).join('.'));
+ }, []).filter(function(chain) {
+ return (list.indexOf(chain) === -1);
+ }));
+ }, []);
+};
+
+/**
+ * Returns true if this document was modified, else false.
+ *
+ * If `path` is given, checks if a path or any full path containing `path` as part of its path chain has been modified.
+ *
+ * ####Example
+ *
+ * doc.set('documents.0.title', 'changed');
+ * doc.isModified() // true
+ * doc.isModified('documents') // true
+ * doc.isModified('documents.0.title') // true
+ * doc.isModified('documents otherProp') // true
+ * doc.isDirectModified('documents') // false
+ *
+ * @param {String} [path] optional
+ * @return {Boolean}
+ * @api public
+ */
+
+Document.prototype.isModified = function(paths) {
+ if (paths) {
+ if (!Array.isArray(paths)) {
+ paths = paths.split(' ');
+ }
+ var modified = this.modifiedPaths();
+ var directModifiedPaths = Object.keys(this.$__.activePaths.states.modify);
+ var isModifiedChild = paths.some(function(path) {
+ return !!~modified.indexOf(path);
+ });
+ return isModifiedChild || paths.some(function(path) {
+ return directModifiedPaths.some(function(mod) {
+ return mod === path || path.indexOf(mod + '.') === 0;
+ });
+ });
+ }
+ return this.$__.activePaths.some('modify');
+};
+
+/**
+ * Checks if a path is set to its default.
+ *
+ * ####Example
+ *
+ * MyModel = mongoose.model('test', { name: { type: String, default: 'Val '} });
+ * var m = new MyModel();
+ * m.$isDefault('name'); // true
+ *
+ * @param {String} [path]
+ * @return {Boolean}
+ * @method $isDefault
+ * @api public
+ */
+
+Document.prototype.$isDefault = function(path) {
+ return (path in this.$__.activePaths.states.default);
+};
+
+/**
+ * Returns true if `path` was directly set and modified, else false.
+ *
+ * ####Example
+ *
+ * doc.set('documents.0.title', 'changed');
+ * doc.isDirectModified('documents.0.title') // true
+ * doc.isDirectModified('documents') // false
+ *
+ * @param {String} path
+ * @return {Boolean}
+ * @api public
+ */
+
+Document.prototype.isDirectModified = function(path) {
+ return (path in this.$__.activePaths.states.modify);
+};
+
+/**
+ * Checks if `path` was initialized.
+ *
+ * @param {String} path
+ * @return {Boolean}
+ * @api public
+ */
+
+Document.prototype.isInit = function(path) {
+ return (path in this.$__.activePaths.states.init);
+};
+
+/**
+ * Checks if `path` was selected in the source query which initialized this document.
+ *
+ * ####Example
+ *
+ * Thing.findOne().select('name').exec(function (err, doc) {
+ * doc.isSelected('name') // true
+ * doc.isSelected('age') // false
+ * })
+ *
+ * @param {String} path
+ * @return {Boolean}
+ * @api public
+ */
+
+Document.prototype.isSelected = function isSelected(path) {
+ if (this.$__.selected) {
+ if (path === '_id') {
+ return this.$__.selected._id !== 0;
+ }
+
+ var paths = Object.keys(this.$__.selected),
+ i = paths.length,
+ inclusive = false,
+ cur;
+
+ if (i === 1 && paths[0] === '_id') {
+ // only _id was selected.
+ return this.$__.selected._id === 0;
+ }
+
+ while (i--) {
+ cur = paths[i];
+ if (cur === '_id') {
+ continue;
+ }
+ inclusive = !!this.$__.selected[cur];
+ break;
+ }
+
+ if (path in this.$__.selected) {
+ return inclusive;
+ }
+
+ i = paths.length;
+ var pathDot = path + '.';
+
+ while (i--) {
+ cur = paths[i];
+ if (cur === '_id') {
+ continue;
+ }
+
+ if (cur.indexOf(pathDot) === 0) {
+ return inclusive;
+ }
+
+ if (pathDot.indexOf(cur + '.') === 0) {
+ return inclusive;
+ }
+ }
+
+ return !inclusive;
+ }
+
+ return true;
+};
+
+/**
+ * Executes registered validation rules for this document.
+ *
+ * ####Note:
+ *
+ * This method is called `pre` save and if a validation rule is violated, [save](#model_Model-save) is aborted and the error is returned to your `callback`.
+ *
+ * ####Example:
+ *
+ * doc.validate(function (err) {
+ * if (err) handleError(err);
+ * else // validation passed
+ * });
+ *
+ * @param {Object} optional options internal options
+ * @param {Function} callback optional callback called after validation completes, passing an error if one occurred
+ * @return {Promise} Promise
+ * @api public
+ */
+
+Document.prototype.validate = function(options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+
+ this.$__validate(callback);
+};
+
+/*!
+ * ignore
+ */
+
+function _getPathsToValidate(doc) {
+ // only validate required fields when necessary
+ var paths = Object.keys(doc.$__.activePaths.states.require).filter(function(path) {
+ if (!doc.isSelected(path) && !doc.isModified(path)) {
+ return false;
+ }
+ var p = doc.schema.path(path);
+ if (typeof p.originalRequiredValue === 'function') {
+ return p.originalRequiredValue.call(doc);
+ }
+ return true;
+ });
+
+ paths = paths.concat(Object.keys(doc.$__.activePaths.states.init));
+ paths = paths.concat(Object.keys(doc.$__.activePaths.states.modify));
+ paths = paths.concat(Object.keys(doc.$__.activePaths.states.default));
+
+ // gh-661: if a whole array is modified, make sure to run validation on all
+ // the children as well
+ for (var i = 0; i < paths.length; ++i) {
+ var path = paths[i];
+ var val = doc.getValue(path);
+ if (val && val.isMongooseArray && !Buffer.isBuffer(val) && !val.isMongooseDocumentArray) {
+ var numElements = val.length;
+ for (var j = 0; j < numElements; ++j) {
+ paths.push(path + '.' + j);
+ }
+ }
+ }
+
+ var flattenOptions = { skipArrays: true };
+ for (i = 0; i < paths.length; ++i) {
+ var pathToCheck = paths[i];
+ if (doc.schema.nested[pathToCheck]) {
+ var _v = doc.getValue(pathToCheck);
+ if (isMongooseObject(_v)) {
+ _v = _v.toObject({ transform: false });
+ }
+ var flat = flatten(_v, '', flattenOptions);
+ var _subpaths = Object.keys(flat).map(function(p) {
+ return pathToCheck + '.' + p;
+ });
+ paths = paths.concat(_subpaths);
+ }
+ }
+
+ return paths;
+}
+
+/*!
+ * ignore
+ */
+
+Document.prototype.$__validate = function(callback) {
+ var _this = this;
+ var _complete = function() {
+ var err = _this.$__.validationError;
+ _this.$__.validationError = undefined;
+ _this.emit('validate', _this);
+ if (err) {
+ for (var key in err.errors) {
+ // Make sure cast errors persist
+ if (!_this.__parent && err.errors[key] instanceof MongooseError.CastError) {
+ _this.invalidate(key, err.errors[key]);
+ }
+ }
+
+ return err;
+ }
+ };
+
+ // only validate required fields when necessary
+ var paths = _getPathsToValidate(this);
+
+ if (paths.length === 0) {
+ process.nextTick(function() {
+ var err = _complete();
+ if (err) {
+ callback(err);
+ return;
+ }
+ callback();
+ });
+ }
+
+ var validating = {},
+ total = 0;
+
+ var complete = function() {
+ var err = _complete();
+ if (err) {
+ callback(err);
+ return;
+ }
+ callback();
+ };
+
+ var validatePath = function(path) {
+ if (validating[path]) {
+ return;
+ }
+
+ validating[path] = true;
+ total++;
+
+ process.nextTick(function() {
+ var p = _this.schema.path(path);
+ if (!p) {
+ return --total || complete();
+ }
+
+ // If user marked as invalid or there was a cast error, don't validate
+ if (!_this.$isValid(path)) {
+ --total || complete();
+ return;
+ }
+
+ var val = _this.getValue(path);
+ p.doValidate(val, function(err) {
+ if (err) {
+ _this.invalidate(path, err, undefined, true);
+ }
+ --total || complete();
+ }, _this);
+ });
+ };
+
+ paths.forEach(validatePath);
+};
+
+/**
+ * Executes registered validation rules (skipping asynchronous validators) for this document.
+ *
+ * ####Note:
+ *
+ * This method is useful if you need synchronous validation.
+ *
+ * ####Example:
+ *
+ * var err = doc.validateSync();
+ * if ( err ){
+ * handleError( err );
+ * } else {
+ * // validation passed
+ * }
+ *
+ * @param {Array|string} pathsToValidate only validate the given paths
+ * @return {MongooseError|undefined} MongooseError if there are errors during validation, or undefined if there is no error.
+ * @api public
+ */
+
+Document.prototype.validateSync = function(pathsToValidate) {
+ var _this = this;
+
+ if (typeof pathsToValidate === 'string') {
+ pathsToValidate = pathsToValidate.split(' ');
+ }
+
+ // only validate required fields when necessary
+ var paths = _getPathsToValidate(this);
+
+ if (pathsToValidate && pathsToValidate.length) {
+ var tmp = [];
+ for (var i = 0; i < paths.length; ++i) {
+ if (pathsToValidate.indexOf(paths[i]) !== -1) {
+ tmp.push(paths[i]);
+ }
+ }
+ paths = tmp;
+ }
+
+ var validating = {};
+
+ paths.forEach(function(path) {
+ if (validating[path]) {
+ return;
+ }
+
+ validating[path] = true;
+
+ var p = _this.schema.path(path);
+ if (!p) {
+ return;
+ }
+ if (!_this.$isValid(path)) {
+ return;
+ }
+
+ var val = _this.getValue(path);
+ var err = p.doValidateSync(val, _this);
+ if (err) {
+ _this.invalidate(path, err, undefined, true);
+ }
+ });
+
+ var err = _this.$__.validationError;
+ _this.$__.validationError = undefined;
+ _this.emit('validate', _this);
+
+ if (err) {
+ for (var key in err.errors) {
+ // Make sure cast errors persist
+ if (err.errors[key] instanceof MongooseError.CastError) {
+ _this.invalidate(key, err.errors[key]);
+ }
+ }
+ }
+
+ return err;
+};
+
+/**
+ * Marks a path as invalid, causing validation to fail.
+ *
+ * The `errorMsg` argument will become the message of the `ValidationError`.
+ *
+ * The `value` argument (if passed) will be available through the `ValidationError.value` property.
+ *
+ * doc.invalidate('size', 'must be less than 20', 14);
+
+ * doc.validate(function (err) {
+ * console.log(err)
+ * // prints
+ * { message: 'Validation failed',
+ * name: 'ValidationError',
+ * errors:
+ * { size:
+ * { message: 'must be less than 20',
+ * name: 'ValidatorError',
+ * path: 'size',
+ * type: 'user defined',
+ * value: 14 } } }
+ * })
+ *
+ * @param {String} path the field to invalidate
+ * @param {String|Error} errorMsg the error which states the reason `path` was invalid
+ * @param {Object|String|Number|any} value optional invalid value
+ * @param {String} [kind] optional `kind` property for the error
+ * @return {ValidationError} the current ValidationError, with all currently invalidated paths
+ * @api public
+ */
+
+Document.prototype.invalidate = function(path, err, val, kind) {
+ if (!this.$__.validationError) {
+ this.$__.validationError = new ValidationError(this);
+ }
+
+ if (this.$__.validationError.errors[path]) {
+ return;
+ }
+
+ if (!err || typeof err === 'string') {
+ err = new ValidatorError({
+ path: path,
+ message: err,
+ type: kind || 'user defined',
+ value: val
+ });
+ }
+
+ if (this.$__.validationError === err) {
+ return this.$__.validationError;
+ }
+
+ this.$__.validationError.errors[path] = err;
+ return this.$__.validationError;
+};
+
+/**
+ * Marks a path as valid, removing existing validation errors.
+ *
+ * @param {String} path the field to mark as valid
+ * @api private
+ * @method $markValid
+ * @receiver Document
+ */
+
+Document.prototype.$markValid = function(path) {
+ if (!this.$__.validationError || !this.$__.validationError.errors[path]) {
+ return;
+ }
+
+ delete this.$__.validationError.errors[path];
+ if (Object.keys(this.$__.validationError.errors).length === 0) {
+ this.$__.validationError = null;
+ }
+};
+
+/**
+ * Checks if a path is invalid
+ *
+ * @param {String} path the field to check
+ * @method $isValid
+ * @api private
+ * @receiver Document
+ */
+
+Document.prototype.$isValid = function(path) {
+ return !this.$__.validationError || !this.$__.validationError.errors[path];
+};
+
+/**
+ * Resets the internal modified state of this document.
+ *
+ * @api private
+ * @return {Document}
+ * @method $__reset
+ * @memberOf Document
+ */
+
+Document.prototype.$__reset = function reset() {
+ var _this = this;
+ DocumentArray || (DocumentArray = require('./types/documentarray'));
+
+ this.$__.activePaths
+ .map('init', 'modify', function(i) {
+ return _this.getValue(i);
+ })
+ .filter(function(val) {
+ return val && val instanceof Array && val.isMongooseDocumentArray && val.length;
+ })
+ .forEach(function(array) {
+ var i = array.length;
+ while (i--) {
+ var doc = array[i];
+ if (!doc) {
+ continue;
+ }
+ doc.$__reset();
+ }
+ });
+
+ // clear atomics
+ this.$__dirty().forEach(function(dirt) {
+ var type = dirt.value;
+ if (type && type._atomics) {
+ type._atomics = {};
+ }
+ });
+
+ // Clear 'dirty' cache
+ this.$__.activePaths.clear('modify');
+ this.$__.activePaths.clear('default');
+ this.$__.validationError = undefined;
+ this.errors = undefined;
+ _this = this;
+ this.schema.requiredPaths().forEach(function(path) {
+ _this.$__.activePaths.require(path);
+ });
+
+ return this;
+};
+
+/**
+ * Returns this documents dirty paths / vals.
+ *
+ * @api private
+ * @method $__dirty
+ * @memberOf Document
+ */
+
+Document.prototype.$__dirty = function() {
+ var _this = this;
+
+ var all = this.$__.activePaths.map('modify', function(path) {
+ return {
+ path: path,
+ value: _this.getValue(path),
+ schema: _this.$__path(path)
+ };
+ });
+
+ // gh-2558: if we had to set a default and the value is not undefined,
+ // we have to save as well
+ all = all.concat(this.$__.activePaths.map('default', function(path) {
+ if (path === '_id' || !_this.getValue(path)) {
+ return;
+ }
+ return {
+ path: path,
+ value: _this.getValue(path),
+ schema: _this.$__path(path)
+ };
+ }));
+
+ // Sort dirty paths in a flat hierarchy.
+ all.sort(function(a, b) {
+ return (a.path < b.path ? -1 : (a.path > b.path ? 1 : 0));
+ });
+
+ // Ignore "foo.a" if "foo" is dirty already.
+ var minimal = [],
+ lastPath,
+ top;
+
+ all.forEach(function(item) {
+ if (!item) {
+ return;
+ }
+ if (item.path.indexOf(lastPath) !== 0) {
+ lastPath = item.path + '.';
+ minimal.push(item);
+ top = item;
+ } else {
+ // special case for top level MongooseArrays
+ if (top.value && top.value._atomics && top.value.hasAtomics()) {
+ // the `top` array itself and a sub path of `top` are being modified.
+ // the only way to honor all of both modifications is through a $set
+ // of entire array.
+ top.value._atomics = {};
+ top.value._atomics.$set = top.value;
+ }
+ }
+ });
+
+ top = lastPath = null;
+ return minimal;
+};
+
+/*!
+ * Compiles schemas.
+ */
+
+function compile(tree, proto, prefix, options) {
+ var keys = Object.keys(tree),
+ i = keys.length,
+ limb,
+ key;
+
+ while (i--) {
+ key = keys[i];
+ limb = tree[key];
+
+ defineKey(key,
+ ((utils.getFunctionName(limb.constructor) === 'Object'
+ && Object.keys(limb).length)
+ && (!limb[options.typeKey] || (options.typeKey === 'type' && limb.type.type))
+ ? limb
+ : null)
+ , proto
+ , prefix
+ , keys
+ , options);
+ }
+}
+
+// gets descriptors for all properties of `object`
+// makes all properties non-enumerable to match previous behavior to #2211
+function getOwnPropertyDescriptors(object) {
+ var result = {};
+
+ Object.getOwnPropertyNames(object).forEach(function(key) {
+ result[key] = Object.getOwnPropertyDescriptor(object, key);
+ result[key].enumerable = true;
+ });
+
+ return result;
+}
+
+/*!
+ * Defines the accessor named prop on the incoming prototype.
+ */
+
+function defineKey(prop, subprops, prototype, prefix, keys, options) {
+ var path = (prefix ? prefix + '.' : '') + prop;
+ prefix = prefix || '';
+
+ if (subprops) {
+ Object.defineProperty(prototype, prop, {
+ enumerable: true,
+ configurable: true,
+ get: function() {
+ var _this = this;
+ if (!this.$__.getters) {
+ this.$__.getters = {};
+ }
+
+ if (!this.$__.getters[path]) {
+ var nested = Object.create(Object.getPrototypeOf(this), getOwnPropertyDescriptors(this));
+
+ // save scope for nested getters/setters
+ if (!prefix) {
+ nested.$__.scope = this;
+ }
+
+ // shadow inherited getters from sub-objects so
+ // thing.nested.nested.nested... doesn't occur (gh-366)
+ var i = 0,
+ len = keys.length;
+
+ for (; i < len; ++i) {
+ // over-write the parents getter without triggering it
+ Object.defineProperty(nested, keys[i], {
+ enumerable: false, // It doesn't show up.
+ writable: true, // We can set it later.
+ configurable: true, // We can Object.defineProperty again.
+ value: undefined // It shadows its parent.
+ });
+ }
+
+ Object.defineProperty(nested, 'toObject', {
+ enumerable: true,
+ configurable: true,
+ writable: false,
+ value: function() {
+ return _this.get(path);
+ }
+ });
+
+ Object.defineProperty(nested, 'toJSON', {
+ enumerable: true,
+ configurable: true,
+ writable: false,
+ value: function() {
+ return _this.get(path);
+ }
+ });
+
+ Object.defineProperty(nested, '$__isNested', {
+ enumerable: true,
+ configurable: true,
+ writable: false,
+ value: true
+ });
+
+ compile(subprops, nested, path, options);
+ this.$__.getters[path] = nested;
+ }
+
+ return this.$__.getters[path];
+ },
+ set: function(v) {
+ if (v instanceof Document) {
+ v = v.toObject({ transform: false });
+ }
+ return (this.$__.scope || this).set(path, v);
+ }
+ });
+ } else {
+ Object.defineProperty(prototype, prop, {
+ enumerable: true,
+ configurable: true,
+ get: function() {
+ return this.get.call(this.$__.scope || this, path);
+ },
+ set: function(v) {
+ return this.set.call(this.$__.scope || this, path, v);
+ }
+ });
+ }
+}
+
+/**
+ * Assigns/compiles `schema` into this documents prototype.
+ *
+ * @param {Schema} schema
+ * @api private
+ * @method $__setSchema
+ * @memberOf Document
+ */
+
+Document.prototype.$__setSchema = function(schema) {
+ compile(schema.tree, this, undefined, schema.options);
+ this.schema = schema;
+};
+
+
+/**
+ * Get active path that were changed and are arrays
+ *
+ * @api private
+ * @method $__getArrayPathsToValidate
+ * @memberOf Document
+ */
+
+Document.prototype.$__getArrayPathsToValidate = function() {
+ DocumentArray || (DocumentArray = require('./types/documentarray'));
+
+ // validate all document arrays.
+ return this.$__.activePaths
+ .map('init', 'modify', function(i) {
+ return this.getValue(i);
+ }.bind(this))
+ .filter(function(val) {
+ return val && val instanceof Array && val.isMongooseDocumentArray && val.length;
+ }).reduce(function(seed, array) {
+ return seed.concat(array);
+ }, [])
+ .filter(function(doc) {
+ return doc;
+ });
+};
+
+
+/**
+ * Get all subdocs (by bfs)
+ *
+ * @api private
+ * @method $__getAllSubdocs
+ * @memberOf Document
+ */
+
+Document.prototype.$__getAllSubdocs = function() {
+ DocumentArray || (DocumentArray = require('./types/documentarray'));
+ Embedded = Embedded || require('./types/embedded');
+
+ function docReducer(seed, path) {
+ var val = this[path];
+
+ if (val instanceof Embedded) {
+ seed.push(val);
+ }
+ if (val && val.$isSingleNested) {
+ seed = Object.keys(val._doc).reduce(docReducer.bind(val._doc), seed);
+ seed.push(val);
+ }
+ if (val && val.isMongooseDocumentArray) {
+ val.forEach(function _docReduce(doc) {
+ if (!doc || !doc._doc) {
+ return;
+ }
+ if (doc instanceof Embedded) {
+ seed.push(doc);
+ }
+ seed = Object.keys(doc._doc).reduce(docReducer.bind(doc._doc), seed);
+ });
+ } else if (val instanceof Document && val.$__isNested) {
+ val = val.toObject();
+ if (val) {
+ seed = Object.keys(val).reduce(docReducer.bind(val), seed);
+ }
+ }
+ return seed;
+ }
+
+ var subDocs = Object.keys(this._doc).reduce(docReducer.bind(this), []);
+
+ return subDocs;
+};
+
+/**
+ * Executes methods queued from the Schema definition
+ *
+ * @api private
+ * @method $__registerHooksFromSchema
+ * @memberOf Document
+ */
+
+Document.prototype.$__registerHooksFromSchema = function() {
+ Embedded = Embedded || require('./types/embedded');
+ var Promise = PromiseProvider.get();
+
+ var _this = this;
+ var q = _this.schema && _this.schema.callQueue;
+ if (!q.length) {
+ return _this;
+ }
+
+ // we are only interested in 'pre' hooks, and group by point-cut
+ var toWrap = q.reduce(function(seed, pair) {
+ if (pair[0] !== 'pre' && pair[0] !== 'post' && pair[0] !== 'on') {
+ _this[pair[0]].apply(_this, pair[1]);
+ return seed;
+ }
+ var args = [].slice.call(pair[1]);
+ var pointCut = pair[0] === 'on' ? 'post' : args[0];
+ if (!(pointCut in seed)) {
+ seed[pointCut] = {post: [], pre: []};
+ }
+ if (pair[0] === 'post') {
+ seed[pointCut].post.push(args);
+ } else if (pair[0] === 'on') {
+ seed[pointCut].push(args);
+ } else {
+ seed[pointCut].pre.push(args);
+ }
+ return seed;
+ }, {post: []});
+
+ // 'post' hooks are simpler
+ toWrap.post.forEach(function(args) {
+ _this.on.apply(_this, args);
+ });
+ delete toWrap.post;
+
+ // 'init' should be synchronous on subdocuments
+ if (toWrap.init && _this instanceof Embedded) {
+ if (toWrap.init.pre) {
+ toWrap.init.pre.forEach(function(args) {
+ _this.$pre.apply(_this, args);
+ });
+ }
+ if (toWrap.init.post) {
+ toWrap.init.post.forEach(function(args) {
+ _this.$post.apply(_this, args);
+ });
+ }
+ delete toWrap.init;
+ } else if (toWrap.set) {
+ // Set hooks also need to be sync re: gh-3479
+ if (toWrap.set.pre) {
+ toWrap.set.pre.forEach(function(args) {
+ _this.$pre.apply(_this, args);
+ });
+ }
+ if (toWrap.set.post) {
+ toWrap.set.post.forEach(function(args) {
+ _this.$post.apply(_this, args);
+ });
+ }
+ delete toWrap.set;
+ }
+
+ Object.keys(toWrap).forEach(function(pointCut) {
+ // this is so we can wrap everything into a promise;
+ var newName = ('$__original_' + pointCut);
+ if (!_this[pointCut]) {
+ return;
+ }
+ _this[newName] = _this[pointCut];
+ _this[pointCut] = function wrappedPointCut() {
+ var args = [].slice.call(arguments);
+ var lastArg = args.pop();
+ var fn;
+ var originalError = new Error();
+ var $results;
+ if (lastArg && typeof lastArg !== 'function') {
+ args.push(lastArg);
+ } else {
+ fn = lastArg;
+ }
+
+ var promise = new Promise.ES6(function(resolve, reject) {
+ args.push(function(error) {
+ if (error) {
+ // gh-2633: since VersionError is very generic, take the
+ // stack trace of the original save() function call rather
+ // than the async trace
+ if (error instanceof VersionError) {
+ error.stack = originalError.stack;
+ }
+ _this.$__handleReject(error);
+ reject(error);
+ return;
+ }
+
+ // There may be multiple results and promise libs other than
+ // mpromise don't support passing multiple values to `resolve()`
+ $results = Array.prototype.slice.call(arguments, 1);
+ resolve.apply(promise, $results);
+ });
+
+ _this[newName].apply(_this, args);
+ });
+ if (fn) {
+ if (_this.constructor.$wrapCallback) {
+ fn = _this.constructor.$wrapCallback(fn);
+ }
+ return promise.then(
+ function() {
+ process.nextTick(function() {
+ fn.apply(null, [null].concat($results));
+ });
+ },
+ function(error) {
+ process.nextTick(function() {
+ fn(error);
+ });
+ });
+ }
+ return promise;
+ };
+
+ toWrap[pointCut].pre.forEach(function(args) {
+ args[0] = newName;
+ _this.$pre.apply(_this, args);
+ });
+ toWrap[pointCut].post.forEach(function(args) {
+ args[0] = newName;
+ _this.$post.apply(_this, args);
+ });
+ });
+ return _this;
+};
+
+Document.prototype.$__handleReject = function handleReject(err) {
+ // emit on the Model if listening
+ if (this.listeners('error').length) {
+ this.emit('error', err);
+ } else if (this.constructor.listeners && this.constructor.listeners('error').length) {
+ this.constructor.emit('error', err);
+ } else if (this.listeners && this.listeners('error').length) {
+ this.emit('error', err);
+ }
+};
+
+/**
+ * Internal helper for toObject() and toJSON() that doesn't manipulate options
+ *
+ * @api private
+ * @method $toObject
+ * @memberOf Document
+ */
+
+Document.prototype.$toObject = function(options, json) {
+ var defaultOptions = {
+ transform: true,
+ json: json,
+ retainKeyOrder: this.schema.options.retainKeyOrder
+ };
+
+ // _isNested will only be true if this is not the top level document, we
+ // should never depopulate
+ if (options && options.depopulate && options._isNested && this.$__.wasPopulated) {
+ // populated paths that we set to a document
+ return clone(this._id, options);
+ }
+
+ // When internally saving this document we always pass options,
+ // bypassing the custom schema options.
+ if (!(options && utils.getFunctionName(options.constructor) === 'Object') ||
+ (options && options._useSchemaOptions)) {
+ if (json) {
+ options = this.schema.options.toJSON ?
+ clone(this.schema.options.toJSON) :
+ {};
+ options.json = true;
+ options._useSchemaOptions = true;
+ } else {
+ options = this.schema.options.toObject ?
+ clone(this.schema.options.toObject) :
+ {};
+ options.json = false;
+ options._useSchemaOptions = true;
+ }
+ }
+
+ for (var key in defaultOptions) {
+ if (options[key] === undefined) {
+ options[key] = defaultOptions[key];
+ }
+ }
+
+ ('minimize' in options) || (options.minimize = this.schema.options.minimize);
+
+ // remember the root transform function
+ // to save it from being overwritten by sub-transform functions
+ var originalTransform = options.transform;
+
+ options._isNested = true;
+
+ var ret = clone(this._doc, options) || {};
+
+ if (options.getters) {
+ applyGetters(this, ret, 'paths', options);
+ // applyGetters for paths will add nested empty objects;
+ // if minimize is set, we need to remove them.
+ if (options.minimize) {
+ ret = minimize(ret) || {};
+ }
+ }
+
+ if (options.virtuals || options.getters && options.virtuals !== false) {
+ applyGetters(this, ret, 'virtuals', options);
+ }
+
+ if (options.versionKey === false && this.schema.options.versionKey) {
+ delete ret[this.schema.options.versionKey];
+ }
+
+ var transform = options.transform;
+
+ // In the case where a subdocument has its own transform function, we need to
+ // check and see if the parent has a transform (options.transform) and if the
+ // child schema has a transform (this.schema.options.toObject) In this case,
+ // we need to adjust options.transform to be the child schema's transform and
+ // not the parent schema's
+ if (transform === true ||
+ (this.schema.options.toObject && transform)) {
+ var opts = options.json ? this.schema.options.toJSON : this.schema.options.toObject;
+
+ if (opts) {
+ transform = (typeof options.transform === 'function' ? options.transform : opts.transform);
+ }
+ } else {
+ options.transform = originalTransform;
+ }
+
+ if (typeof transform === 'function') {
+ var xformed = transform(this, ret, options);
+ if (typeof xformed !== 'undefined') {
+ ret = xformed;
+ }
+ }
+
+ return ret;
+};
+
+/**
+ * Converts this document into a plain javascript object, ready for storage in MongoDB.
+ *
+ * Buffers are converted to instances of [mongodb.Binary](http://mongodb.github.com/node-mongodb-native/api-bson-generated/binary.html) for proper storage.
+ *
+ * ####Options:
+ *
+ * - `getters` apply all getters (path and virtual getters)
+ * - `virtuals` apply virtual getters (can override `getters` option)
+ * - `minimize` remove empty objects (defaults to true)
+ * - `transform` a transform function to apply to the resulting document before returning
+ * - `depopulate` depopulate any populated paths, replacing them with their original refs (defaults to false)
+ * - `versionKey` whether to include the version key (defaults to true)
+ * - `retainKeyOrder` keep the order of object keys. If this is set to true, `Object.keys(new Doc({ a: 1, b: 2}).toObject())` will always produce `['a', 'b']` (defaults to false)
+ *
+ * ####Getters/Virtuals
+ *
+ * Example of only applying path getters
+ *
+ * doc.toObject({ getters: true, virtuals: false })
+ *
+ * Example of only applying virtual getters
+ *
+ * doc.toObject({ virtuals: true })
+ *
+ * Example of applying both path and virtual getters
+ *
+ * doc.toObject({ getters: true })
+ *
+ * To apply these options to every document of your schema by default, set your [schemas](#schema_Schema) `toObject` option to the same argument.
+ *
+ * schema.set('toObject', { virtuals: true })
+ *
+ * ####Transform
+ *
+ * We may need to perform a transformation of the resulting object based on some criteria, say to remove some sensitive information or return a custom object. In this case we set the optional `transform` function.
+ *
+ * Transform functions receive three arguments
+ *
+ * function (doc, ret, options) {}
+ *
+ * - `doc` The mongoose document which is being converted
+ * - `ret` The plain object representation which has been converted
+ * - `options` The options in use (either schema options or the options passed inline)
+ *
+ * ####Example
+ *
+ * // specify the transform schema option
+ * if (!schema.options.toObject) schema.options.toObject = {};
+ * schema.options.toObject.transform = function (doc, ret, options) {
+ * // remove the _id of every document before returning the result
+ * delete ret._id;
+ * return ret;
+ * }
+ *
+ * // without the transformation in the schema
+ * doc.toObject(); // { _id: 'anId', name: 'Wreck-it Ralph' }
+ *
+ * // with the transformation
+ * doc.toObject(); // { name: 'Wreck-it Ralph' }
+ *
+ * With transformations we can do a lot more than remove properties. We can even return completely new customized objects:
+ *
+ * if (!schema.options.toObject) schema.options.toObject = {};
+ * schema.options.toObject.transform = function (doc, ret, options) {
+ * return { movie: ret.name }
+ * }
+ *
+ * // without the transformation in the schema
+ * doc.toObject(); // { _id: 'anId', name: 'Wreck-it Ralph' }
+ *
+ * // with the transformation
+ * doc.toObject(); // { movie: 'Wreck-it Ralph' }
+ *
+ * _Note: if a transform function returns `undefined`, the return value will be ignored._
+ *
+ * Transformations may also be applied inline, overridding any transform set in the options:
+ *
+ * function xform (doc, ret, options) {
+ * return { inline: ret.name, custom: true }
+ * }
+ *
+ * // pass the transform as an inline option
+ * doc.toObject({ transform: xform }); // { inline: 'Wreck-it Ralph', custom: true }
+ *
+ * _Note: if you call `toObject` and pass any options, the transform declared in your schema options will __not__ be applied. To force its application pass `transform: true`_
+ *
+ * if (!schema.options.toObject) schema.options.toObject = {};
+ * schema.options.toObject.hide = '_id';
+ * schema.options.toObject.transform = function (doc, ret, options) {
+ * if (options.hide) {
+ * options.hide.split(' ').forEach(function (prop) {
+ * delete ret[prop];
+ * });
+ * }
+ * return ret;
+ * }
+ *
+ * var doc = new Doc({ _id: 'anId', secret: 47, name: 'Wreck-it Ralph' });
+ * doc.toObject(); // { secret: 47, name: 'Wreck-it Ralph' }
+ * doc.toObject({ hide: 'secret _id' }); // { _id: 'anId', secret: 47, name: 'Wreck-it Ralph' }
+ * doc.toObject({ hide: 'secret _id', transform: true }); // { name: 'Wreck-it Ralph' }
+ *
+ * Transforms are applied _only to the document and are not applied to sub-documents_.
+ *
+ * Transforms, like all of these options, are also available for `toJSON`.
+ *
+ * See [schema options](/docs/guide.html#toObject) for some more details.
+ *
+ * _During save, no custom options are applied to the document before being sent to the database._
+ *
+ * @param {Object} [options]
+ * @return {Object} js object
+ * @see mongodb.Binary http://mongodb.github.com/node-mongodb-native/api-bson-generated/binary.html
+ * @api public
+ */
+
+Document.prototype.toObject = function(options) {
+ return this.$toObject(options);
+};
+
+/*!
+ * Minimizes an object, removing undefined values and empty objects
+ *
+ * @param {Object} object to minimize
+ * @return {Object}
+ */
+
+function minimize(obj) {
+ var keys = Object.keys(obj),
+ i = keys.length,
+ hasKeys,
+ key,
+ val;
+
+ while (i--) {
+ key = keys[i];
+ val = obj[key];
+
+ if (utils.isObject(val)) {
+ obj[key] = minimize(val);
+ }
+
+ if (undefined === obj[key]) {
+ delete obj[key];
+ continue;
+ }
+
+ hasKeys = true;
+ }
+
+ return hasKeys
+ ? obj
+ : undefined;
+}
+
+/*!
+ * Applies virtuals properties to `json`.
+ *
+ * @param {Document} self
+ * @param {Object} json
+ * @param {String} type either `virtuals` or `paths`
+ * @return {Object} `json`
+ */
+
+function applyGetters(self, json, type, options) {
+ var schema = self.schema,
+ paths = Object.keys(schema[type]),
+ i = paths.length,
+ path;
+
+ while (i--) {
+ path = paths[i];
+
+ var parts = path.split('.'),
+ plen = parts.length,
+ last = plen - 1,
+ branch = json,
+ part;
+
+ for (var ii = 0; ii < plen; ++ii) {
+ part = parts[ii];
+ if (ii === last) {
+ branch[part] = clone(self.get(path), options);
+ } else {
+ branch = branch[part] || (branch[part] = {});
+ }
+ }
+ }
+
+ return json;
+}
+
+/**
+ * The return value of this method is used in calls to JSON.stringify(doc).
+ *
+ * This method accepts the same options as [Document#toObject](#document_Document-toObject). To apply the options to every document of your schema by default, set your [schemas](#schema_Schema) `toJSON` option to the same argument.
+ *
+ * schema.set('toJSON', { virtuals: true })
+ *
+ * See [schema options](/docs/guide.html#toJSON) for details.
+ *
+ * @param {Object} options
+ * @return {Object}
+ * @see Document#toObject #document_Document-toObject
+ * @api public
+ */
+
+Document.prototype.toJSON = function(options) {
+ return this.$toObject(options, true);
+};
+
+/**
+ * Helper for console.log
+ *
+ * @api public
+ */
+
+Document.prototype.inspect = function(options) {
+ var isPOJO = options &&
+ utils.getFunctionName(options.constructor) === 'Object';
+ var opts;
+ if (isPOJO) {
+ opts = options;
+ opts.minimize = false;
+ opts.retainKeyOrder = true;
+ }
+ return this.toObject(opts);
+};
+
+/**
+ * Helper for console.log
+ *
+ * @api public
+ * @method toString
+ */
+
+Document.prototype.toString = function() {
+ return inspect(this.inspect());
+};
+
+/**
+ * Returns true if the Document stores the same data as doc.
+ *
+ * Documents are considered equal when they have matching `_id`s, unless neither
+ * document has an `_id`, in which case this function falls back to using
+ * `deepEqual()`.
+ *
+ * @param {Document} doc a document to compare
+ * @return {Boolean}
+ * @api public
+ */
+
+Document.prototype.equals = function(doc) {
+ if (!doc) {
+ return false;
+ }
+
+ var tid = this.get('_id');
+ var docid = doc.get ? doc.get('_id') : doc;
+ if (!tid && !docid) {
+ return deepEqual(this, doc);
+ }
+ return tid && tid.equals
+ ? tid.equals(docid)
+ : tid === docid;
+};
+
+/**
+ * Populates document references, executing the `callback` when complete.
+ * If you want to use promises instead, use this function with
+ * [`execPopulate()`](#document_Document-execPopulate)
+ *
+ * ####Example:
+ *
+ * doc
+ * .populate('company')
+ * .populate({
+ * path: 'notes',
+ * match: /airline/,
+ * select: 'text',
+ * model: 'modelName'
+ * options: opts
+ * }, function (err, user) {
+ * assert(doc._id === user._id) // the document itself is passed
+ * })
+ *
+ * // summary
+ * doc.populate(path) // not executed
+ * doc.populate(options); // not executed
+ * doc.populate(path, callback) // executed
+ * doc.populate(options, callback); // executed
+ * doc.populate(callback); // executed
+ * doc.populate(options).execPopulate() // executed, returns promise
+ *
+ *
+ * ####NOTE:
+ *
+ * Population does not occur unless a `callback` is passed *or* you explicitly
+ * call `execPopulate()`.
+ * Passing the same path a second time will overwrite the previous path options.
+ * See [Model.populate()](#model_Model.populate) for explaination of options.
+ *
+ * @see Model.populate #model_Model.populate
+ * @see Document.execPopulate #document_Document-execPopulate
+ * @param {String|Object} [path] The path to populate or an options object
+ * @param {Function} [callback] When passed, population is invoked
+ * @api public
+ * @return {Document} this
+ */
+
+Document.prototype.populate = function populate() {
+ if (arguments.length === 0) {
+ return this;
+ }
+
+ var pop = this.$__.populate || (this.$__.populate = {});
+ var args = utils.args(arguments);
+ var fn;
+
+ if (typeof args[args.length - 1] === 'function') {
+ fn = args.pop();
+ }
+
+ // allow `doc.populate(callback)`
+ if (args.length) {
+ // use hash to remove duplicate paths
+ var res = utils.populate.apply(null, args);
+ for (var i = 0; i < res.length; ++i) {
+ pop[res[i].path] = res[i];
+ }
+ }
+
+ if (fn) {
+ var paths = utils.object.vals(pop);
+ this.$__.populate = undefined;
+ paths.__noPromise = true;
+ this.constructor.populate(this, paths, fn);
+ }
+
+ return this;
+};
+
+/**
+ * Explicitly executes population and returns a promise. Useful for ES2015
+ * integration.
+ *
+ * ####Example:
+ *
+ * var promise = doc.
+ * populate('company').
+ * populate({
+ * path: 'notes',
+ * match: /airline/,
+ * select: 'text',
+ * model: 'modelName'
+ * options: opts
+ * }).
+ * execPopulate();
+ *
+ * // summary
+ * doc.execPopulate().then(resolve, reject);
+ *
+ *
+ * @see Document.populate #document_Document-populate
+ * @api public
+ * @return {Promise} promise that resolves to the document when population is done
+ */
+
+Document.prototype.execPopulate = function() {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+ return new Promise.ES6(function(resolve, reject) {
+ _this.populate(function(error, res) {
+ if (error) {
+ reject(error);
+ } else {
+ resolve(res);
+ }
+ });
+ });
+};
+
+/**
+ * Gets _id(s) used during population of the given `path`.
+ *
+ * ####Example:
+ *
+ * Model.findOne().populate('author').exec(function (err, doc) {
+ * console.log(doc.author.name) // Dr.Seuss
+ * console.log(doc.populated('author')) // '5144cf8050f071d979c118a7'
+ * })
+ *
+ * If the path was not populated, undefined is returned.
+ *
+ * @param {String} path
+ * @return {Array|ObjectId|Number|Buffer|String|undefined}
+ * @api public
+ */
+
+Document.prototype.populated = function(path, val, options) {
+ // val and options are internal
+
+ if (val === null || val === void 0) {
+ if (!this.$__.populated) {
+ return undefined;
+ }
+ var v = this.$__.populated[path];
+ if (v) {
+ return v.value;
+ }
+ return undefined;
+ }
+
+ // internal
+
+ if (val === true) {
+ if (!this.$__.populated) {
+ return undefined;
+ }
+ return this.$__.populated[path];
+ }
+
+ this.$__.populated || (this.$__.populated = {});
+ this.$__.populated[path] = {value: val, options: options};
+ return val;
+};
+
+/**
+ * Takes a populated field and returns it to its unpopulated state.
+ *
+ * ####Example:
+ *
+ * Model.findOne().populate('author').exec(function (err, doc) {
+ * console.log(doc.author.name); // Dr.Seuss
+ * console.log(doc.depopulate('author'));
+ * console.log(doc.author); // '5144cf8050f071d979c118a7'
+ * })
+ *
+ * If the path was not populated, this is a no-op.
+ *
+ * @param {String} path
+ * @see Document.populate #document_Document-populate
+ * @api public
+ */
+
+Document.prototype.depopulate = function(path) {
+ var populatedIds = this.populated(path);
+ if (!populatedIds) {
+ return;
+ }
+ delete this.$__.populated[path];
+ this.set(path, populatedIds);
+};
+
+
+/**
+ * Returns the full path to this document.
+ *
+ * @param {String} [path]
+ * @return {String}
+ * @api private
+ * @method $__fullPath
+ * @memberOf Document
+ */
+
+Document.prototype.$__fullPath = function(path) {
+ // overridden in SubDocuments
+ return path || '';
+};
+
+/*!
+ * Module exports.
+ */
+
+Document.ValidationError = ValidationError;
+module.exports = exports = Document;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.js
new file mode 100644
index 0000000..10087cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.js
@@ -0,0 +1,21 @@
+'use strict';
+
+/* eslint-env browser */
+
+/*!
+ * Module dependencies.
+ */
+var Document = require('./document.js');
+var BrowserDocument = require('./browserDocument.js');
+
+/**
+ * Returns the Document constructor for the current context
+ *
+ * @api private
+ */
+module.exports = function() {
+ if (typeof window !== 'undefined' && typeof document !== 'undefined' && document === window.document) {
+ return BrowserDocument;
+ }
+ return Document;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.web.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.web.js
new file mode 100644
index 0000000..4223fc3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/document_provider.web.js
@@ -0,0 +1,17 @@
+'use strict';
+
+/* eslint-env browser */
+
+/*!
+ * Module dependencies.
+ */
+var BrowserDocument = require('./browserDocument.js');
+
+/**
+ * Returns the Document constructor for the current context
+ *
+ * @api private
+ */
+module.exports = function() {
+ return BrowserDocument;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/SPEC.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/SPEC.md
new file mode 100644
index 0000000..6464693
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/SPEC.md
@@ -0,0 +1,4 @@
+
+# Driver Spec
+
+TODO
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/ReadPreference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/ReadPreference.js
new file mode 100644
index 0000000..f20cd6c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/ReadPreference.js
@@ -0,0 +1,5 @@
+/*!
+ * ignore
+ */
+
+module.exports = function() {};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/binary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/binary.js
new file mode 100644
index 0000000..4d7a395
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/binary.js
@@ -0,0 +1,12 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var Binary = require('bson').Binary;
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = Binary;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/index.js
new file mode 100644
index 0000000..fa5dbb4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/index.js
@@ -0,0 +1,7 @@
+/*!
+ * Module exports.
+ */
+
+exports.Binary = require('./binary');
+exports.ObjectId = require('./objectid');
+exports.ReadPreference = require('./ReadPreference');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/objectid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/objectid.js
new file mode 100644
index 0000000..e63c04a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/browser/objectid.js
@@ -0,0 +1,14 @@
+
+/*!
+ * [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) ObjectId
+ * @constructor NodeMongoDbObjectId
+ * @see ObjectId
+ */
+
+var ObjectId = require('bson').ObjectID;
+
+/*!
+ * ignore
+ */
+
+module.exports = exports = ObjectId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.js
new file mode 100644
index 0000000..5a842ba
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.js
@@ -0,0 +1,17 @@
+/*!
+ * ignore
+ */
+
+var driver;
+
+if (typeof window === 'undefined') {
+ driver = require(global.MONGOOSE_DRIVER_PATH || './node-mongodb-native');
+} else {
+ driver = require('./browser');
+}
+
+/*!
+ * ignore
+ */
+
+module.exports = driver;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.web.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.web.js
new file mode 100644
index 0000000..f833eb2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/index.web.js
@@ -0,0 +1,5 @@
+/*!
+ * ignore
+ */
+
+module.exports = require('./browser');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js
new file mode 100644
index 0000000..e921d60
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/ReadPreference.js
@@ -0,0 +1,45 @@
+/*!
+ * Module dependencies.
+ */
+
+var mongodb = require('mongodb');
+var ReadPref = mongodb.ReadPreference;
+
+/*!
+ * Converts arguments to ReadPrefs the driver
+ * can understand.
+ *
+ * @param {String|Array} pref
+ * @param {Array} [tags]
+ */
+
+module.exports = function readPref(pref, tags) {
+ if (Array.isArray(pref)) {
+ tags = pref[1];
+ pref = pref[0];
+ }
+
+ if (pref instanceof ReadPref) {
+ return pref;
+ }
+
+ switch (pref) {
+ case 'p':
+ pref = 'primary';
+ break;
+ case 'pp':
+ pref = 'primaryPreferred';
+ break;
+ case 's':
+ pref = 'secondary';
+ break;
+ case 'sp':
+ pref = 'secondaryPreferred';
+ break;
+ case 'n':
+ pref = 'nearest';
+ break;
+ }
+
+ return new ReadPref(pref, tags);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js
new file mode 100644
index 0000000..657efde
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/binary.js
@@ -0,0 +1,8 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var Binary = require('mongodb').Binary;
+
+module.exports = exports = Binary;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
new file mode 100644
index 0000000..fd0da30
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
@@ -0,0 +1,267 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseCollection = require('../../collection'),
+ Collection = require('mongodb').Collection,
+ utils = require('../../utils');
+
+/**
+ * A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) collection implementation.
+ *
+ * All methods methods from the [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) driver are copied and wrapped in queue management.
+ *
+ * @inherits Collection
+ * @api private
+ */
+
+function NativeCollection() {
+ this.collection = null;
+ MongooseCollection.apply(this, arguments);
+}
+
+/*!
+ * Inherit from abstract Collection.
+ */
+
+NativeCollection.prototype.__proto__ = MongooseCollection.prototype;
+
+/**
+ * Called when the connection opens.
+ *
+ * @api private
+ */
+
+NativeCollection.prototype.onOpen = function() {
+ var _this = this;
+
+ // always get a new collection in case the user changed host:port
+ // of parent db instance when re-opening the connection.
+
+ if (!_this.opts.capped.size) {
+ // non-capped
+ callback(null, _this.conn.db.collection(_this.name));
+ return _this.collection;
+ }
+
+ // capped
+ return _this.conn.db.collection(_this.name, function(err, c) {
+ if (err) return callback(err);
+
+ // discover if this collection exists and if it is capped
+ _this.conn.db.listCollections({name: _this.name}).toArray(function(err, docs) {
+ if (err) {
+ return callback(err);
+ }
+ var doc = docs[0];
+ var exists = !!doc;
+
+ if (exists) {
+ if (doc.options && doc.options.capped) {
+ callback(null, c);
+ } else {
+ var msg = 'A non-capped collection exists with the name: ' + _this.name + '\n\n'
+ + ' To use this collection as a capped collection, please '
+ + 'first convert it.\n'
+ + ' http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-Convertingacollectiontocapped';
+ err = new Error(msg);
+ callback(err);
+ }
+ } else {
+ // create
+ var opts = utils.clone(_this.opts.capped);
+ opts.capped = true;
+ _this.conn.db.createCollection(_this.name, opts, callback);
+ }
+ });
+ });
+
+ function callback(err, collection) {
+ if (err) {
+ // likely a strict mode error
+ _this.conn.emit('error', err);
+ } else {
+ _this.collection = collection;
+ MongooseCollection.prototype.onOpen.call(_this);
+ }
+ }
+};
+
+/**
+ * Called when the connection closes
+ *
+ * @api private
+ */
+
+NativeCollection.prototype.onClose = function() {
+ MongooseCollection.prototype.onClose.call(this);
+};
+
+/*!
+ * Copy the collection methods and make them subject to queues
+ */
+
+function iter(i) {
+ NativeCollection.prototype[i] = function() {
+ if (this.buffer) {
+ this.addQueue(i, arguments);
+ return;
+ }
+
+ var collection = this.collection,
+ args = arguments,
+ _this = this,
+ debug = _this.conn.base.options.debug;
+
+ if (debug) {
+ if (typeof debug === 'function') {
+ debug.apply(debug,
+ [_this.name, i].concat(utils.args(args, 0, args.length - 1)));
+ } else {
+ this.$print(_this.name, i, args);
+ }
+ }
+
+ try {
+ return collection[i].apply(collection, args);
+ } catch (error) {
+ // Collection operation may throw because of max bson size, catch it here
+ // See gh-3906
+ if (args.length > 0 &&
+ typeof args[args.length - 1] === 'function') {
+ args[args.length - 1](error);
+ } else {
+ throw error;
+ }
+ }
+ };
+}
+
+for (var i in Collection.prototype) {
+ // Janky hack to work around gh-3005 until we can get rid of the mongoose
+ // collection abstraction
+ try {
+ if (typeof Collection.prototype[i] !== 'function') {
+ continue;
+ }
+ } catch (e) {
+ continue;
+ }
+
+ iter(i);
+}
+
+/**
+ * Debug print helper
+ *
+ * @api public
+ * @method $print
+ */
+
+NativeCollection.prototype.$print = function(name, i, args) {
+ var moduleName = '\x1B[0;36mMongoose:\x1B[0m ';
+ var functionCall = [name, i].join('.');
+ var _args = [];
+ for (var j = args.length - 1; j >= 0; --j) {
+ if (this.$format(args[j]) || _args.length) {
+ _args.unshift(this.$format(args[j]));
+ }
+ }
+ var params = '(' + _args.join(', ') + ')';
+
+ console.error(moduleName + functionCall + params);
+};
+
+/**
+ * Formatter for debug print args
+ *
+ * @api public
+ * @method $format
+ */
+
+NativeCollection.prototype.$format = function(arg) {
+ var type = typeof arg;
+ if (type === 'function' || type === 'undefined') return '';
+ return format(arg);
+};
+
+/*!
+ * Debug print helper
+ */
+
+function map(o) {
+ return format(o, true);
+}
+function formatObjectId(x, key) {
+ var representation = 'ObjectId("' + x[key].toHexString() + '")';
+ x[key] = {inspect: function() { return representation; }};
+}
+function formatDate(x, key) {
+ var representation = 'new Date("' + x[key].toUTCString() + '")';
+ x[key] = {inspect: function() { return representation; }};
+}
+function format(obj, sub) {
+ if (obj && typeof obj.toBSON === 'function') {
+ obj = obj.toBSON();
+ }
+ var x = utils.clone(obj, {retainKeyOrder: 1, transform: false});
+ var representation;
+
+ if (x != null) {
+ if (x.constructor.name === 'Binary') {
+ x = 'BinData(' + x.sub_type + ', "' + x.toString('base64') + '")';
+ } else if (x.constructor.name === 'ObjectID') {
+ representation = 'ObjectId("' + x.toHexString() + '")';
+ x = {inspect: function() { return representation; }};
+ } else if (x.constructor.name === 'Date') {
+ representation = 'new Date("' + x.toUTCString() + '")';
+ x = {inspect: function() { return representation; }};
+ } else if (x.constructor.name === 'Object') {
+ var keys = Object.keys(x);
+ var numKeys = keys.length;
+ var key;
+ for (var i = 0; i < numKeys; ++i) {
+ key = keys[i];
+ if (x[key]) {
+ if (typeof x[key].toBSON === 'function') {
+ x[key] = x[key].toBSON();
+ }
+ if (x[key].constructor.name === 'Binary') {
+ x[key] = 'BinData(' + x[key].sub_type + ', "' +
+ x[key].buffer.toString('base64') + '")';
+ } else if (x[key].constructor.name === 'Object') {
+ x[key] = format(x[key], true);
+ } else if (x[key].constructor.name === 'ObjectID') {
+ formatObjectId(x, key);
+ } else if (x[key].constructor.name === 'Date') {
+ formatDate(x, key);
+ } else if (Array.isArray(x[key])) {
+ x[key] = x[key].map(map);
+ }
+ }
+ }
+ }
+ if (sub) return x;
+ }
+
+ return require('util')
+ .inspect(x, false, 10, true)
+ .replace(/\n/g, '')
+ .replace(/\s{2,}/g, ' ');
+}
+
+/**
+ * Retreives information about this collections indexes.
+ *
+ * @param {Function} callback
+ * @method getIndexes
+ * @api public
+ */
+
+NativeCollection.prototype.getIndexes = NativeCollection.prototype.indexInformation;
+
+/*!
+ * Module exports.
+ */
+
+module.exports = NativeCollection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js
new file mode 100644
index 0000000..c17330d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js
@@ -0,0 +1,386 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseConnection = require('../../connection');
+var mongo = require('mongodb');
+var Db = mongo.Db;
+var Server = mongo.Server;
+var Mongos = mongo.Mongos;
+var STATES = require('../../connectionstate');
+var ReplSetServers = mongo.ReplSet;
+var DisconnectedError = require('../../error/disconnected');
+
+/**
+ * A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
+ *
+ * @inherits Connection
+ * @api private
+ */
+
+function NativeConnection() {
+ MongooseConnection.apply(this, arguments);
+ this._listening = false;
+}
+
+/**
+ * Expose the possible connection states.
+ * @api public
+ */
+
+NativeConnection.STATES = STATES;
+
+/*!
+ * Inherits from Connection.
+ */
+
+NativeConnection.prototype.__proto__ = MongooseConnection.prototype;
+
+/**
+ * Opens the connection to MongoDB.
+ *
+ * @param {Function} fn
+ * @return {Connection} this
+ * @api private
+ */
+
+NativeConnection.prototype.doOpen = function(fn) {
+ var _this = this;
+ var server = new Server(this.host, this.port, this.options.server);
+
+ if (this.options && this.options.mongos) {
+ var mongos = new Mongos([server], this.options.mongos);
+ this.db = new Db(this.name, mongos, this.options.db);
+ } else {
+ this.db = new Db(this.name, server, this.options.db);
+ }
+
+ this.db.open(function(err) {
+ listen(_this);
+
+ if (!mongos) {
+ server.s.server.on('error', function(error) {
+ if (/after \d+ attempts/.test(error.message)) {
+ _this.emit('error', new DisconnectedError(server.s.server.name));
+ }
+ });
+ }
+
+ if (err) return fn(err);
+
+ fn();
+ });
+
+ return this;
+};
+
+/**
+ * Switches to a different database using the same connection pool.
+ *
+ * Returns a new connection object, with the new db.
+ *
+ * @param {String} name The database name
+ * @return {Connection} New Connection Object
+ * @api public
+ */
+
+NativeConnection.prototype.useDb = function(name) {
+ // we have to manually copy all of the attributes...
+ var newConn = new this.constructor();
+ newConn.name = name;
+ newConn.base = this.base;
+ newConn.collections = {};
+ newConn.models = {};
+ newConn.replica = this.replica;
+ newConn.hosts = this.hosts;
+ newConn.host = this.host;
+ newConn.port = this.port;
+ newConn.user = this.user;
+ newConn.pass = this.pass;
+ newConn.options = this.options;
+ newConn._readyState = this._readyState;
+ newConn._closeCalled = this._closeCalled;
+ newConn._hasOpened = this._hasOpened;
+ newConn._listening = false;
+
+ // First, when we create another db object, we are not guaranteed to have a
+ // db object to work with. So, in the case where we have a db object and it
+ // is connected, we can just proceed with setting everything up. However, if
+ // we do not have a db or the state is not connected, then we need to wait on
+ // the 'open' event of the connection before doing the rest of the setup
+ // the 'connected' event is the first time we'll have access to the db object
+
+ var _this = this;
+
+ if (this.db && this._readyState === STATES.connected) {
+ wireup();
+ } else {
+ this.once('connected', wireup);
+ }
+
+ function wireup() {
+ newConn.db = _this.db.db(name);
+ newConn.onOpen();
+ // setup the events appropriately
+ listen(newConn);
+ }
+
+ newConn.name = name;
+
+ // push onto the otherDbs stack, this is used when state changes
+ this.otherDbs.push(newConn);
+ newConn.otherDbs.push(this);
+
+ return newConn;
+};
+
+/*!
+ * Register listeners for important events and bubble appropriately.
+ */
+
+function listen(conn) {
+ if (conn.db._listening) {
+ return;
+ }
+ conn.db._listening = true;
+
+ conn.db.on('close', function() {
+ if (conn._closeCalled) return;
+
+ // the driver never emits an `open` event. auto_reconnect still
+ // emits a `close` event but since we never get another
+ // `open` we can't emit close
+ if (conn.db.serverConfig.autoReconnect) {
+ conn.readyState = STATES.disconnected;
+ conn.emit('close');
+ return;
+ }
+ conn.onClose();
+ });
+ conn.db.on('error', function(err) {
+ conn.emit('error', err);
+ });
+ conn.db.on('reconnect', function() {
+ conn.readyState = STATES.connected;
+ conn.emit('reconnected');
+ });
+ conn.db.on('timeout', function(err) {
+ var error = new Error(err && err.err || 'connection timeout');
+ conn.emit('error', error);
+ });
+ conn.db.on('open', function(err, db) {
+ if (STATES.disconnected === conn.readyState && db && db.databaseName) {
+ conn.readyState = STATES.connected;
+ conn.emit('reconnected');
+ }
+ });
+ conn.db.on('parseError', function(err) {
+ conn.emit('parseError', err);
+ });
+}
+
+/**
+ * Opens a connection to a MongoDB ReplicaSet.
+ *
+ * See description of [doOpen](#NativeConnection-doOpen) for server options. In this case `options.replset` is also passed to ReplSetServers.
+ *
+ * @param {Function} fn
+ * @api private
+ * @return {Connection} this
+ */
+
+NativeConnection.prototype.doOpenSet = function(fn) {
+ var servers = [],
+ _this = this;
+
+ this.hosts.forEach(function(server) {
+ var host = server.host || server.ipc;
+ var port = server.port || 27017;
+ servers.push(new Server(host, port, _this.options.server));
+ });
+
+ var server = this.options.mongos
+ ? new Mongos(servers, this.options.mongos)
+ : new ReplSetServers(servers, this.options.replset || this.options.replSet);
+ this.db = new Db(this.name, server, this.options.db);
+
+ this.db.on('fullsetup', function() {
+ _this.emit('fullsetup');
+ });
+
+ this.db.on('all', function() {
+ _this.emit('all');
+ });
+
+ this.db.open(function(err) {
+ if (err) return fn(err);
+ fn();
+ listen(_this);
+ });
+
+ return this;
+};
+
+/**
+ * Closes the connection
+ *
+ * @param {Function} fn
+ * @return {Connection} this
+ * @api private
+ */
+
+NativeConnection.prototype.doClose = function(fn) {
+ this.db.close(fn);
+ return this;
+};
+
+/**
+ * Prepares default connection options for the node-mongodb-native driver.
+ *
+ * _NOTE: `passed` options take precedence over connection string options._
+ *
+ * @param {Object} passed options that were passed directly during connection
+ * @param {Object} [connStrOptions] options that were passed in the connection string
+ * @api private
+ */
+
+NativeConnection.prototype.parseOptions = function(passed, connStrOpts) {
+ var o = passed || {};
+ o.db || (o.db = {});
+ o.auth || (o.auth = {});
+ o.server || (o.server = {});
+ o.replset || (o.replset = o.replSet) || (o.replset = {});
+ o.server.socketOptions || (o.server.socketOptions = {});
+ o.replset.socketOptions || (o.replset.socketOptions = {});
+ o.mongos || (o.mongos = (connStrOpts && connStrOpts.mongos));
+ (o.mongos === true) && (o.mongos = {});
+
+ var opts = connStrOpts || {};
+ Object.keys(opts).forEach(function(name) {
+ switch (name) {
+ case 'ssl':
+ o.server.ssl = opts.ssl;
+ o.replset.ssl = opts.ssl;
+ o.mongos && (o.mongos.ssl = opts.ssl);
+ break;
+ case 'poolSize':
+ if (typeof o.server[name] === 'undefined') {
+ o.server[name] = o.replset[name] = opts[name];
+ }
+ break;
+ case 'slaveOk':
+ if (typeof o.server.slave_ok === 'undefined') {
+ o.server.slave_ok = opts[name];
+ }
+ break;
+ case 'autoReconnect':
+ if (typeof o.server.auto_reconnect === 'undefined') {
+ o.server.auto_reconnect = opts[name];
+ }
+ break;
+ case 'socketTimeoutMS':
+ case 'connectTimeoutMS':
+ if (typeof o.server.socketOptions[name] === 'undefined') {
+ o.server.socketOptions[name] = o.replset.socketOptions[name] = opts[name];
+ }
+ break;
+ case 'authdb':
+ if (typeof o.auth.authdb === 'undefined') {
+ o.auth.authdb = opts[name];
+ }
+ break;
+ case 'authSource':
+ if (typeof o.auth.authSource === 'undefined') {
+ o.auth.authSource = opts[name];
+ }
+ break;
+ case 'retries':
+ case 'reconnectWait':
+ case 'rs_name':
+ if (typeof o.replset[name] === 'undefined') {
+ o.replset[name] = opts[name];
+ }
+ break;
+ case 'replicaSet':
+ if (typeof o.replset.rs_name === 'undefined') {
+ o.replset.rs_name = opts[name];
+ }
+ break;
+ case 'readSecondary':
+ if (typeof o.replset.read_secondary === 'undefined') {
+ o.replset.read_secondary = opts[name];
+ }
+ break;
+ case 'nativeParser':
+ if (typeof o.db.native_parser === 'undefined') {
+ o.db.native_parser = opts[name];
+ }
+ break;
+ case 'w':
+ case 'safe':
+ case 'fsync':
+ case 'journal':
+ case 'wtimeoutMS':
+ if (typeof o.db[name] === 'undefined') {
+ o.db[name] = opts[name];
+ }
+ break;
+ case 'readPreference':
+ if (typeof o.db.readPreference === 'undefined') {
+ o.db.readPreference = opts[name];
+ }
+ break;
+ case 'readPreferenceTags':
+ if (typeof o.db.read_preference_tags === 'undefined') {
+ o.db.read_preference_tags = opts[name];
+ }
+ break;
+ case 'sslValidate':
+ o.server.sslValidate = opts.sslValidate;
+ o.replset.sslValidate = opts.sslValidate;
+ o.mongos && (o.mongos.sslValidate = opts.sslValidate);
+ }
+ });
+
+ if (!('auto_reconnect' in o.server)) {
+ o.server.auto_reconnect = true;
+ }
+
+ // mongoose creates its own ObjectIds
+ o.db.forceServerObjectId = false;
+
+ // default safe using new nomenclature
+ if (!('journal' in o.db || 'j' in o.db ||
+ 'fsync' in o.db || 'safe' in o.db || 'w' in o.db)) {
+ o.db.w = 1;
+ }
+
+ if (o.promiseLibrary) {
+ o.db.promiseLibrary = o.promiseLibrary;
+ }
+
+ validate(o);
+ return o;
+};
+
+/*!
+ * Validates the driver db options.
+ *
+ * @param {Object} o
+ */
+
+function validate(o) {
+ if (o.db.w === -1 || o.db.w === 0) {
+ if (o.db.journal || o.db.fsync || o.db.safe) {
+ throw new Error(
+ 'Invalid writeConcern: '
+ + 'w set to -1 or 0 cannot be combined with safe|fsync|journal');
+ }
+ }
+}
+
+/*!
+ * Module exports.
+ */
+
+module.exports = NativeConnection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js
new file mode 100644
index 0000000..fa5dbb4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js
@@ -0,0 +1,7 @@
+/*!
+ * Module exports.
+ */
+
+exports.Binary = require('./binary');
+exports.ObjectId = require('./objectid');
+exports.ReadPreference = require('./ReadPreference');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js
new file mode 100644
index 0000000..69fc08f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js
@@ -0,0 +1,14 @@
+
+/*!
+ * [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) ObjectId
+ * @constructor NodeMongoDbObjectId
+ * @see ObjectId
+ */
+
+var ObjectId = require('mongodb').ObjectId;
+
+/*!
+ * ignore
+ */
+
+module.exports = exports = ObjectId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error.js
new file mode 100644
index 0000000..b084e76
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error.js
@@ -0,0 +1,55 @@
+
+/**
+ * MongooseError constructor
+ *
+ * @param {String} msg Error message
+ * @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
+ */
+
+function MongooseError(msg) {
+ Error.call(this);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.message = msg;
+ this.name = 'MongooseError';
+}
+
+/*!
+ * Inherits from Error.
+ */
+
+MongooseError.prototype = Object.create(Error.prototype);
+MongooseError.prototype.constructor = Error;
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = MongooseError;
+
+/**
+ * The default built-in validator error messages.
+ *
+ * @see Error.messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+MongooseError.messages = require('./error/messages');
+
+// backward compat
+MongooseError.Messages = MongooseError.messages;
+
+/*!
+ * Expose subclasses
+ */
+
+MongooseError.CastError = require('./error/cast');
+MongooseError.ValidationError = require('./error/validation');
+MongooseError.ValidatorError = require('./error/validator');
+MongooseError.VersionError = require('./error/version');
+MongooseError.OverwriteModelError = require('./error/overwriteModel');
+MongooseError.MissingSchemaError = require('./error/missingSchema');
+MongooseError.DivergentArrayError = require('./error/divergentArray');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/browserMissingSchema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/browserMissingSchema.js
new file mode 100644
index 0000000..1c7892e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/browserMissingSchema.js
@@ -0,0 +1,32 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/*!
+ * MissingSchema Error constructor.
+ *
+ * @inherits MongooseError
+ */
+
+function MissingSchemaError() {
+ var msg = 'Schema hasn\'t been registered for document.\n'
+ + 'Use mongoose.Document(name, schema)';
+ MongooseError.call(this, msg);
+ Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
+ this.name = 'MissingSchemaError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+MissingSchemaError.prototype = Object.create(MongooseError.prototype);
+MissingSchemaError.prototype.constructor = MongooseError;
+
+/*!
+ * exports
+ */
+
+module.exports = MissingSchemaError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/cast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/cast.js
new file mode 100644
index 0000000..f200a9d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/cast.js
@@ -0,0 +1,60 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+var util = require('util');
+
+/**
+ * Casting Error constructor.
+ *
+ * @param {String} type
+ * @param {String} value
+ * @inherits MongooseError
+ * @api private
+ */
+
+function CastError(type, value, path, reason) {
+ var stringValue = util.inspect(value);
+ stringValue = stringValue.replace(/^'/, '"').replace(/'$/, '"');
+ if (stringValue.charAt(0) !== '"') {
+ stringValue = '"' + stringValue + '"';
+ }
+ MongooseError.call(this, 'Cast to ' + type + ' failed for value ' +
+ stringValue + ' at path "' + path + '"');
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.stringValue = stringValue;
+ this.name = 'CastError';
+ this.kind = type;
+ this.value = value;
+ this.path = path;
+ this.reason = reason;
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+CastError.prototype = Object.create(MongooseError.prototype);
+CastError.prototype.constructor = MongooseError;
+
+/*!
+ * ignore
+ */
+
+CastError.prototype.setModel = function(model) {
+ this.model = model;
+ this.message = 'Cast to ' + this.kind + ' failed for value ' +
+ this.stringValue + ' at path "' + this.path + '"' + ' for model "' +
+ model.modelName + '"';
+};
+
+/*!
+ * exports
+ */
+
+module.exports = CastError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/disconnected.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/disconnected.js
new file mode 100644
index 0000000..b4eece1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/disconnected.js
@@ -0,0 +1,40 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Casting Error constructor.
+ *
+ * @param {String} type
+ * @param {String} value
+ * @inherits MongooseError
+ * @api private
+ */
+
+function DisconnectedError(connectionString) {
+ MongooseError.call(this, 'Ran out of retries trying to reconnect to "' +
+ connectionString + '". Try setting `server.reconnectTries` and ' +
+ '`server.reconnectInterval` to something higher.');
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.name = 'DisconnectedError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+DisconnectedError.prototype = Object.create(MongooseError.prototype);
+DisconnectedError.prototype.constructor = MongooseError;
+
+
+/*!
+ * exports
+ */
+
+module.exports = DisconnectedError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/divergentArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/divergentArray.js
new file mode 100644
index 0000000..1cbaa25
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/divergentArray.js
@@ -0,0 +1,42 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/*!
+ * DivergentArrayError constructor.
+ *
+ * @inherits MongooseError
+ */
+
+function DivergentArrayError(paths) {
+ var msg = 'For your own good, using `document.save()` to update an array '
+ + 'which was selected using an $elemMatch projection OR '
+ + 'populated using skip, limit, query conditions, or exclusion of '
+ + 'the _id field when the operation results in a $pop or $set of '
+ + 'the entire array is not supported. The following '
+ + 'path(s) would have been modified unsafely:\n'
+ + ' ' + paths.join('\n ') + '\n'
+ + 'Use Model.update() to update these arrays instead.';
+ // TODO write up a docs page (FAQ) and link to it
+
+ MongooseError.call(this, msg);
+ Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
+ this.name = 'DivergentArrayError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+DivergentArrayError.prototype = Object.create(MongooseError.prototype);
+DivergentArrayError.prototype.constructor = MongooseError;
+
+
+/*!
+ * exports
+ */
+
+module.exports = DivergentArrayError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/messages.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/messages.js
new file mode 100644
index 0000000..88ddf6e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/messages.js
@@ -0,0 +1,42 @@
+
+/**
+ * The default built-in validator error messages. These may be customized.
+ *
+ * // customize within each schema or globally like so
+ * var mongoose = require('mongoose');
+ * mongoose.Error.messages.String.enum = "Your custom message for {PATH}.";
+ *
+ * As you might have noticed, error messages support basic templating
+ *
+ * - `{PATH}` is replaced with the invalid document path
+ * - `{VALUE}` is replaced with the invalid value
+ * - `{TYPE}` is replaced with the validator type such as "regexp", "min", or "user defined"
+ * - `{MIN}` is replaced with the declared min value for the Number.min validator
+ * - `{MAX}` is replaced with the declared max value for the Number.max validator
+ *
+ * Click the "show code" link below to see all defaults.
+ *
+ * @static messages
+ * @receiver MongooseError
+ * @api public
+ */
+
+var msg = module.exports = exports = {};
+
+msg.general = {};
+msg.general.default = 'Validator failed for path `{PATH}` with value `{VALUE}`';
+msg.general.required = 'Path `{PATH}` is required.';
+
+msg.Number = {};
+msg.Number.min = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';
+msg.Number.max = 'Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).';
+
+msg.Date = {};
+msg.Date.min = 'Path `{PATH}` ({VALUE}) is before minimum allowed value ({MIN}).';
+msg.Date.max = 'Path `{PATH}` ({VALUE}) is after maximum allowed value ({MAX}).';
+
+msg.String = {};
+msg.String.enum = '`{VALUE}` is not a valid enum value for path `{PATH}`.';
+msg.String.match = 'Path `{PATH}` is invalid ({VALUE}).';
+msg.String.minlength = 'Path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).';
+msg.String.maxlength = 'Path `{PATH}` (`{VALUE}`) is longer than the maximum allowed length ({MAXLENGTH}).';
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/missingSchema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/missingSchema.js
new file mode 100644
index 0000000..25eabfa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/missingSchema.js
@@ -0,0 +1,33 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/*!
+ * MissingSchema Error constructor.
+ *
+ * @inherits MongooseError
+ */
+
+function MissingSchemaError(name) {
+ var msg = 'Schema hasn\'t been registered for model "' + name + '".\n'
+ + 'Use mongoose.model(name, schema)';
+ MongooseError.call(this, msg);
+ Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
+ this.name = 'MissingSchemaError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+MissingSchemaError.prototype = Object.create(MongooseError.prototype);
+MissingSchemaError.prototype.constructor = MongooseError;
+
+/*!
+ * exports
+ */
+
+module.exports = MissingSchemaError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/objectExpected.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/objectExpected.js
new file mode 100644
index 0000000..fa863bc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/objectExpected.js
@@ -0,0 +1,35 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Strict mode error constructor
+ *
+ * @param {String} type
+ * @param {String} value
+ * @inherits MongooseError
+ * @api private
+ */
+
+function ObjectExpectedError(path, val) {
+ MongooseError.call(this, 'Tried to set nested object field `' + path +
+ '` to primitive value `' + val + '` and strict mode is set to throw.');
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.name = 'ObjectExpectedError';
+ this.path = path;
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+ObjectExpectedError.prototype = Object.create(MongooseError.prototype);
+ObjectExpectedError.prototype.constructor = MongooseError;
+
+module.exports = ObjectExpectedError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/overwriteModel.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/overwriteModel.js
new file mode 100644
index 0000000..c14ae7f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/overwriteModel.js
@@ -0,0 +1,31 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/*!
+ * OverwriteModel Error constructor.
+ *
+ * @inherits MongooseError
+ */
+
+function OverwriteModelError(name) {
+ MongooseError.call(this, 'Cannot overwrite `' + name + '` model once compiled.');
+ Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
+ this.name = 'OverwriteModelError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+OverwriteModelError.prototype = Object.create(MongooseError.prototype);
+OverwriteModelError.prototype.constructor = MongooseError;
+
+/*!
+ * exports
+ */
+
+module.exports = OverwriteModelError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/strict.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/strict.js
new file mode 100644
index 0000000..6e34431
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/strict.js
@@ -0,0 +1,35 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Strict mode error constructor
+ *
+ * @param {String} type
+ * @param {String} value
+ * @inherits MongooseError
+ * @api private
+ */
+
+function StrictModeError(path) {
+ MongooseError.call(this, 'Field `' + path + '` is not in schema and strict ' +
+ 'mode is set to throw.');
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.name = 'StrictModeError';
+ this.path = path;
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+StrictModeError.prototype = Object.create(MongooseError.prototype);
+StrictModeError.prototype.constructor = MongooseError;
+
+module.exports = StrictModeError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validation.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validation.js
new file mode 100644
index 0000000..e3322d4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validation.js
@@ -0,0 +1,63 @@
+/*!
+ * Module requirements
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Document Validation Error
+ *
+ * @api private
+ * @param {Document} instance
+ * @inherits MongooseError
+ */
+
+function ValidationError(instance) {
+ this.errors = {};
+ if (instance && instance.constructor.name === 'model') {
+ MongooseError.call(this, instance.constructor.modelName + ' validation failed');
+ } else {
+ MongooseError.call(this, 'Validation failed');
+ }
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.name = 'ValidationError';
+ if (instance) {
+ instance.errors = this.errors;
+ }
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+ValidationError.prototype = Object.create(MongooseError.prototype);
+ValidationError.prototype.constructor = MongooseError;
+
+
+/**
+ * Console.log helper
+ */
+
+ValidationError.prototype.toString = function() {
+ var ret = this.name + ': ';
+ var msgs = [];
+
+ Object.keys(this.errors || {}).forEach(function(key) {
+ if (this === this.errors[key]) {
+ return;
+ }
+ msgs.push(String(this.errors[key]));
+ }, this);
+
+ return ret + msgs.join(', ');
+};
+
+/*!
+ * Module exports
+ */
+
+module.exports = exports = ValidationError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validator.js
new file mode 100644
index 0000000..96a3ba1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/validator.js
@@ -0,0 +1,81 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Schema validator error
+ *
+ * @param {Object} properties
+ * @inherits MongooseError
+ * @api private
+ */
+
+function ValidatorError(properties) {
+ var msg = properties.message;
+ if (!msg) {
+ msg = MongooseError.messages.general.default;
+ }
+
+ var message = this.formatMessage(msg, properties);
+ MongooseError.call(this, message);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this);
+ } else {
+ this.stack = new Error().stack;
+ }
+ this.properties = properties;
+ this.name = 'ValidatorError';
+ this.kind = properties.type;
+ this.path = properties.path;
+ this.value = properties.value;
+}
+
+/*!
+ * Inherits from MongooseError
+ */
+
+ValidatorError.prototype = Object.create(MongooseError.prototype);
+ValidatorError.prototype.constructor = MongooseError;
+
+/*!
+ * The object used to define this validator. Not enumerable to hide
+ * it from `require('util').inspect()` output re: gh-3925
+ */
+
+Object.defineProperty(ValidatorError.prototype, 'properties', {
+ enumerable: false,
+ writable: true,
+ value: null
+});
+
+/*!
+ * Formats error messages
+ */
+
+ValidatorError.prototype.formatMessage = function(msg, properties) {
+ var propertyNames = Object.keys(properties);
+ for (var i = 0; i < propertyNames.length; ++i) {
+ var propertyName = propertyNames[i];
+ if (propertyName === 'message') {
+ continue;
+ }
+ msg = msg.replace('{' + propertyName.toUpperCase() + '}', properties[propertyName]);
+ }
+ return msg;
+};
+
+/*!
+ * toString helper
+ */
+
+ValidatorError.prototype.toString = function() {
+ return this.message;
+};
+
+/*!
+ * exports
+ */
+
+module.exports = ValidatorError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/version.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/version.js
new file mode 100644
index 0000000..e509b9b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/error/version.js
@@ -0,0 +1,33 @@
+'use strict';
+
+/*!
+ * Module dependencies.
+ */
+
+var MongooseError = require('../error.js');
+
+/**
+ * Version Error constructor.
+ *
+ * @inherits MongooseError
+ * @api private
+ */
+
+function VersionError(doc) {
+ MongooseError.call(this, 'No matching document found for id "' + doc._id +
+ '"');
+ this.name = 'VersionError';
+}
+
+/*!
+ * Inherits from MongooseError.
+ */
+
+VersionError.prototype = Object.create(MongooseError.prototype);
+VersionError.prototype.constructor = MongooseError;
+
+/*!
+ * exports
+ */
+
+module.exports = VersionError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/index.js
new file mode 100644
index 0000000..e0c6445
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/index.js
@@ -0,0 +1,818 @@
+'use strict';
+
+/*!
+ * Module dependencies.
+ */
+
+var Schema = require('./schema'),
+ SchemaType = require('./schematype'),
+ VirtualType = require('./virtualtype'),
+ STATES = require('./connectionstate'),
+ Types = require('./types'),
+ Query = require('./query'),
+ Model = require('./model'),
+ Document = require('./document'),
+ utils = require('./utils'),
+ format = utils.toCollectionName,
+ pkg = require('../package.json');
+
+var querystring = require('querystring');
+
+var Aggregate = require('./aggregate');
+var PromiseProvider = require('./promise_provider');
+
+/**
+ * Mongoose constructor.
+ *
+ * The exports object of the `mongoose` module is an instance of this class.
+ * Most apps will only use this one instance.
+ *
+ * @api public
+ */
+
+function Mongoose() {
+ this.connections = [];
+ this.plugins = [];
+ this.models = {};
+ this.modelSchemas = {};
+ // default global options
+ this.options = {
+ pluralization: true
+ };
+ var conn = this.createConnection(); // default connection
+ conn.models = this.models;
+}
+
+/**
+ * Expose connection states for user-land
+ *
+ */
+Mongoose.prototype.STATES = STATES;
+
+/**
+ * Sets mongoose options
+ *
+ * ####Example:
+ *
+ * mongoose.set('test', value) // sets the 'test' option to `value`
+ *
+ * mongoose.set('debug', true) // enable logging collection methods + arguments to the console
+ *
+ * mongoose.set('debug', function(collectionName, methodName, arg1, arg2...) {}); // use custom function to log collection methods + arguments
+ *
+ * @param {String} key
+ * @param {String|Function} value
+ * @api public
+ */
+
+Mongoose.prototype.set = function(key, value) {
+ if (arguments.length === 1) {
+ return this.options[key];
+ }
+
+ this.options[key] = value;
+ return this;
+};
+Mongoose.prototype.set.$hasSideEffects = true;
+
+/**
+ * Gets mongoose options
+ *
+ * ####Example:
+ *
+ * mongoose.get('test') // returns the 'test' value
+ *
+ * @param {String} key
+ * @method get
+ * @api public
+ */
+
+Mongoose.prototype.get = Mongoose.prototype.set;
+
+/*!
+ * ReplSet connection string check.
+ */
+
+var rgxReplSet = /^.+,.+$/;
+
+/**
+ * Checks if ?replicaSet query parameter is specified in URI
+ *
+ * ####Example:
+ *
+ * checkReplicaSetInUri('localhost:27000?replicaSet=rs0'); // true
+ *
+ * @param {String} uri
+ * @return {boolean}
+ * @api private
+ */
+
+var checkReplicaSetInUri = function(uri) {
+ if (!uri) {
+ return false;
+ }
+
+ var queryStringStart = uri.indexOf('?');
+ var isReplicaSet = false;
+ if (queryStringStart !== -1) {
+ try {
+ var obj = querystring.parse(uri.substr(queryStringStart + 1));
+ if (obj && obj.replicaSet) {
+ isReplicaSet = true;
+ }
+ } catch (e) {
+ return false;
+ }
+ }
+
+ return isReplicaSet;
+};
+
+/**
+ * Creates a Connection instance.
+ *
+ * Each `connection` instance maps to a single database. This method is helpful when mangaging multiple db connections.
+ *
+ * If arguments are passed, they are proxied to either [Connection#open](#connection_Connection-open) or [Connection#openSet](#connection_Connection-openSet) appropriately. This means we can pass `db`, `server`, and `replset` options to the driver. _Note that the `safe` option specified in your schema will overwrite the `safe` db option specified here unless you set your schemas `safe` option to `undefined`. See [this](/docs/guide.html#safe) for more information._
+ *
+ * _Options passed take precedence over options included in connection strings._
+ *
+ * ####Example:
+ *
+ * // with mongodb:// URI
+ * db = mongoose.createConnection('mongodb://user:pass@localhost:port/database');
+ *
+ * // and options
+ * var opts = { db: { native_parser: true }}
+ * db = mongoose.createConnection('mongodb://user:pass@localhost:port/database', opts);
+ *
+ * // replica sets
+ * db = mongoose.createConnection('mongodb://user:pass@localhost:port,anotherhost:port,yetanother:port/database');
+ *
+ * // and options
+ * var opts = { replset: { strategy: 'ping', rs_name: 'testSet' }}
+ * db = mongoose.createConnection('mongodb://user:pass@localhost:port,anotherhost:port,yetanother:port/database', opts);
+ *
+ * // with [host, database_name[, port] signature
+ * db = mongoose.createConnection('localhost', 'database', port)
+ *
+ * // and options
+ * var opts = { server: { auto_reconnect: false }, user: 'username', pass: 'mypassword' }
+ * db = mongoose.createConnection('localhost', 'database', port, opts)
+ *
+ * // initialize now, connect later
+ * db = mongoose.createConnection();
+ * db.open('localhost', 'database', port, [opts]);
+ *
+ * @param {String} [uri] a mongodb:// URI
+ * @param {Object} [options] options to pass to the driver
+ * @param {Object} [options.config] mongoose-specific options
+ * @param {Boolean} [options.config.autoIndex] set to false to disable automatic index creation for all models associated with this connection.
+ * @see Connection#open #connection_Connection-open
+ * @see Connection#openSet #connection_Connection-openSet
+ * @return {Connection} the created Connection object
+ * @api public
+ */
+
+Mongoose.prototype.createConnection = function(uri, options) {
+ var conn = new Connection(this);
+ this.connections.push(conn);
+
+ var rsOption = options && (options.replset || options.replSet);
+ if (arguments.length) {
+ if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
+ conn.openSet.apply(conn, arguments).catch(function() {});
+ } else if (rsOption &&
+ (rsOption.replicaSet || rsOption.rs_name)) {
+ conn.openSet.apply(conn, arguments).catch(function() {});
+ } else {
+ conn.open.apply(conn, arguments).catch(function() {});
+ }
+ }
+
+ return conn;
+};
+Mongoose.prototype.createConnection.$hasSideEffects = true;
+
+/**
+ * Opens the default mongoose connection.
+ *
+ * If arguments are passed, they are proxied to either
+ * [Connection#open](#connection_Connection-open) or
+ * [Connection#openSet](#connection_Connection-openSet) appropriately.
+ *
+ * _Options passed take precedence over options included in connection strings._
+ *
+ * ####Example:
+ *
+ * mongoose.connect('mongodb://user:pass@localhost:port/database');
+ *
+ * // replica sets
+ * var uri = 'mongodb://user:pass@localhost:port,anotherhost:port,yetanother:port/mydatabase';
+ * mongoose.connect(uri);
+ *
+ * // with options
+ * mongoose.connect(uri, options);
+ *
+ * // connecting to multiple mongos
+ * var uri = 'mongodb://hostA:27501,hostB:27501';
+ * var opts = { mongos: true };
+ * mongoose.connect(uri, opts);
+ *
+ * // optional callback that gets fired when initial connection completed
+ * var uri = 'mongodb://nonexistent.domain:27000';
+ * mongoose.connect(uri, function(error) {
+ * // if error is truthy, the initial connection failed.
+ * })
+ *
+ * @param {String} uri(s)
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @see Mongoose#createConnection #index_Mongoose-createConnection
+ * @api public
+ * @return {MongooseThenable} pseudo-promise wrapper around this
+ */
+
+Mongoose.prototype.connect = function() {
+ var conn = this.connection;
+ if (rgxReplSet.test(arguments[0]) || checkReplicaSetInUri(arguments[0])) {
+ return new MongooseThenable(this, conn.openSet.apply(conn, arguments));
+ }
+
+ return new MongooseThenable(this, conn.open.apply(conn, arguments));
+};
+Mongoose.prototype.connect.$hasSideEffects = true;
+
+/**
+ * Disconnects all connections.
+ *
+ * @param {Function} [fn] called after all connection close.
+ * @return {MongooseThenable} pseudo-promise wrapper around this
+ * @api public
+ */
+
+Mongoose.prototype.disconnect = function(fn) {
+ var error;
+ this.connections.forEach(function(conn) {
+ conn.close(function(err) {
+ if (error) {
+ return;
+ }
+ if (err) {
+ error = err;
+ }
+ });
+ });
+
+ var Promise = PromiseProvider.get();
+ return new MongooseThenable(this, new Promise.ES6(function(resolve, reject) {
+ fn && fn(error);
+ if (error) {
+ reject(error);
+ return;
+ }
+ resolve();
+ }));
+};
+Mongoose.prototype.disconnect.$hasSideEffects = true;
+
+/**
+ * Defines a model or retrieves it.
+ *
+ * Models defined on the `mongoose` instance are available to all connection created by the same `mongoose` instance.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ *
+ * // define an Actor model with this mongoose instance
+ * mongoose.model('Actor', new Schema({ name: String }));
+ *
+ * // create a new connection
+ * var conn = mongoose.createConnection(..);
+ *
+ * // retrieve the Actor model
+ * var Actor = conn.model('Actor');
+ *
+ * _When no `collection` argument is passed, Mongoose produces a collection name by passing the model `name` to the [utils.toCollectionName](#utils_exports.toCollectionName) method. This method pluralizes the name. If you don't like this behavior, either pass a collection name or set your schemas collection name option._
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ name: String }, { collection: 'actor' });
+ *
+ * // or
+ *
+ * schema.set('collection', 'actor');
+ *
+ * // or
+ *
+ * var collectionName = 'actor'
+ * var M = mongoose.model('Actor', schema, collectionName)
+ *
+ * @param {String|Function} name model name or class extending Model
+ * @param {Schema} [schema]
+ * @param {String} [collection] name (optional, inferred from model name)
+ * @param {Boolean} [skipInit] whether to skip initialization (defaults to false)
+ * @api public
+ */
+
+Mongoose.prototype.model = function(name, schema, collection, skipInit) {
+ var model;
+ if (typeof name === 'function') {
+ model = name;
+ name = model.name;
+ if (!(model.prototype instanceof Model)) {
+ throw new mongoose.Error('The provided class ' + name + ' must extend Model');
+ }
+ }
+
+ if (typeof schema === 'string') {
+ collection = schema;
+ schema = false;
+ }
+
+ if (utils.isObject(schema) && !(schema.instanceOfSchema)) {
+ schema = new Schema(schema);
+ }
+ if (schema && !schema.instanceOfSchema) {
+ throw new Error('The 2nd parameter to `mongoose.model()` should be a ' +
+ 'schema or a POJO');
+ }
+
+ if (typeof collection === 'boolean') {
+ skipInit = collection;
+ collection = null;
+ }
+
+ // handle internal options from connection.model()
+ var options;
+ if (skipInit && utils.isObject(skipInit)) {
+ options = skipInit;
+ skipInit = true;
+ } else {
+ options = {};
+ }
+
+ // look up schema for the collection.
+ if (!this.modelSchemas[name]) {
+ if (schema) {
+ // cache it so we only apply plugins once
+ this.modelSchemas[name] = schema;
+ } else {
+ throw new mongoose.Error.MissingSchemaError(name);
+ }
+ }
+
+ if (schema) {
+ this._applyPlugins(schema);
+ }
+
+ var sub;
+
+ // connection.model() may be passing a different schema for
+ // an existing model name. in this case don't read from cache.
+ if (this.models[name] && options.cache !== false) {
+ if (schema && schema.instanceOfSchema && schema !== this.models[name].schema) {
+ throw new mongoose.Error.OverwriteModelError(name);
+ }
+
+ if (collection) {
+ // subclass current model with alternate collection
+ model = this.models[name];
+ schema = model.prototype.schema;
+ sub = model.__subclass(this.connection, schema, collection);
+ // do not cache the sub model
+ return sub;
+ }
+
+ return this.models[name];
+ }
+
+ // ensure a schema exists
+ if (!schema) {
+ schema = this.modelSchemas[name];
+ if (!schema) {
+ throw new mongoose.Error.MissingSchemaError(name);
+ }
+ }
+
+ // Apply relevant "global" options to the schema
+ if (!('pluralization' in schema.options)) schema.options.pluralization = this.options.pluralization;
+
+
+ if (!collection) {
+ collection = schema.get('collection') || format(name, schema.options);
+ }
+
+ var connection = options.connection || this.connection;
+ model = this.Model.compile(model || name, schema, collection, connection, this);
+
+ if (!skipInit) {
+ model.init();
+ }
+
+ if (options.cache === false) {
+ return model;
+ }
+
+ this.models[name] = model;
+ return this.models[name];
+};
+Mongoose.prototype.model.$hasSideEffects = true;
+
+/**
+ * Returns an array of model names created on this instance of Mongoose.
+ *
+ * ####Note:
+ *
+ * _Does not include names of models created using `connection.model()`._
+ *
+ * @api public
+ * @return {Array}
+ */
+
+Mongoose.prototype.modelNames = function() {
+ var names = Object.keys(this.models);
+ return names;
+};
+Mongoose.prototype.modelNames.$hasSideEffects = true;
+
+/**
+ * Applies global plugins to `schema`.
+ *
+ * @param {Schema} schema
+ * @api private
+ */
+
+Mongoose.prototype._applyPlugins = function(schema) {
+ if (schema.$globalPluginsApplied) {
+ return;
+ }
+ var i;
+ var len;
+ for (i = 0, len = this.plugins.length; i < len; ++i) {
+ schema.plugin(this.plugins[i][0], this.plugins[i][1]);
+ }
+ schema.$globalPluginsApplied = true;
+ for (i = 0, len = schema.childSchemas.length; i < len; ++i) {
+ this._applyPlugins(schema.childSchemas[i]);
+ }
+};
+Mongoose.prototype._applyPlugins.$hasSideEffects = true;
+
+/**
+ * Declares a global plugin executed on all Schemas.
+ *
+ * Equivalent to calling `.plugin(fn)` on each Schema you create.
+ *
+ * @param {Function} fn plugin callback
+ * @param {Object} [opts] optional options
+ * @return {Mongoose} this
+ * @see plugins ./plugins.html
+ * @api public
+ */
+
+Mongoose.prototype.plugin = function(fn, opts) {
+ this.plugins.push([fn, opts]);
+ return this;
+};
+Mongoose.prototype.plugin.$hasSideEffects = true;
+
+/**
+ * The default connection of the mongoose module.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * mongoose.connect(...);
+ * mongoose.connection.on('error', cb);
+ *
+ * This is the connection used by default for every model created using [mongoose.model](#index_Mongoose-model).
+ *
+ * @property connection
+ * @return {Connection}
+ * @api public
+ */
+
+Mongoose.prototype.__defineGetter__('connection', function() {
+ return this.connections[0];
+});
+
+Mongoose.prototype.__defineSetter__('connection', function(v) {
+ this.connections[0] = v;
+});
+
+/*!
+ * Driver depentend APIs
+ */
+
+var driver = global.MONGOOSE_DRIVER_PATH || './drivers/node-mongodb-native';
+
+/*!
+ * Connection
+ */
+
+var Connection = require(driver + '/connection');
+
+/*!
+ * Collection
+ */
+
+var Collection = require(driver + '/collection');
+
+/**
+ * The Mongoose Aggregate constructor
+ *
+ * @method Aggregate
+ * @api public
+ */
+
+Mongoose.prototype.Aggregate = Aggregate;
+
+/**
+ * The Mongoose Collection constructor
+ *
+ * @method Collection
+ * @api public
+ */
+
+Mongoose.prototype.Collection = Collection;
+
+/**
+ * The Mongoose [Connection](#connection_Connection) constructor
+ *
+ * @method Connection
+ * @api public
+ */
+
+Mongoose.prototype.Connection = Connection;
+
+/**
+ * The Mongoose version
+ *
+ * @property version
+ * @api public
+ */
+
+Mongoose.prototype.version = pkg.version;
+
+/**
+ * The Mongoose constructor
+ *
+ * The exports of the mongoose module is an instance of this class.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var mongoose2 = new mongoose.Mongoose();
+ *
+ * @method Mongoose
+ * @api public
+ */
+
+Mongoose.prototype.Mongoose = Mongoose;
+
+/**
+ * The Mongoose [Schema](#schema_Schema) constructor
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var Schema = mongoose.Schema;
+ * var CatSchema = new Schema(..);
+ *
+ * @method Schema
+ * @api public
+ */
+
+Mongoose.prototype.Schema = Schema;
+
+/**
+ * The Mongoose [SchemaType](#schematype_SchemaType) constructor
+ *
+ * @method SchemaType
+ * @api public
+ */
+
+Mongoose.prototype.SchemaType = SchemaType;
+
+/**
+ * The various Mongoose SchemaTypes.
+ *
+ * ####Note:
+ *
+ * _Alias of mongoose.Schema.Types for backwards compatibility._
+ *
+ * @property SchemaTypes
+ * @see Schema.SchemaTypes #schema_Schema.Types
+ * @api public
+ */
+
+Mongoose.prototype.SchemaTypes = Schema.Types;
+
+/**
+ * The Mongoose [VirtualType](#virtualtype_VirtualType) constructor
+ *
+ * @method VirtualType
+ * @api public
+ */
+
+Mongoose.prototype.VirtualType = VirtualType;
+
+/**
+ * The various Mongoose Types.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var array = mongoose.Types.Array;
+ *
+ * ####Types:
+ *
+ * - [ObjectId](#types-objectid-js)
+ * - [Buffer](#types-buffer-js)
+ * - [SubDocument](#types-embedded-js)
+ * - [Array](#types-array-js)
+ * - [DocumentArray](#types-documentarray-js)
+ *
+ * Using this exposed access to the `ObjectId` type, we can construct ids on demand.
+ *
+ * var ObjectId = mongoose.Types.ObjectId;
+ * var id1 = new ObjectId;
+ *
+ * @property Types
+ * @api public
+ */
+
+Mongoose.prototype.Types = Types;
+
+/**
+ * The Mongoose [Query](#query_Query) constructor.
+ *
+ * @method Query
+ * @api public
+ */
+
+Mongoose.prototype.Query = Query;
+
+/**
+ * The Mongoose [Promise](#promise_Promise) constructor.
+ *
+ * @method Promise
+ * @api public
+ */
+
+Object.defineProperty(Mongoose.prototype, 'Promise', {
+ get: function() {
+ return PromiseProvider.get();
+ },
+ set: function(lib) {
+ PromiseProvider.set(lib);
+ }
+});
+
+/**
+ * Storage layer for mongoose promises
+ *
+ * @method PromiseProvider
+ * @api public
+ */
+
+Mongoose.prototype.PromiseProvider = PromiseProvider;
+
+/**
+ * The Mongoose [Model](#model_Model) constructor.
+ *
+ * @method Model
+ * @api public
+ */
+
+Mongoose.prototype.Model = Model;
+
+/**
+ * The Mongoose [Document](#document-js) constructor.
+ *
+ * @method Document
+ * @api public
+ */
+
+Mongoose.prototype.Document = Document;
+
+/**
+ * The Mongoose DocumentProvider constructor.
+ *
+ * @method DocumentProvider
+ * @api public
+ */
+
+Mongoose.prototype.DocumentProvider = require('./document_provider');
+
+/**
+ * The [MongooseError](#error_MongooseError) constructor.
+ *
+ * @method Error
+ * @api public
+ */
+
+Mongoose.prototype.Error = require('./error');
+
+/**
+ * The Mongoose CastError constructor
+ *
+ * @method CastError
+ * @param {String} type The name of the type
+ * @param {Any} value The value that failed to cast
+ * @param {String} path The path `a.b.c` in the doc where this cast error occurred
+ * @param {Error} [reason] The original error that was thrown
+ * @api public
+ */
+
+Mongoose.prototype.CastError = require('./error/cast');
+
+/**
+ * The [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) driver Mongoose uses.
+ *
+ * @property mongo
+ * @api public
+ */
+
+Mongoose.prototype.mongo = require('mongodb');
+
+/**
+ * The [mquery](https://github.com/aheckmann/mquery) query builder Mongoose uses.
+ *
+ * @property mquery
+ * @api public
+ */
+
+Mongoose.prototype.mquery = require('mquery');
+
+/**
+ * Wraps the given Mongoose instance into a thenable (pseudo-promise). This
+ * is so `connect()` and `disconnect()` can return a thenable while maintaining
+ * backwards compatibility.
+ *
+ * @api private
+ */
+
+function MongooseThenable(mongoose, promise) {
+ var _this = this;
+ for (var key in mongoose) {
+ if (typeof mongoose[key] === 'function' && mongoose[key].$hasSideEffects) {
+ (function(key) {
+ _this[key] = function() {
+ return mongoose[key].apply(mongoose, arguments);
+ };
+ })(key);
+ } else if (['connection', 'connections'].indexOf(key) !== -1) {
+ _this[key] = mongoose[key];
+ }
+ }
+ this.$opPromise = promise;
+}
+
+MongooseThenable.prototype = new Mongoose;
+
+/**
+ * Ability to use mongoose object as a pseudo-promise so `.connect().then()`
+ * and `.disconnect().then()` are viable.
+ *
+ * @param {Function} onFulfilled
+ * @param {Function} onRejected
+ * @return {Promise}
+ * @api private
+ */
+
+MongooseThenable.prototype.then = function(onFulfilled, onRejected) {
+ var Promise = PromiseProvider.get();
+ if (!this.$opPromise) {
+ return new Promise.ES6(function(resolve, reject) {
+ reject(new Error('Can only call `.then()` if connect() or disconnect() ' +
+ 'has been called'));
+ }).then(onFulfilled, onRejected);
+ }
+ this.$opPromise.$hasHandler = true;
+ return this.$opPromise.then(onFulfilled, onRejected);
+};
+
+/**
+ * Ability to use mongoose object as a pseudo-promise so `.connect().then()`
+ * and `.disconnect().then()` are viable.
+ *
+ * @param {Function} onFulfilled
+ * @param {Function} onRejected
+ * @return {Promise}
+ * @api private
+ */
+
+MongooseThenable.prototype.catch = function(onRejected) {
+ return this.then(null, onRejected);
+};
+
+/*!
+ * The exports object is an instance of Mongoose.
+ *
+ * @api public
+ */
+
+var mongoose = module.exports = exports = new Mongoose;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/internal.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/internal.js
new file mode 100644
index 0000000..edf3338
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/internal.js
@@ -0,0 +1,31 @@
+/*!
+ * Dependencies
+ */
+
+var StateMachine = require('./statemachine');
+var ActiveRoster = StateMachine.ctor('require', 'modify', 'init', 'default', 'ignore');
+
+module.exports = exports = InternalCache;
+
+function InternalCache() {
+ this.strictMode = undefined;
+ this.selected = undefined;
+ this.shardval = undefined;
+ this.saveError = undefined;
+ this.validationError = undefined;
+ this.adhocPaths = undefined;
+ this.removing = undefined;
+ this.inserting = undefined;
+ this.version = undefined;
+ this.getters = {};
+ this._id = undefined;
+ this.populate = undefined; // what we want to populate in this doc
+ this.populated = undefined;// the _ids that have been populated
+ this.wasPopulated = false; // if this doc was the result of a population
+ this.scope = undefined;
+ this.activePaths = new ActiveRoster;
+
+ // embedded docs
+ this.ownerDocument = undefined;
+ this.fullPath = undefined;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/model.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/model.js
new file mode 100644
index 0000000..4a7cbc4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/model.js
@@ -0,0 +1,3414 @@
+/*!
+ * Module dependencies.
+ */
+
+var Document = require('./document');
+var MongooseError = require('./error');
+var VersionError = MongooseError.VersionError;
+var DivergentArrayError = MongooseError.DivergentArrayError;
+var Query = require('./query');
+var Aggregate = require('./aggregate');
+var Schema = require('./schema');
+var utils = require('./utils');
+var hasOwnProperty = utils.object.hasOwnProperty;
+var isMongooseObject = utils.isMongooseObject;
+var EventEmitter = require('events').EventEmitter;
+var MongooseArray = require('./types/array');
+var util = require('util');
+var tick = utils.tick;
+
+var parallel = require('async/parallel');
+var PromiseProvider = require('./promise_provider');
+
+var VERSION_WHERE = 1,
+ VERSION_INC = 2,
+ VERSION_ALL = VERSION_WHERE | VERSION_INC;
+
+var POJO_TO_OBJECT_OPTIONS = {
+ depopulate: true,
+ transform: false,
+ _skipDepopulateTopLevel: true
+};
+
+/**
+ * Model constructor
+ *
+ * Provides the interface to MongoDB collections as well as creates document instances.
+ *
+ * @param {Object} doc values with which to create the document
+ * @inherits Document http://mongoosejs.com/docs/api.html#document-js
+ * @event `error`: If listening to this event, it is emitted when a document was saved without passing a callback and an `error` occurred. If not listening, the event bubbles to the connection used to create this Model.
+ * @event `index`: Emitted after `Model#ensureIndexes` completes. If an error occurred it is passed with the event.
+ * @event `index-single-start`: Emitted when an individual index starts within `Model#ensureIndexes`. The fields and options being used to build the index are also passed with the event.
+ * @event `index-single-done`: Emitted when an individual index finishes within `Model#ensureIndexes`. If an error occurred it is passed with the event. The fields, options, and index name are also passed.
+ * @api public
+ */
+
+function Model(doc, fields, skipId) {
+ Document.call(this, doc, fields, skipId);
+}
+
+/*!
+ * Inherits from Document.
+ *
+ * All Model.prototype features are available on
+ * top level (non-sub) documents.
+ */
+
+Model.prototype.__proto__ = Document.prototype;
+
+/**
+ * Connection the model uses.
+ *
+ * @api public
+ * @property db
+ */
+
+Model.prototype.db;
+
+/**
+ * Collection the model uses.
+ *
+ * @api public
+ * @property collection
+ */
+
+Model.prototype.collection;
+
+/**
+ * The name of the model
+ *
+ * @api public
+ * @property modelName
+ */
+
+Model.prototype.modelName;
+
+/**
+ * If this is a discriminator model, `baseModelName` is the name of
+ * the base model.
+ *
+ * @api public
+ * @property baseModelName
+ */
+
+Model.prototype.baseModelName;
+
+Model.prototype.$__handleSave = function(options, callback) {
+ var _this = this;
+ if (!options.safe && this.schema.options.safe) {
+ options.safe = this.schema.options.safe;
+ }
+ if (typeof options.safe === 'boolean') {
+ options.safe = null;
+ }
+
+ if (this.isNew) {
+ // send entire doc
+ var toObjectOptions = {};
+
+ toObjectOptions.retainKeyOrder = this.schema.options.retainKeyOrder;
+ toObjectOptions.depopulate = 1;
+ toObjectOptions._skipDepopulateTopLevel = true;
+ toObjectOptions.transform = false;
+
+ var obj = this.toObject(toObjectOptions);
+
+ if (!utils.object.hasOwnProperty(obj || {}, '_id')) {
+ // documents must have an _id else mongoose won't know
+ // what to update later if more changes are made. the user
+ // wouldn't know what _id was generated by mongodb either
+ // nor would the ObjectId generated my mongodb necessarily
+ // match the schema definition.
+ setTimeout(function() {
+ callback(new Error('document must have an _id before saving'));
+ }, 0);
+ return;
+ }
+
+ this.$__version(true, obj);
+ this.collection.insert(obj, options.safe, function(err, ret) {
+ if (err) {
+ _this.isNew = true;
+ _this.emit('isNew', true);
+
+ callback(err);
+ return;
+ }
+
+ callback(null, ret);
+ });
+ this.$__reset();
+ this.isNew = false;
+ this.emit('isNew', false);
+ // Make it possible to retry the insert
+ this.$__.inserting = true;
+ } else {
+ // Make sure we don't treat it as a new object on error,
+ // since it already exists
+ this.$__.inserting = false;
+
+ var delta = this.$__delta();
+
+ if (delta) {
+ if (delta instanceof Error) {
+ callback(delta);
+ return;
+ }
+
+ var where = this.$__where(delta[0]);
+
+ if (where instanceof Error) {
+ callback(where);
+ return;
+ }
+
+ this.collection.update(where, delta[1], options.safe, function(err, ret) {
+ if (err) {
+ callback(err);
+ return;
+ }
+ callback(null, ret);
+ });
+ } else {
+ this.$__reset();
+ callback();
+ return;
+ }
+
+ this.emit('isNew', false);
+ }
+};
+
+/*!
+ * ignore
+ */
+
+Model.prototype.$__save = function(options, callback) {
+ var _this = this;
+
+ _this.$__handleSave(options, function(error, result) {
+ if (error) {
+ return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
+ callback(error);
+ });
+ }
+
+ _this.$__reset();
+ _this.$__storeShard();
+
+ var numAffected = 0;
+ if (result) {
+ if (Array.isArray(result)) {
+ numAffected = result.length;
+ } else if (result.result && result.result.n !== undefined) {
+ numAffected = result.result.n;
+ } else if (result.result && result.result.nModified !== undefined) {
+ numAffected = result.result.nModified;
+ } else {
+ numAffected = result;
+ }
+ }
+
+ // was this an update that required a version bump?
+ if (_this.$__.version && !_this.$__.inserting) {
+ var doIncrement = VERSION_INC === (VERSION_INC & _this.$__.version);
+ _this.$__.version = undefined;
+
+ if (numAffected <= 0) {
+ // the update failed. pass an error back
+ var err = new VersionError(_this);
+ return callback(err);
+ }
+
+ // increment version if was successful
+ if (doIncrement) {
+ var key = _this.schema.options.versionKey;
+ var version = _this.getValue(key) | 0;
+ _this.setValue(key, version + 1);
+ }
+ }
+
+ _this.emit('save', _this, numAffected);
+ callback(null, _this, numAffected);
+ });
+};
+
+/**
+ * Saves this document.
+ *
+ * ####Example:
+ *
+ * product.sold = Date.now();
+ * product.save(function (err, product, numAffected) {
+ * if (err) ..
+ * })
+ *
+ * The callback will receive three parameters
+ *
+ * 1. `err` if an error occurred
+ * 2. `product` which is the saved `product`
+ * 3. `numAffected` will be 1 when the document was successfully persisted to MongoDB, otherwise 0. Unless you tweak mongoose's internals, you don't need to worry about checking this parameter for errors - checking `err` is sufficient to make sure your document was properly saved.
+ *
+ * As an extra measure of flow control, save will return a Promise.
+ * ####Example:
+ * product.save().then(function(product) {
+ * ...
+ * });
+ *
+ * For legacy reasons, mongoose stores object keys in reverse order on initial
+ * save. That is, `{ a: 1, b: 2 }` will be saved as `{ b: 2, a: 1 }` in
+ * MongoDB. To override this behavior, set
+ * [the `toObject.retainKeyOrder` option](http://mongoosejs.com/docs/api.html#document_Document-toObject)
+ * to true on your schema.
+ *
+ * @param {Object} [options] options optional options
+ * @param {Object} [options.safe] overrides [schema's safe option](http://mongoosejs.com//docs/guide.html#safe)
+ * @param {Boolean} [options.validateBeforeSave] set to false to save without validating.
+ * @param {Function} [fn] optional callback
+ * @return {Promise} Promise
+ * @api public
+ * @see middleware http://mongoosejs.com/docs/middleware.html
+ */
+
+Model.prototype.save = function(options, fn) {
+ if (typeof options === 'function') {
+ fn = options;
+ options = undefined;
+ }
+
+ if (!options) {
+ options = {};
+ }
+
+ if (fn) {
+ fn = this.constructor.$wrapCallback(fn);
+ }
+
+ return this.$__save(options, fn);
+};
+
+/*!
+ * Determines whether versioning should be skipped for the given path
+ *
+ * @param {Document} self
+ * @param {String} path
+ * @return {Boolean} true if versioning should be skipped for the given path
+ */
+function shouldSkipVersioning(self, path) {
+ var skipVersioning = self.schema.options.skipVersioning;
+ if (!skipVersioning) return false;
+
+ // Remove any array indexes from the path
+ path = path.replace(/\.\d+\./, '.');
+
+ return skipVersioning[path];
+}
+
+/*!
+ * Apply the operation to the delta (update) clause as
+ * well as track versioning for our where clause.
+ *
+ * @param {Document} self
+ * @param {Object} where
+ * @param {Object} delta
+ * @param {Object} data
+ * @param {Mixed} val
+ * @param {String} [operation]
+ */
+
+function operand(self, where, delta, data, val, op) {
+ // delta
+ op || (op = '$set');
+ if (!delta[op]) delta[op] = {};
+ delta[op][data.path] = val;
+
+ // disabled versioning?
+ if (self.schema.options.versionKey === false) return;
+
+ // path excluded from versioning?
+ if (shouldSkipVersioning(self, data.path)) return;
+
+ // already marked for versioning?
+ if (VERSION_ALL === (VERSION_ALL & self.$__.version)) return;
+
+ switch (op) {
+ case '$set':
+ case '$unset':
+ case '$pop':
+ case '$pull':
+ case '$pullAll':
+ case '$push':
+ case '$pushAll':
+ case '$addToSet':
+ break;
+ default:
+ // nothing to do
+ return;
+ }
+
+ // ensure updates sent with positional notation are
+ // editing the correct array element.
+ // only increment the version if an array position changes.
+ // modifying elements of an array is ok if position does not change.
+
+ if (op === '$push' || op === '$pushAll' || op === '$addToSet') {
+ self.$__.version = VERSION_INC;
+ } else if (/^\$p/.test(op)) {
+ // potentially changing array positions
+ self.increment();
+ } else if (Array.isArray(val)) {
+ // $set an array
+ self.increment();
+ } else if (/\.\d+\.|\.\d+$/.test(data.path)) {
+ // now handling $set, $unset
+ // subpath of array
+ self.$__.version = VERSION_WHERE;
+ }
+}
+
+/*!
+ * Compiles an update and where clause for a `val` with _atomics.
+ *
+ * @param {Document} self
+ * @param {Object} where
+ * @param {Object} delta
+ * @param {Object} data
+ * @param {Array} value
+ */
+
+function handleAtomics(self, where, delta, data, value) {
+ if (delta.$set && delta.$set[data.path]) {
+ // $set has precedence over other atomics
+ return;
+ }
+
+ if (typeof value.$__getAtomics === 'function') {
+ value.$__getAtomics().forEach(function(atomic) {
+ var op = atomic[0];
+ var val = atomic[1];
+ if (self.schema.options.usePushEach && op === '$pushAll') {
+ op = '$push';
+ val = { $each: val };
+ }
+ operand(self, where, delta, data, val, op);
+ });
+ return;
+ }
+
+ // legacy support for plugins
+
+ var atomics = value._atomics,
+ ops = Object.keys(atomics),
+ i = ops.length,
+ val,
+ op;
+
+ if (i === 0) {
+ // $set
+
+ if (isMongooseObject(value)) {
+ value = value.toObject({depopulate: 1, _isNested: true});
+ } else if (value.valueOf) {
+ value = value.valueOf();
+ }
+
+ return operand(self, where, delta, data, value);
+ }
+
+ function iter(mem) {
+ return isMongooseObject(mem)
+ ? mem.toObject({depopulate: 1, _isNested: true})
+ : mem;
+ }
+
+ while (i--) {
+ op = ops[i];
+ val = atomics[op];
+
+ if (isMongooseObject(val)) {
+ val = val.toObject({depopulate: true, transform: false, _isNested: true});
+ } else if (Array.isArray(val)) {
+ val = val.map(iter);
+ } else if (val.valueOf) {
+ val = val.valueOf();
+ }
+
+ if (op === '$addToSet') {
+ val = {$each: val};
+ }
+
+ operand(self, where, delta, data, val, op);
+ }
+}
+
+/**
+ * Produces a special query document of the modified properties used in updates.
+ *
+ * @api private
+ * @method $__delta
+ * @memberOf Model
+ */
+
+Model.prototype.$__delta = function() {
+ var dirty = this.$__dirty();
+ if (!dirty.length && VERSION_ALL !== this.$__.version) return;
+
+ var where = {},
+ delta = {},
+ len = dirty.length,
+ divergent = [],
+ d = 0;
+
+ where._id = this._doc._id;
+ if (where._id.toObject) {
+ where._id = where._id.toObject({ transform: false, depopulate: true });
+ }
+
+ for (; d < len; ++d) {
+ var data = dirty[d];
+ var value = data.value;
+
+ var match = checkDivergentArray(this, data.path, value);
+ if (match) {
+ divergent.push(match);
+ continue;
+ }
+
+ var pop = this.populated(data.path, true);
+ if (!pop && this.$__.selected) {
+ // If any array was selected using an $elemMatch projection, we alter the path and where clause
+ // NOTE: MongoDB only supports projected $elemMatch on top level array.
+ var pathSplit = data.path.split('.');
+ var top = pathSplit[0];
+ if (this.$__.selected[top] && this.$__.selected[top].$elemMatch) {
+ // If the selected array entry was modified
+ if (pathSplit.length > 1 && pathSplit[1] == 0 && typeof where[top] === 'undefined') {
+ where[top] = this.$__.selected[top];
+ pathSplit[1] = '$';
+ data.path = pathSplit.join('.');
+ }
+ // if the selected array was modified in any other way throw an error
+ else {
+ divergent.push(data.path);
+ continue;
+ }
+ }
+ }
+
+ if (divergent.length) continue;
+
+ if (undefined === value) {
+ operand(this, where, delta, data, 1, '$unset');
+ } else if (value === null) {
+ operand(this, where, delta, data, null);
+ } else if (value._path && value._atomics) {
+ // arrays and other custom types (support plugins etc)
+ handleAtomics(this, where, delta, data, value);
+ } else if (value._path && Buffer.isBuffer(value)) {
+ // MongooseBuffer
+ value = value.toObject();
+ operand(this, where, delta, data, value);
+ } else {
+ value = utils.clone(value, {depopulate: 1, _isNested: true});
+ operand(this, where, delta, data, value);
+ }
+ }
+
+ if (divergent.length) {
+ return new DivergentArrayError(divergent);
+ }
+
+ if (this.$__.version) {
+ this.$__version(where, delta);
+ }
+
+ return [where, delta];
+};
+
+/*!
+ * Determine if array was populated with some form of filter and is now
+ * being updated in a manner which could overwrite data unintentionally.
+ *
+ * @see https://github.com/Automattic/mongoose/issues/1334
+ * @param {Document} doc
+ * @param {String} path
+ * @return {String|undefined}
+ */
+
+function checkDivergentArray(doc, path, array) {
+ // see if we populated this path
+ var pop = doc.populated(path, true);
+
+ if (!pop && doc.$__.selected) {
+ // If any array was selected using an $elemMatch projection, we deny the update.
+ // NOTE: MongoDB only supports projected $elemMatch on top level array.
+ var top = path.split('.')[0];
+ if (doc.$__.selected[top + '.$']) {
+ return top;
+ }
+ }
+
+ if (!(pop && array && array.isMongooseArray)) return;
+
+ // If the array was populated using options that prevented all
+ // documents from being returned (match, skip, limit) or they
+ // deselected the _id field, $pop and $set of the array are
+ // not safe operations. If _id was deselected, we do not know
+ // how to remove elements. $pop will pop off the _id from the end
+ // of the array in the db which is not guaranteed to be the
+ // same as the last element we have here. $set of the entire array
+ // would be similarily destructive as we never received all
+ // elements of the array and potentially would overwrite data.
+ var check = pop.options.match ||
+ pop.options.options && hasOwnProperty(pop.options.options, 'limit') || // 0 is not permitted
+ pop.options.options && pop.options.options.skip || // 0 is permitted
+ pop.options.select && // deselected _id?
+ (pop.options.select._id === 0 ||
+ /\s?-_id\s?/.test(pop.options.select));
+
+ if (check) {
+ var atomics = array._atomics;
+ if (Object.keys(atomics).length === 0 || atomics.$set || atomics.$pop) {
+ return path;
+ }
+ }
+}
+
+/**
+ * Appends versioning to the where and update clauses.
+ *
+ * @api private
+ * @method $__version
+ * @memberOf Model
+ */
+
+Model.prototype.$__version = function(where, delta) {
+ var key = this.schema.options.versionKey;
+
+ if (where === true) {
+ // this is an insert
+ if (key) this.setValue(key, delta[key] = 0);
+ return;
+ }
+
+ // updates
+
+ // only apply versioning if our versionKey was selected. else
+ // there is no way to select the correct version. we could fail
+ // fast here and force them to include the versionKey but
+ // thats a bit intrusive. can we do this automatically?
+ if (!this.isSelected(key)) {
+ return;
+ }
+
+ // $push $addToSet don't need the where clause set
+ if (VERSION_WHERE === (VERSION_WHERE & this.$__.version)) {
+ where[key] = this.getValue(key);
+ }
+
+ if (VERSION_INC === (VERSION_INC & this.$__.version)) {
+ if (!delta.$set || typeof delta.$set[key] === 'undefined') {
+ delta.$inc || (delta.$inc = {});
+ delta.$inc[key] = 1;
+ }
+ }
+};
+
+/**
+ * Signal that we desire an increment of this documents version.
+ *
+ * ####Example:
+ *
+ * Model.findById(id, function (err, doc) {
+ * doc.increment();
+ * doc.save(function (err) { .. })
+ * })
+ *
+ * @see versionKeys http://mongoosejs.com/docs/guide.html#versionKey
+ * @api public
+ */
+
+Model.prototype.increment = function increment() {
+ this.$__.version = VERSION_ALL;
+ return this;
+};
+
+/**
+ * Returns a query object which applies shardkeys if they exist.
+ *
+ * @api private
+ * @method $__where
+ * @memberOf Model
+ */
+
+Model.prototype.$__where = function _where(where) {
+ where || (where = {});
+
+ var paths,
+ len;
+
+ if (!where._id) {
+ where._id = this._doc._id;
+ }
+
+ if (this.$__.shardval) {
+ paths = Object.keys(this.$__.shardval);
+ len = paths.length;
+
+ for (var i = 0; i < len; ++i) {
+ where[paths[i]] = this.$__.shardval[paths[i]];
+ }
+ }
+
+ if (this._doc._id == null) {
+ return new Error('No _id found on document!');
+ }
+
+ return where;
+};
+
+/**
+ * Removes this document from the db.
+ *
+ * ####Example:
+ * product.remove(function (err, product) {
+ * if (err) return handleError(err);
+ * Product.findById(product._id, function (err, product) {
+ * console.log(product) // null
+ * })
+ * })
+ *
+ *
+ * As an extra measure of flow control, remove will return a Promise (bound to `fn` if passed) so it could be chained, or hooked to recive errors
+ *
+ * ####Example:
+ * product.remove().then(function (product) {
+ * ...
+ * }).onRejected(function (err) {
+ * assert.ok(err)
+ * })
+ *
+ * @param {function(err,product)} [fn] optional callback
+ * @return {Promise} Promise
+ * @api public
+ */
+
+Model.prototype.remove = function remove(options, fn) {
+ if (typeof options === 'function') {
+ fn = options;
+ options = undefined;
+ }
+
+ if (!options) {
+ options = {};
+ }
+
+ if (this.$__.removing) {
+ if (fn) {
+ this.$__.removing.then(
+ function(res) { fn(null, res); },
+ function(err) { fn(err); });
+ }
+ return this;
+ }
+
+ var _this = this;
+ var Promise = PromiseProvider.get();
+
+ if (fn) {
+ fn = this.constructor.$wrapCallback(fn);
+ }
+
+ this.$__.removing = new Promise.ES6(function(resolve, reject) {
+ var where = _this.$__where();
+ if (where instanceof Error) {
+ reject(where);
+ fn && fn(where);
+ return;
+ }
+
+ if (!options.safe && _this.schema.options.safe) {
+ options.safe = _this.schema.options.safe;
+ }
+
+ _this.collection.remove(where, options, function(err) {
+ if (!err) {
+ _this.emit('remove', _this);
+ resolve(_this);
+ fn && fn(null, _this);
+ return;
+ }
+ reject(err);
+ fn && fn(err);
+ });
+ });
+ return this.$__.removing;
+};
+
+/**
+ * Returns another Model instance.
+ *
+ * ####Example:
+ *
+ * var doc = new Tank;
+ * doc.model('User').findById(id, callback);
+ *
+ * @param {String} name model name
+ * @api public
+ */
+
+Model.prototype.model = function model(name) {
+ return this.db.model(name);
+};
+
+/**
+ * Adds a discriminator type.
+ *
+ * ####Example:
+ *
+ * function BaseSchema() {
+ * Schema.apply(this, arguments);
+ *
+ * this.add({
+ * name: String,
+ * createdAt: Date
+ * });
+ * }
+ * util.inherits(BaseSchema, Schema);
+ *
+ * var PersonSchema = new BaseSchema();
+ * var BossSchema = new BaseSchema({ department: String });
+ *
+ * var Person = mongoose.model('Person', PersonSchema);
+ * var Boss = Person.discriminator('Boss', BossSchema);
+ *
+ * @param {String} name discriminator model name
+ * @param {Schema} schema discriminator model schema
+ * @api public
+ */
+
+Model.discriminator = function discriminator(name, schema) {
+ var CUSTOMIZABLE_DISCRIMINATOR_OPTIONS = {
+ toJSON: true,
+ toObject: true,
+ _id: true,
+ id: true
+ };
+
+ if (!(schema && schema.instanceOfSchema)) {
+ throw new Error('You must pass a valid discriminator Schema');
+ }
+
+ if (this.schema.discriminatorMapping && !this.schema.discriminatorMapping.isRoot) {
+ throw new Error('Discriminator "' + name +
+ '" can only be a discriminator of the root model');
+ }
+
+ var key = this.schema.options.discriminatorKey;
+ if (schema.path(key)) {
+ throw new Error('Discriminator "' + name +
+ '" cannot have field with name "' + key + '"');
+ }
+
+ function merge(schema, baseSchema) {
+ utils.merge(schema, baseSchema);
+
+ var obj = {};
+ obj[key] = {
+ default: name,
+ set: function(newName) {
+ if (newName === name) {
+ return name;
+ }
+ throw new Error('Can\'t set discriminator key "' + key + '"');
+ }
+ };
+ obj[key][schema.options.typeKey] = String;
+ schema.add(obj);
+ schema.discriminatorMapping = {key: key, value: name, isRoot: false};
+
+ if (baseSchema.options.collection) {
+ schema.options.collection = baseSchema.options.collection;
+ }
+
+ var toJSON = schema.options.toJSON;
+ var toObject = schema.options.toObject;
+ var _id = schema.options._id;
+ var id = schema.options.id;
+
+ var keys = Object.keys(schema.options);
+
+ for (var i = 0; i < keys.length; ++i) {
+ var _key = keys[i];
+ if (!CUSTOMIZABLE_DISCRIMINATOR_OPTIONS[_key]) {
+ if (!utils.deepEqual(schema.options[_key], baseSchema.options[_key])) {
+ throw new Error('Can\'t customize discriminator option ' + _key +
+ ' (can only modify ' +
+ Object.keys(CUSTOMIZABLE_DISCRIMINATOR_OPTIONS).join(', ') +
+ ')');
+ }
+ }
+ }
+
+ schema.options = utils.clone(baseSchema.options);
+ if (toJSON) schema.options.toJSON = toJSON;
+ if (toObject) schema.options.toObject = toObject;
+ if (typeof _id !== 'undefined') {
+ schema.options._id = _id;
+ }
+ schema.options.id = id;
+
+ schema.callQueue = baseSchema.callQueue.concat(schema.callQueue.slice(schema._defaultMiddleware.length));
+ schema._requiredpaths = undefined; // reset just in case Schema#requiredPaths() was called on either schema
+ }
+
+ // merges base schema into new discriminator schema and sets new type field.
+ merge(schema, this.schema);
+
+ if (!this.discriminators) {
+ this.discriminators = {};
+ }
+
+ if (!this.schema.discriminatorMapping) {
+ this.schema.discriminatorMapping = {key: key, value: null, isRoot: true};
+ }
+
+ if (this.discriminators[name]) {
+ throw new Error('Discriminator with name "' + name + '" already exists');
+ }
+ if (this.db.models[name]) {
+ throw new MongooseError.OverwriteModelError(name);
+ }
+
+ this.discriminators[name] = this.db.model(name, schema, this.collection.name);
+ this.discriminators[name].prototype.__proto__ = this.prototype;
+ Object.defineProperty(this.discriminators[name], 'baseModelName', {
+ value: this.modelName,
+ configurable: true,
+ writable: false
+ });
+
+ // apply methods and statics
+ applyMethods(this.discriminators[name], schema);
+ applyStatics(this.discriminators[name], schema);
+
+ return this.discriminators[name];
+};
+
+// Model (class) features
+
+/*!
+ * Give the constructor the ability to emit events.
+ */
+
+for (var i in EventEmitter.prototype) {
+ Model[i] = EventEmitter.prototype[i];
+}
+
+/**
+ * Called when the model compiles.
+ *
+ * @api private
+ */
+
+Model.init = function init() {
+ if ((this.schema.options.autoIndex) ||
+ (this.schema.options.autoIndex === null && this.db.config.autoIndex)) {
+ this.ensureIndexes({ __noPromise: true, _automatic: true });
+ }
+
+ this.schema.emit('init', this);
+};
+
+/**
+ * Sends `ensureIndex` commands to mongo for each index declared in the schema.
+ *
+ * ####Example:
+ *
+ * Event.ensureIndexes(function (err) {
+ * if (err) return handleError(err);
+ * });
+ *
+ * After completion, an `index` event is emitted on this `Model` passing an error if one occurred.
+ *
+ * ####Example:
+ *
+ * var eventSchema = new Schema({ thing: { type: 'string', unique: true }})
+ * var Event = mongoose.model('Event', eventSchema);
+ *
+ * Event.on('index', function (err) {
+ * if (err) console.error(err); // error occurred during index creation
+ * })
+ *
+ * _NOTE: It is not recommended that you run this in production. Index creation may impact database performance depending on your load. Use with caution._
+ *
+ * The `ensureIndex` commands are not sent in parallel. This is to avoid the `MongoError: cannot add index with a background operation in progress` error. See [this ticket](https://github.com/Automattic/mongoose/issues/1365) for more information.
+ *
+ * @param {Object} [options] internal options
+ * @param {Function} [cb] optional callback
+ * @return {Promise}
+ * @api public
+ */
+
+Model.ensureIndexes = function ensureIndexes(options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+
+ if (options && options.__noPromise) {
+ _ensureIndexes(this, options, callback);
+ return;
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ _ensureIndexes(_this, options || {}, function(error) {
+ if (error) {
+ callback && callback(error);
+ reject(error);
+ }
+ callback && callback();
+ resolve();
+ });
+ });
+};
+
+function _ensureIndexes(model, options, callback) {
+ var indexes = model.schema.indexes();
+ if (!indexes.length) {
+ setImmediate(function() {
+ callback && callback();
+ });
+ return;
+ }
+ // Indexes are created one-by-one to support how MongoDB < 2.4 deals
+ // with background indexes.
+
+ var done = function(err) {
+ if (err && model.schema.options.emitIndexErrors) {
+ model.emit('error', err);
+ }
+ model.emit('index', err);
+ callback && callback(err);
+ };
+
+ var indexSingleDone = function(err, fields, options, name) {
+ model.emit('index-single-done', err, fields, options, name);
+ };
+ var indexSingleStart = function(fields, options) {
+ model.emit('index-single-start', fields, options);
+ };
+
+ var create = function() {
+ var index = indexes.shift();
+ if (!index) return done();
+
+ var indexFields = index[0];
+ var options = index[1];
+ _handleSafe(options);
+
+ indexSingleStart(indexFields, options);
+
+ model.collection.ensureIndex(indexFields, options, tick(function(err, name) {
+ indexSingleDone(err, indexFields, options, name);
+ if (err) {
+ return done(err);
+ }
+ create();
+ }));
+ };
+
+ setImmediate(function() {
+ // If buffering is off, do this manually.
+ if (options._automatic && !model.collection.collection) {
+ model.collection.addQueue(create, []);
+ } else {
+ create();
+ }
+ });
+}
+
+function _handleSafe(options) {
+ if (options.safe) {
+ if (typeof options.safe === 'boolean') {
+ options.w = options.safe;
+ delete options.safe;
+ }
+ if (typeof options.safe === 'object') {
+ options.w = options.safe.w;
+ options.j = options.safe.j;
+ options.wtimeout = options.safe.wtimeout;
+ delete options.safe;
+ }
+ }
+}
+
+/**
+ * Schema the model uses.
+ *
+ * @property schema
+ * @receiver Model
+ * @api public
+ */
+
+Model.schema;
+
+/*!
+ * Connection instance the model uses.
+ *
+ * @property db
+ * @receiver Model
+ * @api public
+ */
+
+Model.db;
+
+/*!
+ * Collection the model uses.
+ *
+ * @property collection
+ * @receiver Model
+ * @api public
+ */
+
+Model.collection;
+
+/**
+ * Base Mongoose instance the model uses.
+ *
+ * @property base
+ * @receiver Model
+ * @api public
+ */
+
+Model.base;
+
+/**
+ * Registered discriminators for this model.
+ *
+ * @property discriminators
+ * @receiver Model
+ * @api public
+ */
+
+Model.discriminators;
+
+/**
+ * Removes documents from the collection.
+ *
+ * ####Example:
+ *
+ * Comment.remove({ title: 'baby born from alien father' }, function (err) {
+ *
+ * });
+ *
+ * ####Note:
+ *
+ * To remove documents without waiting for a response from MongoDB, do not pass a `callback`, then call `exec` on the returned [Query](#query-js):
+ *
+ * var query = Comment.remove({ _id: id });
+ * query.exec();
+ *
+ * ####Note:
+ *
+ * This method sends a remove command directly to MongoDB, no Mongoose documents are involved. Because no Mongoose documents are involved, _no middleware (hooks) are executed_.
+ *
+ * @param {Object} conditions
+ * @param {Function} [callback]
+ * @return {Query}
+ * @api public
+ */
+
+Model.remove = function remove(conditions, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ }
+
+ // get the mongodb collection object
+ var mq = new this.Query(conditions, {}, this, this.collection);
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return mq.remove(callback);
+};
+
+/**
+ * Finds documents
+ *
+ * The `conditions` are cast to their respective SchemaTypes before the command is sent.
+ *
+ * ####Examples:
+ *
+ * // named john and at least 18
+ * MyModel.find({ name: 'john', age: { $gte: 18 }});
+ *
+ * // executes immediately, passing results to callback
+ * MyModel.find({ name: 'john', age: { $gte: 18 }}, function (err, docs) {});
+ *
+ * // name LIKE john and only selecting the "name" and "friends" fields, executing immediately
+ * MyModel.find({ name: /john/i }, 'name friends', function (err, docs) { })
+ *
+ * // passing options
+ * MyModel.find({ name: /john/i }, null, { skip: 10 })
+ *
+ * // passing options and executing immediately
+ * MyModel.find({ name: /john/i }, null, { skip: 10 }, function (err, docs) {});
+ *
+ * // executing a query explicitly
+ * var query = MyModel.find({ name: /john/i }, null, { skip: 10 })
+ * query.exec(function (err, docs) {});
+ *
+ * // using the promise returned from executing a query
+ * var query = MyModel.find({ name: /john/i }, null, { skip: 10 });
+ * var promise = query.exec();
+ * promise.addBack(function (err, docs) {});
+ *
+ * @param {Object} conditions
+ * @param {Object} [projection] optional fields to return (http://bit.ly/1HotzBo)
+ * @param {Object} [options] optional
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see field selection #query_Query-select
+ * @see promise #promise-js
+ * @api public
+ */
+
+Model.find = function find(conditions, projection, options, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ projection = null;
+ options = null;
+ } else if (typeof projection === 'function') {
+ callback = projection;
+ projection = null;
+ options = null;
+ } else if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+
+ var mq = new this.Query({}, {}, this, this.collection);
+ mq.select(projection);
+ mq.setOptions(options);
+ if (this.schema.discriminatorMapping && mq.selectedInclusively()) {
+ mq.select(this.schema.options.discriminatorKey);
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return mq.find(conditions, callback);
+};
+
+/**
+ * Finds a single document by its _id field. `findById(id)` is almost*
+ * equivalent to `findOne({ _id: id })`. If you want to query by a document's
+ * `_id`, use `findById()` instead of `findOne()`.
+ *
+ * The `id` is cast based on the Schema before sending the command.
+ *
+ * Note: `findById()` triggers `findOne` hooks.
+ *
+ * * Except for how it treats `undefined`. If you use `findOne()`, you'll see
+ * that `findOne(undefined)` and `findOne({ _id: undefined })` are equivalent
+ * to `findOne({})` and return arbitrary documents. However, mongoose
+ * translates `findById(undefined)` into `findOne({ _id: null })`.
+ *
+ * ####Example:
+ *
+ * // find adventure by id and execute immediately
+ * Adventure.findById(id, function (err, adventure) {});
+ *
+ * // same as above
+ * Adventure.findById(id).exec(callback);
+ *
+ * // select only the adventures name and length
+ * Adventure.findById(id, 'name length', function (err, adventure) {});
+ *
+ * // same as above
+ * Adventure.findById(id, 'name length').exec(callback);
+ *
+ * // include all properties except for `length`
+ * Adventure.findById(id, '-length').exec(function (err, adventure) {});
+ *
+ * // passing options (in this case return the raw js objects, not mongoose documents by passing `lean`
+ * Adventure.findById(id, 'name', { lean: true }, function (err, doc) {});
+ *
+ * // same as above
+ * Adventure.findById(id, 'name').lean().exec(function (err, doc) {});
+ *
+ * @param {Object|String|Number} id value of `_id` to query by
+ * @param {Object} [projection] optional fields to return (http://bit.ly/1HotzBo)
+ * @param {Object} [options] optional
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see field selection #query_Query-select
+ * @see lean queries #query_Query-lean
+ * @api public
+ */
+
+Model.findById = function findById(id, projection, options, callback) {
+ if (typeof id === 'undefined') {
+ id = null;
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return this.findOne({_id: id}, projection, options, callback);
+};
+
+/**
+ * Finds one document.
+ *
+ * The `conditions` are cast to their respective SchemaTypes before the command is sent.
+ *
+ * *Note:* `conditions` is optional, and if `conditions` is null or undefined,
+ * mongoose will send an empty `findOne` command to MongoDB, which will return
+ * an arbitrary document. If you're querying by `_id`, use `findById()` instead.
+ *
+ * ####Example:
+ *
+ * // find one iphone adventures - iphone adventures??
+ * Adventure.findOne({ type: 'iphone' }, function (err, adventure) {});
+ *
+ * // same as above
+ * Adventure.findOne({ type: 'iphone' }).exec(function (err, adventure) {});
+ *
+ * // select only the adventures name
+ * Adventure.findOne({ type: 'iphone' }, 'name', function (err, adventure) {});
+ *
+ * // same as above
+ * Adventure.findOne({ type: 'iphone' }, 'name').exec(function (err, adventure) {});
+ *
+ * // specify options, in this case lean
+ * Adventure.findOne({ type: 'iphone' }, 'name', { lean: true }, callback);
+ *
+ * // same as above
+ * Adventure.findOne({ type: 'iphone' }, 'name', { lean: true }).exec(callback);
+ *
+ * // chaining findOne queries (same as above)
+ * Adventure.findOne({ type: 'iphone' }).select('name').lean().exec(callback);
+ *
+ * @param {Object} [conditions]
+ * @param {Object} [projection] optional fields to return (http://bit.ly/1HotzBo)
+ * @param {Object} [options] optional
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see field selection #query_Query-select
+ * @see lean queries #query_Query-lean
+ * @api public
+ */
+
+Model.findOne = function findOne(conditions, projection, options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ } else if (typeof projection === 'function') {
+ callback = projection;
+ projection = null;
+ options = null;
+ } else if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ projection = null;
+ options = null;
+ }
+
+ // get the mongodb collection object
+ var mq = new this.Query({}, {}, this, this.collection);
+ mq.select(projection);
+ mq.setOptions(options);
+ if (this.schema.discriminatorMapping && mq.selectedInclusively()) {
+ mq.select(this.schema.options.discriminatorKey);
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return mq.findOne(conditions, callback);
+};
+
+/**
+ * Counts number of matching documents in a database collection.
+ *
+ * ####Example:
+ *
+ * Adventure.count({ type: 'jungle' }, function (err, count) {
+ * if (err) ..
+ * console.log('there are %d jungle adventures', count);
+ * });
+ *
+ * @param {Object} conditions
+ * @param {Function} [callback]
+ * @return {Query}
+ * @api public
+ */
+
+Model.count = function count(conditions, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ }
+
+ // get the mongodb collection object
+ var mq = new this.Query({}, {}, this, this.collection);
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return mq.count(conditions, callback);
+};
+
+/**
+ * Creates a Query for a `distinct` operation.
+ *
+ * Passing a `callback` immediately executes the query.
+ *
+ * ####Example
+ *
+ * Link.distinct('url', { clicks: {$gt: 100}}, function (err, result) {
+ * if (err) return handleError(err);
+ *
+ * assert(Array.isArray(result));
+ * console.log('unique urls with more than 100 clicks', result);
+ * })
+ *
+ * var query = Link.distinct('url');
+ * query.exec(callback);
+ *
+ * @param {String} field
+ * @param {Object} [conditions] optional
+ * @param {Function} [callback]
+ * @return {Query}
+ * @api public
+ */
+
+Model.distinct = function distinct(field, conditions, callback) {
+ // get the mongodb collection object
+ var mq = new this.Query({}, {}, this, this.collection);
+
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ }
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return mq.distinct(field, conditions, callback);
+};
+
+/**
+ * Creates a Query, applies the passed conditions, and returns the Query.
+ *
+ * For example, instead of writing:
+ *
+ * User.find({age: {$gte: 21, $lte: 65}}, callback);
+ *
+ * we can instead write:
+ *
+ * User.where('age').gte(21).lte(65).exec(callback);
+ *
+ * Since the Query class also supports `where` you can continue chaining
+ *
+ * User
+ * .where('age').gte(21).lte(65)
+ * .where('name', /^b/i)
+ * ... etc
+ *
+ * @param {String} path
+ * @param {Object} [val] optional value
+ * @return {Query}
+ * @api public
+ */
+
+Model.where = function where(path, val) {
+ void val; // eslint
+ // get the mongodb collection object
+ var mq = new this.Query({}, {}, this, this.collection).find({});
+ return mq.where.apply(mq, arguments);
+};
+
+/**
+ * Creates a `Query` and specifies a `$where` condition.
+ *
+ * Sometimes you need to query for things in mongodb using a JavaScript expression. You can do so via `find({ $where: javascript })`, or you can use the mongoose shortcut method $where via a Query chain or from your mongoose Model.
+ *
+ * Blog.$where('this.username.indexOf("val") !== -1').exec(function (err, docs) {});
+ *
+ * @param {String|Function} argument is a javascript string or anonymous function
+ * @method $where
+ * @memberOf Model
+ * @return {Query}
+ * @see Query.$where #query_Query-%24where
+ * @api public
+ */
+
+Model.$where = function $where() {
+ var mq = new this.Query({}, {}, this, this.collection).find({});
+ return mq.$where.apply(mq, arguments);
+};
+
+/**
+ * Issues a mongodb findAndModify update command.
+ *
+ * Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found document (if any) to the callback. The query executes immediately if `callback` is passed else a Query object is returned.
+ *
+ * ####Options:
+ *
+ * - `new`: bool - if true, return the modified document rather than the original. defaults to false (changed in 4.0)
+ * - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
+ * - `fields`: {Object|String} - Field selection. Equivalent to `.select(fields).findOneAndUpdate()`
+ * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
+ * - `setDefaultsOnInsert`: if this and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. This option only works on MongoDB >= 2.4 because it relies on [MongoDB's `$setOnInsert` operator](https://docs.mongodb.org/v2.4/reference/operator/update/setOnInsert/).
+ * - `passRawResult`: if true, passes the [raw result from the MongoDB driver as the third callback parameter](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
+ *
+ *
+ * ####Examples:
+ *
+ * A.findOneAndUpdate(conditions, update, options, callback) // executes
+ * A.findOneAndUpdate(conditions, update, options) // returns Query
+ * A.findOneAndUpdate(conditions, update, callback) // executes
+ * A.findOneAndUpdate(conditions, update) // returns Query
+ * A.findOneAndUpdate() // returns Query
+ *
+ * ####Note:
+ *
+ * All top level update keys which are not `atomic` operation names are treated as set operations:
+ *
+ * ####Example:
+ *
+ * var query = { name: 'borne' };
+ * Model.findOneAndUpdate(query, { name: 'jason borne' }, options, callback)
+ *
+ * // is sent as
+ * Model.findOneAndUpdate(query, { $set: { name: 'jason borne' }}, options, callback)
+ *
+ * This helps prevent accidentally overwriting your document with `{ name: 'jason borne' }`.
+ *
+ * ####Note:
+ *
+ * Values are cast to their appropriate types when using the findAndModify helpers.
+ * However, the below are never executed.
+ *
+ * - defaults
+ * - setters
+ *
+ * `findAndModify` helpers support limited defaults and validation. You can
+ * enable these by setting the `setDefaultsOnInsert` and `runValidators` options,
+ * respectively.
+ *
+ * If you need full-fledged validation, use the traditional approach of first
+ * retrieving the document.
+ *
+ * Model.findById(id, function (err, doc) {
+ * if (err) ..
+ * doc.name = 'jason borne';
+ * doc.save(callback);
+ * });
+ *
+ * @param {Object} [conditions]
+ * @param {Object} [update]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @api public
+ */
+
+Model.findOneAndUpdate = function(conditions, update, options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ } else if (arguments.length === 1) {
+ if (typeof conditions === 'function') {
+ var msg = 'Model.findOneAndUpdate(): First argument must not be a function.\n\n'
+ + ' ' + this.modelName + '.findOneAndUpdate(conditions, update, options, callback)\n'
+ + ' ' + this.modelName + '.findOneAndUpdate(conditions, update, options)\n'
+ + ' ' + this.modelName + '.findOneAndUpdate(conditions, update)\n'
+ + ' ' + this.modelName + '.findOneAndUpdate(update)\n'
+ + ' ' + this.modelName + '.findOneAndUpdate()\n';
+ throw new TypeError(msg);
+ }
+ update = conditions;
+ conditions = undefined;
+ }
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var fields;
+ if (options && options.fields) {
+ fields = options.fields;
+ }
+
+ update = utils.clone(update, {depopulate: 1, _isNested: true});
+ if (this.schema.options.versionKey && options && options.upsert) {
+ if (!update.$setOnInsert) {
+ update.$setOnInsert = {};
+ }
+ update.$setOnInsert[this.schema.options.versionKey] = 0;
+ }
+
+ var mq = new this.Query({}, {}, this, this.collection);
+ mq.select(fields);
+
+ return mq.findOneAndUpdate(conditions, update, options, callback);
+};
+
+/**
+ * Issues a mongodb findAndModify update command by a document's _id field.
+ * `findByIdAndUpdate(id, ...)` is equivalent to `findOneAndUpdate({ _id: id }, ...)`.
+ *
+ * Finds a matching document, updates it according to the `update` arg,
+ * passing any `options`, and returns the found document (if any) to the
+ * callback. The query executes immediately if `callback` is passed else a
+ * Query object is returned.
+ *
+ * This function triggers `findOneAndUpdate` middleware.
+ *
+ * ####Options:
+ *
+ * - `new`: bool - true to return the modified document rather than the original. defaults to false
+ * - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
+ * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
+ * - `setDefaultsOnInsert`: if this and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. This option only works on MongoDB >= 2.4 because it relies on [MongoDB's `$setOnInsert` operator](https://docs.mongodb.org/v2.4/reference/operator/update/setOnInsert/).
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `select`: sets the document fields to return
+ *
+ * ####Examples:
+ *
+ * A.findByIdAndUpdate(id, update, options, callback) // executes
+ * A.findByIdAndUpdate(id, update, options) // returns Query
+ * A.findByIdAndUpdate(id, update, callback) // executes
+ * A.findByIdAndUpdate(id, update) // returns Query
+ * A.findByIdAndUpdate() // returns Query
+ *
+ * ####Note:
+ *
+ * All top level update keys which are not `atomic` operation names are treated as set operations:
+ *
+ * ####Example:
+ *
+ * Model.findByIdAndUpdate(id, { name: 'jason borne' }, options, callback)
+ *
+ * // is sent as
+ * Model.findByIdAndUpdate(id, { $set: { name: 'jason borne' }}, options, callback)
+ *
+ * This helps prevent accidentally overwriting your document with `{ name: 'jason borne' }`.
+ *
+ * ####Note:
+ *
+ * Values are cast to their appropriate types when using the findAndModify helpers.
+ * However, the below are never executed.
+ *
+ * - defaults
+ * - setters
+ *
+ * `findAndModify` helpers support limited defaults and validation. You can
+ * enable these by setting the `setDefaultsOnInsert` and `runValidators` options,
+ * respectively.
+ *
+ * If you need full-fledged validation, use the traditional approach of first
+ * retrieving the document.
+ *
+ * Model.findById(id, function (err, doc) {
+ * if (err) ..
+ * doc.name = 'jason borne';
+ * doc.save(callback);
+ * });
+ *
+ * @param {Object|Number|String} id value of `_id` to query by
+ * @param {Object} [update]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see Model.findOneAndUpdate #model_Model.findOneAndUpdate
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @api public
+ */
+
+Model.findByIdAndUpdate = function(id, update, options, callback) {
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+ if (arguments.length === 1) {
+ if (typeof id === 'function') {
+ var msg = 'Model.findByIdAndUpdate(): First argument must not be a function.\n\n'
+ + ' ' + this.modelName + '.findByIdAndUpdate(id, callback)\n'
+ + ' ' + this.modelName + '.findByIdAndUpdate(id)\n'
+ + ' ' + this.modelName + '.findByIdAndUpdate()\n';
+ throw new TypeError(msg);
+ }
+ return this.findOneAndUpdate({_id: id}, undefined);
+ }
+
+ // if a model is passed in instead of an id
+ if (id instanceof Document) {
+ id = id._id;
+ }
+
+ return this.findOneAndUpdate.call(this, {_id: id}, update, options, callback);
+};
+
+/**
+ * Issue a mongodb findAndModify remove command.
+ *
+ * Finds a matching document, removes it, passing the found document (if any) to the callback.
+ *
+ * Executes immediately if `callback` is passed else a Query object is returned.
+ *
+ * ####Options:
+ *
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
+ * - `select`: sets the document fields to return
+ *
+ * ####Examples:
+ *
+ * A.findOneAndRemove(conditions, options, callback) // executes
+ * A.findOneAndRemove(conditions, options) // return Query
+ * A.findOneAndRemove(conditions, callback) // executes
+ * A.findOneAndRemove(conditions) // returns Query
+ * A.findOneAndRemove() // returns Query
+ *
+ * Values are cast to their appropriate types when using the findAndModify helpers.
+ * However, the below are never executed.
+ *
+ * - defaults
+ * - setters
+ *
+ * `findAndModify` helpers support limited defaults and validation. You can
+ * enable these by setting the `setDefaultsOnInsert` and `runValidators` options,
+ * respectively.
+ *
+ * If you need full-fledged validation, use the traditional approach of first
+ * retrieving the document.
+ *
+ * Model.findById(id, function (err, doc) {
+ * if (err) ..
+ * doc.name = 'jason borne';
+ * doc.save(callback);
+ * });
+ *
+ * @param {Object} conditions
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @api public
+ */
+
+Model.findOneAndRemove = function(conditions, options, callback) {
+ if (arguments.length === 1 && typeof conditions === 'function') {
+ var msg = 'Model.findOneAndRemove(): First argument must not be a function.\n\n'
+ + ' ' + this.modelName + '.findOneAndRemove(conditions, callback)\n'
+ + ' ' + this.modelName + '.findOneAndRemove(conditions)\n'
+ + ' ' + this.modelName + '.findOneAndRemove()\n';
+ throw new TypeError(msg);
+ }
+
+ if (typeof options === 'function') {
+ callback = options;
+ options = undefined;
+ }
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var fields;
+ if (options) {
+ fields = options.select;
+ options.select = undefined;
+ }
+
+ var mq = new this.Query({}, {}, this, this.collection);
+ mq.select(fields);
+
+ return mq.findOneAndRemove(conditions, options, callback);
+};
+
+/**
+ * Issue a mongodb findAndModify remove command by a document's _id field. `findByIdAndRemove(id, ...)` is equivalent to `findOneAndRemove({ _id: id }, ...)`.
+ *
+ * Finds a matching document, removes it, passing the found document (if any) to the callback.
+ *
+ * Executes immediately if `callback` is passed, else a `Query` object is returned.
+ *
+ * ####Options:
+ *
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `select`: sets the document fields to return
+ *
+ * ####Examples:
+ *
+ * A.findByIdAndRemove(id, options, callback) // executes
+ * A.findByIdAndRemove(id, options) // return Query
+ * A.findByIdAndRemove(id, callback) // executes
+ * A.findByIdAndRemove(id) // returns Query
+ * A.findByIdAndRemove() // returns Query
+ *
+ * @param {Object|Number|String} id value of `_id` to query by
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query}
+ * @see Model.findOneAndRemove #model_Model.findOneAndRemove
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ */
+
+Model.findByIdAndRemove = function(id, options, callback) {
+ if (arguments.length === 1 && typeof id === 'function') {
+ var msg = 'Model.findByIdAndRemove(): First argument must not be a function.\n\n'
+ + ' ' + this.modelName + '.findByIdAndRemove(id, callback)\n'
+ + ' ' + this.modelName + '.findByIdAndRemove(id)\n'
+ + ' ' + this.modelName + '.findByIdAndRemove()\n';
+ throw new TypeError(msg);
+ }
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ return this.findOneAndRemove({_id: id}, options, callback);
+};
+
+/**
+ * Shortcut for saving one or more documents to the database.
+ * `MyModel.create(docs)` does `new MyModel(doc).save()` for every doc in
+ * docs.
+ *
+ * Hooks Triggered:
+ * - `save()`
+ *
+ * ####Example:
+ *
+ * // pass individual docs
+ * Candy.create({ type: 'jelly bean' }, { type: 'snickers' }, function (err, jellybean, snickers) {
+ * if (err) // ...
+ * });
+ *
+ * // pass an array
+ * var array = [{ type: 'jelly bean' }, { type: 'snickers' }];
+ * Candy.create(array, function (err, candies) {
+ * if (err) // ...
+ *
+ * var jellybean = candies[0];
+ * var snickers = candies[1];
+ * // ...
+ * });
+ *
+ * // callback is optional; use the returned promise if you like:
+ * var promise = Candy.create({ type: 'jawbreaker' });
+ * promise.then(function (jawbreaker) {
+ * // ...
+ * })
+ *
+ * @param {Array|Object|*} doc(s)
+ * @param {Function} [callback] callback
+ * @return {Promise}
+ * @api public
+ */
+
+Model.create = function create(doc, callback) {
+ var args;
+ var cb;
+
+ if (Array.isArray(doc)) {
+ args = doc;
+ cb = callback;
+ } else {
+ var last = arguments[arguments.length - 1];
+ if (typeof last === 'function') {
+ cb = last;
+ args = utils.args(arguments, 0, arguments.length - 1);
+ } else {
+ args = utils.args(arguments);
+ }
+ }
+
+ var Promise = PromiseProvider.get();
+ var _this = this;
+ if (cb) {
+ cb = this.$wrapCallback(cb);
+ }
+
+ var promise = new Promise.ES6(function(resolve, reject) {
+ if (args.length === 0) {
+ setImmediate(function() {
+ cb && cb(null);
+ resolve(null);
+ });
+ return;
+ }
+
+ var toExecute = [];
+ args.forEach(function(doc) {
+ toExecute.push(function(callback) {
+ var toSave = doc instanceof _this ? doc : new _this(doc);
+ var callbackWrapper = function(error, doc) {
+ if (error) {
+ return callback(error);
+ }
+ callback(null, doc);
+ };
+
+ // Hack to avoid getting a promise because of
+ // $__registerHooksFromSchema
+ if (toSave.$__original_save) {
+ toSave.$__original_save({ __noPromise: true }, callbackWrapper);
+ } else {
+ toSave.save({ __noPromise: true }, callbackWrapper);
+ }
+ });
+ });
+
+ parallel(toExecute, function(error, savedDocs) {
+ if (error) {
+ if (cb) {
+ cb(error);
+ } else {
+ reject(error);
+ }
+ return;
+ }
+
+ if (doc instanceof Array) {
+ resolve(savedDocs);
+ cb && cb.call(_this, null, savedDocs);
+ } else {
+ resolve.apply(promise, savedDocs);
+ if (cb) {
+ savedDocs.unshift(null);
+ cb.apply(_this, savedDocs);
+ }
+ }
+ });
+ });
+
+ return promise;
+};
+
+/**
+ * Shortcut for validating an array of documents and inserting them into
+ * MongoDB if they're all valid. This function is faster than `.create()`
+ * because it only sends one operation to the server, rather than one for each
+ * document.
+ *
+ * This function does **not** trigger save middleware.
+ *
+ * ####Example:
+ *
+ * var arr = [{ name: 'Star Wars' }, { name: 'The Empire Strikes Back' }];
+ * Movies.insertMany(arr, function(error, docs) {});
+ *
+ * @param {Array|Object|*} doc(s)
+ * @param {Function} [callback] callback
+ * @return {Promise}
+ * @api public
+ */
+
+Model.insertMany = function(arr, callback) {
+ var _this = this;
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var toExecute = [];
+ arr.forEach(function(doc) {
+ toExecute.push(function(callback) {
+ doc = new _this(doc);
+ doc.validate({ __noPromise: true }, function(error) {
+ if (error) {
+ return callback(error);
+ }
+ callback(null, doc);
+ });
+ });
+ });
+
+ parallel(toExecute, function(error, docs) {
+ if (error) {
+ callback && callback(error);
+ return;
+ }
+ var docObjects = docs.map(function(doc) {
+ if (doc.schema.options.versionKey) {
+ doc[doc.schema.options.versionKey] = 0;
+ }
+ if (doc.initializeTimestamps) {
+ return doc.initializeTimestamps().toObject(POJO_TO_OBJECT_OPTIONS);
+ }
+ return doc.toObject(POJO_TO_OBJECT_OPTIONS);
+ });
+ _this.collection.insertMany(docObjects, function(error) {
+ if (error) {
+ callback && callback(error);
+ return;
+ }
+ for (var i = 0; i < docs.length; ++i) {
+ docs[i].isNew = false;
+ docs[i].emit('isNew', false);
+ }
+ callback && callback(null, docs);
+ });
+ });
+};
+
+/**
+ * Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
+ * The document returned has no paths marked as modified initially.
+ *
+ * ####Example:
+ *
+ * // hydrate previous data into a Mongoose document
+ * var mongooseCandy = Candy.hydrate({ _id: '54108337212ffb6d459f854c', type: 'jelly bean' });
+ *
+ * @param {Object} obj
+ * @return {Document}
+ * @api public
+ */
+
+Model.hydrate = function(obj) {
+ var model = require('./queryhelpers').createModel(this, obj);
+ model.init(obj);
+ return model;
+};
+
+/**
+ * Updates documents in the database without returning them.
+ *
+ * ####Examples:
+ *
+ * MyModel.update({ age: { $gt: 18 } }, { oldEnough: true }, fn);
+ * MyModel.update({ name: 'Tobi' }, { ferret: true }, { multi: true }, function (err, raw) {
+ * if (err) return handleError(err);
+ * console.log('The raw response from Mongo was ', raw);
+ * });
+ *
+ * ####Valid options:
+ *
+ * - `safe` (boolean) safe mode (defaults to value set in schema (true))
+ * - `upsert` (boolean) whether to create the doc if it doesn't match (false)
+ * - `multi` (boolean) whether multiple documents should be updated (false)
+ * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
+ * - `setDefaultsOnInsert`: if this and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. This option only works on MongoDB >= 2.4 because it relies on [MongoDB's `$setOnInsert` operator](https://docs.mongodb.org/v2.4/reference/operator/update/setOnInsert/).
+ * - `strict` (boolean) overrides the `strict` option for this update
+ * - `overwrite` (boolean) disables update-only mode, allowing you to overwrite the doc (false)
+ *
+ * All `update` values are cast to their appropriate SchemaTypes before being sent.
+ *
+ * The `callback` function receives `(err, rawResponse)`.
+ *
+ * - `err` is the error if any occurred
+ * - `rawResponse` is the full response from Mongo
+ *
+ * ####Note:
+ *
+ * All top level keys which are not `atomic` operation names are treated as set operations:
+ *
+ * ####Example:
+ *
+ * var query = { name: 'borne' };
+ * Model.update(query, { name: 'jason borne' }, options, callback)
+ *
+ * // is sent as
+ * Model.update(query, { $set: { name: 'jason borne' }}, options, callback)
+ * // if overwrite option is false. If overwrite is true, sent without the $set wrapper.
+ *
+ * This helps prevent accidentally overwriting all documents in your collection with `{ name: 'jason borne' }`.
+ *
+ * ####Note:
+ *
+ * Be careful to not use an existing model instance for the update clause (this won't work and can cause weird behavior like infinite loops). Also, ensure that the update clause does not have an _id property, which causes Mongo to return a "Mod on _id not allowed" error.
+ *
+ * ####Note:
+ *
+ * To update documents without waiting for a response from MongoDB, do not pass a `callback`, then call `exec` on the returned [Query](#query-js):
+ *
+ * Comment.update({ _id: id }, { $set: { text: 'changed' }}).exec();
+ *
+ * ####Note:
+ *
+ * Although values are casted to their appropriate types when using update, the following are *not* applied:
+ *
+ * - defaults
+ * - setters
+ * - validators
+ * - middleware
+ *
+ * If you need those features, use the traditional approach of first retrieving the document.
+ *
+ * Model.findOne({ name: 'borne' }, function (err, doc) {
+ * if (err) ..
+ * doc.name = 'jason borne';
+ * doc.save(callback);
+ * })
+ *
+ * @see strict http://mongoosejs.com/docs/guide.html#strict
+ * @see response http://docs.mongodb.org/v2.6/reference/command/update/#output
+ * @param {Object} conditions
+ * @param {Object} doc
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query}
+ * @api public
+ */
+
+Model.update = function update(conditions, doc, options, callback) {
+ var mq = new this.Query({}, {}, this, this.collection);
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+ // gh-2406
+ // make local deep copy of conditions
+ if (conditions instanceof Document) {
+ conditions = conditions.toObject();
+ } else {
+ conditions = utils.clone(conditions, {retainKeyOrder: true});
+ }
+ options = typeof options === 'function' ? options : utils.clone(options);
+
+ if (this.schema.options.versionKey && options && options.upsert) {
+ if (!doc.$setOnInsert) {
+ doc.$setOnInsert = {};
+ }
+ doc.$setOnInsert[this.schema.options.versionKey] = 0;
+ }
+
+ return mq.update(conditions, doc, options, callback);
+};
+
+/**
+ * Executes a mapReduce command.
+ *
+ * `o` is an object specifying all mapReduce options as well as the map and reduce functions. All options are delegated to the driver implementation. See [node-mongodb-native mapReduce() documentation](http://mongodb.github.io/node-mongodb-native/api-generated/collection.html#mapreduce) for more detail about options.
+ *
+ * ####Example:
+ *
+ * var o = {};
+ * o.map = function () { emit(this.name, 1) }
+ * o.reduce = function (k, vals) { return vals.length }
+ * User.mapReduce(o, function (err, results) {
+ * console.log(results)
+ * })
+ *
+ * ####Other options:
+ *
+ * - `query` {Object} query filter object.
+ * - `sort` {Object} sort input objects using this key
+ * - `limit` {Number} max number of documents
+ * - `keeptemp` {Boolean, default:false} keep temporary data
+ * - `finalize` {Function} finalize function
+ * - `scope` {Object} scope variables exposed to map/reduce/finalize during execution
+ * - `jsMode` {Boolean, default:false} it is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X
+ * - `verbose` {Boolean, default:false} provide statistics on job execution time.
+ * - `readPreference` {String}
+ * - `out*` {Object, default: {inline:1}} sets the output target for the map reduce job.
+ *
+ * ####* out options:
+ *
+ * - `{inline:1}` the results are returned in an array
+ * - `{replace: 'collectionName'}` add the results to collectionName: the results replace the collection
+ * - `{reduce: 'collectionName'}` add the results to collectionName: if dups are detected, uses the reducer / finalize functions
+ * - `{merge: 'collectionName'}` add the results to collectionName: if dups exist the new docs overwrite the old
+ *
+ * If `options.out` is set to `replace`, `merge`, or `reduce`, a Model instance is returned that can be used for further querying. Queries run against this model are all executed with the `lean` option; meaning only the js object is returned and no Mongoose magic is applied (getters, setters, etc).
+ *
+ * ####Example:
+ *
+ * var o = {};
+ * o.map = function () { emit(this.name, 1) }
+ * o.reduce = function (k, vals) { return vals.length }
+ * o.out = { replace: 'createdCollectionNameForResults' }
+ * o.verbose = true;
+ *
+ * User.mapReduce(o, function (err, model, stats) {
+ * console.log('map reduce took %d ms', stats.processtime)
+ * model.find().where('value').gt(10).exec(function (err, docs) {
+ * console.log(docs);
+ * });
+ * })
+ *
+ * // a promise is returned so you may instead write
+ * var promise = User.mapReduce(o);
+ * promise.then(function (model, stats) {
+ * console.log('map reduce took %d ms', stats.processtime)
+ * return model.find().where('value').gt(10).exec();
+ * }).then(function (docs) {
+ * console.log(docs);
+ * }).then(null, handleError).end()
+ *
+ * @param {Object} o an object specifying map-reduce options
+ * @param {Function} [callback] optional callback
+ * @see http://www.mongodb.org/display/DOCS/MapReduce
+ * @return {Promise}
+ * @api public
+ */
+
+Model.mapReduce = function mapReduce(o, callback) {
+ var _this = this;
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ if (!Model.mapReduce.schema) {
+ var opts = {noId: true, noVirtualId: true, strict: false};
+ Model.mapReduce.schema = new Schema({}, opts);
+ }
+
+ if (!o.out) o.out = {inline: 1};
+ if (o.verbose !== false) o.verbose = true;
+
+ o.map = String(o.map);
+ o.reduce = String(o.reduce);
+
+ if (o.query) {
+ var q = new _this.Query(o.query);
+ q.cast(_this);
+ o.query = q._conditions;
+ q = undefined;
+ }
+
+ _this.collection.mapReduce(null, null, o, function(err, ret, stats) {
+ if (err) {
+ callback && callback(err);
+ reject(err);
+ return;
+ }
+
+ if (ret.findOne && ret.mapReduce) {
+ // returned a collection, convert to Model
+ var model = Model.compile(
+ '_mapreduce_' + ret.collectionName
+ , Model.mapReduce.schema
+ , ret.collectionName
+ , _this.db
+ , _this.base);
+
+ model._mapreduce = true;
+
+ callback && callback(null, model, stats);
+ return resolve(model, stats);
+ }
+
+ callback && callback(null, ret, stats);
+ resolve(ret, stats);
+ });
+ });
+};
+
+/**
+ * geoNear support for Mongoose
+ *
+ * ####Options:
+ * - `lean` {Boolean} return the raw object
+ * - All options supported by the driver are also supported
+ *
+ * ####Example:
+ *
+ * // Legacy point
+ * Model.geoNear([1,3], { maxDistance : 5, spherical : true }, function(err, results, stats) {
+ * console.log(results);
+ * });
+ *
+ * // geoJson
+ * var point = { type : "Point", coordinates : [9,9] };
+ * Model.geoNear(point, { maxDistance : 5, spherical : true }, function(err, results, stats) {
+ * console.log(results);
+ * });
+ *
+ * @param {Object|Array} GeoJSON point or legacy coordinate pair [x,y] to search near
+ * @param {Object} options for the qurery
+ * @param {Function} [callback] optional callback for the query
+ * @return {Promise}
+ * @see http://docs.mongodb.org/manual/core/2dsphere/
+ * @see http://mongodb.github.io/node-mongodb-native/api-generated/collection.html?highlight=geonear#geoNear
+ * @api public
+ */
+
+Model.geoNear = function(near, options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ if (!near) {
+ return new Promise.ES6(function(resolve, reject) {
+ var error = new Error('Must pass a near option to geoNear');
+ reject(error);
+ callback && callback(error);
+ });
+ }
+
+ var x, y;
+
+ return new Promise.ES6(function(resolve, reject) {
+ var handler = function(err, res) {
+ if (err) {
+ reject(err);
+ callback && callback(err);
+ return;
+ }
+ if (options.lean) {
+ resolve(res.results, res.stats);
+ callback && callback(null, res.results, res.stats);
+ return;
+ }
+
+ var count = res.results.length;
+ // if there are no results, fulfill the promise now
+ if (count === 0) {
+ resolve(res.results, res.stats);
+ callback && callback(null, res.results, res.stats);
+ return;
+ }
+
+ var errSeen = false;
+
+ function init(err) {
+ if (err && !errSeen) {
+ errSeen = true;
+ reject(err);
+ callback && callback(err);
+ return;
+ }
+ if (--count <= 0) {
+ resolve(res.results, res.stats);
+ callback && callback(null, res.results, res.stats);
+ }
+ }
+
+ for (var i = 0; i < res.results.length; i++) {
+ var temp = res.results[i].obj;
+ res.results[i].obj = new _this();
+ res.results[i].obj.init(temp, init);
+ }
+ };
+
+ if (Array.isArray(near)) {
+ if (near.length !== 2) {
+ var error = new Error('If using legacy coordinates, must be an array ' +
+ 'of size 2 for geoNear');
+ reject(error);
+ callback && callback(error);
+ return;
+ }
+ x = near[0];
+ y = near[1];
+ _this.collection.geoNear(x, y, options, handler);
+ } else {
+ if (near.type !== 'Point' || !Array.isArray(near.coordinates)) {
+ error = new Error('Must pass either a legacy coordinate array or ' +
+ 'GeoJSON Point to geoNear');
+ reject(error);
+ callback && callback(error);
+ return;
+ }
+
+ _this.collection.geoNear(near, options, handler);
+ }
+ });
+};
+
+/**
+ * Performs [aggregations](http://docs.mongodb.org/manual/applications/aggregation/) on the models collection.
+ *
+ * If a `callback` is passed, the `aggregate` is executed and a `Promise` is returned. If a callback is not passed, the `aggregate` itself is returned.
+ *
+ * ####Example:
+ *
+ * // Find the max balance of all accounts
+ * Users.aggregate(
+ * { $group: { _id: null, maxBalance: { $max: '$balance' }}}
+ * , { $project: { _id: 0, maxBalance: 1 }}
+ * , function (err, res) {
+ * if (err) return handleError(err);
+ * console.log(res); // [ { maxBalance: 98000 } ]
+ * });
+ *
+ * // Or use the aggregation pipeline builder.
+ * Users.aggregate()
+ * .group({ _id: null, maxBalance: { $max: '$balance' } })
+ * .select('-id maxBalance')
+ * .exec(function (err, res) {
+ * if (err) return handleError(err);
+ * console.log(res); // [ { maxBalance: 98 } ]
+ * });
+ *
+ * ####NOTE:
+ *
+ * - Arguments are not cast to the model's schema because `$project` operators allow redefining the "shape" of the documents at any stage of the pipeline, which may leave documents in an incompatible format.
+ * - The documents returned are plain javascript objects, not mongoose documents (since any shape of document can be returned).
+ * - Requires MongoDB >= 2.1
+ *
+ * @see Aggregate #aggregate_Aggregate
+ * @see MongoDB http://docs.mongodb.org/manual/applications/aggregation/
+ * @param {Object|Array} [...] aggregation pipeline operator(s) or operator array
+ * @param {Function} [callback]
+ * @return {Aggregate|Promise}
+ * @api public
+ */
+
+Model.aggregate = function aggregate() {
+ var args = [].slice.call(arguments),
+ aggregate,
+ callback;
+
+ if (typeof args[args.length - 1] === 'function') {
+ callback = args.pop();
+ }
+
+ if (args.length === 1 && util.isArray(args[0])) {
+ aggregate = new Aggregate(args[0]);
+ } else {
+ aggregate = new Aggregate(args);
+ }
+
+ aggregate.model(this);
+
+ if (typeof callback === 'undefined') {
+ return aggregate;
+ }
+
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ aggregate.exec(callback);
+};
+
+/**
+ * Implements `$geoSearch` functionality for Mongoose
+ *
+ * ####Example:
+ *
+ * var options = { near: [10, 10], maxDistance: 5 };
+ * Locations.geoSearch({ type : "house" }, options, function(err, res) {
+ * console.log(res);
+ * });
+ *
+ * ####Options:
+ * - `near` {Array} x,y point to search for
+ * - `maxDistance` {Number} the maximum distance from the point near that a result can be
+ * - `limit` {Number} The maximum number of results to return
+ * - `lean` {Boolean} return the raw object instead of the Mongoose Model
+ *
+ * @param {Object} conditions an object that specifies the match condition (required)
+ * @param {Object} options for the geoSearch, some (near, maxDistance) are required
+ * @param {Function} [callback] optional callback
+ * @return {Promise}
+ * @see http://docs.mongodb.org/manual/reference/command/geoSearch/
+ * @see http://docs.mongodb.org/manual/core/geohaystack/
+ * @api public
+ */
+
+Model.geoSearch = function(conditions, options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ var _this = this;
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ var error;
+ if (conditions === undefined || !utils.isObject(conditions)) {
+ error = new Error('Must pass conditions to geoSearch');
+ } else if (!options.near) {
+ error = new Error('Must specify the near option in geoSearch');
+ } else if (!Array.isArray(options.near)) {
+ error = new Error('near option must be an array [x, y]');
+ }
+
+ if (error) {
+ callback && callback(error);
+ reject(error);
+ return;
+ }
+
+ // send the conditions in the options object
+ options.search = conditions;
+
+ _this.collection.geoHaystackSearch(options.near[0], options.near[1], options, function(err, res) {
+ // have to deal with driver problem. Should be fixed in a soon-ish release
+ // (7/8/2013)
+ if (err) {
+ callback && callback(err);
+ reject(err);
+ return;
+ }
+
+ var count = res.results.length;
+ if (options.lean || count === 0) {
+ callback && callback(null, res.results, res.stats);
+ resolve(res.results, res.stats);
+ return;
+ }
+
+ var errSeen = false;
+
+ function init(err) {
+ if (err && !errSeen) {
+ callback && callback(err);
+ reject(err);
+ return;
+ }
+
+ if (!--count && !errSeen) {
+ callback && callback(null, res.results, res.stats);
+ resolve(res.results, res.stats);
+ }
+ }
+
+ for (var i = 0; i < res.results.length; i++) {
+ var temp = res.results[i];
+ res.results[i] = new _this();
+ res.results[i].init(temp, {}, init);
+ }
+ });
+ });
+};
+
+/**
+ * Populates document references.
+ *
+ * ####Available options:
+ *
+ * - path: space delimited path(s) to populate
+ * - select: optional fields to select
+ * - match: optional query conditions to match
+ * - model: optional name of the model to use for population
+ * - options: optional query options like sort, limit, etc
+ *
+ * ####Examples:
+ *
+ * // populates a single object
+ * User.findById(id, function (err, user) {
+ * var opts = [
+ * { path: 'company', match: { x: 1 }, select: 'name' }
+ * , { path: 'notes', options: { limit: 10 }, model: 'override' }
+ * ]
+ *
+ * User.populate(user, opts, function (err, user) {
+ * console.log(user);
+ * })
+ * })
+ *
+ * // populates an array of objects
+ * User.find(match, function (err, users) {
+ * var opts = [{ path: 'company', match: { x: 1 }, select: 'name' }]
+ *
+ * var promise = User.populate(users, opts);
+ * promise.then(console.log).end();
+ * })
+ *
+ * // imagine a Weapon model exists with two saved documents:
+ * // { _id: 389, name: 'whip' }
+ * // { _id: 8921, name: 'boomerang' }
+ *
+ * var user = { name: 'Indiana Jones', weapon: 389 }
+ * Weapon.populate(user, { path: 'weapon', model: 'Weapon' }, function (err, user) {
+ * console.log(user.weapon.name) // whip
+ * })
+ *
+ * // populate many plain objects
+ * var users = [{ name: 'Indiana Jones', weapon: 389 }]
+ * users.push({ name: 'Batman', weapon: 8921 })
+ * Weapon.populate(users, { path: 'weapon' }, function (err, users) {
+ * users.forEach(function (user) {
+ * console.log('%s uses a %s', users.name, user.weapon.name)
+ * // Indiana Jones uses a whip
+ * // Batman uses a boomerang
+ * })
+ * })
+ * // Note that we didn't need to specify the Weapon model because
+ * // we were already using it's populate() method.
+ *
+ * @param {Document|Array} docs Either a single document or array of documents to populate.
+ * @param {Object} options A hash of key/val (path, options) used for population.
+ * @param {Function} [callback(err,doc)] Optional callback, executed upon completion. Receives `err` and the `doc(s)`.
+ * @return {Promise}
+ * @api public
+ */
+
+Model.populate = function(docs, paths, callback) {
+ var _this = this;
+ if (callback) {
+ callback = this.$wrapCallback(callback);
+ }
+
+ // normalized paths
+ var noPromise = paths && !!paths.__noPromise;
+ paths = utils.populate(paths);
+
+ // data that should persist across subPopulate calls
+ var cache = {};
+
+ if (noPromise) {
+ _populate(this, docs, paths, cache, callback);
+ } else {
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ _populate(_this, docs, paths, cache, function(error, docs) {
+ if (error) {
+ callback && callback(error);
+ reject(error);
+ } else {
+ callback && callback(null, docs);
+ resolve(docs);
+ }
+ });
+ });
+ }
+};
+
+/*!
+ * Populate helper
+ *
+ * @param {Model} model the model to use
+ * @param {Document|Array} docs Either a single document or array of documents to populate.
+ * @param {Object} paths
+ * @param {Function} [cb(err,doc)] Optional callback, executed upon completion. Receives `err` and the `doc(s)`.
+ * @return {Function}
+ * @api private
+ */
+
+function _populate(model, docs, paths, cache, callback) {
+ var pending = paths.length;
+
+ if (pending === 0) {
+ return callback(null, docs);
+ }
+
+ // each path has its own query options and must be executed separately
+ var i = pending;
+ var path;
+ while (i--) {
+ path = paths[i];
+ populate(model, docs, path, next);
+ }
+
+ function next(err) {
+ if (err) {
+ return callback(err);
+ }
+ if (--pending) {
+ return;
+ }
+ callback(null, docs);
+ }
+}
+
+/*!
+ * Populates `docs`
+ */
+var excludeIdReg = /\s?-_id\s?/,
+ excludeIdRegGlobal = /\s?-_id\s?/g;
+
+function populate(model, docs, options, callback) {
+ var modelsMap;
+
+ // normalize single / multiple docs passed
+ if (!Array.isArray(docs)) {
+ docs = [docs];
+ }
+
+ if (docs.length === 0 || docs.every(utils.isNullOrUndefined)) {
+ return callback();
+ }
+
+ modelsMap = getModelsMapForPopulate(model, docs, options);
+
+ var i, len = modelsMap.length,
+ mod, match, select, vals = [];
+
+ function flatten(item) {
+ // no need to include undefined values in our query
+ return undefined !== item;
+ }
+
+ var _remaining = len;
+ var hasOne = false;
+ for (i = 0; i < len; i++) {
+ mod = modelsMap[i];
+ select = mod.options.select;
+
+ if (mod.options.match) {
+ match = utils.object.shallowCopy(mod.options.match);
+ } else {
+ match = {};
+ }
+
+ var ids = utils.array.flatten(mod.ids, flatten);
+ ids = utils.array.unique(ids);
+
+ if (ids.length === 0 || ids.every(utils.isNullOrUndefined)) {
+ --_remaining;
+ continue;
+ }
+
+ hasOne = true;
+ if (mod.foreignField !== '_id' || !match['_id']) {
+ match[mod.foreignField] = { $in: ids };
+ }
+
+ var assignmentOpts = {};
+ assignmentOpts.sort = mod.options.options && mod.options.options.sort || undefined;
+ assignmentOpts.excludeId = excludeIdReg.test(select) || (select && select._id === 0);
+
+ if (assignmentOpts.excludeId) {
+ // override the exclusion from the query so we can use the _id
+ // for document matching during assignment. we'll delete the
+ // _id back off before returning the result.
+ if (typeof select === 'string') {
+ select = select.replace(excludeIdRegGlobal, ' ');
+ } else {
+ // preserve original select conditions by copying
+ select = utils.object.shallowCopy(select);
+ delete select._id;
+ }
+ }
+
+ if (mod.options.options && mod.options.options.limit) {
+ assignmentOpts.originalLimit = mod.options.options.limit;
+ mod.options.options.limit = mod.options.options.limit * ids.length;
+ }
+
+ var subPopulate = mod.options.populate;
+ var query = mod.Model.find(match, select, mod.options.options);
+ if (subPopulate) {
+ query.populate(subPopulate);
+ }
+ query.exec(next.bind(this, mod, assignmentOpts));
+ }
+
+ if (!hasOne) {
+ return callback();
+ }
+
+ function next(options, assignmentOpts, err, valsFromDb) {
+ if (err) return callback(err);
+ vals = vals.concat(valsFromDb);
+ _assign(null, vals, options, assignmentOpts);
+ if (--_remaining === 0) {
+ callback();
+ }
+ }
+
+ function _assign(err, vals, mod, assignmentOpts) {
+ if (err) return callback(err);
+
+ var options = mod.options;
+ var _val;
+ var lean = options.options && options.options.lean,
+ len = vals.length,
+ rawOrder = {}, rawDocs = {}, key, val;
+
+ // optimization:
+ // record the document positions as returned by
+ // the query result.
+ for (var i = 0; i < len; i++) {
+ val = vals[i];
+ if (val) {
+ _val = utils.getValue(mod.foreignField, val);
+ if (Array.isArray(_val)) {
+ var _valLength = _val.length;
+ for (var j = 0; j < _valLength; ++j) {
+ if (_val[j] instanceof Document) {
+ _val[j] = _val[j]._id;
+ }
+ key = String(_val[j]);
+ if (rawDocs[key]) {
+ if (Array.isArray(rawDocs[key])) {
+ rawDocs[key].push(val);
+ rawOrder[key].push(i);
+ } else {
+ rawDocs[key] = [rawDocs[key], val];
+ rawOrder[key] = [rawOrder[key], i];
+ }
+ } else {
+ rawDocs[key] = val;
+ rawOrder[key] = i;
+ }
+ }
+ } else {
+ if (_val instanceof Document) {
+ _val = _val._id;
+ }
+ key = String(_val);
+ if (rawDocs[key]) {
+ if (Array.isArray(rawDocs[key])) {
+ rawDocs[key].push(val);
+ rawOrder[key].push(i);
+ } else {
+ rawDocs[key] = [rawDocs[key], val];
+ rawOrder[key] = [rawOrder[key], i];
+ }
+ } else {
+ rawDocs[key] = val;
+ rawOrder[key] = i;
+ }
+ }
+ // flag each as result of population
+ if (!lean) {
+ val.$__.wasPopulated = true;
+ }
+ }
+ }
+
+ assignVals({
+ originalModel: model,
+ rawIds: mod.ids,
+ localField: mod.localField,
+ foreignField: mod.foreignField,
+ rawDocs: rawDocs,
+ rawOrder: rawOrder,
+ docs: mod.docs,
+ path: options.path,
+ options: assignmentOpts,
+ justOne: mod.justOne,
+ isVirtual: mod.isVirtual
+ });
+ }
+}
+
+/*!
+ * Assigns documents returned from a population query back
+ * to the original document path.
+ */
+
+function assignVals(o) {
+ // replace the original ids in our intermediate _ids structure
+ // with the documents found by query
+ assignRawDocsToIdStructure(o.rawIds, o.rawDocs, o.rawOrder, o.options,
+ o.localField, o.foreignField);
+
+ // now update the original documents being populated using the
+ // result structure that contains real documents.
+
+ var docs = o.docs;
+ var rawIds = o.rawIds;
+ var options = o.options;
+
+ function setValue(val) {
+ return valueFilter(val, options);
+ }
+
+ for (var i = 0; i < docs.length; ++i) {
+ if (utils.getValue(o.path, docs[i]) == null &&
+ !o.originalModel.schema._getVirtual(o.path)) {
+ continue;
+ }
+
+ if (o.isVirtual && !o.justOne && !Array.isArray(rawIds[i])) {
+ rawIds[i] = [rawIds[i]];
+ }
+ utils.setValue(o.path, rawIds[i], docs[i], setValue);
+ }
+}
+
+/*!
+ * Assign `vals` returned by mongo query to the `rawIds`
+ * structure returned from utils.getVals() honoring
+ * query sort order if specified by user.
+ *
+ * This can be optimized.
+ *
+ * Rules:
+ *
+ * if the value of the path is not an array, use findOne rules, else find.
+ * for findOne the results are assigned directly to doc path (including null results).
+ * for find, if user specified sort order, results are assigned directly
+ * else documents are put back in original order of array if found in results
+ *
+ * @param {Array} rawIds
+ * @param {Array} vals
+ * @param {Boolean} sort
+ * @api private
+ */
+
+function assignRawDocsToIdStructure(rawIds, resultDocs, resultOrder, options, localFields, foreignFields, recursed) {
+ // honor user specified sort order
+ var newOrder = [];
+ var sorting = options.sort && rawIds.length > 1;
+ var doc;
+ var sid;
+ var id;
+
+ for (var i = 0; i < rawIds.length; ++i) {
+ id = rawIds[i];
+
+ if (Array.isArray(id)) {
+ // handle [ [id0, id2], [id3] ]
+ assignRawDocsToIdStructure(id, resultDocs, resultOrder, options, localFields, foreignFields, true);
+ newOrder.push(id);
+ continue;
+ }
+
+ if (id === null && !sorting) {
+ // keep nulls for findOne unless sorting, which always
+ // removes them (backward compat)
+ newOrder.push(id);
+ continue;
+ }
+
+ sid = String(id);
+
+ if (recursed) {
+ // apply find behavior
+
+ // assign matching documents in original order unless sorting
+ doc = resultDocs[sid];
+ if (doc) {
+ if (sorting) {
+ newOrder[resultOrder[sid]] = doc;
+ } else {
+ newOrder.push(doc);
+ }
+ } else {
+ newOrder.push(id);
+ }
+ } else {
+ // apply findOne behavior - if document in results, assign, else assign null
+ newOrder[i] = doc = resultDocs[sid] || null;
+ }
+ }
+
+ rawIds.length = 0;
+ if (newOrder.length) {
+ // reassign the documents based on corrected order
+
+ // forEach skips over sparse entries in arrays so we
+ // can safely use this to our advantage dealing with sorted
+ // result sets too.
+ newOrder.forEach(function(doc, i) {
+ if (!doc) {
+ return;
+ }
+ rawIds[i] = doc;
+ });
+ }
+}
+
+function getModelsMapForPopulate(model, docs, options) {
+ var i, doc, len = docs.length,
+ available = {},
+ map = [],
+ modelNameFromQuery = options.model && options.model.modelName || options.model,
+ schema, refPath, Model, currentOptions, modelNames, modelName, discriminatorKey, modelForFindSchema;
+
+ var originalOptions = utils.clone(options);
+ var isVirtual = false;
+
+ schema = model._getSchema(options.path);
+
+ if (schema && schema.caster) {
+ schema = schema.caster;
+ }
+
+ if (!schema && model.discriminators) {
+ discriminatorKey = model.schema.discriminatorMapping.key;
+ }
+
+ refPath = schema && schema.options && schema.options.refPath;
+
+ for (i = 0; i < len; i++) {
+ doc = docs[i];
+
+ if (refPath) {
+ modelNames = utils.getValue(refPath, doc);
+ if (Array.isArray(modelNames)) {
+ modelNames = modelNames.filter(function(v) {
+ return v != null;
+ });
+ }
+ } else {
+ if (!modelNameFromQuery) {
+ var modelForCurrentDoc = model;
+ var schemaForCurrentDoc;
+
+ if (!schema && discriminatorKey) {
+ modelForFindSchema = utils.getValue(discriminatorKey, doc);
+
+ if (modelForFindSchema) {
+ modelForCurrentDoc = model.db.model(modelForFindSchema);
+ schemaForCurrentDoc = modelForCurrentDoc._getSchema(options.path);
+
+ if (schemaForCurrentDoc && schemaForCurrentDoc.caster) {
+ schemaForCurrentDoc = schemaForCurrentDoc.caster;
+ }
+ }
+ } else {
+ schemaForCurrentDoc = schema;
+ }
+ var virtual = modelForCurrentDoc.schema._getVirtual(options.path);
+
+ if (schemaForCurrentDoc && schemaForCurrentDoc.options && schemaForCurrentDoc.options.ref) {
+ modelNames = [schemaForCurrentDoc.options.ref];
+ } else if (virtual && virtual.options && virtual.options.ref) {
+ modelNames = [virtual && virtual.options && virtual.options.ref];
+ isVirtual = true;
+ } else {
+ modelNames = [model.modelName];
+ }
+ } else {
+ modelNames = [modelNameFromQuery]; // query options
+ }
+ }
+
+ if (!modelNames) {
+ continue;
+ }
+
+ if (!Array.isArray(modelNames)) {
+ modelNames = [modelNames];
+ }
+
+ virtual = model.schema._getVirtual(options.path);
+ var localField = virtual && virtual.options ?
+ (virtual.$nestedSchemaPath ? virtual.$nestedSchemaPath + '.' : '') + virtual.options.localField :
+ options.path;
+ var foreignField = virtual && virtual.options ?
+ virtual.options.foreignField :
+ '_id';
+ var justOne = virtual && virtual.options && virtual.options.justOne;
+ if (virtual && virtual.options && virtual.options.ref) {
+ isVirtual = true;
+ }
+
+ if (virtual && (!localField || !foreignField)) {
+ throw new Error('If you are populating a virtual, you must set the ' +
+ 'localField and foreignField options');
+ }
+
+ options.isVirtual = isVirtual;
+ var ret = convertTo_id(utils.getValue(localField, doc));
+ var id = String(utils.getValue(foreignField, doc));
+ options._docs[id] = Array.isArray(ret) ? ret.slice() : ret;
+ if (doc.$__) {
+ doc.populated(options.path, options._docs[id], options);
+ }
+
+ var k = modelNames.length;
+ while (k--) {
+ modelName = modelNames[k];
+ Model = originalOptions.model && originalOptions.model.modelName ?
+ originalOptions.model :
+ model.db.model(modelName);
+
+ if (!available[modelName]) {
+ currentOptions = {
+ model: Model
+ };
+
+ if (isVirtual && virtual.options && virtual.options.options) {
+ currentOptions.options = utils.clone(virtual.options.options, {
+ retainKeyOrder: true
+ });
+ }
+ utils.merge(currentOptions, options);
+ if (schema && !discriminatorKey) {
+ currentOptions.model = Model;
+ }
+ options.model = Model;
+
+ available[modelName] = {
+ Model: Model,
+ options: currentOptions,
+ docs: [doc],
+ ids: [ret],
+ // Assume only 1 localField + foreignField
+ localField: localField,
+ foreignField: foreignField,
+ justOne: justOne,
+ isVirtual: isVirtual
+ };
+ map.push(available[modelName]);
+ } else {
+ available[modelName].docs.push(doc);
+ available[modelName].ids.push(ret);
+ }
+ }
+ }
+
+ return map;
+}
+
+/*!
+ * Retrieve the _id of `val` if a Document or Array of Documents.
+ *
+ * @param {Array|Document|Any} val
+ * @return {Array|Document|Any}
+ */
+
+function convertTo_id(val) {
+ if (val instanceof Model) return val._id;
+
+ if (Array.isArray(val)) {
+ for (var i = 0; i < val.length; ++i) {
+ if (val[i] instanceof Model) {
+ val[i] = val[i]._id;
+ }
+ }
+ if (val.isMongooseArray) {
+ return new MongooseArray(val, val._path, val._parent);
+ }
+
+ return [].concat(val);
+ }
+
+ return val;
+}
+
+/*!
+ * 1) Apply backwards compatible find/findOne behavior to sub documents
+ *
+ * find logic:
+ * a) filter out non-documents
+ * b) remove _id from sub docs when user specified
+ *
+ * findOne
+ * a) if no doc found, set to null
+ * b) remove _id from sub docs when user specified
+ *
+ * 2) Remove _ids when specified by users query.
+ *
+ * background:
+ * _ids are left in the query even when user excludes them so
+ * that population mapping can occur.
+ */
+
+function valueFilter(val, assignmentOpts) {
+ if (Array.isArray(val)) {
+ // find logic
+ var ret = [];
+ var numValues = val.length;
+ for (var i = 0; i < numValues; ++i) {
+ var subdoc = val[i];
+ if (!isDoc(subdoc)) continue;
+ maybeRemoveId(subdoc, assignmentOpts);
+ ret.push(subdoc);
+ if (assignmentOpts.originalLimit &&
+ ret.length >= assignmentOpts.originalLimit) {
+ break;
+ }
+ }
+
+ // Since we don't want to have to create a new mongoosearray, make sure to
+ // modify the array in place
+ while (val.length > ret.length) {
+ Array.prototype.pop.apply(val, []);
+ }
+ for (i = 0; i < ret.length; ++i) {
+ val[i] = ret[i];
+ }
+ return val;
+ }
+
+ // findOne
+ if (isDoc(val)) {
+ maybeRemoveId(val, assignmentOpts);
+ return val;
+ }
+
+ return null;
+}
+
+/*!
+ * Remove _id from `subdoc` if user specified "lean" query option
+ */
+
+function maybeRemoveId(subdoc, assignmentOpts) {
+ if (assignmentOpts.excludeId) {
+ if (typeof subdoc.setValue === 'function') {
+ delete subdoc._doc._id;
+ } else {
+ delete subdoc._id;
+ }
+ }
+}
+
+/*!
+ * Determine if `doc` is a document returned
+ * by a populate query.
+ */
+
+function isDoc(doc) {
+ if (doc == null) {
+ return false;
+ }
+
+ var type = typeof doc;
+ if (type === 'string') {
+ return false;
+ }
+
+ if (type === 'number') {
+ return false;
+ }
+
+ if (Buffer.isBuffer(doc)) {
+ return false;
+ }
+
+ if (doc.constructor.name === 'ObjectID') {
+ return false;
+ }
+
+ // only docs
+ return true;
+}
+
+/**
+ * Finds the schema for `path`. This is different than
+ * calling `schema.path` as it also resolves paths with
+ * positional selectors (something.$.another.$.path).
+ *
+ * @param {String} path
+ * @return {Schema}
+ * @api private
+ */
+
+Model._getSchema = function _getSchema(path) {
+ return this.schema._getSchema(path);
+};
+
+/*!
+ * Compiler utility.
+ *
+ * @param {String|Function} name model name or class extending Model
+ * @param {Schema} schema
+ * @param {String} collectionName
+ * @param {Connection} connection
+ * @param {Mongoose} base mongoose instance
+ */
+
+Model.compile = function compile(name, schema, collectionName, connection, base) {
+ var versioningEnabled = schema.options.versionKey !== false;
+
+ if (versioningEnabled && !schema.paths[schema.options.versionKey]) {
+ // add versioning to top level documents only
+ var o = {};
+ o[schema.options.versionKey] = Number;
+ schema.add(o);
+ }
+
+ var model;
+ if (typeof name === 'function' && name.prototype instanceof Model) {
+ model = name;
+ name = model.name;
+ schema.loadClass(model, true);
+ } else {
+ // generate new class
+ model = function model(doc, fields, skipId) {
+ if (!(this instanceof model)) {
+ return new model(doc, fields, skipId);
+ }
+ Model.call(this, doc, fields, skipId);
+ };
+ }
+
+ model.hooks = schema.s.hooks.clone();
+ model.base = base;
+ model.modelName = name;
+ if (!(model.prototype instanceof Model)) {
+ model.__proto__ = Model;
+ model.prototype.__proto__ = Model.prototype;
+ }
+ model.model = Model.prototype.model;
+ model.db = model.prototype.db = connection;
+ model.discriminators = model.prototype.discriminators = undefined;
+
+ model.prototype.$__setSchema(schema);
+
+ var collectionOptions = {
+ bufferCommands: schema.options.bufferCommands,
+ capped: schema.options.capped
+ };
+
+ model.prototype.collection = connection.collection(
+ collectionName
+ , collectionOptions
+ );
+
+ // apply methods and statics
+ applyMethods(model, schema);
+ applyStatics(model, schema);
+
+ model.schema = model.prototype.schema;
+ model.collection = model.prototype.collection;
+
+ // Create custom query constructor
+ model.Query = function() {
+ Query.apply(this, arguments);
+ this.options.retainKeyOrder = model.schema.options.retainKeyOrder;
+ };
+ model.Query.prototype = Object.create(Query.prototype);
+ model.Query.base = Query.base;
+ applyQueryMethods(model, schema.query);
+
+ var kareemOptions = { useErrorHandlers: true };
+ model.$__insertMany = model.hooks.createWrapper('insertMany',
+ model.insertMany, model, kareemOptions);
+ model.insertMany = function(arr, callback) {
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve, reject) {
+ model.$__insertMany(arr, function(error, result) {
+ if (error) {
+ callback && callback(error);
+ return reject(error);
+ }
+ callback && callback(null, result);
+ resolve(result);
+ });
+ });
+ };
+
+ return model;
+};
+
+/*!
+ * Register methods for this model
+ *
+ * @param {Model} model
+ * @param {Schema} schema
+ */
+var applyMethods = function(model, schema) {
+ function apply(method, schema) {
+ Object.defineProperty(model.prototype, method, {
+ get: function() {
+ var h = {};
+ for (var k in schema.methods[method]) {
+ h[k] = schema.methods[method][k].bind(this);
+ }
+ return h;
+ },
+ configurable: true
+ });
+ }
+ for (var method in schema.methods) {
+ if (schema.tree.hasOwnProperty(method)) {
+ throw new Error('You have a method and a property in your schema both ' +
+ 'named "' + method + '"');
+ }
+ if (typeof schema.methods[method] === 'function') {
+ model.prototype[method] = schema.methods[method];
+ } else {
+ apply(method, schema);
+ }
+ }
+};
+
+/*!
+ * Register statics for this model
+ * @param {Model} model
+ * @param {Schema} schema
+ */
+var applyStatics = function(model, schema) {
+ for (var i in schema.statics) {
+ model[i] = schema.statics[i];
+ }
+};
+
+/*!
+ * Register custom query methods for this model
+ *
+ * @param {Model} model
+ * @param {Schema} schema
+ */
+
+function applyQueryMethods(model, methods) {
+ for (var i in methods) {
+ model.Query.prototype[i] = methods[i];
+ }
+}
+
+/*!
+ * Subclass this model with `conn`, `schema`, and `collection` settings.
+ *
+ * @param {Connection} conn
+ * @param {Schema} [schema]
+ * @param {String} [collection]
+ * @return {Model}
+ */
+
+Model.__subclass = function subclass(conn, schema, collection) {
+ // subclass model using this connection and collection name
+ var _this = this;
+
+ var Model = function Model(doc, fields, skipId) {
+ if (!(this instanceof Model)) {
+ return new Model(doc, fields, skipId);
+ }
+ _this.call(this, doc, fields, skipId);
+ };
+
+ Model.__proto__ = _this;
+ Model.prototype.__proto__ = _this.prototype;
+ Model.db = Model.prototype.db = conn;
+
+ var s = schema && typeof schema !== 'string'
+ ? schema
+ : _this.prototype.schema;
+
+ var options = s.options || {};
+
+ if (!collection) {
+ collection = _this.prototype.schema.get('collection')
+ || utils.toCollectionName(_this.modelName, options);
+ }
+
+ var collectionOptions = {
+ bufferCommands: s ? options.bufferCommands : true,
+ capped: s && options.capped
+ };
+
+ Model.prototype.collection = conn.collection(collection, collectionOptions);
+ Model.collection = Model.prototype.collection;
+ Model.init();
+ return Model;
+};
+
+Model.$wrapCallback = function(callback) {
+ var _this = this;
+ return function() {
+ try {
+ callback.apply(null, arguments);
+ } catch (error) {
+ _this.emit('error', error);
+ }
+ };
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = Model;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise.js
new file mode 100644
index 0000000..72163ea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise.js
@@ -0,0 +1,314 @@
+/*!
+ * Module dependencies
+ */
+
+var MPromise = require('mpromise');
+var util = require('util');
+
+/**
+ * Promise constructor.
+ *
+ * Promises are returned from executed queries. Example:
+ *
+ * var query = Candy.find({ bar: true });
+ * var promise = query.exec();
+ *
+ * DEPRECATED. Mongoose 5.0 will use native promises by default (or bluebird,
+ * if native promises are not present) but still
+ * support plugging in your own ES6-compatible promises library. Mongoose 5.0
+ * will **not** support mpromise.
+ *
+ * @param {Function} fn a function which will be called when the promise is resolved that accepts `fn(err, ...){}` as signature
+ * @inherits mpromise https://github.com/aheckmann/mpromise
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `err`: Emits when the promise is rejected
+ * @event `complete`: Emits when the promise is fulfilled
+ * @api public
+ * @deprecated
+ */
+
+function Promise(fn) {
+ MPromise.call(this, fn);
+}
+
+/**
+ * ES6-style promise constructor wrapper around mpromise.
+ *
+ * @param {Function} resolver
+ * @return {Promise} new promise
+ * @api public
+ */
+Promise.ES6 = function(resolver) {
+ var promise = new Promise();
+
+ // No try/catch for backwards compatibility
+ resolver(
+ function() {
+ promise.complete.apply(promise, arguments);
+ },
+ function(e) {
+ promise.error(e);
+ });
+
+ return promise;
+};
+
+/*!
+ * Inherit from mpromise
+ */
+
+Promise.prototype = Object.create(MPromise.prototype, {
+ constructor: {
+ value: Promise,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+});
+
+/*!
+ * ignore
+ */
+
+Promise.prototype.then = util.deprecate(Promise.prototype.then,
+ 'Mongoose: mpromise (mongoose\'s default promise library) is deprecated, ' +
+ 'plug in your own promise library instead: ' +
+ 'http://mongoosejs.com/docs/promises.html');
+
+/**
+ * ES6-style `.catch()` shorthand
+ *
+ * @method catch
+ * @memberOf Promise
+ * @param {Function} onReject
+ * @return {Promise}
+ * @api public
+ */
+
+Promise.prototype.catch = function(onReject) {
+ return this.then(null, onReject);
+};
+
+/*!
+ * Override event names for backward compatibility.
+ */
+
+Promise.SUCCESS = 'complete';
+Promise.FAILURE = 'err';
+
+/**
+ * Adds `listener` to the `event`.
+ *
+ * If `event` is either the success or failure event and the event has already been emitted, the`listener` is called immediately and passed the results of the original emitted event.
+ *
+ * @see mpromise#on https://github.com/aheckmann/mpromise#on
+ * @method on
+ * @memberOf Promise
+ * @param {String} event
+ * @param {Function} listener
+ * @return {Promise} this
+ * @api public
+ */
+
+/**
+ * Rejects this promise with `reason`.
+ *
+ * If the promise has already been fulfilled or rejected, not action is taken.
+ *
+ * @see mpromise#reject https://github.com/aheckmann/mpromise#reject
+ * @method reject
+ * @memberOf Promise
+ * @param {Object|String|Error} reason
+ * @return {Promise} this
+ * @api public
+ */
+
+/**
+ * Rejects this promise with `err`.
+ *
+ * If the promise has already been fulfilled or rejected, not action is taken.
+ *
+ * Differs from [#reject](#promise_Promise-reject) by first casting `err` to an `Error` if it is not `instanceof Error`.
+ *
+ * @api public
+ * @param {Error|String} err
+ * @return {Promise} this
+ */
+
+Promise.prototype.error = function(err) {
+ if (!(err instanceof Error)) {
+ if (err instanceof Object) {
+ err = util.inspect(err);
+ }
+ err = new Error(err);
+ }
+ return this.reject(err);
+};
+
+/**
+ * Resolves this promise to a rejected state if `err` is passed or a fulfilled state if no `err` is passed.
+ *
+ * If the promise has already been fulfilled or rejected, not action is taken.
+ *
+ * `err` will be cast to an Error if not already instanceof Error.
+ *
+ * _NOTE: overrides [mpromise#resolve](https://github.com/aheckmann/mpromise#resolve) to provide error casting._
+ *
+ * @param {Error} [err] error or null
+ * @param {Object} [val] value to fulfill the promise with
+ * @api public
+ * @deprecated
+ */
+
+Promise.prototype.resolve = function(err) {
+ if (err) return this.error(err);
+ return this.fulfill.apply(this, Array.prototype.slice.call(arguments, 1));
+};
+
+/**
+ * Adds a single function as a listener to both err and complete.
+ *
+ * It will be executed with traditional node.js argument position when the promise is resolved.
+ *
+ * promise.addBack(function (err, args...) {
+ * if (err) return handleError(err);
+ * console.log('success');
+ * })
+ *
+ * Alias of [mpromise#onResolve](https://github.com/aheckmann/mpromise#onresolve).
+ *
+ * _Deprecated. Use `onResolve` instead._
+ *
+ * @method addBack
+ * @param {Function} listener
+ * @return {Promise} this
+ * @deprecated
+ */
+
+Promise.prototype.addBack = Promise.prototype.onResolve;
+
+/**
+ * Fulfills this promise with passed arguments.
+ *
+ * @method fulfill
+ * @receiver Promise
+ * @see https://github.com/aheckmann/mpromise#fulfill
+ * @param {any} args
+ * @api public
+ * @deprecated
+ */
+
+/**
+ * Fulfills this promise with passed arguments.
+ *
+ * Alias of [mpromise#fulfill](https://github.com/aheckmann/mpromise#fulfill).
+ *
+ * _Deprecated. Use `fulfill` instead._
+ *
+ * @method complete
+ * @receiver Promise
+ * @param {any} args
+ * @api public
+ * @deprecated
+ */
+
+Promise.prototype.complete = MPromise.prototype.fulfill;
+
+/**
+ * Adds a listener to the `complete` (success) event.
+ *
+ * Alias of [mpromise#onFulfill](https://github.com/aheckmann/mpromise#onfulfill).
+ *
+ * _Deprecated. Use `onFulfill` instead._
+ *
+ * @method addCallback
+ * @param {Function} listener
+ * @return {Promise} this
+ * @api public
+ * @deprecated
+ */
+
+Promise.prototype.addCallback = Promise.prototype.onFulfill;
+
+/**
+ * Adds a listener to the `err` (rejected) event.
+ *
+ * Alias of [mpromise#onReject](https://github.com/aheckmann/mpromise#onreject).
+ *
+ * _Deprecated. Use `onReject` instead._
+ *
+ * @method addErrback
+ * @param {Function} listener
+ * @return {Promise} this
+ * @api public
+ * @deprecated
+ */
+
+Promise.prototype.addErrback = Promise.prototype.onReject;
+
+/**
+ * Creates a new promise and returns it. If `onFulfill` or `onReject` are passed, they are added as SUCCESS/ERROR callbacks to this promise after the nextTick.
+ *
+ * Conforms to [promises/A+](https://github.com/promises-aplus/promises-spec) specification.
+ *
+ * ####Example:
+ *
+ * var promise = Meetups.find({ tags: 'javascript' }).select('_id').exec();
+ * promise.then(function (meetups) {
+ * var ids = meetups.map(function (m) {
+ * return m._id;
+ * });
+ * return People.find({ meetups: { $in: ids }).exec();
+ * }).then(function (people) {
+ * if (people.length < 10000) {
+ * throw new Error('Too few people!!!');
+ * } else {
+ * throw new Error('Still need more people!!!');
+ * }
+ * }).then(null, function (err) {
+ * assert.ok(err instanceof Error);
+ * });
+ *
+ * @see promises-A+ https://github.com/promises-aplus/promises-spec
+ * @see mpromise#then https://github.com/aheckmann/mpromise#then
+ * @method then
+ * @memberOf Promise
+ * @param {Function} onFulFill
+ * @param {Function} onReject
+ * @return {Promise} newPromise
+ * @deprecated
+ */
+
+/**
+ * Signifies that this promise was the last in a chain of `then()s`: if a handler passed to the call to `then` which produced this promise throws, the exception will go uncaught.
+ *
+ * ####Example:
+ *
+ * var p = new Promise;
+ * p.then(function(){ throw new Error('shucks') });
+ * setTimeout(function () {
+ * p.fulfill();
+ * // error was caught and swallowed by the promise returned from
+ * // p.then(). we either have to always register handlers on
+ * // the returned promises or we can do the following...
+ * }, 10);
+ *
+ * // this time we use .end() which prevents catching thrown errors
+ * var p = new Promise;
+ * var p2 = p.then(function(){ throw new Error('shucks') }).end(); // <--
+ * setTimeout(function () {
+ * p.fulfill(); // throws "shucks"
+ * }, 10);
+ *
+ * @api public
+ * @see mpromise#end https://github.com/aheckmann/mpromise#end
+ * @method end
+ * @memberOf Promise
+ * @deprecated
+ */
+
+/*!
+ * expose
+ */
+
+module.exports = Promise;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise_provider.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise_provider.js
new file mode 100644
index 0000000..368cf85
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/promise_provider.js
@@ -0,0 +1,51 @@
+/*!
+ * Module dependencies.
+ */
+
+var MPromise = require('./promise');
+
+/**
+ * Helper for multiplexing promise implementations
+ *
+ * @api private
+ */
+
+var Promise = {
+ _promise: MPromise
+};
+
+/**
+ * Get the current promise constructor
+ *
+ * @api private
+ */
+Promise.get = function() {
+ return Promise._promise;
+};
+
+/**
+ * Set the current promise constructor
+ *
+ * @api private
+ */
+
+Promise.set = function(lib) {
+ if (lib === MPromise) {
+ return Promise.reset();
+ }
+ Promise._promise = require('./ES6Promise');
+ Promise._promise.use(lib);
+ require('mquery').Promise = Promise._promise.ES6;
+};
+
+/**
+ * Resets to using mpromise
+ *
+ * @api private
+ */
+
+Promise.reset = function() {
+ Promise._promise = MPromise;
+};
+
+module.exports = Promise;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/query.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/query.js
new file mode 100644
index 0000000..66a5537
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/query.js
@@ -0,0 +1,3413 @@
+/*!
+ * Module dependencies.
+ */
+
+var PromiseProvider = require('./promise_provider');
+var QueryCursor = require('./querycursor');
+var QueryStream = require('./querystream');
+var StrictModeError = require('./error/strict');
+var cast = require('./cast');
+var helpers = require('./queryhelpers');
+var mquery = require('mquery');
+var readPref = require('./drivers').ReadPreference;
+var setDefaultsOnInsert = require('./services/setDefaultsOnInsert');
+var updateValidators = require('./services/updateValidators');
+var util = require('util');
+var utils = require('./utils');
+
+/**
+ * Query constructor used for building queries.
+ *
+ * ####Example:
+ *
+ * var query = new Query();
+ * query.setOptions({ lean : true });
+ * query.collection(model.collection);
+ * query.where('age').gte(21).exec(callback);
+ *
+ * @param {Object} [options]
+ * @param {Object} [model]
+ * @param {Object} [conditions]
+ * @param {Object} [collection] Mongoose collection
+ * @api private
+ */
+
+function Query(conditions, options, model, collection) {
+ // this stuff is for dealing with custom queries created by #toConstructor
+ if (!this._mongooseOptions) {
+ this._mongooseOptions = {};
+ }
+
+ // this is the case where we have a CustomQuery, we need to check if we got
+ // options passed in, and if we did, merge them in
+ if (options) {
+ var keys = Object.keys(options);
+ for (var i = 0; i < keys.length; ++i) {
+ var k = keys[i];
+ this._mongooseOptions[k] = options[k];
+ }
+ }
+
+ if (collection) {
+ this.mongooseCollection = collection;
+ }
+
+ if (model) {
+ this.model = model;
+ this.schema = model.schema;
+ }
+
+ // this is needed because map reduce returns a model that can be queried, but
+ // all of the queries on said model should be lean
+ if (this.model && this.model._mapreduce) {
+ this.lean();
+ }
+
+ // inherit mquery
+ mquery.call(this, this.mongooseCollection, options);
+
+ if (conditions) {
+ this.find(conditions);
+ }
+
+ if (this.schema) {
+ var kareemOptions = { useErrorHandlers: true };
+ this._count = this.model.hooks.createWrapper('count',
+ Query.prototype._count, this, kareemOptions);
+ this._execUpdate = this.model.hooks.createWrapper('update',
+ Query.prototype._execUpdate, this, kareemOptions);
+ this._find = this.model.hooks.createWrapper('find',
+ Query.prototype._find, this, kareemOptions);
+ this._findOne = this.model.hooks.createWrapper('findOne',
+ Query.prototype._findOne, this, kareemOptions);
+ this._findOneAndRemove = this.model.hooks.createWrapper('findOneAndRemove',
+ Query.prototype._findOneAndRemove, this, kareemOptions);
+ this._findOneAndUpdate = this.model.hooks.createWrapper('findOneAndUpdate',
+ Query.prototype._findOneAndUpdate, this, kareemOptions);
+ }
+}
+
+/*!
+ * inherit mquery
+ */
+
+Query.prototype = new mquery;
+Query.prototype.constructor = Query;
+Query.base = mquery.prototype;
+
+/**
+ * Flag to opt out of using `$geoWithin`.
+ *
+ * mongoose.Query.use$geoWithin = false;
+ *
+ * MongoDB 2.4 deprecated the use of `$within`, replacing it with `$geoWithin`. Mongoose uses `$geoWithin` by default (which is 100% backward compatible with $within). If you are running an older version of MongoDB, set this flag to `false` so your `within()` queries continue to work.
+ *
+ * @see http://docs.mongodb.org/manual/reference/operator/geoWithin/
+ * @default true
+ * @property use$geoWithin
+ * @memberOf Query
+ * @receiver Query
+ * @api public
+ */
+
+Query.use$geoWithin = mquery.use$geoWithin;
+
+/**
+ * Converts this query to a customized, reusable query constructor with all arguments and options retained.
+ *
+ * ####Example
+ *
+ * // Create a query for adventure movies and read from the primary
+ * // node in the replica-set unless it is down, in which case we'll
+ * // read from a secondary node.
+ * var query = Movie.find({ tags: 'adventure' }).read('primaryPreferred');
+ *
+ * // create a custom Query constructor based off these settings
+ * var Adventure = query.toConstructor();
+ *
+ * // Adventure is now a subclass of mongoose.Query and works the same way but with the
+ * // default query parameters and options set.
+ * Adventure().exec(callback)
+ *
+ * // further narrow down our query results while still using the previous settings
+ * Adventure().where({ name: /^Life/ }).exec(callback);
+ *
+ * // since Adventure is a stand-alone constructor we can also add our own
+ * // helper methods and getters without impacting global queries
+ * Adventure.prototype.startsWith = function (prefix) {
+ * this.where({ name: new RegExp('^' + prefix) })
+ * return this;
+ * }
+ * Object.defineProperty(Adventure.prototype, 'highlyRated', {
+ * get: function () {
+ * this.where({ rating: { $gt: 4.5 }});
+ * return this;
+ * }
+ * })
+ * Adventure().highlyRated.startsWith('Life').exec(callback)
+ *
+ * New in 3.7.3
+ *
+ * @return {Query} subclass-of-Query
+ * @api public
+ */
+
+Query.prototype.toConstructor = function toConstructor() {
+ var model = this.model;
+ var coll = this.mongooseCollection;
+
+ var CustomQuery = function(criteria, options) {
+ if (!(this instanceof CustomQuery)) {
+ return new CustomQuery(criteria, options);
+ }
+ this._mongooseOptions = utils.clone(p._mongooseOptions);
+ Query.call(this, criteria, options || null, model, coll);
+ };
+
+ util.inherits(CustomQuery, Query);
+
+ // set inherited defaults
+ var p = CustomQuery.prototype;
+
+ p.options = {};
+
+ p.setOptions(this.options);
+
+ p.op = this.op;
+ p._conditions = utils.clone(this._conditions, { retainKeyOrder: true });
+ p._fields = utils.clone(this._fields);
+ p._update = utils.clone(this._update);
+ p._path = this._path;
+ p._distinct = this._distinct;
+ p._collection = this._collection;
+ p._mongooseOptions = this._mongooseOptions;
+
+ return CustomQuery;
+};
+
+/**
+ * Specifies a javascript function or expression to pass to MongoDBs query system.
+ *
+ * ####Example
+ *
+ * query.$where('this.comments.length === 10 || this.name.length === 5')
+ *
+ * // or
+ *
+ * query.$where(function () {
+ * return this.comments.length === 10 || this.name.length === 5;
+ * })
+ *
+ * ####NOTE:
+ *
+ * Only use `$where` when you have a condition that cannot be met using other MongoDB operators like `$lt`.
+ * **Be sure to read about all of [its caveats](http://docs.mongodb.org/manual/reference/operator/where/) before using.**
+ *
+ * @see $where http://docs.mongodb.org/manual/reference/operator/where/
+ * @method $where
+ * @param {String|Function} js javascript string or function
+ * @return {Query} this
+ * @memberOf Query
+ * @method $where
+ * @api public
+ */
+
+/**
+ * Specifies a `path` for use with chaining.
+ *
+ * ####Example
+ *
+ * // instead of writing:
+ * User.find({age: {$gte: 21, $lte: 65}}, callback);
+ *
+ * // we can instead write:
+ * User.where('age').gte(21).lte(65);
+ *
+ * // passing query conditions is permitted
+ * User.find().where({ name: 'vonderful' })
+ *
+ * // chaining
+ * User
+ * .where('age').gte(21).lte(65)
+ * .where('name', /^vonderful/i)
+ * .where('friends').slice(10)
+ * .exec(callback)
+ *
+ * @method where
+ * @memberOf Query
+ * @param {String|Object} [path]
+ * @param {any} [val]
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies the complementary comparison value for paths specified with `where()`
+ *
+ * ####Example
+ *
+ * User.where('age').equals(49);
+ *
+ * // is the same as
+ *
+ * User.where('age', 49);
+ *
+ * @method equals
+ * @memberOf Query
+ * @param {Object} val
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies arguments for an `$or` condition.
+ *
+ * ####Example
+ *
+ * query.or([{ color: 'red' }, { status: 'emergency' }])
+ *
+ * @see $or http://docs.mongodb.org/manual/reference/operator/or/
+ * @method or
+ * @memberOf Query
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies arguments for a `$nor` condition.
+ *
+ * ####Example
+ *
+ * query.nor([{ color: 'green' }, { status: 'ok' }])
+ *
+ * @see $nor http://docs.mongodb.org/manual/reference/operator/nor/
+ * @method nor
+ * @memberOf Query
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies arguments for a `$and` condition.
+ *
+ * ####Example
+ *
+ * query.and([{ color: 'green' }, { status: 'ok' }])
+ *
+ * @method and
+ * @memberOf Query
+ * @see $and http://docs.mongodb.org/manual/reference/operator/and/
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies a $gt query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * ####Example
+ *
+ * Thing.find().where('age').gt(21)
+ *
+ * // or
+ * Thing.find().gt('age', 21)
+ *
+ * @method gt
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @see $gt http://docs.mongodb.org/manual/reference/operator/gt/
+ * @api public
+ */
+
+/**
+ * Specifies a $gte query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method gte
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @see $gte http://docs.mongodb.org/manual/reference/operator/gte/
+ * @api public
+ */
+
+/**
+ * Specifies a $lt query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method lt
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @see $lt http://docs.mongodb.org/manual/reference/operator/lt/
+ * @api public
+ */
+
+/**
+ * Specifies a $lte query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method lte
+ * @see $lte http://docs.mongodb.org/manual/reference/operator/lte/
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $ne query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $ne http://docs.mongodb.org/manual/reference/operator/ne/
+ * @method ne
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $in query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $in http://docs.mongodb.org/manual/reference/operator/in/
+ * @method in
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $nin query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $nin http://docs.mongodb.org/manual/reference/operator/nin/
+ * @method nin
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $all query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $all http://docs.mongodb.org/manual/reference/operator/all/
+ * @method all
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $size query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * ####Example
+ *
+ * MyModel.where('tags').size(0).exec(function (err, docs) {
+ * if (err) return handleError(err);
+ *
+ * assert(Array.isArray(docs));
+ * console.log('documents with 0 tags', docs);
+ * })
+ *
+ * @see $size http://docs.mongodb.org/manual/reference/operator/size/
+ * @method size
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $regex query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $regex http://docs.mongodb.org/manual/reference/operator/regex/
+ * @method regex
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $maxDistance query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
+ * @method maxDistance
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a `$mod` condition
+ *
+ * @method mod
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @return {Query} this
+ * @see $mod http://docs.mongodb.org/manual/reference/operator/mod/
+ * @api public
+ */
+
+/**
+ * Specifies an `$exists` condition
+ *
+ * ####Example
+ *
+ * // { name: { $exists: true }}
+ * Thing.where('name').exists()
+ * Thing.where('name').exists(true)
+ * Thing.find().exists('name')
+ *
+ * // { name: { $exists: false }}
+ * Thing.where('name').exists(false);
+ * Thing.find().exists('name', false);
+ *
+ * @method exists
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @return {Query} this
+ * @see $exists http://docs.mongodb.org/manual/reference/operator/exists/
+ * @api public
+ */
+
+/**
+ * Specifies an `$elemMatch` condition
+ *
+ * ####Example
+ *
+ * query.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}})
+ *
+ * query.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}})
+ *
+ * query.elemMatch('comment', function (elem) {
+ * elem.where('author').equals('autobot');
+ * elem.where('votes').gte(5);
+ * })
+ *
+ * query.where('comment').elemMatch(function (elem) {
+ * elem.where({ author: 'autobot' });
+ * elem.where('votes').gte(5);
+ * })
+ *
+ * @method elemMatch
+ * @memberOf Query
+ * @param {String|Object|Function} path
+ * @param {Object|Function} criteria
+ * @return {Query} this
+ * @see $elemMatch http://docs.mongodb.org/manual/reference/operator/elemMatch/
+ * @api public
+ */
+
+/**
+ * Defines a `$within` or `$geoWithin` argument for geo-spatial queries.
+ *
+ * ####Example
+ *
+ * query.where(path).within().box()
+ * query.where(path).within().circle()
+ * query.where(path).within().geometry()
+ *
+ * query.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
+ * query.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
+ * query.where('loc').within({ polygon: [[],[],[],[]] });
+ *
+ * query.where('loc').within([], [], []) // polygon
+ * query.where('loc').within([], []) // box
+ * query.where('loc').within({ type: 'LineString', coordinates: [...] }); // geometry
+ *
+ * **MUST** be used after `where()`.
+ *
+ * ####NOTE:
+ *
+ * As of Mongoose 3.7, `$geoWithin` is always used for queries. To change this behavior, see [Query.use$geoWithin](#query_Query-use%2524geoWithin).
+ *
+ * ####NOTE:
+ *
+ * In Mongoose 3.7, `within` changed from a getter to a function. If you need the old syntax, use [this](https://github.com/ebensing/mongoose-within).
+ *
+ * @method within
+ * @see $polygon http://docs.mongodb.org/manual/reference/operator/polygon/
+ * @see $box http://docs.mongodb.org/manual/reference/operator/box/
+ * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
+ * @see $center http://docs.mongodb.org/manual/reference/operator/center/
+ * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
+ * @memberOf Query
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Specifies a $slice projection for an array.
+ *
+ * ####Example
+ *
+ * query.slice('comments', 5)
+ * query.slice('comments', -5)
+ * query.slice('comments', [10, 5])
+ * query.where('comments').slice(5)
+ * query.where('comments').slice([-10, 5])
+ *
+ * @method slice
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val number/range of elements to slice
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
+ * @see $slice http://docs.mongodb.org/manual/reference/projection/slice/#prj._S_slice
+ * @api public
+ */
+
+/**
+ * Specifies the maximum number of documents the query will return.
+ *
+ * ####Example
+ *
+ * query.limit(20)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method limit
+ * @memberOf Query
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies the number of documents to skip.
+ *
+ * ####Example
+ *
+ * query.skip(100).limit(20)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method skip
+ * @memberOf Query
+ * @param {Number} val
+ * @see cursor.skip http://docs.mongodb.org/manual/reference/method/cursor.skip/
+ * @api public
+ */
+
+/**
+ * Specifies the maxScan option.
+ *
+ * ####Example
+ *
+ * query.maxScan(100)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method maxScan
+ * @memberOf Query
+ * @param {Number} val
+ * @see maxScan http://docs.mongodb.org/manual/reference/operator/maxScan/
+ * @api public
+ */
+
+/**
+ * Specifies the batchSize option.
+ *
+ * ####Example
+ *
+ * query.batchSize(100)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method batchSize
+ * @memberOf Query
+ * @param {Number} val
+ * @see batchSize http://docs.mongodb.org/manual/reference/method/cursor.batchSize/
+ * @api public
+ */
+
+/**
+ * Specifies the `comment` option.
+ *
+ * ####Example
+ *
+ * query.comment('login query')
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method comment
+ * @memberOf Query
+ * @param {Number} val
+ * @see comment http://docs.mongodb.org/manual/reference/operator/comment/
+ * @api public
+ */
+
+/**
+ * Specifies this query as a `snapshot` query.
+ *
+ * ####Example
+ *
+ * query.snapshot() // true
+ * query.snapshot(true)
+ * query.snapshot(false)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method snapshot
+ * @memberOf Query
+ * @see snapshot http://docs.mongodb.org/manual/reference/operator/snapshot/
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Sets query hints.
+ *
+ * ####Example
+ *
+ * query.hint({ indexA: 1, indexB: -1})
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method hint
+ * @memberOf Query
+ * @param {Object} val a hint object
+ * @return {Query} this
+ * @see $hint http://docs.mongodb.org/manual/reference/operator/hint/
+ * @api public
+ */
+
+/**
+ * Specifies which document fields to include or exclude (also known as the query "projection")
+ *
+ * When using string syntax, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included. Lastly, if a path is prefixed with `+`, it forces inclusion of the path, which is useful for paths excluded at the [schema level](/docs/api.html#schematype_SchemaType-select).
+ *
+ * ####Example
+ *
+ * // include a and b, exclude other fields
+ * query.select('a b');
+ *
+ * // exclude c and d, include other fields
+ * query.select('-c -d');
+ *
+ * // or you may use object notation, useful when
+ * // you have keys already prefixed with a "-"
+ * query.select({ a: 1, b: 1 });
+ * query.select({ c: 0, d: 0 });
+ *
+ * // force inclusion of field excluded at schema level
+ * query.select('+path')
+ *
+ * ####NOTE:
+ *
+ * Cannot be used with `distinct()`.
+ *
+ * _v2 had slightly different syntax such as allowing arrays of field names. This support was removed in v3._
+ *
+ * @method select
+ * @memberOf Query
+ * @param {Object|String} arg
+ * @return {Query} this
+ * @see SchemaType
+ * @api public
+ */
+
+/**
+ * _DEPRECATED_ Sets the slaveOk option.
+ *
+ * **Deprecated** in MongoDB 2.2 in favor of [read preferences](#query_Query-read).
+ *
+ * ####Example:
+ *
+ * query.slaveOk() // true
+ * query.slaveOk(true)
+ * query.slaveOk(false)
+ *
+ * @method slaveOk
+ * @memberOf Query
+ * @deprecated use read() preferences instead if on mongodb >= 2.2
+ * @param {Boolean} v defaults to true
+ * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
+ * @see slaveOk http://docs.mongodb.org/manual/reference/method/rs.slaveOk/
+ * @see read() #query_Query-read
+ * @return {Query} this
+ * @api public
+ */
+
+/**
+ * Determines the MongoDB nodes from which to read.
+ *
+ * ####Preferences:
+ *
+ * primary - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.
+ * secondary Read from secondary if available, otherwise error.
+ * primaryPreferred Read from primary if available, otherwise a secondary.
+ * secondaryPreferred Read from a secondary if available, otherwise read from the primary.
+ * nearest All operations read from among the nearest candidates, but unlike other modes, this option will include both the primary and all secondaries in the random selection.
+ *
+ * Aliases
+ *
+ * p primary
+ * pp primaryPreferred
+ * s secondary
+ * sp secondaryPreferred
+ * n nearest
+ *
+ * ####Example:
+ *
+ * new Query().read('primary')
+ * new Query().read('p') // same as primary
+ *
+ * new Query().read('primaryPreferred')
+ * new Query().read('pp') // same as primaryPreferred
+ *
+ * new Query().read('secondary')
+ * new Query().read('s') // same as secondary
+ *
+ * new Query().read('secondaryPreferred')
+ * new Query().read('sp') // same as secondaryPreferred
+ *
+ * new Query().read('nearest')
+ * new Query().read('n') // same as nearest
+ *
+ * // read from secondaries with matching tags
+ * new Query().read('s', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }])
+ *
+ * Read more about how to use read preferrences [here](http://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
+ *
+ * @method read
+ * @memberOf Query
+ * @param {String} pref one of the listed preference options or aliases
+ * @param {Array} [tags] optional tags for this query
+ * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
+ * @see driver http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.read = function read(pref, tags) {
+ // first cast into a ReadPreference object to support tags
+ var read = readPref.call(readPref, pref, tags);
+ return Query.base.read.call(this, read);
+};
+
+/**
+ * Merges another Query or conditions object into this one.
+ *
+ * When a Query is passed, conditions, field selection and options are merged.
+ *
+ * New in 3.7.0
+ *
+ * @method merge
+ * @memberOf Query
+ * @param {Query|Object} source
+ * @return {Query} this
+ */
+
+/**
+ * Sets query options.
+ *
+ * ####Options:
+ *
+ * - [tailable](http://www.mongodb.org/display/DOCS/Tailable+Cursors) *
+ * - [sort](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D) *
+ * - [limit](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D) *
+ * - [skip](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D) *
+ * - [maxscan](https://docs.mongodb.org/v3.2/reference/operator/meta/maxScan/#metaOp._S_maxScan) *
+ * - [batchSize](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D) *
+ * - [comment](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment) *
+ * - [snapshot](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D) *
+ * - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint) *
+ * - [readPreference](http://docs.mongodb.org/manual/applications/replication/#read-preference) **
+ * - [lean](./api.html#query_Query-lean) *
+ * - [safe](http://www.mongodb.org/display/DOCS/getLastError+Command)
+ *
+ * _* denotes a query helper method is also available_
+ * _** query helper method to set `readPreference` is `read()`_
+ *
+ * @param {Object} options
+ * @api public
+ */
+
+Query.prototype.setOptions = function(options, overwrite) {
+ // overwrite is only for internal use
+ if (overwrite) {
+ // ensure that _mongooseOptions & options are two different objects
+ this._mongooseOptions = (options && utils.clone(options)) || {};
+ this.options = options || {};
+
+ if ('populate' in options) {
+ this.populate(this._mongooseOptions);
+ }
+ return this;
+ }
+
+ if (!(options && options.constructor.name === 'Object')) {
+ return this;
+ }
+
+ if (options && Array.isArray(options.populate)) {
+ var populate = options.populate;
+ delete options.populate;
+ var _numPopulate = populate.length;
+ for (var i = 0; i < _numPopulate; ++i) {
+ this.populate(populate[i]);
+ }
+ }
+
+ return Query.base.setOptions.call(this, options);
+};
+
+/**
+ * Returns the current query conditions as a JSON object.
+ *
+ * ####Example:
+ *
+ * var query = new Query();
+ * query.find({ a: 1 }).where('b').gt(2);
+ * query.getQuery(); // { a: 1, b: { $gt: 2 } }
+ *
+ * @return {Object} current query conditions
+ * @api public
+ */
+
+Query.prototype.getQuery = function() {
+ return this._conditions;
+};
+
+/**
+ * Returns the current update operations as a JSON object.
+ *
+ * ####Example:
+ *
+ * var query = new Query();
+ * query.update({}, { $set: { a: 5 } });
+ * query.getUpdate(); // { $set: { a: 5 } }
+ *
+ * @return {Object} current update operations
+ * @api public
+ */
+
+Query.prototype.getUpdate = function() {
+ return this._update;
+};
+
+/**
+ * Returns fields selection for this query.
+ *
+ * @method _fieldsForExec
+ * @return {Object}
+ * @api private
+ * @receiver Query
+ */
+
+/**
+ * Return an update document with corrected $set operations.
+ *
+ * @method _updateForExec
+ * @api private
+ * @receiver Query
+ */
+
+Query.prototype._updateForExec = function() {
+ var update = utils.clone(this._update, {
+ retainKeyOrder: true,
+ transform: false,
+ depopulate: true
+ });
+ var ops = Object.keys(update);
+ var i = ops.length;
+ var ret = {};
+
+ while (i--) {
+ var op = ops[i];
+
+ if (this.options.overwrite) {
+ ret[op] = update[op];
+ continue;
+ }
+
+ if ('$' !== op[0]) {
+ // fix up $set sugar
+ if (!ret.$set) {
+ if (update.$set) {
+ ret.$set = update.$set;
+ } else {
+ ret.$set = {};
+ }
+ }
+ ret.$set[op] = update[op];
+ ops.splice(i, 1);
+ if (!~ops.indexOf('$set')) ops.push('$set');
+ } else if ('$set' === op) {
+ if (!ret.$set) {
+ ret[op] = update[op];
+ }
+ } else {
+ ret[op] = update[op];
+ }
+ }
+
+ this._compiledUpdate = ret;
+ return ret;
+};
+
+/**
+ * Makes sure _path is set.
+ *
+ * @method _ensurePath
+ * @param {String} method
+ * @api private
+ * @receiver Query
+ */
+
+/**
+ * Determines if `conds` can be merged using `mquery().merge()`
+ *
+ * @method canMerge
+ * @memberOf Query
+ * @param {Object} conds
+ * @return {Boolean}
+ * @api private
+ */
+
+/**
+ * Returns default options for this query.
+ *
+ * @param {Model} model
+ * @api private
+ */
+
+Query.prototype._optionsForExec = function(model) {
+ var options = Query.base._optionsForExec.call(this);
+
+ delete options.populate;
+ delete options.retainKeyOrder;
+ model = model || this.model;
+
+ if (!model) {
+ return options;
+ }
+
+ if (!('safe' in options) && model.schema.options.safe) {
+ options.safe = model.schema.options.safe;
+ }
+
+ if (!('readPreference' in options) && model.schema.options.read) {
+ options.readPreference = model.schema.options.read;
+ }
+
+ return options;
+};
+
+/**
+ * Sets the lean option.
+ *
+ * Documents returned from queries with the `lean` option enabled are plain javascript objects, not [MongooseDocuments](#document-js). They have no `save` method, getters/setters or other Mongoose magic applied.
+ *
+ * ####Example:
+ *
+ * new Query().lean() // true
+ * new Query().lean(true)
+ * new Query().lean(false)
+ *
+ * Model.find().lean().exec(function (err, docs) {
+ * docs[0] instanceof mongoose.Document // false
+ * });
+ *
+ * This is a [great](https://groups.google.com/forum/#!topic/mongoose-orm/u2_DzDydcnA/discussion) option in high-performance read-only scenarios, especially when combined with [stream](#query_Query-stream).
+ *
+ * @param {Boolean} bool defaults to true
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.lean = function(v) {
+ this._mongooseOptions.lean = arguments.length ? !!v : true;
+ return this;
+};
+
+/**
+ * Thunk around find()
+ *
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api private
+ */
+Query.prototype._find = function(callback) {
+ if (this._castError) {
+ callback(this._castError);
+ return this;
+ }
+
+ this._applyPaths();
+ this._fields = this._castFields(this._fields);
+
+ var fields = this._fieldsForExec();
+ var options = this._mongooseOptions;
+ var _this = this;
+
+ var cb = function(err, docs) {
+ if (err) {
+ return callback(err);
+ }
+
+ if (docs.length === 0) {
+ return callback(null, docs);
+ }
+
+ if (!options.populate) {
+ return options.lean === true
+ ? callback(null, docs)
+ : completeMany(_this.model, docs, fields, _this, null, callback);
+ }
+
+ var pop = helpers.preparePopulationOptionsMQ(_this, options);
+ pop.__noPromise = true;
+ _this.model.populate(docs, pop, function(err, docs) {
+ if (err) return callback(err);
+ return options.lean === true
+ ? callback(null, docs)
+ : completeMany(_this.model, docs, fields, _this, pop, callback);
+ });
+ };
+
+ return Query.base.find.call(this, {}, cb);
+};
+
+/**
+ * Finds documents.
+ *
+ * When no `callback` is passed, the query is not executed. When the query is executed, the result will be an array of documents.
+ *
+ * ####Example
+ *
+ * query.find({ name: 'Los Pollos Hermanos' }).find(callback)
+ *
+ * @param {Object} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.find = function(conditions, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = {};
+ }
+
+ conditions = utils.toObject(conditions);
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ prepareDiscriminatorCriteria(this);
+
+ try {
+ this.cast(this.model);
+ this._castError = null;
+ } catch (err) {
+ this._castError = err;
+ }
+
+ // if we don't have a callback, then just return the query object
+ if (!callback) {
+ return Query.base.find.call(this);
+ }
+
+ this._find(callback);
+
+ return this;
+};
+
+/**
+ * Merges another Query or conditions object into this one.
+ *
+ * When a Query is passed, conditions, field selection and options are merged.
+ *
+ * @param {Query|Object} source
+ * @return {Query} this
+ */
+
+Query.prototype.merge = function(source) {
+ if (!source) {
+ return this;
+ }
+
+ var opts = { retainKeyOrder: this.options.retainKeyOrder, overwrite: true };
+
+ if (source instanceof Query) {
+ // if source has a feature, apply it to ourselves
+
+ if (source._conditions) {
+ utils.merge(this._conditions, source._conditions, opts);
+ }
+
+ if (source._fields) {
+ this._fields || (this._fields = {});
+ utils.merge(this._fields, source._fields, opts);
+ }
+
+ if (source.options) {
+ this.options || (this.options = {});
+ utils.merge(this.options, source.options, opts);
+ }
+
+ if (source._update) {
+ this._update || (this._update = {});
+ utils.mergeClone(this._update, source._update);
+ }
+
+ if (source._distinct) {
+ this._distinct = source._distinct;
+ }
+
+ return this;
+ }
+
+ // plain object
+ utils.merge(this._conditions, source, opts);
+
+ return this;
+};
+
+/*!
+ * hydrates many documents
+ *
+ * @param {Model} model
+ * @param {Array} docs
+ * @param {Object} fields
+ * @param {Query} self
+ * @param {Array} [pop] array of paths used in population
+ * @param {Function} callback
+ */
+
+function completeMany(model, docs, fields, self, pop, callback) {
+ var arr = [];
+ var count = docs.length;
+ var len = count;
+ var opts = pop ?
+ {populated: pop}
+ : undefined;
+ function init(err) {
+ if (err) return callback(err);
+ --count || callback(null, arr);
+ }
+ for (var i = 0; i < len; ++i) {
+ arr[i] = helpers.createModel(model, docs[i], fields);
+ arr[i].init(docs[i], opts, init);
+ }
+}
+
+/**
+ * Thunk around findOne()
+ *
+ * @param {Function} [callback]
+ * @see findOne http://docs.mongodb.org/manual/reference/method/db.collection.findOne/
+ * @api private
+ */
+
+Query.prototype._findOne = function(callback) {
+ if (this._castError) {
+ return callback(this._castError);
+ }
+
+ this._applyPaths();
+ this._fields = this._castFields(this._fields);
+
+ var options = this._mongooseOptions;
+ var projection = this._fieldsForExec();
+ var _this = this;
+
+ // don't pass in the conditions because we already merged them in
+ Query.base.findOne.call(_this, {}, function(err, doc) {
+ if (err) {
+ return callback(err);
+ }
+ if (!doc) {
+ return callback(null, null);
+ }
+
+ if (!options.populate) {
+ return options.lean === true
+ ? callback(null, doc)
+ : completeOne(_this.model, doc, null, projection, _this, null, callback);
+ }
+
+ var pop = helpers.preparePopulationOptionsMQ(_this, options);
+ pop.__noPromise = true;
+ _this.model.populate(doc, pop, function(err, doc) {
+ if (err) {
+ return callback(err);
+ }
+ return options.lean === true
+ ? callback(null, doc)
+ : completeOne(_this.model, doc, null, projection, _this, pop, callback);
+ });
+ });
+};
+
+/**
+ * Declares the query a findOne operation. When executed, the first found document is passed to the callback.
+ *
+ * Passing a `callback` executes the query. The result of the query is a single document.
+ *
+ * * *Note:* `conditions` is optional, and if `conditions` is null or undefined,
+ * mongoose will send an empty `findOne` command to MongoDB, which will return
+ * an arbitrary document. If you're querying by `_id`, use `Model.findById()`
+ * instead.
+ *
+ * ####Example
+ *
+ * var query = Kitten.where({ color: 'white' });
+ * query.findOne(function (err, kitten) {
+ * if (err) return handleError(err);
+ * if (kitten) {
+ * // doc may be null if no document matched
+ * }
+ * });
+ *
+ * @param {Object|Query} [criteria] mongodb selector
+ * @param {Object} [projection] optional fields to return
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see findOne http://docs.mongodb.org/manual/reference/method/db.collection.findOne/
+ * @see Query.select #query_Query-select
+ * @api public
+ */
+
+Query.prototype.findOne = function(conditions, projection, options, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = null;
+ projection = null;
+ options = null;
+ } else if (typeof projection === 'function') {
+ callback = projection;
+ options = null;
+ projection = null;
+ } else if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+
+ // make sure we don't send in the whole Document to merge()
+ conditions = utils.toObject(conditions);
+
+ this.op = 'findOne';
+
+ if (options) {
+ this.setOptions(options);
+ }
+
+ if (projection) {
+ this.select(projection);
+ }
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ } else if (conditions != null) {
+ throw new Error('Invalid argument to findOne(): ' +
+ util.inspect(conditions));
+ }
+
+ prepareDiscriminatorCriteria(this);
+
+ try {
+ this.cast(this.model);
+ this._castError = null;
+ } catch (err) {
+ this._castError = err;
+ }
+
+ if (!callback) {
+ // already merged in the conditions, don't need to send them in.
+ return Query.base.findOne.call(this);
+ }
+
+ this._findOne(callback);
+
+ return this;
+};
+
+/**
+ * Thunk around count()
+ *
+ * @param {Function} [callback]
+ * @see count http://docs.mongodb.org/manual/reference/method/db.collection.count/
+ * @api private
+ */
+
+Query.prototype._count = function(callback) {
+ try {
+ this.cast(this.model);
+ } catch (err) {
+ process.nextTick(function() {
+ callback(err);
+ });
+ return this;
+ }
+
+ var conds = this._conditions;
+ var options = this._optionsForExec();
+
+ this._collection.count(conds, options, utils.tick(callback));
+};
+
+/**
+ * Specifying this query as a `count` query.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example:
+ *
+ * var countQuery = model.where({ 'color': 'black' }).count();
+ *
+ * query.count({ color: 'black' }).count(callback)
+ *
+ * query.count({ color: 'black' }, callback)
+ *
+ * query.where('color', 'black').count(function (err, count) {
+ * if (err) return handleError(err);
+ * console.log('there are %d kittens', count);
+ * })
+ *
+ * @param {Object} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see count http://docs.mongodb.org/manual/reference/method/db.collection.count/
+ * @api public
+ */
+
+Query.prototype.count = function(conditions, callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = undefined;
+ }
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ this.op = 'count';
+ if (!callback) {
+ return this;
+ }
+
+ this._count(callback);
+
+ return this;
+};
+
+/**
+ * Declares or executes a distict() operation.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example
+ *
+ * distinct(field, conditions, callback)
+ * distinct(field, conditions)
+ * distinct(field, callback)
+ * distinct(field)
+ * distinct(callback)
+ * distinct()
+ *
+ * @param {String} [field]
+ * @param {Object|Query} [criteria]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see distinct http://docs.mongodb.org/manual/reference/method/db.collection.distinct/
+ * @api public
+ */
+
+Query.prototype.distinct = function(field, conditions, callback) {
+ if (!callback) {
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = undefined;
+ } else if (typeof field === 'function') {
+ callback = field;
+ field = undefined;
+ conditions = undefined;
+ }
+ }
+
+ conditions = utils.toObject(conditions);
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ try {
+ this.cast(this.model);
+ } catch (err) {
+ if (!callback) {
+ throw err;
+ }
+ callback(err);
+ return this;
+ }
+
+ return Query.base.distinct.call(this, {}, field, callback);
+};
+
+/**
+ * Sets the sort order
+ *
+ * If an object is passed, values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`.
+ *
+ * If a string is passed, it must be a space delimited list of path names. The
+ * sort order of each path is ascending unless the path name is prefixed with `-`
+ * which will be treated as descending.
+ *
+ * ####Example
+ *
+ * // sort by "field" ascending and "test" descending
+ * query.sort({ field: 'asc', test: -1 });
+ *
+ * // equivalent
+ * query.sort('field -test');
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @param {Object|String} arg
+ * @return {Query} this
+ * @see cursor.sort http://docs.mongodb.org/manual/reference/method/cursor.sort/
+ * @api public
+ */
+
+Query.prototype.sort = function(arg) {
+ var nArg = {};
+
+ if (arguments.length > 1) {
+ throw new Error('sort() only takes 1 Argument');
+ }
+
+ if (Array.isArray(arg)) {
+ // time to deal with the terrible syntax
+ for (var i = 0; i < arg.length; i++) {
+ if (!Array.isArray(arg[i])) throw new Error('Invalid sort() argument.');
+ nArg[arg[i][0]] = arg[i][1];
+ }
+ } else {
+ nArg = arg;
+ }
+
+ return Query.base.sort.call(this, nArg);
+};
+
+/**
+ * Declare and/or execute this query as a remove() operation.
+ *
+ * ####Example
+ *
+ * Model.remove({ artist: 'Anne Murray' }, callback)
+ *
+ * ####Note
+ *
+ * The operation is only executed when a callback is passed. To force execution without a callback, you must first call `remove()` and then execute it by using the `exec()` method.
+ *
+ * // not executed
+ * var query = Model.find().remove({ name: 'Anne Murray' })
+ *
+ * // executed
+ * query.remove({ name: 'Anne Murray' }, callback)
+ * query.remove({ name: 'Anne Murray' }).remove(callback)
+ *
+ * // executed without a callback
+ * query.exec()
+ *
+ * // summary
+ * query.remove(conds, fn); // executes
+ * query.remove(conds)
+ * query.remove(fn) // executes
+ * query.remove()
+ *
+ * @param {Object|Query} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see remove http://docs.mongodb.org/manual/reference/method/db.collection.remove/
+ * @api public
+ */
+
+Query.prototype.remove = function(cond, callback) {
+ if (typeof cond === 'function') {
+ callback = cond;
+ cond = null;
+ }
+
+ var cb = typeof callback === 'function';
+
+ try {
+ this.cast(this.model);
+ } catch (err) {
+ if (cb) return process.nextTick(callback.bind(null, err));
+ return this;
+ }
+
+ return Query.base.remove.call(this, cond, callback);
+};
+
+/*!
+ * hydrates a document
+ *
+ * @param {Model} model
+ * @param {Document} doc
+ * @param {Object} res 3rd parameter to callback
+ * @param {Object} fields
+ * @param {Query} self
+ * @param {Array} [pop] array of paths used in population
+ * @param {Function} callback
+ */
+
+function completeOne(model, doc, res, fields, self, pop, callback) {
+ var opts = pop ?
+ {populated: pop}
+ : undefined;
+
+ var casted = helpers.createModel(model, doc, fields);
+ casted.init(doc, opts, function(err) {
+ if (err) {
+ return callback(err);
+ }
+ if (res) {
+ return callback(null, casted, res);
+ }
+ callback(null, casted);
+ });
+}
+
+/*!
+ * If the model is a discriminator type and not root, then add the key & value to the criteria.
+ */
+
+function prepareDiscriminatorCriteria(query) {
+ if (!query || !query.model || !query.model.schema) {
+ return;
+ }
+
+ var schema = query.model.schema;
+
+ if (schema && schema.discriminatorMapping && !schema.discriminatorMapping.isRoot) {
+ query._conditions[schema.discriminatorMapping.key] = schema.discriminatorMapping.value;
+ }
+}
+
+/**
+ * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) update command.
+ *
+ * Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found document (if any) to the callback. The query executes immediately if `callback` is passed.
+ *
+ * ####Available options
+ *
+ * - `new`: bool - if true, return the modified document rather than the original. defaults to false (changed in 4.0)
+ * - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
+ * - `fields`: {Object|String} - Field selection. Equivalent to `.select(fields).findOneAndUpdate()`
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
+ * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
+ * - `setDefaultsOnInsert`: if this and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. This option only works on MongoDB >= 2.4 because it relies on [MongoDB's `$setOnInsert` operator](https://docs.mongodb.org/v2.4/reference/operator/update/setOnInsert/).
+ * - `passRawResult`: if true, passes the [raw result from the MongoDB driver as the third callback parameter](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
+ * - `context` (string) if set to 'query' and `runValidators` is on, `this` will refer to the query in custom validator functions that update validation runs. Does nothing if `runValidators` is false.
+ *
+ * ####Callback Signature
+ * function(error, doc) {
+ * // error: any errors that occurred
+ * // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
+ * }
+ *
+ * ####Examples
+ *
+ * query.findOneAndUpdate(conditions, update, options, callback) // executes
+ * query.findOneAndUpdate(conditions, update, options) // returns Query
+ * query.findOneAndUpdate(conditions, update, callback) // executes
+ * query.findOneAndUpdate(conditions, update) // returns Query
+ * query.findOneAndUpdate(update, callback) // returns Query
+ * query.findOneAndUpdate(update) // returns Query
+ * query.findOneAndUpdate(callback) // executes
+ * query.findOneAndUpdate() // returns Query
+ *
+ * @method findOneAndUpdate
+ * @memberOf Query
+ * @param {Object|Query} [query]
+ * @param {Object} [doc]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.findOneAndUpdate = function(criteria, doc, options, callback) {
+ this.op = 'findOneAndUpdate';
+ this._validate();
+
+ switch (arguments.length) {
+ case 3:
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ break;
+ case 2:
+ if (typeof doc === 'function') {
+ callback = doc;
+ doc = criteria;
+ criteria = undefined;
+ }
+ options = undefined;
+ break;
+ case 1:
+ if (typeof criteria === 'function') {
+ callback = criteria;
+ criteria = options = doc = undefined;
+ } else {
+ doc = criteria;
+ criteria = options = undefined;
+ }
+ }
+
+ if (mquery.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ // apply doc
+ if (doc) {
+ this._mergeUpdate(doc);
+ }
+
+ if (options) {
+ options = utils.clone(options, { retainKeyOrder: true });
+ if (options.projection) {
+ this.select(options.projection);
+ delete options.projection;
+ }
+ if (options.fields) {
+ this.select(options.fields);
+ delete options.fields;
+ }
+
+ this.setOptions(options);
+ }
+
+ if (!callback) {
+ return this;
+ }
+
+ return this._findOneAndUpdate(callback);
+};
+
+/**
+ * Thunk around findOneAndUpdate()
+ *
+ * @param {Function} [callback]
+ * @api private
+ */
+
+Query.prototype._findOneAndUpdate = function(callback) {
+ this._findAndModify('update', callback);
+ return this;
+};
+
+/**
+ * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) remove command.
+ *
+ * Finds a matching document, removes it, passing the found document (if any) to the callback. Executes immediately if `callback` is passed.
+ *
+ * ####Available options
+ *
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ * - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
+ * - `passRawResult`: if true, passes the [raw result from the MongoDB driver as the third callback parameter](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
+ *
+ * ####Callback Signature
+ * function(error, doc, result) {
+ * // error: any errors that occurred
+ * // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
+ * // result: [raw result from the MongoDB driver](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify)
+ * }
+ *
+ * ####Examples
+ *
+ * A.where().findOneAndRemove(conditions, options, callback) // executes
+ * A.where().findOneAndRemove(conditions, options) // return Query
+ * A.where().findOneAndRemove(conditions, callback) // executes
+ * A.where().findOneAndRemove(conditions) // returns Query
+ * A.where().findOneAndRemove(callback) // executes
+ * A.where().findOneAndRemove() // returns Query
+ *
+ * @method findOneAndRemove
+ * @memberOf Query
+ * @param {Object} [conditions]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @api public
+ */
+
+Query.prototype.findOneAndRemove = function(conditions, options, callback) {
+ this.op = 'findOneAndRemove';
+ this._validate();
+
+ switch (arguments.length) {
+ case 2:
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+ break;
+ case 1:
+ if (typeof conditions === 'function') {
+ callback = conditions;
+ conditions = undefined;
+ options = undefined;
+ }
+ break;
+ }
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ options && this.setOptions(options);
+
+ if (!callback) {
+ return this;
+ }
+
+ this._findOneAndRemove(callback);
+
+ return this;
+};
+
+/**
+ * Thunk around findOneAndRemove()
+ *
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api private
+ */
+Query.prototype._findOneAndRemove = function(callback) {
+ Query.base.findOneAndRemove.call(this, callback);
+};
+
+/**
+ * Override mquery.prototype._findAndModify to provide casting etc.
+ *
+ * @param {String} type - either "remove" or "update"
+ * @param {Function} callback
+ * @api private
+ */
+
+Query.prototype._findAndModify = function(type, callback) {
+ if (typeof callback !== 'function') {
+ throw new Error('Expected callback in _findAndModify');
+ }
+
+ var model = this.model;
+ var schema = model.schema;
+ var _this = this;
+ var castedQuery;
+ var castedDoc;
+ var fields;
+ var opts;
+ var doValidate;
+
+ castedQuery = castQuery(this);
+ if (castedQuery instanceof Error) {
+ return callback(castedQuery);
+ }
+
+ opts = this._optionsForExec(model);
+
+ if ('strict' in opts) {
+ this._mongooseOptions.strict = opts.strict;
+ }
+
+ if (type === 'remove') {
+ opts.remove = true;
+ } else {
+ if (!('new' in opts)) {
+ opts.new = false;
+ }
+ if (!('upsert' in opts)) {
+ opts.upsert = false;
+ }
+ if (opts.upsert || opts['new']) {
+ opts.remove = false;
+ }
+
+ castedDoc = castDoc(this, opts.overwrite);
+ castedDoc = setDefaultsOnInsert(this, schema, castedDoc, opts);
+ if (!castedDoc) {
+ if (opts.upsert) {
+ // still need to do the upsert to empty doc
+ var doc = utils.clone(castedQuery);
+ delete doc._id;
+ castedDoc = {$set: doc};
+ } else {
+ return this.findOne(callback);
+ }
+ } else if (castedDoc instanceof Error) {
+ return callback(castedDoc);
+ } else {
+ // In order to make MongoDB 2.6 happy (see
+ // https://jira.mongodb.org/browse/SERVER-12266 and related issues)
+ // if we have an actual update document but $set is empty, junk the $set.
+ if (castedDoc.$set && Object.keys(castedDoc.$set).length === 0) {
+ delete castedDoc.$set;
+ }
+ }
+
+ doValidate = updateValidators(this, schema, castedDoc, opts);
+ }
+
+ this._applyPaths();
+
+ var options = this._mongooseOptions;
+
+ if (this._fields) {
+ fields = utils.clone(this._fields);
+ opts.fields = this._castFields(fields);
+ if (opts.fields instanceof Error) {
+ return callback(opts.fields);
+ }
+ }
+
+ if (opts.sort) convertSortToArray(opts);
+
+ var cb = function(err, doc, res) {
+ if (err) {
+ return callback(err);
+ }
+
+ if (!doc || (utils.isObject(doc) && Object.keys(doc).length === 0)) {
+ if (opts.passRawResult) {
+ return callback(null, null, res);
+ }
+ return callback(null, null);
+ }
+
+ if (!opts.passRawResult) {
+ res = null;
+ }
+
+ if (!options.populate) {
+ return options.lean === true
+ ? callback(null, doc)
+ : completeOne(_this.model, doc, res, fields, _this, null, callback);
+ }
+
+ var pop = helpers.preparePopulationOptionsMQ(_this, options);
+ pop.__noPromise = true;
+ _this.model.populate(doc, pop, function(err, doc) {
+ if (err) {
+ return callback(err);
+ }
+
+ return options.lean === true
+ ? callback(null, doc)
+ : completeOne(_this.model, doc, res, fields, _this, pop, callback);
+ });
+ };
+
+ if (opts.runValidators && doValidate) {
+ var _callback = function(error) {
+ if (error) {
+ return callback(error);
+ }
+ _this._collection.findAndModify(castedQuery, castedDoc, opts, utils.tick(function(error, res) {
+ return cb(error, res ? res.value : res, res);
+ }));
+ };
+
+ try {
+ doValidate(_callback);
+ } catch (error) {
+ callback(error);
+ }
+ } else {
+ this._collection.findAndModify(castedQuery, castedDoc, opts, utils.tick(function(error, res) {
+ return cb(error, res ? res.value : res, res);
+ }));
+ }
+
+ return this;
+};
+
+/**
+ * Override mquery.prototype._mergeUpdate to handle mongoose objects in
+ * updates.
+ *
+ * @param {Object} doc
+ * @api private
+ */
+
+Query.prototype._mergeUpdate = function(doc) {
+ if (!this._update) this._update = {};
+ if (doc instanceof Query) {
+ if (doc._update) {
+ utils.mergeClone(this._update, doc._update);
+ }
+ } else {
+ utils.mergeClone(this._update, doc);
+ }
+};
+
+/*!
+ * The mongodb driver 1.3.23 only supports the nested array sort
+ * syntax. We must convert it or sorting findAndModify will not work.
+ */
+
+function convertSortToArray(opts) {
+ if (Array.isArray(opts.sort)) {
+ return;
+ }
+ if (!utils.isObject(opts.sort)) {
+ return;
+ }
+
+ var sort = [];
+
+ for (var key in opts.sort) {
+ if (utils.object.hasOwnProperty(opts.sort, key)) {
+ sort.push([key, opts.sort[key]]);
+ }
+ }
+
+ opts.sort = sort;
+}
+
+/**
+ * Internal thunk for .update()
+ *
+ * @param {Function} callback
+ * @see Model.update #model_Model.update
+ * @api private
+ */
+Query.prototype._execUpdate = function(callback) {
+ var schema = this.model.schema;
+ var doValidate;
+ var _this;
+
+ var castedQuery = this._conditions;
+ var castedDoc = this._update;
+ var options = this.options;
+
+ if (this._castError) {
+ callback(this._castError);
+ return this;
+ }
+
+ if (this.options.runValidators) {
+ _this = this;
+ doValidate = updateValidators(this, schema, castedDoc, options);
+ var _callback = function(err) {
+ if (err) {
+ return callback(err);
+ }
+
+ Query.base.update.call(_this, castedQuery, castedDoc, options, callback);
+ };
+ try {
+ doValidate(_callback);
+ } catch (err) {
+ process.nextTick(function() {
+ callback(err);
+ });
+ }
+ return this;
+ }
+
+ Query.base.update.call(this, castedQuery, castedDoc, options, callback);
+ return this;
+};
+
+/**
+ * Declare and/or execute this query as an update() operation.
+ *
+ * _All paths passed that are not $atomic operations will become $set ops._
+ *
+ * ####Example
+ *
+ * Model.where({ _id: id }).update({ title: 'words' })
+ *
+ * // becomes
+ *
+ * Model.where({ _id: id }).update({ $set: { title: 'words' }})
+ *
+ * ####Valid options:
+ *
+ * - `safe` (boolean) safe mode (defaults to value set in schema (true))
+ * - `upsert` (boolean) whether to create the doc if it doesn't match (false)
+ * - `multi` (boolean) whether multiple documents should be updated (false)
+ * - `runValidators`: if true, runs [update validators](/docs/validation.html#update-validators) on this command. Update validators validate the update operation against the model's schema.
+ * - `setDefaultsOnInsert`: if this and `upsert` are true, mongoose will apply the [defaults](http://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created. This option only works on MongoDB >= 2.4 because it relies on [MongoDB's `$setOnInsert` operator](https://docs.mongodb.org/v2.4/reference/operator/update/setOnInsert/).
+ * - `strict` (boolean) overrides the `strict` option for this update
+ * - `overwrite` (boolean) disables update-only mode, allowing you to overwrite the doc (false)
+ * - `context` (string) if set to 'query' and `runValidators` is on, `this` will refer to the query in custom validator functions that update validation runs. Does nothing if `runValidators` is false.
+ *
+ * ####Note
+ *
+ * Passing an empty object `{}` as the doc will result in a no-op unless the `overwrite` option is passed. Without the `overwrite` option set, the update operation will be ignored and the callback executed without sending the command to MongoDB so as to prevent accidently overwritting documents in the collection.
+ *
+ * ####Note
+ *
+ * The operation is only executed when a callback is passed. To force execution without a callback, we must first call update() and then execute it by using the `exec()` method.
+ *
+ * var q = Model.where({ _id: id });
+ * q.update({ $set: { name: 'bob' }}).update(); // not executed
+ *
+ * q.update({ $set: { name: 'bob' }}).exec(); // executed
+ *
+ * // keys that are not $atomic ops become $set.
+ * // this executes the same command as the previous example.
+ * q.update({ name: 'bob' }).exec();
+ *
+ * // overwriting with empty docs
+ * var q = Model.where({ _id: id }).setOptions({ overwrite: true })
+ * q.update({ }, callback); // executes
+ *
+ * // multi update with overwrite to empty doc
+ * var q = Model.where({ _id: id });
+ * q.setOptions({ multi: true, overwrite: true })
+ * q.update({ });
+ * q.update(callback); // executed
+ *
+ * // multi updates
+ * Model.where()
+ * .update({ name: /^match/ }, { $set: { arr: [] }}, { multi: true }, callback)
+ *
+ * // more multi updates
+ * Model.where()
+ * .setOptions({ multi: true })
+ * .update({ $set: { arr: [] }}, callback)
+ *
+ * // single update by default
+ * Model.where({ email: 'address@example.com' })
+ * .update({ $inc: { counter: 1 }}, callback)
+ *
+ * API summary
+ *
+ * update(criteria, doc, options, cb) // executes
+ * update(criteria, doc, options)
+ * update(criteria, doc, cb) // executes
+ * update(criteria, doc)
+ * update(doc, cb) // executes
+ * update(doc)
+ * update(cb) // executes
+ * update(true) // executes
+ * update()
+ *
+ * @param {Object} [criteria]
+ * @param {Object} [doc] the update command
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see Model.update #model_Model.update
+ * @see update http://docs.mongodb.org/manual/reference/method/db.collection.update/
+ * @api public
+ */
+
+Query.prototype.update = function(conditions, doc, options, callback) {
+ if (typeof options === 'function') {
+ // .update(conditions, doc, callback)
+ callback = options;
+ options = null;
+ } else if (typeof doc === 'function') {
+ // .update(doc, callback);
+ callback = doc;
+ doc = conditions;
+ conditions = {};
+ options = null;
+ } else if (typeof conditions === 'function') {
+ // .update(callback)
+ callback = conditions;
+ conditions = undefined;
+ doc = undefined;
+ options = undefined;
+ } else if (typeof conditions === 'object' && !doc && !options && !callback) {
+ // .update(doc)
+ doc = conditions;
+ conditions = undefined;
+ options = undefined;
+ callback = undefined;
+ }
+
+ // make sure we don't send in the whole Document to merge()
+ conditions = utils.toObject(conditions);
+
+ var oldCb = callback;
+ if (oldCb) {
+ if (typeof oldCb === 'function') {
+ callback = function(error, result) {
+ oldCb(error, result ? result.result : {ok: 0, n: 0, nModified: 0});
+ };
+ } else {
+ throw new Error('Invalid callback() argument.');
+ }
+ }
+
+ // strict is an option used in the update checking, make sure it gets set
+ if (options) {
+ if ('strict' in options) {
+ this._mongooseOptions.strict = options.strict;
+ }
+ }
+
+ // if doc is undefined at this point, this means this function is being
+ // executed by exec(not always see below). Grab the update doc from here in
+ // order to validate
+ // This could also be somebody calling update() or update({}). Probably not a
+ // common use case, check for _update to make sure we don't do anything bad
+ if (!doc && this._update) {
+ doc = this._updateForExec();
+ }
+
+ if (mquery.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ // validate the selector part of the query
+ var castedQuery = castQuery(this);
+ if (castedQuery instanceof Error) {
+ this._castError = castedQuery;
+ if (callback) {
+ callback(castedQuery);
+ return this;
+ } else if (!options || !options.dontThrowCastError) {
+ throw castedQuery;
+ }
+ }
+
+ // validate the update part of the query
+ var castedDoc;
+ try {
+ var $options = {retainKeyOrder: true};
+ if (options && options.minimize) {
+ $options.minimize = true;
+ }
+ castedDoc = this._castUpdate(utils.clone(doc, $options),
+ options && options.overwrite);
+ } catch (err) {
+ this._castError = castedQuery;
+ if (callback) {
+ callback(err);
+ return this;
+ } else if (!options || !options.dontThrowCastError) {
+ throw err;
+ }
+ }
+
+ castedDoc = setDefaultsOnInsert(this, this.schema, castedDoc, options);
+ if (!castedDoc) {
+ // Make sure promises know that this is still an update, see gh-2796
+ this.op = 'update';
+ callback && callback(null);
+ return this;
+ }
+
+ if (utils.isObject(options)) {
+ this.setOptions(options);
+ }
+
+ if (!this._update) this._update = castedDoc;
+
+ // Hooks
+ if (callback) {
+ return this._execUpdate(callback);
+ }
+
+ return Query.base.update.call(this, castedQuery, castedDoc, options, callback);
+};
+
+/**
+ * Executes the query
+ *
+ * ####Examples:
+ *
+ * var promise = query.exec();
+ * var promise = query.exec('update');
+ *
+ * query.exec(callback);
+ * query.exec('find', callback);
+ *
+ * @param {String|Function} [operation]
+ * @param {Function} [callback]
+ * @return {Promise}
+ * @api public
+ */
+
+Query.prototype.exec = function exec(op, callback) {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+
+ if (typeof op === 'function') {
+ callback = op;
+ op = null;
+ } else if (typeof op === 'string') {
+ this.op = op;
+ }
+
+ var _results;
+ var promise = new Promise.ES6(function(resolve, reject) {
+ if (!_this.op) {
+ resolve();
+ return;
+ }
+
+ _this[_this.op].call(_this, function(error, res) {
+ if (error) {
+ reject(error);
+ return;
+ }
+ _results = arguments;
+ resolve(res);
+ });
+ });
+
+ if (callback) {
+ promise.then(
+ function() {
+ callback.apply(null, _results);
+ },
+ function(error) {
+ callback(error);
+ }).
+ catch(function(error) {
+ // If we made it here, we must have an error in the callback re:
+ // gh-4500, so we need to emit.
+ setImmediate(function() {
+ _this.model.emit('error', error);
+ });
+ });
+ }
+
+ return promise;
+};
+
+/**
+ * Executes the query returning a `Promise` which will be
+ * resolved with either the doc(s) or rejected with the error.
+ *
+ * @param {Function} [resolve]
+ * @param {Function} [reject]
+ * @return {Promise}
+ * @api public
+ */
+
+Query.prototype.then = function(resolve, reject) {
+ return this.exec().then(resolve, reject);
+};
+
+/**
+ * Executes the query returning a `Promise` which will be
+ * resolved with either the doc(s) or rejected with the error.
+ * Like `.then()`, but only takes a rejection handler.
+ *
+ * @param {Function} [reject]
+ * @return {Promise}
+ * @api public
+ */
+
+Query.prototype.catch = function(reject) {
+ return this.exec().then(null, reject);
+};
+
+/**
+ * Finds the schema for `path`. This is different than
+ * calling `schema.path` as it also resolves paths with
+ * positional selectors (something.$.another.$.path).
+ *
+ * @param {String} path
+ * @api private
+ */
+
+Query.prototype._getSchema = function _getSchema(path) {
+ return this.model._getSchema(path);
+};
+
+/*!
+ * These operators require casting docs
+ * to real Documents for Update operations.
+ */
+
+var castOps = {
+ $push: 1,
+ $pushAll: 1,
+ $addToSet: 1,
+ $set: 1
+};
+
+/*!
+ * These operators should be cast to numbers instead
+ * of their path schema type.
+ */
+
+var numberOps = {
+ $pop: 1,
+ $unset: 1,
+ $inc: 1
+};
+
+/**
+ * Casts obj for an update command.
+ *
+ * @param {Object} obj
+ * @return {Object} obj after casting its values
+ * @api private
+ */
+
+Query.prototype._castUpdate = function _castUpdate(obj, overwrite) {
+ if (!obj) {
+ return undefined;
+ }
+
+ var ops = Object.keys(obj);
+ var i = ops.length;
+ var ret = {};
+ var hasKeys;
+ var val;
+ var hasDollarKey = false;
+
+ while (i--) {
+ var op = ops[i];
+ // if overwrite is set, don't do any of the special $set stuff
+ if (op[0] !== '$' && !overwrite) {
+ // fix up $set sugar
+ if (!ret.$set) {
+ if (obj.$set) {
+ ret.$set = obj.$set;
+ } else {
+ ret.$set = {};
+ }
+ }
+ ret.$set[op] = obj[op];
+ ops.splice(i, 1);
+ if (!~ops.indexOf('$set')) ops.push('$set');
+ } else if (op === '$set') {
+ if (!ret.$set) {
+ ret[op] = obj[op];
+ }
+ } else {
+ ret[op] = obj[op];
+ }
+ }
+
+ // cast each value
+ i = ops.length;
+
+ // if we get passed {} for the update, we still need to respect that when it
+ // is an overwrite scenario
+ if (overwrite) {
+ hasKeys = true;
+ }
+
+ while (i--) {
+ op = ops[i];
+ val = ret[op];
+ hasDollarKey = hasDollarKey || op.charAt(0) === '$';
+ if (val &&
+ val.constructor.name === 'Object' &&
+ (!overwrite || hasDollarKey)) {
+ hasKeys |= this._walkUpdatePath(val, op);
+ } else if (overwrite && ret.constructor.name === 'Object') {
+ // if we are just using overwrite, cast the query and then we will
+ // *always* return the value, even if it is an empty object. We need to
+ // set hasKeys above because we need to account for the case where the
+ // user passes {} and wants to clobber the whole document
+ // Also, _walkUpdatePath expects an operation, so give it $set since that
+ // is basically what we're doing
+ this._walkUpdatePath(ret, '$set');
+ } else {
+ var msg = 'Invalid atomic update value for ' + op + '. '
+ + 'Expected an object, received ' + typeof val;
+ throw new Error(msg);
+ }
+ }
+
+ return hasKeys && ret;
+};
+
+/**
+ * Walk each path of obj and cast its values
+ * according to its schema.
+ *
+ * @param {Object} obj - part of a query
+ * @param {String} op - the atomic operator ($pull, $set, etc)
+ * @param {String} pref - path prefix (internal only)
+ * @return {Bool} true if this path has keys to update
+ * @api private
+ */
+
+Query.prototype._walkUpdatePath = function _walkUpdatePath(obj, op, pref) {
+ var prefix = pref ? pref + '.' : '',
+ keys = Object.keys(obj),
+ i = keys.length,
+ hasKeys = false,
+ schema,
+ key,
+ val;
+
+ var useNestedStrict = this.schema.options.useNestedStrict;
+
+ while (i--) {
+ key = keys[i];
+ val = obj[key];
+
+ if (val && val.constructor.name === 'Object') {
+ // watch for embedded doc schemas
+ schema = this._getSchema(prefix + key);
+ if (schema && schema.caster && op in castOps) {
+ // embedded doc schema
+ hasKeys = true;
+
+ if ('$each' in val) {
+ obj[key] = {
+ $each: this._castUpdateVal(schema, val.$each, op)
+ };
+
+ if (val.$slice != null) {
+ obj[key].$slice = val.$slice | 0;
+ }
+
+ if (val.$sort) {
+ obj[key].$sort = val.$sort;
+ }
+
+ if (!!val.$position || val.$position === 0) {
+ obj[key].$position = val.$position;
+ }
+ } else {
+ obj[key] = this._castUpdateVal(schema, val, op);
+ }
+ } else if (op === '$currentDate') {
+ // $currentDate can take an object
+ obj[key] = this._castUpdateVal(schema, val, op);
+ hasKeys = true;
+ } else if (op === '$set' && schema) {
+ obj[key] = this._castUpdateVal(schema, val, op);
+ hasKeys = true;
+ } else {
+ var pathToCheck = (prefix + key);
+ var v = this.model.schema._getPathType(pathToCheck);
+ var _strict = 'strict' in this._mongooseOptions ?
+ this._mongooseOptions.strict :
+ ((useNestedStrict && v.schema) || this.schema).options.strict;
+ if (v.pathType === 'undefined') {
+ if (_strict === 'throw') {
+ throw new StrictModeError(pathToCheck);
+ } else if (_strict) {
+ delete obj[key];
+ continue;
+ }
+ }
+
+ // gh-2314
+ // we should be able to set a schema-less field
+ // to an empty object literal
+ hasKeys |= this._walkUpdatePath(val, op, prefix + key) ||
+ (utils.isObject(val) && Object.keys(val).length === 0);
+ }
+ } else {
+ var checkPath = (key === '$each' || key === '$or' || key === '$and') ?
+ pref : prefix + key;
+ schema = this._getSchema(checkPath);
+
+ var pathDetails = this.model.schema._getPathType(checkPath);
+ var isStrict = 'strict' in this._mongooseOptions ?
+ this._mongooseOptions.strict :
+ ((useNestedStrict && pathDetails.schema) || this.schema).options.strict;
+
+ var skip = isStrict &&
+ !schema &&
+ !/real|nested/.test(pathDetails.pathType);
+
+ if (skip) {
+ if (isStrict === 'throw') {
+ throw new StrictModeError(prefix + key);
+ } else {
+ delete obj[key];
+ }
+ } else {
+ // gh-1845 temporary fix: ignore $rename. See gh-3027 for tracking
+ // improving this.
+ if (op === '$rename') {
+ hasKeys = true;
+ continue;
+ }
+
+ hasKeys = true;
+ obj[key] = this._castUpdateVal(schema, val, op, key);
+ }
+ }
+ }
+ return hasKeys;
+};
+
+/**
+ * Casts `val` according to `schema` and atomic `op`.
+ *
+ * @param {Schema} schema
+ * @param {Object} val
+ * @param {String} op - the atomic operator ($pull, $set, etc)
+ * @param {String} [$conditional]
+ * @api private
+ */
+
+Query.prototype._castUpdateVal = function _castUpdateVal(schema, val, op, $conditional) {
+ if (!schema) {
+ // non-existing schema path
+ return op in numberOps
+ ? Number(val)
+ : val;
+ }
+
+ var cond = schema.caster && op in castOps &&
+ (utils.isObject(val) || Array.isArray(val));
+ if (cond) {
+ // Cast values for ops that add data to MongoDB.
+ // Ensures embedded documents get ObjectIds etc.
+ var tmp = schema.cast(val);
+ if (Array.isArray(val)) {
+ val = tmp;
+ } else if (Array.isArray(tmp)) {
+ val = tmp[0];
+ } else {
+ val = tmp;
+ }
+ }
+
+ if (op in numberOps) {
+ if (op === '$inc') {
+ return schema.castForQuery(val);
+ }
+ return Number(val);
+ }
+ if (op === '$currentDate') {
+ if (typeof val === 'object') {
+ return {$type: val.$type};
+ }
+ return Boolean(val);
+ }
+ if (/^\$/.test($conditional)) {
+ return schema.castForQuery($conditional, val);
+ }
+
+ return schema.castForQuery(val);
+};
+
+/*!
+ * castQuery
+ * @api private
+ */
+
+function castQuery(query) {
+ try {
+ return query.cast(query.model);
+ } catch (err) {
+ return err;
+ }
+}
+
+/*!
+ * castDoc
+ * @api private
+ */
+
+function castDoc(query, overwrite) {
+ try {
+ return query._castUpdate(query._update, overwrite);
+ } catch (err) {
+ return err;
+ }
+}
+
+/**
+ * Specifies paths which should be populated with other documents.
+ *
+ * ####Example:
+ *
+ * Kitten.findOne().populate('owner').exec(function (err, kitten) {
+ * console.log(kitten.owner.name) // Max
+ * })
+ *
+ * Kitten.find().populate({
+ * path: 'owner'
+ * , select: 'name'
+ * , match: { color: 'black' }
+ * , options: { sort: { name: -1 }}
+ * }).exec(function (err, kittens) {
+ * console.log(kittens[0].owner.name) // Zoopa
+ * })
+ *
+ * // alternatively
+ * Kitten.find().populate('owner', 'name', null, {sort: { name: -1 }}).exec(function (err, kittens) {
+ * console.log(kittens[0].owner.name) // Zoopa
+ * })
+ *
+ * Paths are populated after the query executes and a response is received. A separate query is then executed for each path specified for population. After a response for each query has also been returned, the results are passed to the callback.
+ *
+ * @param {Object|String} path either the path to populate or an object specifying all parameters
+ * @param {Object|String} [select] Field selection for the population query
+ * @param {Model} [model] The model you wish to use for population. If not specified, populate will look up the model by the name in the Schema's `ref` field.
+ * @param {Object} [match] Conditions for the population query
+ * @param {Object} [options] Options for the population query (sort, etc)
+ * @see population ./populate.html
+ * @see Query#select #query_Query-select
+ * @see Model.populate #model_Model.populate
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.populate = function() {
+ var res = utils.populate.apply(null, arguments);
+ var opts = this._mongooseOptions;
+
+ if (!utils.isObject(opts.populate)) {
+ opts.populate = {};
+ }
+
+ var pop = opts.populate;
+
+ for (var i = 0; i < res.length; ++i) {
+ var path = res[i].path;
+ if (pop[path] && pop[path].populate && res[i].populate) {
+ res[i].populate = pop[path].populate.concat(res[i].populate);
+ }
+ pop[res[i].path] = res[i];
+ }
+
+ return this;
+};
+
+/**
+ * Casts this query to the schema of `model`
+ *
+ * ####Note
+ *
+ * If `obj` is present, it is cast instead of this query.
+ *
+ * @param {Model} model
+ * @param {Object} [obj]
+ * @return {Object}
+ * @api public
+ */
+
+Query.prototype.cast = function(model, obj) {
+ obj || (obj = this._conditions);
+
+ try {
+ return cast(model.schema, obj);
+ } catch (err) {
+ // CastError, assign model
+ if (typeof err.setModel === 'function') {
+ err.setModel(model);
+ }
+ throw err;
+ }
+};
+
+/**
+ * Casts selected field arguments for field selection with mongo 2.2
+ *
+ * query.select({ ids: { $elemMatch: { $in: [hexString] }})
+ *
+ * @param {Object} fields
+ * @see https://github.com/Automattic/mongoose/issues/1091
+ * @see http://docs.mongodb.org/manual/reference/projection/elemMatch/
+ * @api private
+ */
+
+Query.prototype._castFields = function _castFields(fields) {
+ var selected,
+ elemMatchKeys,
+ keys,
+ key,
+ out,
+ i;
+
+ if (fields) {
+ keys = Object.keys(fields);
+ elemMatchKeys = [];
+ i = keys.length;
+
+ // collect $elemMatch args
+ while (i--) {
+ key = keys[i];
+ if (fields[key].$elemMatch) {
+ selected || (selected = {});
+ selected[key] = fields[key];
+ elemMatchKeys.push(key);
+ }
+ }
+ }
+
+ if (selected) {
+ // they passed $elemMatch, cast em
+ try {
+ out = this.cast(this.model, selected);
+ } catch (err) {
+ return err;
+ }
+
+ // apply the casted field args
+ i = elemMatchKeys.length;
+ while (i--) {
+ key = elemMatchKeys[i];
+ fields[key] = out[key];
+ }
+ }
+
+ return fields;
+};
+
+/**
+ * Applies schematype selected options to this query.
+ * @api private
+ */
+
+Query.prototype._applyPaths = function applyPaths() {
+ // determine if query is selecting or excluding fields
+
+ var fields = this._fields,
+ exclude,
+ keys,
+ ki;
+
+ if (fields) {
+ keys = Object.keys(fields);
+ ki = keys.length;
+
+ while (ki--) {
+ if (keys[ki][0] === '+') continue;
+ exclude = fields[keys[ki]] === 0;
+ break;
+ }
+ }
+
+ // if selecting, apply default schematype select:true fields
+ // if excluding, apply schematype select:false fields
+
+ var selected = [],
+ excluded = [],
+ seen = [];
+
+ var analyzePath = function(path, type) {
+ if (typeof type.selected !== 'boolean') return;
+
+ var plusPath = '+' + path;
+ if (fields && plusPath in fields) {
+ // forced inclusion
+ delete fields[plusPath];
+
+ // if there are other fields being included, add this one
+ // if no other included fields, leave this out (implied inclusion)
+ if (exclude === false && keys.length > 1 && !~keys.indexOf(path)) {
+ fields[path] = 1;
+ }
+
+ return;
+ }
+
+ // check for parent exclusions
+ var root = path.split('.')[0];
+ if (~excluded.indexOf(root)) return;
+
+ (type.selected ? selected : excluded).push(path);
+ };
+
+ var analyzeSchema = function(schema, prefix) {
+ prefix || (prefix = '');
+
+ // avoid recursion
+ if (~seen.indexOf(schema)) return;
+ seen.push(schema);
+
+ schema.eachPath(function(path, type) {
+ if (prefix) path = prefix + '.' + path;
+
+ analyzePath(path, type);
+
+ // array of subdocs?
+ if (type.schema) {
+ analyzeSchema(type.schema, path);
+ }
+ });
+ };
+
+ analyzeSchema(this.model.schema);
+
+ switch (exclude) {
+ case true:
+ excluded.length && this.select('-' + excluded.join(' -'));
+ break;
+ case false:
+ if (this.model.schema && this.model.schema.paths['_id'] &&
+ this.model.schema.paths['_id'].options && this.model.schema.paths['_id'].options.select === false) {
+ selected.push('-_id');
+ }
+ selected.length && this.select(selected.join(' '));
+ break;
+ case undefined:
+ // user didn't specify fields, implies returning all fields.
+ // only need to apply excluded fields
+ excluded.length && this.select('-' + excluded.join(' -'));
+ break;
+ }
+ seen = excluded = selected = keys = fields = null;
+};
+
+/**
+ * Returns a Node.js 0.8 style [read stream](http://nodejs.org/docs/v0.8.21/api/stream.html#stream_readable_stream) interface.
+ *
+ * ####Example
+ *
+ * // follows the nodejs 0.8 stream api
+ * Thing.find({ name: /^hello/ }).stream().pipe(res)
+ *
+ * // manual streaming
+ * var stream = Thing.find({ name: /^hello/ }).stream();
+ *
+ * stream.on('data', function (doc) {
+ * // do something with the mongoose document
+ * }).on('error', function (err) {
+ * // handle the error
+ * }).on('close', function () {
+ * // the stream is closed
+ * });
+ *
+ * ####Valid options
+ *
+ * - `transform`: optional function which accepts a mongoose document. The return value of the function will be emitted on `data`.
+ *
+ * ####Example
+ *
+ * // JSON.stringify all documents before emitting
+ * var stream = Thing.find().stream({ transform: JSON.stringify });
+ * stream.pipe(writeStream);
+ *
+ * @return {QueryStream}
+ * @param {Object} [options]
+ * @see QueryStream
+ * @api public
+ */
+
+Query.prototype.stream = function stream(opts) {
+ this._applyPaths();
+ this._fields = this._castFields(this._fields);
+ return new QueryStream(this, opts);
+};
+Query.prototype.stream = util.deprecate(Query.prototype.stream, 'Mongoose: ' +
+ 'Query.prototype.stream() is deprecated in mongoose >= 4.5.0, ' +
+ 'use Query.prototype.cursor() instead');
+
+/**
+ * Returns a wrapper around a [mongodb driver cursor](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
+ * A QueryCursor exposes a [Streams3](https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/)-compatible
+ * interface, as well as a `.next()` function.
+ *
+ * ####Example
+ *
+ * // There are 2 ways to use a cursor. First, as a stream:
+ * Thing.
+ * find({ name: /^hello/ }).
+ * cursor().
+ * on('data', function(doc) { console.log(doc); }).
+ * on('end', function() { console.log('Done!'); });
+ *
+ * // Or you can use `.next()` to manually get the next doc in the stream.
+ * // `.next()` returns a promise, so you can use promises or callbacks.
+ * var cursor = Thing.find({ name: /^hello/ }).cursor();
+ * cursor.next(function(error, doc) {
+ * console.log(doc);
+ * });
+ *
+ * // Because `.next()` returns a promise, you can use co
+ * // to easily iterate through all documents without loading them
+ * // all into memory.
+ * co(function*() {
+ * const cursor = Thing.find({ name: /^hello/ }).cursor();
+ * for (let doc = yield cursor.next(); doc != null; doc = yield cursor.next()) {
+ * console.log(doc);
+ * }
+ * });
+ *
+ * ####Valid options
+ *
+ * - `transform`: optional function which accepts a mongoose document. The return value of the function will be emitted on `data` and returned by `.next()`.
+ *
+ * @return {QueryCursor}
+ * @param {Object} [options]
+ * @see QueryCursor
+ * @api public
+ */
+
+Query.prototype.cursor = function cursor(opts) {
+ this._applyPaths();
+ this._fields = this._castFields(this._fields);
+ this.setOptions({ fields: this._fieldsForExec() });
+ if (opts) {
+ this.setOptions(opts);
+ }
+
+ try {
+ this.cast(this.model);
+ } catch (err) {
+ return (new QueryCursor(this, this.options))._markError(err);
+ }
+
+ return new QueryCursor(this, this.options);
+};
+
+// the rest of these are basically to support older Mongoose syntax with mquery
+
+/**
+ * _DEPRECATED_ Alias of `maxScan`
+ *
+ * @deprecated
+ * @see maxScan #query_Query-maxScan
+ * @method maxscan
+ * @memberOf Query
+ */
+
+Query.prototype.maxscan = Query.base.maxScan;
+
+/**
+ * Sets the tailable option (for use with capped collections).
+ *
+ * ####Example
+ *
+ * query.tailable() // true
+ * query.tailable(true)
+ * query.tailable(false)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @param {Boolean} bool defaults to true
+ * @param {Object} [opts] options to set
+ * @param {Number} [opts.numberOfRetries] if cursor is exhausted, retry this many times before giving up
+ * @param {Number} [opts.tailableRetryInterval] if cursor is exhausted, wait this many milliseconds before retrying
+ * @see tailable http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/
+ * @api public
+ */
+
+Query.prototype.tailable = function(val, opts) {
+ // we need to support the tailable({ awaitdata : true }) as well as the
+ // tailable(true, {awaitdata :true}) syntax that mquery does not support
+ if (val && val.constructor.name === 'Object') {
+ opts = val;
+ val = true;
+ }
+
+ if (val === undefined) {
+ val = true;
+ }
+
+ if (opts && typeof opts === 'object') {
+ for (var key in opts) {
+ if (key === 'awaitdata') {
+ // For backwards compatibility
+ this.options[key] = !!opts[key];
+ } else {
+ this.options[key] = opts[key];
+ }
+ }
+ }
+
+ return Query.base.tailable.call(this, val);
+};
+
+/**
+ * Declares an intersects query for `geometry()`.
+ *
+ * ####Example
+ *
+ * query.where('path').intersects().geometry({
+ * type: 'LineString'
+ * , coordinates: [[180.0, 11.0], [180, 9.0]]
+ * })
+ *
+ * query.where('path').intersects({
+ * type: 'LineString'
+ * , coordinates: [[180.0, 11.0], [180, 9.0]]
+ * })
+ *
+ * ####NOTE:
+ *
+ * **MUST** be used after `where()`.
+ *
+ * ####NOTE:
+ *
+ * In Mongoose 3.7, `intersects` changed from a getter to a function. If you need the old syntax, use [this](https://github.com/ebensing/mongoose-within).
+ *
+ * @method intersects
+ * @memberOf Query
+ * @param {Object} [arg]
+ * @return {Query} this
+ * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
+ * @see geoIntersects http://docs.mongodb.org/manual/reference/operator/geoIntersects/
+ * @api public
+ */
+
+/**
+ * Specifies a `$geometry` condition
+ *
+ * ####Example
+ *
+ * var polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
+ * query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
+ *
+ * // or
+ * var polyB = [[ 0, 0 ], [ 1, 1 ]]
+ * query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
+ *
+ * // or
+ * var polyC = [ 0, 0 ]
+ * query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
+ *
+ * // or
+ * query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })
+ *
+ * The argument is assigned to the most recent path passed to `where()`.
+ *
+ * ####NOTE:
+ *
+ * `geometry()` **must** come after either `intersects()` or `within()`.
+ *
+ * The `object` argument must contain `type` and `coordinates` properties.
+ * - type {String}
+ * - coordinates {Array}
+ *
+ * @method geometry
+ * @memberOf Query
+ * @param {Object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
+ * @return {Query} this
+ * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
+ * @see http://docs.mongodb.org/manual/release-notes/2.4/#new-geospatial-indexes-with-geojson-and-improved-spherical-geometry
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+/**
+ * Specifies a `$near` or `$nearSphere` condition
+ *
+ * These operators return documents sorted by distance.
+ *
+ * ####Example
+ *
+ * query.where('loc').near({ center: [10, 10] });
+ * query.where('loc').near({ center: [10, 10], maxDistance: 5 });
+ * query.where('loc').near({ center: [10, 10], maxDistance: 5, spherical: true });
+ * query.near('loc', { center: [10, 10], maxDistance: 5 });
+ *
+ * @method near
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Object} val
+ * @return {Query} this
+ * @see $near http://docs.mongodb.org/manual/reference/operator/near/
+ * @see $nearSphere http://docs.mongodb.org/manual/reference/operator/nearSphere/
+ * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+/*!
+ * Overwriting mquery is needed to support a couple different near() forms found in older
+ * versions of mongoose
+ * near([1,1])
+ * near(1,1)
+ * near(field, [1,2])
+ * near(field, 1, 2)
+ * In addition to all of the normal forms supported by mquery
+ */
+
+Query.prototype.near = function() {
+ var params = [];
+ var sphere = this._mongooseOptions.nearSphere;
+
+ // TODO refactor
+
+ if (arguments.length === 1) {
+ if (Array.isArray(arguments[0])) {
+ params.push({center: arguments[0], spherical: sphere});
+ } else if (typeof arguments[0] === 'string') {
+ // just passing a path
+ params.push(arguments[0]);
+ } else if (utils.isObject(arguments[0])) {
+ if (typeof arguments[0].spherical !== 'boolean') {
+ arguments[0].spherical = sphere;
+ }
+ params.push(arguments[0]);
+ } else {
+ throw new TypeError('invalid argument');
+ }
+ } else if (arguments.length === 2) {
+ if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
+ params.push({center: [arguments[0], arguments[1]], spherical: sphere});
+ } else if (typeof arguments[0] === 'string' && Array.isArray(arguments[1])) {
+ params.push(arguments[0]);
+ params.push({center: arguments[1], spherical: sphere});
+ } else if (typeof arguments[0] === 'string' && utils.isObject(arguments[1])) {
+ params.push(arguments[0]);
+ if (typeof arguments[1].spherical !== 'boolean') {
+ arguments[1].spherical = sphere;
+ }
+ params.push(arguments[1]);
+ } else {
+ throw new TypeError('invalid argument');
+ }
+ } else if (arguments.length === 3) {
+ if (typeof arguments[0] === 'string' && typeof arguments[1] === 'number'
+ && typeof arguments[2] === 'number') {
+ params.push(arguments[0]);
+ params.push({center: [arguments[1], arguments[2]], spherical: sphere});
+ } else {
+ throw new TypeError('invalid argument');
+ }
+ } else {
+ throw new TypeError('invalid argument');
+ }
+
+ return Query.base.near.apply(this, params);
+};
+
+/**
+ * _DEPRECATED_ Specifies a `$nearSphere` condition
+ *
+ * ####Example
+ *
+ * query.where('loc').nearSphere({ center: [10, 10], maxDistance: 5 });
+ *
+ * **Deprecated.** Use `query.near()` instead with the `spherical` option set to `true`.
+ *
+ * ####Example
+ *
+ * query.where('loc').near({ center: [10, 10], spherical: true });
+ *
+ * @deprecated
+ * @see near() #query_Query-near
+ * @see $near http://docs.mongodb.org/manual/reference/operator/near/
+ * @see $nearSphere http://docs.mongodb.org/manual/reference/operator/nearSphere/
+ * @see $maxDistance http://docs.mongodb.org/manual/reference/operator/maxDistance/
+ */
+
+Query.prototype.nearSphere = function() {
+ this._mongooseOptions.nearSphere = true;
+ this.near.apply(this, arguments);
+ return this;
+};
+
+/**
+ * Specifies a $polygon condition
+ *
+ * ####Example
+ *
+ * query.where('loc').within().polygon([10,20], [13, 25], [7,15])
+ * query.polygon('loc', [10,20], [13, 25], [7,15])
+ *
+ * @method polygon
+ * @memberOf Query
+ * @param {String|Array} [path]
+ * @param {Array|Object} [coordinatePairs...]
+ * @return {Query} this
+ * @see $polygon http://docs.mongodb.org/manual/reference/operator/polygon/
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+/**
+ * Specifies a $box condition
+ *
+ * ####Example
+ *
+ * var lowerLeft = [40.73083, -73.99756]
+ * var upperRight= [40.741404, -73.988135]
+ *
+ * query.where('loc').within().box(lowerLeft, upperRight)
+ * query.box({ ll : lowerLeft, ur : upperRight })
+ *
+ * @method box
+ * @memberOf Query
+ * @see $box http://docs.mongodb.org/manual/reference/operator/box/
+ * @see within() Query#within #query_Query-within
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @param {Object} val
+ * @param [Array] Upper Right Coords
+ * @return {Query} this
+ * @api public
+ */
+
+/*!
+ * this is needed to support the mongoose syntax of:
+ * box(field, { ll : [x,y], ur : [x2,y2] })
+ * box({ ll : [x,y], ur : [x2,y2] })
+ */
+
+Query.prototype.box = function(ll, ur) {
+ if (!Array.isArray(ll) && utils.isObject(ll)) {
+ ur = ll.ur;
+ ll = ll.ll;
+ }
+ return Query.base.box.call(this, ll, ur);
+};
+
+/**
+ * Specifies a $center or $centerSphere condition.
+ *
+ * ####Example
+ *
+ * var area = { center: [50, 50], radius: 10, unique: true }
+ * query.where('loc').within().circle(area)
+ * // alternatively
+ * query.circle('loc', area);
+ *
+ * // spherical calculations
+ * var area = { center: [50, 50], radius: 10, unique: true, spherical: true }
+ * query.where('loc').within().circle(area)
+ * // alternatively
+ * query.circle('loc', area);
+ *
+ * New in 3.7.0
+ *
+ * @method circle
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Object} area
+ * @return {Query} this
+ * @see $center http://docs.mongodb.org/manual/reference/operator/center/
+ * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
+ * @see $geoWithin http://docs.mongodb.org/manual/reference/operator/geoWithin/
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+/**
+ * _DEPRECATED_ Alias for [circle](#query_Query-circle)
+ *
+ * **Deprecated.** Use [circle](#query_Query-circle) instead.
+ *
+ * @deprecated
+ * @method center
+ * @memberOf Query
+ * @api public
+ */
+
+Query.prototype.center = Query.base.circle;
+
+/**
+ * _DEPRECATED_ Specifies a $centerSphere condition
+ *
+ * **Deprecated.** Use [circle](#query_Query-circle) instead.
+ *
+ * ####Example
+ *
+ * var area = { center: [50, 50], radius: 10 };
+ * query.where('loc').within().centerSphere(area);
+ *
+ * @deprecated
+ * @param {String} [path]
+ * @param {Object} val
+ * @return {Query} this
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @see $centerSphere http://docs.mongodb.org/manual/reference/operator/centerSphere/
+ * @api public
+ */
+
+Query.prototype.centerSphere = function() {
+ if (arguments[0] && arguments[0].constructor.name === 'Object') {
+ arguments[0].spherical = true;
+ }
+
+ if (arguments[1] && arguments[1].constructor.name === 'Object') {
+ arguments[1].spherical = true;
+ }
+
+ Query.base.circle.apply(this, arguments);
+};
+
+/**
+ * Determines if field selection has been made.
+ *
+ * @method selected
+ * @memberOf Query
+ * @return {Boolean}
+ * @api public
+ */
+
+/**
+ * Determines if inclusive field selection has been made.
+ *
+ * query.selectedInclusively() // false
+ * query.select('name')
+ * query.selectedInclusively() // true
+ *
+ * @method selectedInclusively
+ * @memberOf Query
+ * @return {Boolean}
+ * @api public
+ */
+
+/**
+ * Determines if exclusive field selection has been made.
+ *
+ * query.selectedExclusively() // false
+ * query.select('-name')
+ * query.selectedExclusively() // true
+ * query.selectedInclusively() // false
+ *
+ * @method selectedExclusively
+ * @memberOf Query
+ * @return {Boolean}
+ * @api public
+ */
+
+/*!
+ * Export
+ */
+
+module.exports = Query;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querycursor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querycursor.js
new file mode 100644
index 0000000..da82a5b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querycursor.js
@@ -0,0 +1,314 @@
+/*!
+ * Module dependencies.
+ */
+
+var PromiseProvider = require('./promise_provider');
+var Readable = require('stream').Readable;
+var helpers = require('./queryhelpers');
+var util = require('util');
+
+/**
+ * A QueryCursor is a concurrency primitive for processing query results
+ * one document at a time. A QueryCursor fulfills the [Node.js streams3 API](https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/),
+ * in addition to several other mechanisms for loading documents from MongoDB
+ * one at a time.
+ *
+ * Unless you're an advanced user, do **not** instantiate this class directly.
+ * Use [`Query#cursor()`](/docs/api.html#query_Query-cursor) instead.
+ *
+ * @param {Query} query
+ * @param {Object} options query options passed to `.find()`
+ * @inherits Readable
+ * @event `cursor`: Emitted when the cursor is created
+ * @event `error`: Emitted when an error occurred
+ * @event `data`: Emitted when the stream is flowing and the next doc is ready
+ * @event `end`: Emitted when the stream is exhausted
+ * @api public
+ */
+
+function QueryCursor(query, options) {
+ Readable.call(this, { objectMode: true });
+
+ this.cursor = null;
+ this.query = query;
+ this._transforms = options.transform ? [options.transform] : [];
+ var _this = this;
+ var model = query.model;
+ model.collection.find(query._conditions, options, function(err, cursor) {
+ if (_this._error) {
+ cursor.close(function() {});
+ _this.listeners('error').length > 0 && _this.emit('error', _this._error);
+ }
+ if (err) {
+ return _this.emit('error', err);
+ }
+ _this.cursor = cursor;
+ _this.emit('cursor', cursor);
+ });
+}
+
+util.inherits(QueryCursor, Readable);
+
+/*!
+ * Necessary to satisfy the Readable API
+ */
+
+QueryCursor.prototype._read = function() {
+ var _this = this;
+ _next(this, function(error, doc) {
+ if (error) {
+ return _this.emit('error', error);
+ }
+ if (!doc) {
+ _this.push(null);
+ return _this.cursor.close(function(error) {
+ if (error) {
+ return _this.emit('error', error);
+ }
+ _this.emit('close');
+ });
+ }
+ _this.push(doc);
+ });
+};
+
+/**
+ * Registers a transform function which subsequently maps documents retrieved
+ * via the streams interface or `.next()`
+ *
+ * ####Example
+ *
+ * // Map documents returned by `data` events
+ * Thing.
+ * find({ name: /^hello/ }).
+ * cursor().
+ * map(function (doc) {
+ * doc.foo = "bar";
+ * return doc;
+ * })
+ * on('data', function(doc) { console.log(doc.foo); });
+ *
+ * // Or map documents returned by `.next()`
+ * var cursor = Thing.find({ name: /^hello/ }).
+ * cursor().
+ * map(function (doc) {
+ * doc.foo = "bar";
+ * return doc;
+ * });
+ * cursor.next(function(error, doc) {
+ * console.log(doc.foo);
+ * });
+ *
+ * @param {Function} fn
+ * @return {QueryCursor}
+ * @api public
+ * @method map
+ */
+
+QueryCursor.prototype.map = function(fn) {
+ this._transforms.push(fn);
+ return this;
+};
+
+/*!
+ * Marks this cursor as errored
+ */
+
+QueryCursor.prototype._markError = function(error) {
+ this._error = error;
+ return this;
+};
+
+/**
+ * Marks this cursor as closed. Will stop streaming and subsequent calls to
+ * `next()` will error.
+ *
+ * @param {Function} callback
+ * @return {Promise}
+ * @api public
+ * @method close
+ * @emits close
+ * @see MongoDB driver cursor#close http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close
+ */
+
+QueryCursor.prototype.close = function(callback) {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+ return new Promise.ES6(function(resolve, reject) {
+ _this.cursor.close(function(error) {
+ if (error) {
+ callback && callback(error);
+ reject(error);
+ return _this.listeners('error').length > 0 &&
+ _this.emit('error', error);
+ }
+ _this.emit('close');
+ resolve();
+ callback && callback();
+ });
+ });
+};
+
+/**
+ * Get the next document from this cursor. Will return `null` when there are
+ * no documents left.
+ *
+ * @param {Function} callback
+ * @return {Promise}
+ * @api public
+ * @method next
+ */
+
+QueryCursor.prototype.next = function(callback) {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+ return new Promise.ES6(function(resolve, reject) {
+ _next(_this, function(error, doc) {
+ if (error) {
+ callback && callback(error);
+ return reject(error);
+ }
+ callback && callback(null, doc);
+ resolve(doc);
+ });
+ });
+};
+
+/**
+ * Execute `fn` for every document in the cursor. If `fn` returns a promise,
+ * will wait for the promise to resolve before iterating on to the next one.
+ * Returns a promise that resolves when done.
+ *
+ * @param {Function} fn
+ * @param {Function} [callback] executed when all docs have been processed
+ * @return {Promise}
+ * @api public
+ * @method eachAsync
+ */
+
+QueryCursor.prototype.eachAsync = function(fn, callback) {
+ var Promise = PromiseProvider.get();
+ var _this = this;
+
+ var handleNextResult = function(doc, callback) {
+ var promise = fn(doc);
+ if (promise && typeof promise.then === 'function') {
+ promise.then(
+ function() { callback(null); },
+ function(error) { callback(error); });
+ } else {
+ callback(null);
+ }
+ };
+
+ var iterate = function(callback) {
+ return _next(_this, function(error, doc) {
+ if (error) {
+ return callback(error);
+ }
+ if (!doc) {
+ return callback(null);
+ }
+ handleNextResult(doc, function(error) {
+ if (error) {
+ return callback(error);
+ }
+ // Make sure to clear the stack re: gh-4697
+ setTimeout(function() {
+ iterate(callback);
+ }, 0);
+ });
+ });
+ };
+
+ return new Promise.ES6(function(resolve, reject) {
+ iterate(function(error) {
+ if (error) {
+ callback && callback(error);
+ return reject(error);
+ }
+ callback && callback(null);
+ return resolve();
+ });
+ });
+};
+
+/*!
+ * Get the next doc from the underlying cursor and mongooseify it
+ * (populate, etc.)
+ */
+
+function _next(ctx, cb) {
+ var callback = cb;
+ if (ctx._transforms.length) {
+ callback = function(err, doc) {
+ if (err || doc === null) return cb(err, doc);
+ cb(err, ctx._transforms.reduce(function(doc, fn) {
+ return fn(doc);
+ }, doc));
+ };
+ }
+
+ if (ctx._error) {
+ return process.nextTick(function() {
+ callback(ctx._error);
+ });
+ }
+
+ if (ctx.cursor) {
+ ctx.cursor.next(function(error, doc) {
+ if (error) {
+ return callback(error);
+ }
+ if (!doc) {
+ return callback(null, null);
+ }
+
+ var opts = ctx.query._mongooseOptions;
+ if (!opts.populate) {
+ return opts.lean === true ?
+ callback(null, doc) :
+ _create(ctx, doc, null, callback);
+ }
+
+ var pop = helpers.preparePopulationOptionsMQ(ctx.query,
+ ctx.query._mongooseOptions);
+ pop.forEach(function(option) {
+ delete option.model;
+ });
+ pop.__noPromise = true;
+ ctx.query.model.populate(doc, pop, function(err, doc) {
+ if (err) {
+ return callback(err);
+ }
+ return opts.lean === true ?
+ callback(null, doc) :
+ _create(ctx, doc, pop, callback);
+ });
+ });
+ } else {
+ ctx.once('cursor', function() {
+ _next(ctx, callback);
+ });
+ }
+}
+
+/*!
+ * Convert a raw doc into a full mongoose doc.
+ */
+
+function _create(ctx, doc, populatedIds, cb) {
+ var instance = helpers.createModel(ctx.query.model, doc, ctx.query._fields);
+ var opts = populatedIds ?
+ { populated: populatedIds } :
+ undefined;
+
+ instance.init(doc, opts, function(err) {
+ if (err) {
+ return cb(err);
+ }
+ cb(null, instance);
+ });
+}
+
+module.exports = QueryCursor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/queryhelpers.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/queryhelpers.js
new file mode 100644
index 0000000..3e0b82d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/queryhelpers.js
@@ -0,0 +1,78 @@
+
+/*!
+ * Module dependencies
+ */
+
+var utils = require('./utils');
+
+/*!
+ * Prepare a set of path options for query population.
+ *
+ * @param {Query} query
+ * @param {Object} options
+ * @return {Array}
+ */
+
+exports.preparePopulationOptions = function preparePopulationOptions(query, options) {
+ var pop = utils.object.vals(query.options.populate);
+
+ // lean options should trickle through all queries
+ if (options.lean) pop.forEach(makeLean);
+
+ return pop;
+};
+
+/*!
+ * Prepare a set of path options for query population. This is the MongooseQuery
+ * version
+ *
+ * @param {Query} query
+ * @param {Object} options
+ * @return {Array}
+ */
+
+exports.preparePopulationOptionsMQ = function preparePopulationOptionsMQ(query, options) {
+ var pop = utils.object.vals(query._mongooseOptions.populate);
+
+ // lean options should trickle through all queries
+ if (options.lean) pop.forEach(makeLean);
+
+ return pop;
+};
+
+/*!
+ * If the document is a mapped discriminator type, it returns a model instance for that type, otherwise,
+ * it returns an instance of the given model.
+ *
+ * @param {Model} model
+ * @param {Object} doc
+ * @param {Object} fields
+ *
+ * @return {Model}
+ */
+exports.createModel = function createModel(model, doc, fields) {
+ var discriminatorMapping = model.schema
+ ? model.schema.discriminatorMapping
+ : null;
+
+ var key = discriminatorMapping && discriminatorMapping.isRoot
+ ? discriminatorMapping.key
+ : null;
+
+ if (key && doc[key] && model.discriminators && model.discriminators[doc[key]]) {
+ return new model.discriminators[doc[key]](undefined, fields, true);
+ }
+
+ return new model(undefined, fields, true);
+};
+
+/*!
+ * Set each path query option to lean
+ *
+ * @param {Object} option
+ */
+
+function makeLean(option) {
+ option.options || (option.options = {});
+ option.options.lean = true;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querystream.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querystream.js
new file mode 100644
index 0000000..2918e25
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/querystream.js
@@ -0,0 +1,367 @@
+/* eslint no-empty: 1 */
+
+/*!
+ * Module dependencies.
+ */
+
+var Stream = require('stream').Stream;
+var utils = require('./utils');
+var helpers = require('./queryhelpers');
+var K = function(k) {
+ return k;
+};
+
+/**
+ * Provides a Node.js 0.8 style [ReadStream](http://nodejs.org/docs/v0.8.21/api/stream.html#stream_readable_stream) interface for Queries.
+ *
+ * var stream = Model.find().stream();
+ *
+ * stream.on('data', function (doc) {
+ * // do something with the mongoose document
+ * }).on('error', function (err) {
+ * // handle the error
+ * }).on('close', function () {
+ * // the stream is closed
+ * });
+ *
+ *
+ * The stream interface allows us to simply "plug-in" to other _Node.js 0.8_ style write streams.
+ *
+ * Model.where('created').gte(twoWeeksAgo).stream().pipe(writeStream);
+ *
+ * ####Valid options
+ *
+ * - `transform`: optional function which accepts a mongoose document. The return value of the function will be emitted on `data`.
+ *
+ * ####Example
+ *
+ * // JSON.stringify all documents before emitting
+ * var stream = Thing.find().stream({ transform: JSON.stringify });
+ * stream.pipe(writeStream);
+ *
+ * _NOTE: plugging into an HTTP response will *not* work out of the box. Those streams expect only strings or buffers to be emitted, so first formatting our documents as strings/buffers is necessary._
+ *
+ * _NOTE: these streams are Node.js 0.8 style read streams which differ from Node.js 0.10 style. Node.js 0.10 streams are not well tested yet and are not guaranteed to work._
+ *
+ * @param {Query} query
+ * @param {Object} [options]
+ * @inherits NodeJS Stream http://nodejs.org/docs/v0.8.21/api/stream.html#stream_readable_stream
+ * @event `data`: emits a single Mongoose document
+ * @event `error`: emits when an error occurs during streaming. This will emit _before_ the `close` event.
+ * @event `close`: emits when the stream reaches the end of the cursor or an error occurs, or the stream is manually `destroy`ed. After this event, no more events are emitted.
+ * @api public
+ */
+
+function QueryStream(query, options) {
+ Stream.call(this);
+
+ this.query = query;
+ this.readable = true;
+ this.paused = false;
+ this._cursor = null;
+ this._destroyed = null;
+ this._fields = null;
+ this._buffer = null;
+ this._inline = T_INIT;
+ this._running = false;
+ this._transform = options && typeof options.transform === 'function'
+ ? options.transform
+ : K;
+
+ // give time to hook up events
+ var _this = this;
+ process.nextTick(function() {
+ _this._init();
+ });
+}
+
+/*!
+ * Inherit from Stream
+ */
+
+QueryStream.prototype.__proto__ = Stream.prototype;
+
+/**
+ * Flag stating whether or not this stream is readable.
+ *
+ * @property readable
+ * @api public
+ */
+
+QueryStream.prototype.readable;
+
+/**
+ * Flag stating whether or not this stream is paused.
+ *
+ * @property paused
+ * @api public
+ */
+
+QueryStream.prototype.paused;
+
+// trampoline flags
+var T_INIT = 0;
+var T_IDLE = 1;
+var T_CONT = 2;
+
+/**
+ * Initializes the query.
+ *
+ * @api private
+ */
+
+QueryStream.prototype._init = function() {
+ if (this._destroyed) {
+ return;
+ }
+
+ var query = this.query,
+ model = query.model,
+ options = query._optionsForExec(model),
+ _this = this;
+
+ try {
+ query.cast(model);
+ } catch (err) {
+ return _this.destroy(err);
+ }
+
+ _this._fields = utils.clone(query._fields);
+ options.fields = query._castFields(_this._fields);
+
+ model.collection.find(query._conditions, options, function(err, cursor) {
+ if (err) {
+ return _this.destroy(err);
+ }
+ _this._cursor = cursor;
+ _this._next();
+ });
+};
+
+/**
+ * Trampoline for pulling the next doc from cursor.
+ *
+ * @see QueryStream#__next #querystream_QueryStream-__next
+ * @api private
+ */
+
+QueryStream.prototype._next = function _next() {
+ if (this.paused || this._destroyed) {
+ this._running = false;
+ return this._running;
+ }
+
+ this._running = true;
+
+ if (this._buffer && this._buffer.length) {
+ var arg;
+ while (!this.paused && !this._destroyed && (arg = this._buffer.shift())) { // eslint-disable-line no-cond-assign
+ this._onNextObject.apply(this, arg);
+ }
+ }
+
+ // avoid stack overflows with large result sets.
+ // trampoline instead of recursion.
+ while (this.__next()) {
+ }
+};
+
+/**
+ * Pulls the next doc from the cursor.
+ *
+ * @see QueryStream#_next #querystream_QueryStream-_next
+ * @api private
+ */
+
+QueryStream.prototype.__next = function() {
+ if (this.paused || this._destroyed) {
+ this._running = false;
+ return this._running;
+ }
+
+ var _this = this;
+ _this._inline = T_INIT;
+
+ _this._cursor.nextObject(function cursorcb(err, doc) {
+ _this._onNextObject(err, doc);
+ });
+
+ // if onNextObject() was already called in this tick
+ // return ourselves to the trampoline.
+ if (T_CONT === this._inline) {
+ return true;
+ }
+ // onNextObject() hasn't fired yet. tell onNextObject
+ // that its ok to call _next b/c we are not within
+ // the trampoline anymore.
+ this._inline = T_IDLE;
+};
+
+/**
+ * Transforms raw `doc`s returned from the cursor into a model instance.
+ *
+ * @param {Error|null} err
+ * @param {Object} doc
+ * @api private
+ */
+
+QueryStream.prototype._onNextObject = function _onNextObject(err, doc) {
+ if (this._destroyed) {
+ return;
+ }
+
+ if (this.paused) {
+ this._buffer || (this._buffer = []);
+ this._buffer.push([err, doc]);
+ this._running = false;
+ return this._running;
+ }
+
+ if (err) {
+ return this.destroy(err);
+ }
+
+ // when doc is null we hit the end of the cursor
+ if (!doc) {
+ this.emit('end');
+ return this.destroy();
+ }
+
+ var opts = this.query._mongooseOptions;
+
+ if (!opts.populate) {
+ return opts.lean === true ?
+ emit(this, doc) :
+ createAndEmit(this, null, doc);
+ }
+
+ var _this = this;
+ var pop = helpers.preparePopulationOptionsMQ(_this.query, _this.query._mongooseOptions);
+
+ // Hack to work around gh-3108
+ pop.forEach(function(option) {
+ delete option.model;
+ });
+
+ pop.__noPromise = true;
+ _this.query.model.populate(doc, pop, function(err, doc) {
+ if (err) {
+ return _this.destroy(err);
+ }
+ return opts.lean === true ?
+ emit(_this, doc) :
+ createAndEmit(_this, pop, doc);
+ });
+};
+
+function createAndEmit(self, populatedIds, doc) {
+ var instance = helpers.createModel(self.query.model, doc, self._fields);
+ var opts = populatedIds ?
+ {populated: populatedIds} :
+ undefined;
+
+ instance.init(doc, opts, function(err) {
+ if (err) {
+ return self.destroy(err);
+ }
+ emit(self, instance);
+ });
+}
+
+/*!
+ * Emit a data event and manage the trampoline state
+ */
+
+function emit(self, doc) {
+ self.emit('data', self._transform(doc));
+
+ // trampoline management
+ if (T_IDLE === self._inline) {
+ // no longer in trampoline. restart it.
+ self._next();
+ } else {
+ // in a trampoline. tell __next that its
+ // ok to continue jumping.
+ self._inline = T_CONT;
+ }
+}
+
+/**
+ * Pauses this stream.
+ *
+ * @api public
+ */
+
+QueryStream.prototype.pause = function() {
+ this.paused = true;
+};
+
+/**
+ * Resumes this stream.
+ *
+ * @api public
+ */
+
+QueryStream.prototype.resume = function() {
+ this.paused = false;
+
+ if (!this._cursor) {
+ // cannot start if not initialized
+ return;
+ }
+
+ // are we within the trampoline?
+ if (T_INIT === this._inline) {
+ return;
+ }
+
+ if (!this._running) {
+ // outside QueryStream control, need manual restart
+ return this._next();
+ }
+};
+
+/**
+ * Destroys the stream, closing the underlying cursor, which emits the close event. No more events will be emitted after the close event.
+ *
+ * @param {Error} [err]
+ * @api public
+ */
+
+QueryStream.prototype.destroy = function(err) {
+ if (this._destroyed) {
+ return;
+ }
+ this._destroyed = true;
+ this._running = false;
+ this.readable = false;
+
+ if (this._cursor) {
+ this._cursor.close();
+ }
+
+ if (err) {
+ this.emit('error', err);
+ }
+
+ this.emit('close');
+};
+
+/**
+ * Pipes this query stream into another stream. This method is inherited from NodeJS Streams.
+ *
+ * ####Example:
+ *
+ * query.stream().pipe(writeStream [, options])
+ *
+ * @method pipe
+ * @memberOf QueryStream
+ * @see NodeJS http://nodejs.org/api/stream.html
+ * @api public
+ */
+
+/*!
+ * Module exports
+ */
+
+module.exports = exports = QueryStream;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema.js
new file mode 100644
index 0000000..7e28f58
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema.js
@@ -0,0 +1,1768 @@
+/*!
+ * Module dependencies.
+ */
+
+var readPref = require('./drivers').ReadPreference;
+var EventEmitter = require('events').EventEmitter;
+var VirtualType = require('./virtualtype');
+var utils = require('./utils');
+var MongooseTypes;
+var Kareem = require('kareem');
+var each = require('async/each');
+var SchemaType = require('./schematype');
+
+var IS_KAREEM_HOOK = {
+ count: true,
+ find: true,
+ findOne: true,
+ findOneAndUpdate: true,
+ findOneAndRemove: true,
+ insertMany: true,
+ update: true
+};
+
+/**
+ * Schema constructor.
+ *
+ * ####Example:
+ *
+ * var child = new Schema({ name: String });
+ * var schema = new Schema({ name: String, age: Number, children: [child] });
+ * var Tree = mongoose.model('Tree', schema);
+ *
+ * // setting schema options
+ * new Schema({ name: String }, { _id: false, autoIndex: false })
+ *
+ * ####Options:
+ *
+ * - [autoIndex](/docs/guide.html#autoIndex): bool - defaults to null (which means use the connection's autoIndex option)
+ * - [bufferCommands](/docs/guide.html#bufferCommands): bool - defaults to true
+ * - [capped](/docs/guide.html#capped): bool - defaults to false
+ * - [collection](/docs/guide.html#collection): string - no default
+ * - [emitIndexErrors](/docs/guide.html#emitIndexErrors): bool - defaults to false.
+ * - [id](/docs/guide.html#id): bool - defaults to true
+ * - [_id](/docs/guide.html#_id): bool - defaults to true
+ * - `minimize`: bool - controls [document#toObject](#document_Document-toObject) behavior when called manually - defaults to true
+ * - [read](/docs/guide.html#read): string
+ * - [safe](/docs/guide.html#safe): bool - defaults to true.
+ * - [shardKey](/docs/guide.html#shardKey): bool - defaults to `null`
+ * - [strict](/docs/guide.html#strict): bool - defaults to true
+ * - [toJSON](/docs/guide.html#toJSON) - object - no default
+ * - [toObject](/docs/guide.html#toObject) - object - no default
+ * - [typeKey](/docs/guide.html#typeKey) - string - defaults to 'type'
+ * - [useNestedStrict](/docs/guide.html#useNestedStrict) - boolean - defaults to false
+ * - [validateBeforeSave](/docs/guide.html#validateBeforeSave) - bool - defaults to `true`
+ * - [versionKey](/docs/guide.html#versionKey): string - defaults to "__v"
+ *
+ * ####Note:
+ *
+ * _When nesting schemas, (`children` in the example above), always declare the child schema first before passing it into its parent._
+ *
+ * @param {Object} definition
+ * @param {Object} [options]
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `init`: Emitted after the schema is compiled into a `Model`.
+ * @api public
+ */
+
+function Schema(obj, options) {
+ if (!(this instanceof Schema)) {
+ return new Schema(obj, options);
+ }
+
+ this.obj = obj;
+ this.paths = {};
+ this.subpaths = {};
+ this.virtuals = {};
+ this.singleNestedPaths = {};
+ this.nested = {};
+ this.inherits = {};
+ this.callQueue = [];
+ this._indexes = [];
+ this.methods = {};
+ this.statics = {};
+ this.tree = {};
+ this._requiredpaths = undefined;
+ this.discriminatorMapping = undefined;
+ this._indexedpaths = undefined;
+ this.query = {};
+ this.childSchemas = [];
+
+ this.s = {
+ hooks: new Kareem(),
+ kareemHooks: IS_KAREEM_HOOK
+ };
+
+ this.options = this.defaultOptions(options);
+
+ // build paths
+ if (obj) {
+ this.add(obj);
+ }
+
+ // check if _id's value is a subdocument (gh-2276)
+ var _idSubDoc = obj && obj._id && utils.isObject(obj._id);
+
+ // ensure the documents get an auto _id unless disabled
+ var auto_id = !this.paths['_id'] &&
+ (!this.options.noId && this.options._id) && !_idSubDoc;
+
+ if (auto_id) {
+ obj = {_id: {auto: true}};
+ obj._id[this.options.typeKey] = Schema.ObjectId;
+ this.add(obj);
+ }
+
+ // ensure the documents receive an id getter unless disabled
+ var autoid = !this.paths['id'] &&
+ (!this.options.noVirtualId && this.options.id);
+ if (autoid) {
+ this.virtual('id').get(idGetter);
+ }
+
+ for (var i = 0; i < this._defaultMiddleware.length; ++i) {
+ var m = this._defaultMiddleware[i];
+ this[m.kind](m.hook, !!m.isAsync, m.fn);
+ }
+
+ if (this.options.timestamps) {
+ this.setupTimestamp(this.options.timestamps);
+ }
+}
+
+/*!
+ * Returns this documents _id cast to a string.
+ */
+
+function idGetter() {
+ if (this.$__._id) {
+ return this.$__._id;
+ }
+
+ this.$__._id = this._id == null
+ ? null
+ : String(this._id);
+ return this.$__._id;
+}
+
+/*!
+ * Inherit from EventEmitter.
+ */
+Schema.prototype = Object.create(EventEmitter.prototype);
+Schema.prototype.constructor = Schema;
+Schema.prototype.instanceOfSchema = true;
+
+/**
+ * Default middleware attached to a schema. Cannot be changed.
+ *
+ * This field is used to make sure discriminators don't get multiple copies of
+ * built-in middleware. Declared as a constant because changing this at runtime
+ * may lead to instability with Model.prototype.discriminator().
+ *
+ * @api private
+ * @property _defaultMiddleware
+ */
+Object.defineProperty(Schema.prototype, '_defaultMiddleware', {
+ configurable: false,
+ enumerable: false,
+ writable: false,
+ value: [
+ {
+ kind: 'pre',
+ hook: 'save',
+ fn: function(next, options) {
+ var _this = this;
+ // Nested docs have their own presave
+ if (this.ownerDocument) {
+ return next();
+ }
+
+ var hasValidateBeforeSaveOption = options &&
+ (typeof options === 'object') &&
+ ('validateBeforeSave' in options);
+
+ var shouldValidate;
+ if (hasValidateBeforeSaveOption) {
+ shouldValidate = !!options.validateBeforeSave;
+ } else {
+ shouldValidate = this.schema.options.validateBeforeSave;
+ }
+
+ // Validate
+ if (shouldValidate) {
+ // HACK: use $__original_validate to avoid promises so bluebird doesn't
+ // complain
+ if (this.$__original_validate) {
+ this.$__original_validate({__noPromise: true}, function(error) {
+ return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
+ next(error);
+ });
+ });
+ } else {
+ this.validate({__noPromise: true}, function(error) {
+ return _this.schema.s.hooks.execPost('save:error', _this, [ _this], { error: error }, function(error) {
+ next(error);
+ });
+ });
+ }
+ } else {
+ next();
+ }
+ }
+ },
+ {
+ kind: 'pre',
+ hook: 'save',
+ isAsync: true,
+ fn: function(next, done) {
+ var _this = this;
+ var subdocs = this.$__getAllSubdocs();
+
+ if (!subdocs.length || this.$__preSavingFromParent) {
+ done();
+ next();
+ return;
+ }
+
+ each(subdocs, function(subdoc, cb) {
+ subdoc.$__preSavingFromParent = true;
+ subdoc.save(function(err) {
+ cb(err);
+ });
+ }, function(error) {
+ for (var i = 0; i < subdocs.length; ++i) {
+ delete subdocs[i].$__preSavingFromParent;
+ }
+ if (error) {
+ return _this.schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
+ done(error);
+ });
+ }
+ next();
+ done();
+ });
+ }
+ },
+ {
+ kind: 'pre',
+ hook: 'validate',
+ isAsync: true,
+ fn: function(next, done) {
+ // Hack to ensure that we always wrap validate() in a promise
+ next();
+ done();
+ }
+ },
+ {
+ kind: 'pre',
+ hook: 'remove',
+ isAsync: true,
+ fn: function(next, done) {
+ if (this.ownerDocument) {
+ done();
+ next();
+ return;
+ }
+
+ var subdocs = this.$__getAllSubdocs();
+
+ if (!subdocs.length || this.$__preSavingFromParent) {
+ done();
+ next();
+ return;
+ }
+
+ each(subdocs, function(subdoc, cb) {
+ subdoc.remove({ noop: true }, function(err) {
+ cb(err);
+ });
+ }, function(error) {
+ if (error) {
+ done(error);
+ return;
+ }
+ next();
+ done();
+ });
+ }
+ }
+ ]
+});
+
+
+/**
+ * The original object passed to the schema constructor
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ a: String }).add({ b: String });
+ * schema.obj; // { a: String }
+ *
+ * @api public
+ * @property obj
+ */
+
+Schema.prototype.obj;
+
+/**
+ * Schema as flat paths
+ *
+ * ####Example:
+ * {
+ * '_id' : SchemaType,
+ * , 'nested.key' : SchemaType,
+ * }
+ *
+ * @api private
+ * @property paths
+ */
+
+Schema.prototype.paths;
+
+/**
+ * Schema as a tree
+ *
+ * ####Example:
+ * {
+ * '_id' : ObjectId
+ * , 'nested' : {
+ * 'key' : String
+ * }
+ * }
+ *
+ * @api private
+ * @property tree
+ */
+
+Schema.prototype.tree;
+
+/**
+ * Returns default options for this schema, merged with `options`.
+ *
+ * @param {Object} options
+ * @return {Object}
+ * @api private
+ */
+
+Schema.prototype.defaultOptions = function(options) {
+ if (options && options.safe === false) {
+ options.safe = {w: 0};
+ }
+
+ if (options && options.safe && options.safe.w === 0) {
+ // if you turn off safe writes, then versioning goes off as well
+ options.versionKey = false;
+ }
+
+ options = utils.options({
+ strict: true,
+ bufferCommands: true,
+ capped: false, // { size, max, autoIndexId }
+ versionKey: '__v',
+ discriminatorKey: '__t',
+ minimize: true,
+ autoIndex: null,
+ shardKey: null,
+ read: null,
+ validateBeforeSave: true,
+ // the following are only applied at construction time
+ noId: false, // deprecated, use { _id: false }
+ _id: true,
+ noVirtualId: false, // deprecated, use { id: false }
+ id: true,
+ typeKey: 'type',
+ retainKeyOrder: false
+ }, options);
+
+ if (options.read) {
+ options.read = readPref(options.read);
+ }
+
+ return options;
+};
+
+/**
+ * Adds key path / schema type pairs to this schema.
+ *
+ * ####Example:
+ *
+ * var ToySchema = new Schema;
+ * ToySchema.add({ name: 'string', color: 'string', price: 'number' });
+ *
+ * @param {Object} obj
+ * @param {String} prefix
+ * @api public
+ */
+
+Schema.prototype.add = function add(obj, prefix) {
+ prefix = prefix || '';
+ var keys = Object.keys(obj);
+
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+
+ if (obj[key] == null) {
+ throw new TypeError('Invalid value for schema path `' + prefix + key + '`');
+ }
+
+ if (Array.isArray(obj[key]) && obj[key].length === 1 && obj[key][0] == null) {
+ throw new TypeError('Invalid value for schema Array path `' + prefix + key + '`');
+ }
+
+ if (utils.isObject(obj[key]) &&
+ (!obj[key].constructor || utils.getFunctionName(obj[key].constructor) === 'Object') &&
+ (!obj[key][this.options.typeKey] || (this.options.typeKey === 'type' && obj[key].type.type))) {
+ if (Object.keys(obj[key]).length) {
+ // nested object { last: { name: String }}
+ this.nested[prefix + key] = true;
+ this.add(obj[key], prefix + key + '.');
+ } else {
+ if (prefix) {
+ this.nested[prefix.substr(0, prefix.length - 1)] = true;
+ }
+ this.path(prefix + key, obj[key]); // mixed type
+ }
+ } else {
+ if (prefix) {
+ this.nested[prefix.substr(0, prefix.length - 1)] = true;
+ }
+ this.path(prefix + key, obj[key]);
+ }
+ }
+};
+
+/**
+ * Reserved document keys.
+ *
+ * Keys in this object are names that are rejected in schema declarations b/c they conflict with mongoose functionality. Using these key name will throw an error.
+ *
+ * on, emit, _events, db, get, set, init, isNew, errors, schema, options, modelName, collection, _pres, _posts, toObject
+ *
+ * _NOTE:_ Use of these terms as method names is permitted, but play at your own risk, as they may be existing mongoose document methods you are stomping on.
+ *
+ * var schema = new Schema(..);
+ * schema.methods.init = function () {} // potentially breaking
+ */
+
+Schema.reserved = Object.create(null);
+var reserved = Schema.reserved;
+// Core object
+reserved['prototype'] =
+// EventEmitter
+reserved.emit =
+reserved.on =
+reserved.once =
+reserved.listeners =
+reserved.removeListener =
+// document properties and functions
+reserved.collection =
+reserved.db =
+reserved.errors =
+reserved.init =
+reserved.isModified =
+reserved.isNew =
+reserved.get =
+reserved.modelName =
+reserved.save =
+reserved.schema =
+reserved.set =
+reserved.toObject =
+reserved.validate =
+// hooks.js
+reserved._pres = reserved._posts = 1;
+
+/*!
+ * Document keys to print warnings for
+ */
+
+var warnings = {};
+warnings.increment = '`increment` should not be used as a schema path name ' +
+ 'unless you have disabled versioning.';
+
+/**
+ * Gets/sets schema paths.
+ *
+ * Sets a path (if arity 2)
+ * Gets a path (if arity 1)
+ *
+ * ####Example
+ *
+ * schema.path('name') // returns a SchemaType
+ * schema.path('name', Number) // changes the schemaType of `name` to Number
+ *
+ * @param {String} path
+ * @param {Object} constructor
+ * @api public
+ */
+
+Schema.prototype.path = function(path, obj) {
+ if (obj === undefined) {
+ if (this.paths[path]) {
+ return this.paths[path];
+ }
+ if (this.subpaths[path]) {
+ return this.subpaths[path];
+ }
+ if (this.singleNestedPaths[path]) {
+ return this.singleNestedPaths[path];
+ }
+
+ // subpaths?
+ return /\.\d+\.?.*$/.test(path)
+ ? getPositionalPath(this, path)
+ : undefined;
+ }
+
+ // some path names conflict with document methods
+ if (reserved[path]) {
+ throw new Error('`' + path + '` may not be used as a schema pathname');
+ }
+
+ if (warnings[path]) {
+ console.log('WARN: ' + warnings[path]);
+ }
+
+ // update the tree
+ var subpaths = path.split(/\./),
+ last = subpaths.pop(),
+ branch = this.tree;
+
+ subpaths.forEach(function(sub, i) {
+ if (!branch[sub]) {
+ branch[sub] = {};
+ }
+ if (typeof branch[sub] !== 'object') {
+ var msg = 'Cannot set nested path `' + path + '`. '
+ + 'Parent path `'
+ + subpaths.slice(0, i).concat([sub]).join('.')
+ + '` already set to type ' + branch[sub].name
+ + '.';
+ throw new Error(msg);
+ }
+ branch = branch[sub];
+ });
+
+ branch[last] = utils.clone(obj);
+
+ this.paths[path] = Schema.interpretAsType(path, obj, this.options);
+
+ if (this.paths[path].$isSingleNested) {
+ for (var key in this.paths[path].schema.paths) {
+ this.singleNestedPaths[path + '.' + key] =
+ this.paths[path].schema.paths[key];
+ }
+ for (key in this.paths[path].schema.singleNestedPaths) {
+ this.singleNestedPaths[path + '.' + key] =
+ this.paths[path].schema.singleNestedPaths[key];
+ }
+
+ this.childSchemas.push(this.paths[path].schema);
+ } else if (this.paths[path].$isMongooseDocumentArray) {
+ this.childSchemas.push(this.paths[path].schema);
+ }
+ return this;
+};
+
+/**
+ * Converts type arguments into Mongoose Types.
+ *
+ * @param {String} path
+ * @param {Object} obj constructor
+ * @api private
+ */
+
+Schema.interpretAsType = function(path, obj, options) {
+ if (obj.constructor) {
+ var constructorName = utils.getFunctionName(obj.constructor);
+ if (constructorName !== 'Object') {
+ var oldObj = obj;
+ obj = {};
+ obj[options.typeKey] = oldObj;
+ }
+ }
+
+ // Get the type making sure to allow keys named "type"
+ // and default to mixed if not specified.
+ // { type: { type: String, default: 'freshcut' } }
+ var type = obj[options.typeKey] && (options.typeKey !== 'type' || !obj.type.type)
+ ? obj[options.typeKey]
+ : {};
+
+ if (utils.getFunctionName(type.constructor) === 'Object' || type === 'mixed') {
+ return new MongooseTypes.Mixed(path, obj);
+ }
+
+ if (Array.isArray(type) || Array === type || type === 'array') {
+ // if it was specified through { type } look for `cast`
+ var cast = (Array === type || type === 'array')
+ ? obj.cast
+ : type[0];
+
+ if (cast && cast.instanceOfSchema) {
+ return new MongooseTypes.DocumentArray(path, cast, obj);
+ }
+
+ if (Array.isArray(cast)) {
+ return new MongooseTypes.Array(path, Schema.interpretAsType(path, cast, options), obj);
+ }
+
+ if (typeof cast === 'string') {
+ cast = MongooseTypes[cast.charAt(0).toUpperCase() + cast.substring(1)];
+ } else if (cast && (!cast[options.typeKey] || (options.typeKey === 'type' && cast.type.type))
+ && utils.getFunctionName(cast.constructor) === 'Object') {
+ if (Object.keys(cast).length) {
+ // The `minimize` and `typeKey` options propagate to child schemas
+ // declared inline, like `{ arr: [{ val: { $type: String } }] }`.
+ // See gh-3560
+ var childSchemaOptions = {minimize: options.minimize};
+ if (options.typeKey) {
+ childSchemaOptions.typeKey = options.typeKey;
+ }
+ var childSchema = new Schema(cast, childSchemaOptions);
+ childSchema.$implicitlyCreated = true;
+ return new MongooseTypes.DocumentArray(path, childSchema, obj);
+ } else {
+ // Special case: empty object becomes mixed
+ return new MongooseTypes.Array(path, MongooseTypes.Mixed, obj);
+ }
+ }
+
+ if (cast) {
+ type = cast[options.typeKey] && (options.typeKey !== 'type' || !cast.type.type)
+ ? cast[options.typeKey]
+ : cast;
+
+ name = typeof type === 'string'
+ ? type
+ : type.schemaName || utils.getFunctionName(type);
+
+ if (!(name in MongooseTypes)) {
+ throw new TypeError('Undefined type `' + name + '` at array `' + path +
+ '`');
+ }
+ }
+
+ return new MongooseTypes.Array(path, cast || MongooseTypes.Mixed, obj, options);
+ }
+
+ if (type && type.instanceOfSchema) {
+ return new MongooseTypes.Embedded(type, path, obj);
+ }
+
+ var name;
+ if (Buffer.isBuffer(type)) {
+ name = 'Buffer';
+ } else {
+ name = typeof type === 'string'
+ ? type
+ // If not string, `type` is a function. Outside of IE, function.name
+ // gives you the function name. In IE, you need to compute it
+ : type.schemaName || utils.getFunctionName(type);
+ }
+
+ if (name) {
+ name = name.charAt(0).toUpperCase() + name.substring(1);
+ }
+
+ if (undefined == MongooseTypes[name]) {
+ throw new TypeError('Undefined type `' + name + '` at `' + path +
+ '`\n Did you try nesting Schemas? ' +
+ 'You can only nest using refs or arrays.');
+ }
+
+ return new MongooseTypes[name](path, obj);
+};
+
+/**
+ * Iterates the schemas paths similar to Array#forEach.
+ *
+ * The callback is passed the pathname and schemaType as arguments on each iteration.
+ *
+ * @param {Function} fn callback function
+ * @return {Schema} this
+ * @api public
+ */
+
+Schema.prototype.eachPath = function(fn) {
+ var keys = Object.keys(this.paths),
+ len = keys.length;
+
+ for (var i = 0; i < len; ++i) {
+ fn(keys[i], this.paths[keys[i]]);
+ }
+
+ return this;
+};
+
+/**
+ * Returns an Array of path strings that are required by this schema.
+ *
+ * @api public
+ * @param {Boolean} invalidate refresh the cache
+ * @return {Array}
+ */
+
+Schema.prototype.requiredPaths = function requiredPaths(invalidate) {
+ if (this._requiredpaths && !invalidate) {
+ return this._requiredpaths;
+ }
+
+ var paths = Object.keys(this.paths),
+ i = paths.length,
+ ret = [];
+
+ while (i--) {
+ var path = paths[i];
+ if (this.paths[path].isRequired) {
+ ret.push(path);
+ }
+ }
+ this._requiredpaths = ret;
+ return this._requiredpaths;
+};
+
+/**
+ * Returns indexes from fields and schema-level indexes (cached).
+ *
+ * @api private
+ * @return {Array}
+ */
+
+Schema.prototype.indexedPaths = function indexedPaths() {
+ if (this._indexedpaths) {
+ return this._indexedpaths;
+ }
+ this._indexedpaths = this.indexes();
+ return this._indexedpaths;
+};
+
+/**
+ * Returns the pathType of `path` for this schema.
+ *
+ * Given a path, returns whether it is a real, virtual, nested, or ad-hoc/undefined path.
+ *
+ * @param {String} path
+ * @return {String}
+ * @api public
+ */
+
+Schema.prototype.pathType = function(path) {
+ if (path in this.paths) {
+ return 'real';
+ }
+ if (path in this.virtuals) {
+ return 'virtual';
+ }
+ if (path in this.nested) {
+ return 'nested';
+ }
+ if (path in this.subpaths) {
+ return 'real';
+ }
+ if (path in this.singleNestedPaths) {
+ return 'real';
+ }
+
+ if (/\.\d+\.|\.\d+$/.test(path)) {
+ return getPositionalPathType(this, path);
+ }
+ return 'adhocOrUndefined';
+};
+
+/**
+ * Returns true iff this path is a child of a mixed schema.
+ *
+ * @param {String} path
+ * @return {Boolean}
+ * @api private
+ */
+
+Schema.prototype.hasMixedParent = function(path) {
+ var subpaths = path.split(/\./g);
+ path = '';
+ for (var i = 0; i < subpaths.length; ++i) {
+ path = i > 0 ? path + '.' + subpaths[i] : subpaths[i];
+ if (path in this.paths &&
+ this.paths[path] instanceof MongooseTypes.Mixed) {
+ return true;
+ }
+ }
+
+ return false;
+};
+
+/**
+ * Setup updatedAt and createdAt timestamps to documents if enabled
+ *
+ * @param {Boolean|Object} timestamps timestamps options
+ * @api private
+ */
+Schema.prototype.setupTimestamp = function(timestamps) {
+ if (timestamps) {
+ var createdAt = timestamps.createdAt || 'createdAt';
+ var updatedAt = timestamps.updatedAt || 'updatedAt';
+ var schemaAdditions = {};
+
+ schemaAdditions[updatedAt] = Date;
+
+ if (!this.paths[createdAt]) {
+ schemaAdditions[createdAt] = Date;
+ }
+
+ this.add(schemaAdditions);
+
+ this.pre('save', function(next) {
+ var defaultTimestamp = new Date();
+ var auto_id = this._id && this._id.auto;
+
+ if (!this[createdAt] && this.isSelected(createdAt)) {
+ this[createdAt] = auto_id ? this._id.getTimestamp() : defaultTimestamp;
+ }
+
+ if (this.isNew || this.isModified()) {
+ this[updatedAt] = this.isNew ? this[createdAt] : defaultTimestamp;
+ }
+
+ next();
+ });
+
+ var genUpdates = function(overwrite) {
+ var now = new Date();
+ var updates = {};
+ if (overwrite) {
+ updates[updatedAt] = now;
+ updates[createdAt] = now;
+ return updates;
+ }
+ updates = { $set: {}, $setOnInsert: {} };
+ updates.$set[updatedAt] = now;
+ updates.$setOnInsert[createdAt] = now;
+
+ return updates;
+ };
+
+ this.methods.initializeTimestamps = function() {
+ if (!this[createdAt]) {
+ this[createdAt] = new Date();
+ }
+ if (!this[updatedAt]) {
+ this[updatedAt] = new Date();
+ }
+ return this;
+ };
+
+ this.pre('findOneAndUpdate', function(next) {
+ var overwrite = this.options.overwrite;
+ this.findOneAndUpdate({}, genUpdates(overwrite), { overwrite: overwrite });
+ applyTimestampsToChildren(this);
+ next();
+ });
+
+ this.pre('update', function(next) {
+ var overwrite = this.options.overwrite;
+ this.update({}, genUpdates(overwrite), { overwrite: overwrite });
+ applyTimestampsToChildren(this);
+ next();
+ });
+ }
+};
+
+/*!
+ * ignore
+ */
+
+function applyTimestampsToChildren(query) {
+ var now = new Date();
+ var update = query.getUpdate();
+ var keys = Object.keys(update);
+ var key;
+ var schema = query.model.schema;
+ var len;
+ var createdAt;
+ var updatedAt;
+ var timestamps;
+ var path;
+
+ var hasDollarKey = keys.length && keys[0].charAt(0) === '$';
+
+ if (hasDollarKey) {
+ if (update.$push) {
+ for (key in update.$push) {
+ var $path = schema.path(key);
+ if (update.$push[key] &&
+ $path &&
+ $path.$isMongooseDocumentArray &&
+ $path.schema.options.timestamps) {
+ timestamps = $path.schema.options.timestamps;
+ createdAt = timestamps.createdAt || 'createdAt';
+ updatedAt = timestamps.updatedAt || 'updatedAt';
+ update.$push[key][updatedAt] = now;
+ update.$push[key][createdAt] = now;
+ }
+ }
+ }
+ if (update.$set) {
+ for (key in update.$set) {
+ path = schema.path(key);
+ if (!path) {
+ continue;
+ }
+ if (Array.isArray(update.$set[key]) && path.$isMongooseDocumentArray) {
+ len = update.$set[key].length;
+ timestamps = schema.path(key).schema.options.timestamps;
+ if (timestamps) {
+ createdAt = timestamps.createdAt || 'createdAt';
+ updatedAt = timestamps.updatedAt || 'updatedAt';
+ for (var i = 0; i < len; ++i) {
+ update.$set[key][i][updatedAt] = now;
+ update.$set[key][i][createdAt] = now;
+ }
+ }
+ } else if (update.$set[key] && path.$isSingleNested) {
+ timestamps = schema.path(key).schema.options.timestamps;
+ if (timestamps) {
+ createdAt = timestamps.createdAt || 'createdAt';
+ updatedAt = timestamps.updatedAt || 'updatedAt';
+ update.$set[key][updatedAt] = now;
+ update.$set[key][createdAt] = now;
+ }
+ }
+ }
+ }
+ }
+}
+
+/*!
+ * ignore
+ */
+
+function getPositionalPathType(self, path) {
+ var subpaths = path.split(/\.(\d+)\.|\.(\d+)$/).filter(Boolean);
+ if (subpaths.length < 2) {
+ return self.paths[subpaths[0]];
+ }
+
+ var val = self.path(subpaths[0]);
+ var isNested = false;
+ if (!val) {
+ return val;
+ }
+
+ var last = subpaths.length - 1,
+ subpath,
+ i = 1;
+
+ for (; i < subpaths.length; ++i) {
+ isNested = false;
+ subpath = subpaths[i];
+
+ if (i === last && val && !/\D/.test(subpath)) {
+ if (val.$isMongooseDocumentArray) {
+ var oldVal = val;
+ val = new SchemaType(subpath);
+ val.cast = function(value, doc, init) {
+ return oldVal.cast(value, doc, init)[0];
+ };
+ val.caster = oldVal.caster;
+ val.schema = oldVal.schema;
+ } else if (val instanceof MongooseTypes.Array) {
+ // StringSchema, NumberSchema, etc
+ val = val.caster;
+ } else {
+ val = undefined;
+ }
+ break;
+ }
+
+ // ignore if its just a position segment: path.0.subpath
+ if (!/\D/.test(subpath)) {
+ continue;
+ }
+
+ if (!(val && val.schema)) {
+ val = undefined;
+ break;
+ }
+
+ var type = val.schema.pathType(subpath);
+ isNested = (type === 'nested');
+ val = val.schema.path(subpath);
+ }
+
+ self.subpaths[path] = val;
+ if (val) {
+ return 'real';
+ }
+ if (isNested) {
+ return 'nested';
+ }
+ return 'adhocOrUndefined';
+}
+
+
+/*!
+ * ignore
+ */
+
+function getPositionalPath(self, path) {
+ getPositionalPathType(self, path);
+ return self.subpaths[path];
+}
+
+/**
+ * Adds a method call to the queue.
+ *
+ * @param {String} name name of the document method to call later
+ * @param {Array} args arguments to pass to the method
+ * @api public
+ */
+
+Schema.prototype.queue = function(name, args) {
+ this.callQueue.push([name, args]);
+ return this;
+};
+
+/**
+ * Defines a pre hook for the document.
+ *
+ * ####Example
+ *
+ * var toySchema = new Schema(..);
+ *
+ * toySchema.pre('save', function (next) {
+ * if (!this.created) this.created = new Date;
+ * next();
+ * })
+ *
+ * toySchema.pre('validate', function (next) {
+ * if (this.name !== 'Woody') this.name = 'Woody';
+ * next();
+ * })
+ *
+ * @param {String} method
+ * @param {Function} callback
+ * @see hooks.js https://github.com/bnoguchi/hooks-js/tree/31ec571cef0332e21121ee7157e0cf9728572cc3
+ * @api public
+ */
+
+Schema.prototype.pre = function() {
+ var name = arguments[0];
+ if (IS_KAREEM_HOOK[name]) {
+ this.s.hooks.pre.apply(this.s.hooks, arguments);
+ return this;
+ }
+ return this.queue('pre', arguments);
+};
+
+/**
+ * Defines a post hook for the document
+ *
+ * var schema = new Schema(..);
+ * schema.post('save', function (doc) {
+ * console.log('this fired after a document was saved');
+ * });
+ *
+ * shema.post('find', function(docs) {
+ * console.log('this fired after you run a find query');
+ * });
+ *
+ * var Model = mongoose.model('Model', schema);
+ *
+ * var m = new Model(..);
+ * m.save(function(err) {
+ * console.log('this fires after the `post` hook');
+ * });
+ *
+ * m.find(function(err, docs) {
+ * console.log('this fires after the post find hook');
+ * });
+ *
+ * @param {String} method name of the method to hook
+ * @param {Function} fn callback
+ * @see middleware http://mongoosejs.com/docs/middleware.html
+ * @see hooks.js https://www.npmjs.com/package/hooks-fixed
+ * @see kareem http://npmjs.org/package/kareem
+ * @api public
+ */
+
+Schema.prototype.post = function(method, fn) {
+ if (IS_KAREEM_HOOK[method]) {
+ this.s.hooks.post.apply(this.s.hooks, arguments);
+ return this;
+ }
+ // assuming that all callbacks with arity < 2 are synchronous post hooks
+ if (fn.length < 2) {
+ return this.queue('on', [arguments[0], function(doc) {
+ return fn.call(doc, doc);
+ }]);
+ }
+
+ if (fn.length === 3) {
+ this.s.hooks.post(method + ':error', fn);
+ return this;
+ }
+
+ return this.queue('post', [arguments[0], function(next) {
+ // wrap original function so that the callback goes last,
+ // for compatibility with old code that is using synchronous post hooks
+ var _this = this;
+ var args = Array.prototype.slice.call(arguments, 1);
+ fn.call(this, this, function(err) {
+ return next.apply(_this, [err].concat(args));
+ });
+ }]);
+};
+
+/**
+ * Registers a plugin for this schema.
+ *
+ * @param {Function} plugin callback
+ * @param {Object} [opts]
+ * @see plugins
+ * @api public
+ */
+
+Schema.prototype.plugin = function(fn, opts) {
+ fn(this, opts);
+ return this;
+};
+
+/**
+ * Adds an instance method to documents constructed from Models compiled from this schema.
+ *
+ * ####Example
+ *
+ * var schema = kittySchema = new Schema(..);
+ *
+ * schema.method('meow', function () {
+ * console.log('meeeeeoooooooooooow');
+ * })
+ *
+ * var Kitty = mongoose.model('Kitty', schema);
+ *
+ * var fizz = new Kitty;
+ * fizz.meow(); // meeeeeooooooooooooow
+ *
+ * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as methods.
+ *
+ * schema.method({
+ * purr: function () {}
+ * , scratch: function () {}
+ * });
+ *
+ * // later
+ * fizz.purr();
+ * fizz.scratch();
+ *
+ * @param {String|Object} method name
+ * @param {Function} [fn]
+ * @api public
+ */
+
+Schema.prototype.method = function(name, fn) {
+ if (typeof name !== 'string') {
+ for (var i in name) {
+ this.methods[i] = name[i];
+ }
+ } else {
+ this.methods[name] = fn;
+ }
+ return this;
+};
+
+/**
+ * Adds static "class" methods to Models compiled from this schema.
+ *
+ * ####Example
+ *
+ * var schema = new Schema(..);
+ * schema.static('findByName', function (name, callback) {
+ * return this.find({ name: name }, callback);
+ * });
+ *
+ * var Drink = mongoose.model('Drink', schema);
+ * Drink.findByName('sanpellegrino', function (err, drinks) {
+ * //
+ * });
+ *
+ * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as statics.
+ *
+ * @param {String|Object} name
+ * @param {Function} [fn]
+ * @api public
+ */
+
+Schema.prototype.static = function(name, fn) {
+ if (typeof name !== 'string') {
+ for (var i in name) {
+ this.statics[i] = name[i];
+ }
+ } else {
+ this.statics[name] = fn;
+ }
+ return this;
+};
+
+/**
+ * Defines an index (most likely compound) for this schema.
+ *
+ * ####Example
+ *
+ * schema.index({ first: 1, last: -1 })
+ *
+ * @param {Object} fields
+ * @param {Object} [options] Options to pass to [MongoDB driver's `createIndex()` function](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#createIndex)
+ * @param {String} [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
+ * @api public
+ */
+
+Schema.prototype.index = function(fields, options) {
+ options || (options = {});
+
+ if (options.expires) {
+ utils.expires(options);
+ }
+
+ this._indexes.push([fields, options]);
+ return this;
+};
+
+/**
+ * Sets/gets a schema option.
+ *
+ * ####Example
+ *
+ * schema.set('strict'); // 'true' by default
+ * schema.set('strict', false); // Sets 'strict' to false
+ * schema.set('strict'); // 'false'
+ *
+ * @param {String} key option name
+ * @param {Object} [value] if not passed, the current option value is returned
+ * @see Schema ./
+ * @api public
+ */
+
+Schema.prototype.set = function(key, value, _tags) {
+ if (arguments.length === 1) {
+ return this.options[key];
+ }
+
+ switch (key) {
+ case 'read':
+ this.options[key] = readPref(value, _tags);
+ break;
+ case 'safe':
+ this.options[key] = value === false
+ ? {w: 0}
+ : value;
+ break;
+ case 'timestamps':
+ this.setupTimestamp(value);
+ this.options[key] = value;
+ break;
+ default:
+ this.options[key] = value;
+ }
+
+ return this;
+};
+
+/**
+ * Gets a schema option.
+ *
+ * @param {String} key option name
+ * @api public
+ */
+
+Schema.prototype.get = function(key) {
+ return this.options[key];
+};
+
+/**
+ * The allowed index types
+ *
+ * @static indexTypes
+ * @receiver Schema
+ * @api public
+ */
+
+var indexTypes = '2d 2dsphere hashed text'.split(' ');
+
+Object.defineProperty(Schema, 'indexTypes', {
+ get: function() {
+ return indexTypes;
+ },
+ set: function() {
+ throw new Error('Cannot overwrite Schema.indexTypes');
+ }
+});
+
+/**
+ * Compiles indexes from fields and schema-level indexes
+ *
+ * @api public
+ */
+
+Schema.prototype.indexes = function() {
+ 'use strict';
+
+ var indexes = [];
+ var seenPrefix = {};
+
+ var collectIndexes = function(schema, prefix) {
+ if (seenPrefix[prefix]) {
+ return;
+ }
+ seenPrefix[prefix] = true;
+
+ prefix = prefix || '';
+ var key, path, index, field, isObject, options, type;
+ var keys = Object.keys(schema.paths);
+
+ for (var i = 0; i < keys.length; ++i) {
+ key = keys[i];
+ path = schema.paths[key];
+
+ if ((path instanceof MongooseTypes.DocumentArray) || path.$isSingleNested) {
+ collectIndexes(path.schema, key + '.');
+ } else {
+ index = path._index;
+
+ if (index !== false && index !== null && index !== undefined) {
+ field = {};
+ isObject = utils.isObject(index);
+ options = isObject ? index : {};
+ type = typeof index === 'string' ? index :
+ isObject ? index.type :
+ false;
+
+ if (type && ~Schema.indexTypes.indexOf(type)) {
+ field[prefix + key] = type;
+ } else if (options.text) {
+ field[prefix + key] = 'text';
+ delete options.text;
+ } else {
+ field[prefix + key] = 1;
+ }
+
+ delete options.type;
+ if (!('background' in options)) {
+ options.background = true;
+ }
+
+ indexes.push([field, options]);
+ }
+ }
+ }
+
+ if (prefix) {
+ fixSubIndexPaths(schema, prefix);
+ } else {
+ schema._indexes.forEach(function(index) {
+ if (!('background' in index[1])) {
+ index[1].background = true;
+ }
+ });
+ indexes = indexes.concat(schema._indexes);
+ }
+ };
+
+ collectIndexes(this);
+ return indexes;
+
+ /*!
+ * Checks for indexes added to subdocs using Schema.index().
+ * These indexes need their paths prefixed properly.
+ *
+ * schema._indexes = [ [indexObj, options], [indexObj, options] ..]
+ */
+
+ function fixSubIndexPaths(schema, prefix) {
+ var subindexes = schema._indexes,
+ len = subindexes.length,
+ indexObj,
+ newindex,
+ klen,
+ keys,
+ key,
+ i = 0,
+ j;
+
+ for (i = 0; i < len; ++i) {
+ indexObj = subindexes[i][0];
+ keys = Object.keys(indexObj);
+ klen = keys.length;
+ newindex = {};
+
+ // use forward iteration, order matters
+ for (j = 0; j < klen; ++j) {
+ key = keys[j];
+ newindex[prefix + key] = indexObj[key];
+ }
+
+ indexes.push([newindex, subindexes[i][1]]);
+ }
+ }
+};
+
+/**
+ * Creates a virtual type with the given name.
+ *
+ * @param {String} name
+ * @param {Object} [options]
+ * @return {VirtualType}
+ */
+
+Schema.prototype.virtual = function(name, options) {
+ if (options && options.ref) {
+ if (!options.localField) {
+ throw new Error('Reference virtuals require `localField` option');
+ }
+
+ if (!options.foreignField) {
+ throw new Error('Reference virtuals require `foreignField` option');
+ }
+
+ this.pre('init', function(next, obj) {
+ if (name in obj) {
+ if (!this.$$populatedVirtuals) {
+ this.$$populatedVirtuals = {};
+ }
+
+ if (options.justOne) {
+ this.$$populatedVirtuals[name] = Array.isArray(obj[name]) ?
+ obj[name][0] :
+ obj[name];
+ } else {
+ this.$$populatedVirtuals[name] = Array.isArray(obj[name]) ?
+ obj[name] :
+ obj[name] == null ? [] : [obj[name]];
+ }
+
+ delete obj[name];
+ }
+ if (this.ownerDocument) {
+ next();
+ return obj;
+ } else {
+ next();
+ }
+ });
+
+ var virtual = this.virtual(name);
+ virtual.options = options;
+ return virtual.
+ get(function() {
+ if (!this.$$populatedVirtuals) {
+ this.$$populatedVirtuals = {};
+ }
+ if (name in this.$$populatedVirtuals) {
+ return this.$$populatedVirtuals[name];
+ }
+ return null;
+ }).
+ set(function(v) {
+ if (!this.$$populatedVirtuals) {
+ this.$$populatedVirtuals = {};
+ }
+ this.$$populatedVirtuals[name] = v;
+ });
+ }
+
+ var virtuals = this.virtuals;
+ var parts = name.split('.');
+
+ if (this.pathType(name) === 'real') {
+ throw new Error('Virtual path "' + name + '"' +
+ ' conflicts with a real path in the schema');
+ }
+
+ virtuals[name] = parts.reduce(function(mem, part, i) {
+ mem[part] || (mem[part] = (i === parts.length - 1)
+ ? new VirtualType(options, name)
+ : {});
+ return mem[part];
+ }, this.tree);
+
+ return virtuals[name];
+};
+
+/*!
+ * ignore
+ */
+
+Schema.prototype._getVirtual = function(name) {
+ return _getVirtual(this, name);
+};
+
+/*!
+ * ignore
+ */
+
+function _getVirtual(schema, name) {
+ var parts = name.split('.');
+ var cur = '';
+ var nestedSchemaPath = '';
+ for (var i = 0; i < parts.length; ++i) {
+ cur += (cur.length > 0 ? '.' : '') + parts[i];
+ if (schema.virtuals[cur]) {
+ if (i === parts.length - 1) {
+ schema.virtuals[cur].$nestedSchemaPath = nestedSchemaPath;
+ return schema.virtuals[cur];
+ }
+ continue;
+ } else if (schema.paths[cur] && schema.paths[cur].schema) {
+ schema = schema.paths[cur].schema;
+ nestedSchemaPath += (nestedSchemaPath.length > 0 ? '.' : '') + cur;
+ cur = '';
+ } else {
+ return null;
+ }
+ }
+}
+
+/**
+ * Returns the virtual type with the given `name`.
+ *
+ * @param {String} name
+ * @return {VirtualType}
+ */
+
+Schema.prototype.virtualpath = function(name) {
+ return this.virtuals[name];
+};
+
+/**
+ * Removes the given `path` (or [`paths`]).
+ *
+ * @param {String|Array} path
+ *
+ * @api public
+ */
+Schema.prototype.remove = function(path) {
+ if (typeof path === 'string') {
+ path = [path];
+ }
+ if (Array.isArray(path)) {
+ path.forEach(function(name) {
+ if (this.path(name)) {
+ delete this.paths[name];
+
+ var pieces = name.split('.');
+ var last = pieces.pop();
+ var branch = this.tree;
+ for (var i = 0; i < pieces.length; ++i) {
+ branch = branch[pieces[i]];
+ }
+ delete branch[last];
+ }
+ }, this);
+ }
+};
+
+/**
+ * Loads an ES6 class into a schema. Maps setters + getters, static methods, and instance methods to schema virtuals, statics, and methods.
+ *
+ * @param {Function} model
+ */
+Schema.prototype.loadClass = function(model, virtualsOnly) {
+ if (model === Object.prototype || model === Function.prototype) {
+ return this;
+ }
+
+ // Add static methods
+ if (!virtualsOnly) {
+ Object.getOwnPropertyNames(model).forEach(function(name) {
+ if (name.match(/^(length|name|prototype)$/)) {
+ return;
+ }
+ var method = Object.getOwnPropertyDescriptor(model, name);
+ if (typeof method.value === 'function') this.static(name, method.value);
+ }, this);
+ }
+
+ // Add methods and virtuals
+ Object.getOwnPropertyNames(model.prototype).forEach(function(name) {
+ if (name.match(/^(constructor)$/)) {
+ return;
+ }
+ var method = Object.getOwnPropertyDescriptor(model.prototype, name);
+ if (!virtualsOnly) {
+ if (typeof method.value === 'function') {
+ this.method(name, method.value);
+ }
+ }
+ if (typeof method.get === 'function') {
+ this.virtual(name).get(method.get);
+ }
+ if (typeof method.set === 'function') {
+ this.virtual(name).set(method.set);
+ }
+ }, this);
+
+ return (this.loadClass(Object.getPrototypeOf(model)));
+};
+
+/*!
+ * ignore
+ */
+
+Schema.prototype._getSchema = function(path) {
+ var _this = this;
+ var pathschema = _this.path(path);
+ var resultPath = [];
+
+ if (pathschema) {
+ pathschema.$fullPath = path;
+ return pathschema;
+ }
+
+ function search(parts, schema) {
+ var p = parts.length + 1,
+ foundschema,
+ trypath;
+
+ while (p--) {
+ trypath = parts.slice(0, p).join('.');
+ foundschema = schema.path(trypath);
+ if (foundschema) {
+ resultPath.push(trypath);
+
+ if (foundschema.caster) {
+ // array of Mixed?
+ if (foundschema.caster instanceof MongooseTypes.Mixed) {
+ foundschema.caster.$fullPath = resultPath.join('.');
+ return foundschema.caster;
+ }
+
+ // Now that we found the array, we need to check if there
+ // are remaining document paths to look up for casting.
+ // Also we need to handle array.$.path since schema.path
+ // doesn't work for that.
+ // If there is no foundschema.schema we are dealing with
+ // a path like array.$
+ if (p !== parts.length && foundschema.schema) {
+ if (parts[p] === '$') {
+ // comments.$.comments.$.title
+ return search(parts.slice(p + 1), foundschema.schema);
+ }
+ // this is the last path of the selector
+ return search(parts.slice(p), foundschema.schema);
+ }
+ }
+
+ foundschema.$fullPath = resultPath.join('.');
+
+ return foundschema;
+ }
+ }
+ }
+
+ // look for arrays
+ return search(path.split('.'), _this);
+};
+
+/*!
+ * ignore
+ */
+
+Schema.prototype._getPathType = function(path) {
+ var _this = this;
+ var pathschema = _this.path(path);
+
+ if (pathschema) {
+ return 'real';
+ }
+
+ function search(parts, schema) {
+ var p = parts.length + 1,
+ foundschema,
+ trypath;
+
+ while (p--) {
+ trypath = parts.slice(0, p).join('.');
+ foundschema = schema.path(trypath);
+ if (foundschema) {
+ if (foundschema.caster) {
+ // array of Mixed?
+ if (foundschema.caster instanceof MongooseTypes.Mixed) {
+ return { schema: foundschema, pathType: 'mixed' };
+ }
+
+ // Now that we found the array, we need to check if there
+ // are remaining document paths to look up for casting.
+ // Also we need to handle array.$.path since schema.path
+ // doesn't work for that.
+ // If there is no foundschema.schema we are dealing with
+ // a path like array.$
+ if (p !== parts.length && foundschema.schema) {
+ if (parts[p] === '$') {
+ if (p === parts.length - 1) {
+ return { schema: foundschema, pathType: 'nested' };
+ }
+ // comments.$.comments.$.title
+ return search(parts.slice(p + 1), foundschema.schema);
+ }
+ // this is the last path of the selector
+ return search(parts.slice(p), foundschema.schema);
+ }
+ return {
+ schema: foundschema,
+ pathType: foundschema.$isSingleNested ? 'nested' : 'array'
+ };
+ }
+ return { schema: foundschema, pathType: 'real' };
+ } else if (p === parts.length && schema.nested[trypath]) {
+ return { schema: schema, pathType: 'nested' };
+ }
+ }
+ return { schema: foundschema || schema, pathType: 'undefined' };
+ }
+
+ // look for arrays
+ return search(path.split('.'), _this);
+};
+
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = Schema;
+
+// require down here because of reference issues
+
+/**
+ * The various built-in Mongoose Schema Types.
+ *
+ * ####Example:
+ *
+ * var mongoose = require('mongoose');
+ * var ObjectId = mongoose.Schema.Types.ObjectId;
+ *
+ * ####Types:
+ *
+ * - [String](#schema-string-js)
+ * - [Number](#schema-number-js)
+ * - [Boolean](#schema-boolean-js) | Bool
+ * - [Array](#schema-array-js)
+ * - [Buffer](#schema-buffer-js)
+ * - [Date](#schema-date-js)
+ * - [ObjectId](#schema-objectid-js) | Oid
+ * - [Mixed](#schema-mixed-js)
+ *
+ * Using this exposed access to the `Mixed` SchemaType, we can use them in our schema.
+ *
+ * var Mixed = mongoose.Schema.Types.Mixed;
+ * new mongoose.Schema({ _user: Mixed })
+ *
+ * @api public
+ */
+
+Schema.Types = MongooseTypes = require('./schema/index');
+
+/*!
+ * ignore
+ */
+
+exports.ObjectId = MongooseTypes.ObjectId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/array.js
new file mode 100644
index 0000000..06a708a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/array.js
@@ -0,0 +1,314 @@
+/*!
+ * Module dependencies.
+ */
+
+var SchemaType = require('../schematype');
+var CastError = SchemaType.CastError;
+var Types = {
+ Boolean: require('./boolean'),
+ Date: require('./date'),
+ Number: require('./number'),
+ String: require('./string'),
+ ObjectId: require('./objectid'),
+ Buffer: require('./buffer')
+};
+var MongooseArray = require('../types').Array;
+var EmbeddedDoc = require('../types').Embedded;
+var Mixed = require('./mixed');
+var cast = require('../cast');
+var util = require('util');
+var utils = require('../utils');
+var castToNumber = require('./operators/helpers').castToNumber;
+var geospatial = require('./operators/geospatial');
+
+/**
+ * Array SchemaType constructor
+ *
+ * @param {String} key
+ * @param {SchemaType} cast
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaArray(key, cast, options, schemaOptions) {
+ var typeKey = 'type';
+ if (schemaOptions && schemaOptions.typeKey) {
+ typeKey = schemaOptions.typeKey;
+ }
+
+ if (cast) {
+ var castOptions = {};
+
+ if (utils.getFunctionName(cast.constructor) === 'Object') {
+ if (cast[typeKey]) {
+ // support { type: Woot }
+ castOptions = utils.clone(cast); // do not alter user arguments
+ delete castOptions[typeKey];
+ cast = cast[typeKey];
+ } else {
+ cast = Mixed;
+ }
+ }
+
+ // support { type: 'String' }
+ var name = typeof cast === 'string'
+ ? cast
+ : utils.getFunctionName(cast);
+
+ var caster = name in Types
+ ? Types[name]
+ : cast;
+
+ this.casterConstructor = caster;
+ if (typeof caster === 'function') {
+ this.caster = new caster(null, castOptions);
+ } else {
+ this.caster = caster;
+ }
+
+ if (!(this.caster instanceof EmbeddedDoc)) {
+ this.caster.path = key;
+ }
+ }
+
+ SchemaType.call(this, key, options, 'Array');
+
+ var defaultArr;
+ var fn;
+
+ if (this.defaultValue != null) {
+ defaultArr = this.defaultValue;
+ fn = typeof defaultArr === 'function';
+ }
+
+ if (!('defaultValue' in this) || this.defaultValue !== void 0) {
+ this.default(function() {
+ var arr = [];
+ if (fn) {
+ arr = defaultArr();
+ } else if (defaultArr != null) {
+ arr = defaultArr;
+ }
+ // Leave it up to `cast()` to convert the array
+ return arr;
+ });
+ }
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaArray.schemaName = 'Array';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaArray.prototype = Object.create(SchemaType.prototype);
+SchemaArray.prototype.constructor = SchemaArray;
+
+/**
+ * Check if the given value satisfies a required validator. The given value
+ * must be not null nor undefined, and have a non-zero length.
+ *
+ * @param {Any} value
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaArray.prototype.checkRequired = function(value) {
+ return !!(value && value.length);
+};
+
+/**
+ * Overrides the getters application for the population special-case
+ *
+ * @param {Object} value
+ * @param {Object} scope
+ * @api private
+ */
+
+SchemaArray.prototype.applyGetters = function(value, scope) {
+ if (this.caster.options && this.caster.options.ref) {
+ // means the object id was populated
+ return value;
+ }
+
+ return SchemaType.prototype.applyGetters.call(this, value, scope);
+};
+
+/**
+ * Casts values for set().
+ *
+ * @param {Object} value
+ * @param {Document} doc document that triggers the casting
+ * @param {Boolean} init whether this is an initialization cast
+ * @api private
+ */
+
+SchemaArray.prototype.cast = function(value, doc, init) {
+ if (Array.isArray(value)) {
+ if (!value.length && doc) {
+ var indexes = doc.schema.indexedPaths();
+
+ for (var i = 0, l = indexes.length; i < l; ++i) {
+ var pathIndex = indexes[i][0][this.path];
+ if (pathIndex === '2dsphere' || pathIndex === '2d') {
+ return;
+ }
+ }
+ }
+
+ if (!(value && value.isMongooseArray)) {
+ value = new MongooseArray(value, this.path, doc);
+ } else if (value && value.isMongooseArray) {
+ // We need to create a new array, otherwise change tracking will
+ // update the old doc (gh-4449)
+ value = new MongooseArray(value, this.path, doc);
+ }
+
+ if (this.caster) {
+ try {
+ for (i = 0, l = value.length; i < l; i++) {
+ value[i] = this.caster.cast(value[i], doc, init);
+ }
+ } catch (e) {
+ // rethrow
+ throw new CastError('[' + e.kind + ']', util.inspect(value), this.path, e);
+ }
+ }
+
+ return value;
+ }
+ // gh-2442: if we're loading this from the db and its not an array, mark
+ // the whole array as modified.
+ if (!!doc && !!init) {
+ doc.markModified(this.path);
+ }
+ return this.cast([value], doc, init);
+};
+
+/**
+ * Casts values for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [value]
+ * @api private
+ */
+
+SchemaArray.prototype.castForQuery = function($conditional, value) {
+ var handler,
+ val;
+
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with Array.');
+ }
+
+ val = handler.call(this, value);
+ } else {
+ val = $conditional;
+ var proto = this.casterConstructor.prototype;
+ var method = proto && (proto.castForQuery || proto.cast);
+ var caster = this.caster;
+
+ if (Array.isArray(val)) {
+ val = val.map(function(v) {
+ if (utils.isObject(v) && v.$elemMatch) {
+ return v;
+ }
+ if (method) {
+ v = method.call(caster, v);
+ }
+ return v;
+ });
+ } else if (method) {
+ val = method.call(caster, val);
+ }
+ }
+
+ return val;
+};
+
+function cast$all(val) {
+ if (!Array.isArray(val)) {
+ val = [val];
+ }
+
+ val = val.map(function(v) {
+ if (utils.isObject(v)) {
+ var o = {};
+ o[this.path] = v;
+ return cast(this.casterConstructor.schema, o)[this.path];
+ }
+ return v;
+ }, this);
+
+ return this.castForQuery(val);
+}
+
+function cast$elemMatch(val) {
+ var keys = Object.keys(val);
+ var numKeys = keys.length;
+ var key;
+ var value;
+ for (var i = 0; i < numKeys; ++i) {
+ key = keys[i];
+ value = val[key];
+ if (key.indexOf('$') === 0 && value) {
+ val[key] = this.castForQuery(key, value);
+ }
+ }
+
+ return cast(this.casterConstructor.schema, val);
+}
+
+var handle = SchemaArray.prototype.$conditionalHandlers = {};
+
+handle.$all = cast$all;
+handle.$options = String;
+handle.$elemMatch = cast$elemMatch;
+handle.$geoIntersects = geospatial.cast$geoIntersects;
+handle.$or = handle.$and = function(val) {
+ if (!Array.isArray(val)) {
+ throw new TypeError('conditional $or/$and require array');
+ }
+
+ var ret = [];
+ for (var i = 0; i < val.length; ++i) {
+ ret.push(cast(this.casterConstructor.schema, val[i]));
+ }
+
+ return ret;
+};
+
+handle.$near =
+handle.$nearSphere = geospatial.cast$near;
+
+handle.$within =
+handle.$geoWithin = geospatial.cast$within;
+
+handle.$size =
+handle.$minDistance =
+handle.$maxDistance = castToNumber;
+
+handle.$eq =
+handle.$gt =
+handle.$gte =
+handle.$in =
+handle.$lt =
+handle.$lte =
+handle.$ne =
+handle.$nin =
+handle.$regex = SchemaArray.prototype.castForQuery;
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/boolean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/boolean.js
new file mode 100644
index 0000000..206d9fd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/boolean.js
@@ -0,0 +1,103 @@
+/*!
+ * Module dependencies.
+ */
+
+var utils = require('../utils');
+
+var SchemaType = require('../schematype');
+
+/**
+ * Boolean SchemaType constructor.
+ *
+ * @param {String} path
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaBoolean(path, options) {
+ SchemaType.call(this, path, options, 'Boolean');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaBoolean.schemaName = 'Boolean';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaBoolean.prototype = Object.create(SchemaType.prototype);
+SchemaBoolean.prototype.constructor = SchemaBoolean;
+
+/**
+ * Check if the given value satisfies a required validator. For a boolean
+ * to satisfy a required validator, it must be strictly equal to true or to
+ * false.
+ *
+ * @param {Any} value
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaBoolean.prototype.checkRequired = function(value) {
+ return value === true || value === false;
+};
+
+/**
+ * Casts to boolean
+ *
+ * @param {Object} value
+ * @api private
+ */
+
+SchemaBoolean.prototype.cast = function(value) {
+ if (value === null) {
+ return value;
+ }
+ if (value === '0') {
+ return false;
+ }
+ if (value === 'true') {
+ return true;
+ }
+ if (value === 'false') {
+ return false;
+ }
+ return !!value;
+};
+
+SchemaBoolean.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {});
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} val
+ * @api private
+ */
+
+SchemaBoolean.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = SchemaBoolean.$conditionalHandlers[$conditional];
+
+ if (handler) {
+ return handler.call(this, val);
+ }
+
+ return this.cast(val);
+ }
+
+ return this.cast($conditional);
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaBoolean;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/buffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/buffer.js
new file mode 100644
index 0000000..e7fe814
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/buffer.js
@@ -0,0 +1,188 @@
+/*!
+ * Module dependencies.
+ */
+
+var handleBitwiseOperator = require('./operators/bitwise');
+var utils = require('../utils');
+
+var MongooseBuffer = require('../types').Buffer;
+var SchemaType = require('../schematype');
+
+var Binary = MongooseBuffer.Binary;
+var CastError = SchemaType.CastError;
+var Document;
+
+/**
+ * Buffer SchemaType constructor
+ *
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaBuffer(key, options) {
+ SchemaType.call(this, key, options, 'Buffer');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaBuffer.schemaName = 'Buffer';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaBuffer.prototype = Object.create(SchemaType.prototype);
+SchemaBuffer.prototype.constructor = SchemaBuffer;
+
+/**
+ * Check if the given value satisfies a required validator. To satisfy a
+ * required validator, a buffer must not be null or undefined and have
+ * non-zero length.
+ *
+ * @param {Any} value
+ * @param {Document} doc
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaBuffer.prototype.checkRequired = function(value, doc) {
+ if (SchemaType._isRef(this, value, doc, true)) {
+ return !!value;
+ }
+ return !!(value && value.length);
+};
+
+/**
+ * Casts contents
+ *
+ * @param {Object} value
+ * @param {Document} doc document that triggers the casting
+ * @param {Boolean} init
+ * @api private
+ */
+
+SchemaBuffer.prototype.cast = function(value, doc, init) {
+ var ret;
+ if (SchemaType._isRef(this, value, doc, init)) {
+ // wait! we may need to cast this to a document
+
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ // lazy load
+ Document || (Document = require('./../document'));
+
+ if (value instanceof Document) {
+ value.$__.wasPopulated = true;
+ return value;
+ }
+
+ // setting a populated path
+ if (Buffer.isBuffer(value)) {
+ return value;
+ } else if (!utils.isObject(value)) {
+ throw new CastError('buffer', value, this.path);
+ }
+
+ // Handle the case where user directly sets a populated
+ // path to a plain object; cast to the Model used in
+ // the population query.
+ var path = doc.$__fullPath(this.path);
+ var owner = doc.ownerDocument ? doc.ownerDocument() : doc;
+ var pop = owner.populated(path, true);
+ ret = new pop.options.model(value);
+ ret.$__.wasPopulated = true;
+ return ret;
+ }
+
+ // documents
+ if (value && value._id) {
+ value = value._id;
+ }
+
+ if (value && value.isMongooseBuffer) {
+ return value;
+ }
+
+ if (Buffer.isBuffer(value)) {
+ if (!value || !value.isMongooseBuffer) {
+ value = new MongooseBuffer(value, [this.path, doc]);
+ }
+
+ return value;
+ } else if (value instanceof Binary) {
+ ret = new MongooseBuffer(value.value(true), [this.path, doc]);
+ if (typeof value.sub_type !== 'number') {
+ throw new CastError('buffer', value, this.path);
+ }
+ ret._subtype = value.sub_type;
+ return ret;
+ }
+
+ if (value === null) {
+ return value;
+ }
+
+ var type = typeof value;
+ if (type === 'string' || type === 'number' || Array.isArray(value)) {
+ if (type === 'number') {
+ value = [value];
+ }
+ ret = new MongooseBuffer(value, [this.path, doc]);
+ return ret;
+ }
+
+ throw new CastError('buffer', value, this.path);
+};
+
+/*!
+ * ignore
+ */
+function handleSingle(val) {
+ return this.castForQuery(val);
+}
+
+SchemaBuffer.prototype.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {
+ $bitsAllClear: handleBitwiseOperator,
+ $bitsAnyClear: handleBitwiseOperator,
+ $bitsAllSet: handleBitwiseOperator,
+ $bitsAnySet: handleBitwiseOperator,
+ $gt: handleSingle,
+ $gte: handleSingle,
+ $lt: handleSingle,
+ $lte: handleSingle
+ });
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [value]
+ * @api private
+ */
+
+SchemaBuffer.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with Buffer.');
+ }
+ return handler.call(this, val);
+ }
+ val = $conditional;
+ return this.cast(val).toObject({ transform: false });
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/date.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/date.js
new file mode 100644
index 0000000..b7bcf22
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/date.js
@@ -0,0 +1,296 @@
+/*!
+ * Module requirements.
+ */
+
+var MongooseError = require('../error');
+var utils = require('../utils');
+
+var SchemaType = require('../schematype');
+
+var CastError = SchemaType.CastError;
+
+/**
+ * Date SchemaType constructor.
+ *
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaDate(key, options) {
+ SchemaType.call(this, key, options, 'Date');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaDate.schemaName = 'Date';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaDate.prototype = Object.create(SchemaType.prototype);
+SchemaDate.prototype.constructor = SchemaDate;
+
+/**
+ * Declares a TTL index (rounded to the nearest second) for _Date_ types only.
+ *
+ * This sets the `expireAfterSeconds` index option available in MongoDB >= 2.1.2.
+ * This index type is only compatible with Date types.
+ *
+ * ####Example:
+ *
+ * // expire in 24 hours
+ * new Schema({ createdAt: { type: Date, expires: 60*60*24 }});
+ *
+ * `expires` utilizes the `ms` module from [guille](https://github.com/guille/) allowing us to use a friendlier syntax:
+ *
+ * ####Example:
+ *
+ * // expire in 24 hours
+ * new Schema({ createdAt: { type: Date, expires: '24h' }});
+ *
+ * // expire in 1.5 hours
+ * new Schema({ createdAt: { type: Date, expires: '1.5h' }});
+ *
+ * // expire in 7 days
+ * var schema = new Schema({ createdAt: Date });
+ * schema.path('createdAt').expires('7d');
+ *
+ * @param {Number|String} when
+ * @added 3.0.0
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaDate.prototype.expires = function(when) {
+ if (!this._index || this._index.constructor.name !== 'Object') {
+ this._index = {};
+ }
+
+ this._index.expires = when;
+ utils.expires(this._index);
+ return this;
+};
+
+/**
+ * Check if the given value satisfies a required validator. To satisfy
+ * a required validator, the given value must be an instance of `Date`.
+ *
+ * @param {Any} value
+ * @param {Document} doc
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaDate.prototype.checkRequired = function(value) {
+ return value instanceof Date;
+};
+
+/**
+ * Sets a minimum date validator.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ d: { type: Date, min: Date('1970-01-01') })
+ * var M = db.model('M', s)
+ * var m = new M({ d: Date('1969-12-31') })
+ * m.save(function (err) {
+ * console.error(err) // validator error
+ * m.d = Date('2014-12-08');
+ * m.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MIN} token which will be replaced with the invalid value
+ * var min = [Date('1970-01-01'), 'The value of path `{PATH}` ({VALUE}) is beneath the limit ({MIN}).'];
+ * var schema = new Schema({ d: { type: Date, min: min })
+ * var M = mongoose.model('M', schema);
+ * var s= new M({ d: Date('1969-12-31') });
+ * s.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `d` (1969-12-31) is before the limit (1970-01-01).
+ * })
+ *
+ * @param {Date} value minimum date
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaDate.prototype.min = function(value, message) {
+ if (this.minValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.minValidator;
+ }, this);
+ }
+
+ if (value) {
+ var msg = message || MongooseError.messages.Date.min;
+ msg = msg.replace(/{MIN}/, (value === Date.now ? 'Date.now()' : this.cast(value).toString()));
+ var _this = this;
+ this.validators.push({
+ validator: this.minValidator = function(val) {
+ var min = (value === Date.now ? value() : _this.cast(value));
+ return val === null || val.valueOf() >= min.valueOf();
+ },
+ message: msg,
+ type: 'min',
+ min: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Sets a maximum date validator.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ d: { type: Date, max: Date('2014-01-01') })
+ * var M = db.model('M', s)
+ * var m = new M({ d: Date('2014-12-08') })
+ * m.save(function (err) {
+ * console.error(err) // validator error
+ * m.d = Date('2013-12-31');
+ * m.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MAX} token which will be replaced with the invalid value
+ * var max = [Date('2014-01-01'), 'The value of path `{PATH}` ({VALUE}) exceeds the limit ({MAX}).'];
+ * var schema = new Schema({ d: { type: Date, max: max })
+ * var M = mongoose.model('M', schema);
+ * var s= new M({ d: Date('2014-12-08') });
+ * s.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `d` (2014-12-08) exceeds the limit (2014-01-01).
+ * })
+ *
+ * @param {Date} maximum date
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaDate.prototype.max = function(value, message) {
+ if (this.maxValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.maxValidator;
+ }, this);
+ }
+
+ if (value) {
+ var msg = message || MongooseError.messages.Date.max;
+ msg = msg.replace(/{MAX}/, (value === Date.now ? 'Date.now()' : this.cast(value).toString()));
+ var _this = this;
+ this.validators.push({
+ validator: this.maxValidator = function(val) {
+ var max = (value === Date.now ? value() : _this.cast(value));
+ return val === null || val.valueOf() <= max.valueOf();
+ },
+ message: msg,
+ type: 'max',
+ max: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Casts to date
+ *
+ * @param {Object} value to cast
+ * @api private
+ */
+
+SchemaDate.prototype.cast = function(value) {
+ // If null or undefined
+ if (value === null || value === void 0 || value === '') {
+ return null;
+ }
+
+ if (value instanceof Date) {
+ if (isNaN(value.valueOf())) {
+ throw new CastError('date', value, this.path);
+ }
+
+ return value;
+ }
+
+ var date;
+
+ if (typeof value === 'boolean') {
+ throw new CastError('date', value, this.path);
+ }
+
+ if (value instanceof Number || typeof value === 'number'
+ || String(value) == Number(value)) {
+ // support for timestamps
+ date = new Date(Number(value));
+ } else if (value.valueOf) {
+ // support for moment.js
+ date = new Date(value.valueOf());
+ }
+
+ if (!isNaN(date.valueOf())) {
+ return date;
+ }
+
+ throw new CastError('date', value, this.path);
+};
+
+/*!
+ * Date Query casting.
+ *
+ * @api private
+ */
+
+function handleSingle(val) {
+ return this.cast(val);
+}
+
+SchemaDate.prototype.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {
+ $gt: handleSingle,
+ $gte: handleSingle,
+ $lt: handleSingle,
+ $lte: handleSingle
+ });
+
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [value]
+ * @api private
+ */
+
+SchemaDate.prototype.castForQuery = function($conditional, val) {
+ var handler;
+
+ if (arguments.length !== 2) {
+ return this.cast($conditional);
+ }
+
+ handler = this.$conditionalHandlers[$conditional];
+
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with Date.');
+ }
+
+ return handler.call(this, val);
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaDate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/documentarray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/documentarray.js
new file mode 100644
index 0000000..96da049
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/documentarray.js
@@ -0,0 +1,313 @@
+/* eslint no-empty: 1 */
+
+/*!
+ * Module dependencies.
+ */
+
+var ArrayType = require('./array');
+var CastError = require('../error/cast');
+var MongooseDocumentArray = require('../types/documentarray');
+var SchemaType = require('../schematype');
+var Subdocument = require('../types/embedded');
+var util = require('util');
+
+/**
+ * SubdocsArray SchemaType constructor
+ *
+ * @param {String} key
+ * @param {Schema} schema
+ * @param {Object} options
+ * @inherits SchemaArray
+ * @api public
+ */
+
+function DocumentArray(key, schema, options) {
+ // compile an embedded document for this schema
+ function EmbeddedDocument() {
+ Subdocument.apply(this, arguments);
+ }
+
+ EmbeddedDocument.prototype = Object.create(Subdocument.prototype);
+ EmbeddedDocument.prototype.$__setSchema(schema);
+ EmbeddedDocument.schema = schema;
+
+ // apply methods
+ for (var i in schema.methods) {
+ EmbeddedDocument.prototype[i] = schema.methods[i];
+ }
+
+ // apply statics
+ for (i in schema.statics) {
+ EmbeddedDocument[i] = schema.statics[i];
+ }
+
+ EmbeddedDocument.options = options;
+
+ ArrayType.call(this, key, EmbeddedDocument, options);
+
+ this.schema = schema;
+ this.$isMongooseDocumentArray = true;
+ var fn = this.defaultValue;
+
+ if (!('defaultValue' in this) || fn !== void 0) {
+ this.default(function() {
+ var arr = fn.call(this);
+ if (!Array.isArray(arr)) {
+ arr = [arr];
+ }
+ // Leave it up to `cast()` to convert this to a documentarray
+ return arr;
+ });
+ }
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+DocumentArray.schemaName = 'DocumentArray';
+
+/*!
+ * Inherits from ArrayType.
+ */
+DocumentArray.prototype = Object.create(ArrayType.prototype);
+DocumentArray.prototype.constructor = DocumentArray;
+
+/**
+ * Performs local validations first, then validations on each embedded doc
+ *
+ * @api private
+ */
+
+DocumentArray.prototype.doValidate = function(array, fn, scope, options) {
+ var _this = this;
+ SchemaType.prototype.doValidate.call(this, array, function(err) {
+ if (err) {
+ return fn(err);
+ }
+
+ var count = array && array.length;
+ var error;
+
+ if (!count) {
+ return fn();
+ }
+ if (options && options.updateValidator) {
+ return fn();
+ }
+
+ // handle sparse arrays, do not use array.forEach which does not
+ // iterate over sparse elements yet reports array.length including
+ // them :(
+
+ function callback(err) {
+ if (err) {
+ error = err;
+ }
+ --count || fn(error);
+ }
+
+ for (var i = 0, len = count; i < len; ++i) {
+ // sidestep sparse entries
+ var doc = array[i];
+ if (!doc) {
+ --count || fn(error);
+ continue;
+ }
+
+ // If you set the array index directly, the doc might not yet be
+ // a full fledged mongoose subdoc, so make it into one.
+ if (!(doc instanceof Subdocument)) {
+ doc = array[i] = new _this.casterConstructor(doc, array, undefined,
+ undefined, i);
+ }
+
+ // HACK: use $__original_validate to avoid promises so bluebird doesn't
+ // complain
+ if (doc.$__original_validate) {
+ doc.$__original_validate({__noPromise: true}, callback);
+ } else {
+ doc.validate({__noPromise: true}, callback);
+ }
+ }
+ }, scope);
+};
+
+/**
+ * Performs local validations first, then validations on each embedded doc.
+ *
+ * ####Note:
+ *
+ * This method ignores the asynchronous validators.
+ *
+ * @return {MongooseError|undefined}
+ * @api private
+ */
+
+DocumentArray.prototype.doValidateSync = function(array, scope) {
+ var schemaTypeError = SchemaType.prototype.doValidateSync.call(this, array, scope);
+ if (schemaTypeError) {
+ return schemaTypeError;
+ }
+
+ var count = array && array.length,
+ resultError = null;
+
+ if (!count) {
+ return;
+ }
+
+ // handle sparse arrays, do not use array.forEach which does not
+ // iterate over sparse elements yet reports array.length including
+ // them :(
+
+ for (var i = 0, len = count; i < len; ++i) {
+ // only first error
+ if (resultError) {
+ break;
+ }
+ // sidestep sparse entries
+ var doc = array[i];
+ if (!doc) {
+ continue;
+ }
+
+ var subdocValidateError = doc.validateSync();
+
+ if (subdocValidateError) {
+ resultError = subdocValidateError;
+ }
+ }
+
+ return resultError;
+};
+
+/**
+ * Casts contents
+ *
+ * @param {Object} value
+ * @param {Document} document that triggers the casting
+ * @api private
+ */
+
+DocumentArray.prototype.cast = function(value, doc, init, prev, options) {
+ var selected,
+ subdoc,
+ i;
+
+ if (!Array.isArray(value)) {
+ // gh-2442 mark whole array as modified if we're initializing a doc from
+ // the db and the path isn't an array in the document
+ if (!!doc && init) {
+ doc.markModified(this.path);
+ }
+ return this.cast([value], doc, init, prev);
+ }
+
+ if (!(value && value.isMongooseDocumentArray) &&
+ (!options || !options.skipDocumentArrayCast)) {
+ value = new MongooseDocumentArray(value, this.path, doc);
+ if (prev && prev._handlers) {
+ for (var key in prev._handlers) {
+ doc.removeListener(key, prev._handlers[key]);
+ }
+ }
+ } else if (value && value.isMongooseDocumentArray) {
+ // We need to create a new array, otherwise change tracking will
+ // update the old doc (gh-4449)
+ value = new MongooseDocumentArray(value, this.path, doc);
+ }
+
+ i = value.length;
+
+ while (i--) {
+ if (!value[i]) {
+ continue;
+ }
+ // Check if the document has a different schema (re gh-3701)
+ if ((value[i] instanceof Subdocument) &&
+ value[i].schema !== this.casterConstructor.schema) {
+ value[i] = value[i].toObject({transform: false});
+ }
+ if (!(value[i] instanceof Subdocument) && value[i]) {
+ if (init) {
+ if (doc) {
+ selected || (selected = scopePaths(this, doc.$__.selected, init));
+ } else {
+ selected = true;
+ }
+
+ subdoc = new this.casterConstructor(null, value, true, selected, i);
+ value[i] = subdoc.init(value[i]);
+ } else {
+ try {
+ subdoc = prev.id(value[i]._id);
+ } catch (e) {
+ }
+
+ if (prev && subdoc) {
+ // handle resetting doc with existing id but differing data
+ // doc.array = [{ doc: 'val' }]
+ subdoc.set(value[i]);
+ // if set() is hooked it will have no return value
+ // see gh-746
+ value[i] = subdoc;
+ } else {
+ try {
+ subdoc = new this.casterConstructor(value[i], value, undefined,
+ undefined, i);
+ // if set() is hooked it will have no return value
+ // see gh-746
+ value[i] = subdoc;
+ } catch (error) {
+ var valueInErrorMessage = util.inspect(value[i]);
+ throw new CastError('embedded', valueInErrorMessage,
+ value._path, error);
+ }
+ }
+ }
+ }
+ }
+
+ return value;
+};
+
+/*!
+ * Scopes paths selected in a query to this array.
+ * Necessary for proper default application of subdocument values.
+ *
+ * @param {DocumentArray} array - the array to scope `fields` paths
+ * @param {Object|undefined} fields - the root fields selected in the query
+ * @param {Boolean|undefined} init - if we are being created part of a query result
+ */
+
+function scopePaths(array, fields, init) {
+ if (!(init && fields)) {
+ return undefined;
+ }
+
+ var path = array.path + '.',
+ keys = Object.keys(fields),
+ i = keys.length,
+ selected = {},
+ hasKeys,
+ key;
+
+ while (i--) {
+ key = keys[i];
+ if (key.indexOf(path) === 0) {
+ hasKeys || (hasKeys = true);
+ selected[key.substring(path.length)] = fields[key];
+ }
+ }
+
+ return hasKeys && selected || undefined;
+}
+
+/*!
+ * Module exports.
+ */
+
+module.exports = DocumentArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/embedded.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/embedded.js
new file mode 100644
index 0000000..1d3d892
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/embedded.js
@@ -0,0 +1,177 @@
+'use strict';
+
+/*!
+ * Module dependencies.
+ */
+
+var SchemaType = require('../schematype');
+var Subdocument = require('../types/subdocument');
+var castToNumber = require('./operators/helpers').castToNumber;
+var geospatial = require('./operators/geospatial');
+
+module.exports = Embedded;
+
+/**
+ * Sub-schema schematype constructor
+ *
+ * @param {Schema} schema
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function Embedded(schema, path, options) {
+ var _embedded = function(value, path, parent) {
+ var _this = this;
+ Subdocument.apply(this, arguments);
+ this.$parent = parent;
+ if (parent) {
+ parent.on('save', function() {
+ _this.emit('save', _this);
+ });
+
+ parent.on('isNew', function(val) {
+ _this.isNew = val;
+ _this.emit('isNew', val);
+ });
+ }
+ };
+ _embedded.prototype = Object.create(Subdocument.prototype);
+ _embedded.prototype.$__setSchema(schema);
+ _embedded.schema = schema;
+ _embedded.$isSingleNested = true;
+ _embedded.prototype.$basePath = path;
+ _embedded.prototype.toBSON = function() {
+ return this.toObject({
+ transform: false,
+ retainKeyOrder: schema.options.retainKeyOrder
+ });
+ };
+
+ // apply methods
+ for (var i in schema.methods) {
+ _embedded.prototype[i] = schema.methods[i];
+ }
+
+ // apply statics
+ for (i in schema.statics) {
+ _embedded[i] = schema.statics[i];
+ }
+
+ this.caster = _embedded;
+ this.schema = schema;
+ this.$isSingleNested = true;
+ SchemaType.call(this, path, options, 'Embedded');
+}
+
+Embedded.prototype = Object.create(SchemaType.prototype);
+
+/**
+ * Special case for when users use a common location schema to represent
+ * locations for use with $geoWithin.
+ * https://docs.mongodb.org/manual/reference/operator/query/geoWithin/
+ *
+ * @param {Object} val
+ * @api private
+ */
+
+Embedded.prototype.$conditionalHandlers.$geoWithin = function(val) {
+ return { $geometry: this.castForQuery(val.$geometry) };
+};
+
+/*!
+ * ignore
+ */
+
+Embedded.prototype.$conditionalHandlers.$near =
+Embedded.prototype.$conditionalHandlers.$nearSphere = geospatial.cast$near;
+
+Embedded.prototype.$conditionalHandlers.$within =
+Embedded.prototype.$conditionalHandlers.$geoWithin = geospatial.cast$within;
+
+Embedded.prototype.$conditionalHandlers.$geoIntersects =
+ geospatial.cast$geoIntersects;
+
+Embedded.prototype.$conditionalHandlers.$minDistance = castToNumber;
+Embedded.prototype.$conditionalHandlers.$maxDistance = castToNumber;
+
+/**
+ * Casts contents
+ *
+ * @param {Object} value
+ * @api private
+ */
+
+Embedded.prototype.cast = function(val, doc, init) {
+ if (val && val.$isSingleNested) {
+ return val;
+ }
+ var subdoc = new this.caster(void 0, doc ? doc.$__.selected : void 0, doc);
+ if (init) {
+ subdoc.init(val);
+ } else {
+ subdoc.set(val, undefined, true);
+ }
+ return subdoc;
+};
+
+/**
+ * Casts contents for query
+ *
+ * @param {string} [$conditional] optional query operator (like `$eq` or `$in`)
+ * @param {any} value
+ * @api private
+ */
+
+Embedded.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional);
+ }
+ return handler.call(this, val);
+ }
+ val = $conditional;
+ if (val == null) {
+ return val;
+ }
+
+ return new this.caster(val);
+};
+
+/**
+ * Async validation on this single nested doc.
+ *
+ * @api private
+ */
+
+Embedded.prototype.doValidate = function(value, fn, scope) {
+ SchemaType.prototype.doValidate.call(this, value, function(error) {
+ if (error) {
+ return fn(error);
+ }
+ if (!value) {
+ return fn(null);
+ }
+ value.validate(fn, {__noPromise: true});
+ }, scope);
+};
+
+/**
+ * Synchronously validate this single nested doc
+ *
+ * @api private
+ */
+
+Embedded.prototype.doValidateSync = function(value, scope) {
+ var schemaTypeError = SchemaType.prototype.doValidateSync.call(this, value, scope);
+ if (schemaTypeError) {
+ return schemaTypeError;
+ }
+ if (!value) {
+ return;
+ }
+ return value.validateSync();
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/index.js
new file mode 100644
index 0000000..f2935c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/index.js
@@ -0,0 +1,30 @@
+
+/*!
+ * Module exports.
+ */
+
+exports.String = require('./string');
+
+exports.Number = require('./number');
+
+exports.Boolean = require('./boolean');
+
+exports.DocumentArray = require('./documentarray');
+
+exports.Embedded = require('./embedded');
+
+exports.Array = require('./array');
+
+exports.Buffer = require('./buffer');
+
+exports.Date = require('./date');
+
+exports.ObjectId = require('./objectid');
+
+exports.Mixed = require('./mixed');
+
+// alias
+
+exports.Oid = exports.ObjectId;
+exports.Object = exports.Mixed;
+exports.Bool = exports.Boolean;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/mixed.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/mixed.js
new file mode 100644
index 0000000..e4c23ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/mixed.js
@@ -0,0 +1,80 @@
+/*!
+ * Module dependencies.
+ */
+
+var SchemaType = require('../schematype');
+var utils = require('../utils');
+
+/**
+ * Mixed SchemaType constructor.
+ *
+ * @param {String} path
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function Mixed(path, options) {
+ if (options && options.default) {
+ var def = options.default;
+ if (Array.isArray(def) && def.length === 0) {
+ // make sure empty array defaults are handled
+ options.default = Array;
+ } else if (!options.shared && utils.isObject(def) && Object.keys(def).length === 0) {
+ // prevent odd "shared" objects between documents
+ options.default = function() {
+ return {};
+ };
+ }
+ }
+
+ SchemaType.call(this, path, options, 'Mixed');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+Mixed.schemaName = 'Mixed';
+
+/*!
+ * Inherits from SchemaType.
+ */
+Mixed.prototype = Object.create(SchemaType.prototype);
+Mixed.prototype.constructor = Mixed;
+
+/**
+ * Casts `val` for Mixed.
+ *
+ * _this is a no-op_
+ *
+ * @param {Object} value to cast
+ * @api private
+ */
+
+Mixed.prototype.cast = function(val) {
+ return val;
+};
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $cond
+ * @param {any} [val]
+ * @api private
+ */
+
+Mixed.prototype.castForQuery = function($cond, val) {
+ if (arguments.length === 2) {
+ return val;
+ }
+ return $cond;
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = Mixed;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/number.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/number.js
new file mode 100644
index 0000000..a91f6dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/number.js
@@ -0,0 +1,290 @@
+/*!
+ * Module requirements.
+ */
+
+var SchemaType = require('../schematype');
+var CastError = SchemaType.CastError;
+var handleBitwiseOperator = require('./operators/bitwise');
+var MongooseError = require('../error');
+var utils = require('../utils');
+var Document;
+
+/**
+ * Number SchemaType constructor.
+ *
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaNumber(key, options) {
+ SchemaType.call(this, key, options, 'Number');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaNumber.schemaName = 'Number';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaNumber.prototype = Object.create(SchemaType.prototype);
+SchemaNumber.prototype.constructor = SchemaNumber;
+
+/**
+ * Check if the given value satisfies a required validator.
+ *
+ * @param {Any} value
+ * @param {Document} doc
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) {
+ if (SchemaType._isRef(this, value, doc, true)) {
+ return !!value;
+ }
+ return typeof value === 'number' || value instanceof Number;
+};
+
+/**
+ * Sets a minimum number validator.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ n: { type: Number, min: 10 })
+ * var M = db.model('M', s)
+ * var m = new M({ n: 9 })
+ * m.save(function (err) {
+ * console.error(err) // validator error
+ * m.n = 10;
+ * m.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MIN} token which will be replaced with the invalid value
+ * var min = [10, 'The value of path `{PATH}` ({VALUE}) is beneath the limit ({MIN}).'];
+ * var schema = new Schema({ n: { type: Number, min: min })
+ * var M = mongoose.model('Measurement', schema);
+ * var s= new M({ n: 4 });
+ * s.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `n` (4) is beneath the limit (10).
+ * })
+ *
+ * @param {Number} value minimum number
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaNumber.prototype.min = function(value, message) {
+ if (this.minValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.minValidator;
+ }, this);
+ }
+
+ if (value !== null && value !== undefined) {
+ var msg = message || MongooseError.messages.Number.min;
+ msg = msg.replace(/{MIN}/, value);
+ this.validators.push({
+ validator: this.minValidator = function(v) {
+ return v == null || v >= value;
+ },
+ message: msg,
+ type: 'min',
+ min: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Sets a maximum number validator.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ n: { type: Number, max: 10 })
+ * var M = db.model('M', s)
+ * var m = new M({ n: 11 })
+ * m.save(function (err) {
+ * console.error(err) // validator error
+ * m.n = 10;
+ * m.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MAX} token which will be replaced with the invalid value
+ * var max = [10, 'The value of path `{PATH}` ({VALUE}) exceeds the limit ({MAX}).'];
+ * var schema = new Schema({ n: { type: Number, max: max })
+ * var M = mongoose.model('Measurement', schema);
+ * var s= new M({ n: 4 });
+ * s.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `n` (4) exceeds the limit (10).
+ * })
+ *
+ * @param {Number} maximum number
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaNumber.prototype.max = function(value, message) {
+ if (this.maxValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.maxValidator;
+ }, this);
+ }
+
+ if (value !== null && value !== undefined) {
+ var msg = message || MongooseError.messages.Number.max;
+ msg = msg.replace(/{MAX}/, value);
+ this.validators.push({
+ validator: this.maxValidator = function(v) {
+ return v == null || v <= value;
+ },
+ message: msg,
+ type: 'max',
+ max: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Casts to number
+ *
+ * @param {Object} value value to cast
+ * @param {Document} doc document that triggers the casting
+ * @param {Boolean} init
+ * @api private
+ */
+
+SchemaNumber.prototype.cast = function(value, doc, init) {
+ if (SchemaType._isRef(this, value, doc, init)) {
+ // wait! we may need to cast this to a document
+
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ // lazy load
+ Document || (Document = require('./../document'));
+
+ if (value instanceof Document) {
+ value.$__.wasPopulated = true;
+ return value;
+ }
+
+ // setting a populated path
+ if (typeof value === 'number') {
+ return value;
+ } else if (Buffer.isBuffer(value) || !utils.isObject(value)) {
+ throw new CastError('number', value, this.path);
+ }
+
+ // Handle the case where user directly sets a populated
+ // path to a plain object; cast to the Model used in
+ // the population query.
+ var path = doc.$__fullPath(this.path);
+ var owner = doc.ownerDocument ? doc.ownerDocument() : doc;
+ var pop = owner.populated(path, true);
+ var ret = new pop.options.model(value);
+ ret.$__.wasPopulated = true;
+ return ret;
+ }
+
+ var val = value && typeof value._id !== 'undefined' ?
+ value._id : // documents
+ value;
+
+ if (!isNaN(val)) {
+ if (val === null) {
+ return val;
+ }
+ if (val === '') {
+ return null;
+ }
+ if (typeof val === 'string' || typeof val === 'boolean') {
+ val = Number(val);
+ }
+ if (val instanceof Number) {
+ return val;
+ }
+ if (typeof val === 'number') {
+ return val;
+ }
+ if (val.toString && !Array.isArray(val) && val.toString() == Number(val)) {
+ return new Number(val);
+ }
+ }
+
+ throw new CastError('number', value, this.path);
+};
+
+/*!
+ * ignore
+ */
+
+function handleSingle(val) {
+ return this.cast(val);
+}
+
+function handleArray(val) {
+ var _this = this;
+ if (!Array.isArray(val)) {
+ return [this.cast(val)];
+ }
+ return val.map(function(m) {
+ return _this.cast(m);
+ });
+}
+
+SchemaNumber.prototype.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {
+ $bitsAllClear: handleBitwiseOperator,
+ $bitsAnyClear: handleBitwiseOperator,
+ $bitsAllSet: handleBitwiseOperator,
+ $bitsAnySet: handleBitwiseOperator,
+ $gt: handleSingle,
+ $gte: handleSingle,
+ $lt: handleSingle,
+ $lte: handleSingle,
+ $mod: handleArray
+ });
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [value]
+ * @api private
+ */
+
+SchemaNumber.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with Number.');
+ }
+ return handler.call(this, val);
+ }
+ val = this.cast($conditional);
+ return val;
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaNumber;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/objectid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/objectid.js
new file mode 100644
index 0000000..2885823
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/objectid.js
@@ -0,0 +1,207 @@
+/* eslint no-empty: 1 */
+
+/*!
+ * Module dependencies.
+ */
+
+var SchemaType = require('../schematype'),
+ CastError = SchemaType.CastError,
+ oid = require('../types/objectid'),
+ utils = require('../utils'),
+ Document;
+
+/**
+ * ObjectId SchemaType constructor.
+ *
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function ObjectId(key, options) {
+ SchemaType.call(this, key, options, 'ObjectID');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+ObjectId.schemaName = 'ObjectId';
+
+/*!
+ * Inherits from SchemaType.
+ */
+ObjectId.prototype = Object.create(SchemaType.prototype);
+ObjectId.prototype.constructor = ObjectId;
+
+/**
+ * Adds an auto-generated ObjectId default if turnOn is true.
+ * @param {Boolean} turnOn auto generated ObjectId defaults
+ * @api public
+ * @return {SchemaType} this
+ */
+
+ObjectId.prototype.auto = function(turnOn) {
+ if (turnOn) {
+ this.default(defaultId);
+ this.set(resetId);
+ }
+
+ return this;
+};
+
+/**
+ * Check if the given value satisfies a required validator.
+ *
+ * @param {Any} value
+ * @param {Document} doc
+ * @return {Boolean}
+ * @api public
+ */
+
+ObjectId.prototype.checkRequired = function checkRequired(value, doc) {
+ if (SchemaType._isRef(this, value, doc, true)) {
+ return !!value;
+ }
+ return value instanceof oid;
+};
+
+/**
+ * Casts to ObjectId
+ *
+ * @param {Object} value
+ * @param {Object} doc
+ * @param {Boolean} init whether this is an initialization cast
+ * @api private
+ */
+
+ObjectId.prototype.cast = function(value, doc, init) {
+ if (SchemaType._isRef(this, value, doc, init)) {
+ // wait! we may need to cast this to a document
+
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ // lazy load
+ Document || (Document = require('./../document'));
+
+ if (value instanceof Document) {
+ value.$__.wasPopulated = true;
+ return value;
+ }
+
+ // setting a populated path
+ if (value instanceof oid) {
+ return value;
+ } else if (Buffer.isBuffer(value) || !utils.isObject(value)) {
+ throw new CastError('ObjectId', value, this.path);
+ }
+
+ // Handle the case where user directly sets a populated
+ // path to a plain object; cast to the Model used in
+ // the population query.
+ var path = doc.$__fullPath(this.path);
+ var owner = doc.ownerDocument ? doc.ownerDocument() : doc;
+ var pop = owner.populated(path, true);
+ var ret = value;
+ if (!doc.$__.populated ||
+ !doc.$__.populated[path] ||
+ !doc.$__.populated[path].options ||
+ !doc.$__.populated[path].options.options ||
+ !doc.$__.populated[path].options.options.lean) {
+ ret = new pop.options.model(value);
+ ret.$__.wasPopulated = true;
+ }
+
+ return ret;
+ }
+
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ if (value instanceof oid) {
+ return value;
+ }
+
+ if (value._id) {
+ if (value._id instanceof oid) {
+ return value._id;
+ }
+ if (value._id.toString instanceof Function) {
+ try {
+ return new oid(value._id.toString());
+ } catch (e) {
+ }
+ }
+ }
+
+ if (value.toString instanceof Function) {
+ try {
+ return new oid(value.toString());
+ } catch (err) {
+ throw new CastError('ObjectId', value, this.path);
+ }
+ }
+
+ throw new CastError('ObjectId', value, this.path);
+};
+
+/*!
+ * ignore
+ */
+
+function handleSingle(val) {
+ return this.cast(val);
+}
+
+ObjectId.prototype.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {
+ $gt: handleSingle,
+ $gte: handleSingle,
+ $lt: handleSingle,
+ $lte: handleSingle
+ });
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [val]
+ * @api private
+ */
+
+ObjectId.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with ObjectId.');
+ }
+ return handler.call(this, val);
+ }
+ return this.cast($conditional);
+};
+
+/*!
+ * ignore
+ */
+
+function defaultId() {
+ return new oid();
+}
+
+function resetId(v) {
+ this.$__._id = null;
+ return v;
+}
+
+/*!
+ * Module exports.
+ */
+
+module.exports = ObjectId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/bitwise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/bitwise.js
new file mode 100644
index 0000000..c1fdd34
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/bitwise.js
@@ -0,0 +1,36 @@
+/*!
+ * Module requirements.
+ */
+
+var CastError = require('../../error/cast');
+
+/*!
+ * ignore
+ */
+
+function handleBitwiseOperator(val) {
+ var _this = this;
+ if (Array.isArray(val)) {
+ return val.map(function(v) {
+ return _castNumber(_this.path, v);
+ });
+ } else if (Buffer.isBuffer(val)) {
+ return val;
+ }
+ // Assume trying to cast to number
+ return _castNumber(_this.path, val);
+}
+
+/*!
+ * ignore
+ */
+
+function _castNumber(path, num) {
+ var v = Number(num);
+ if (isNaN(v)) {
+ throw new CastError('number', num, path);
+ }
+ return v;
+}
+
+module.exports = handleBitwiseOperator;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/geospatial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/geospatial.js
new file mode 100644
index 0000000..b490d2d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/geospatial.js
@@ -0,0 +1,100 @@
+/*!
+ * Module requirements.
+ */
+
+var castArraysOfNumbers = require('./helpers').castArraysOfNumbers;
+var castToNumber = require('./helpers').castToNumber;
+
+/*!
+ * ignore
+ */
+
+exports.cast$geoIntersects = cast$geoIntersects;
+exports.cast$near = cast$near;
+exports.cast$within = cast$within;
+
+function cast$near(val) {
+ var SchemaArray = require('../array');
+
+ if (Array.isArray(val)) {
+ castArraysOfNumbers(val, this);
+ return val;
+ }
+
+ _castMinMaxDistance(this, val);
+
+ if (val && val.$geometry) {
+ return cast$geometry(val, this);
+ }
+
+ return SchemaArray.prototype.castForQuery.call(this, val);
+}
+
+function cast$geometry(val, self) {
+ switch (val.$geometry.type) {
+ case 'Polygon':
+ case 'LineString':
+ case 'Point':
+ castArraysOfNumbers(val.$geometry.coordinates, self);
+ break;
+ default:
+ // ignore unknowns
+ break;
+ }
+
+ _castMinMaxDistance(this, val);
+
+ return val;
+}
+
+function cast$within(val) {
+ _castMinMaxDistance(this, val);
+
+ if (val.$box || val.$polygon) {
+ var type = val.$box ? '$box' : '$polygon';
+ val[type].forEach(function(arr) {
+ if (!Array.isArray(arr)) {
+ var msg = 'Invalid $within $box argument. '
+ + 'Expected an array, received ' + arr;
+ throw new TypeError(msg);
+ }
+ arr.forEach(function(v, i) {
+ arr[i] = castToNumber.call(this, v);
+ });
+ });
+ } else if (val.$center || val.$centerSphere) {
+ type = val.$center ? '$center' : '$centerSphere';
+ val[type].forEach(function(item, i) {
+ if (Array.isArray(item)) {
+ item.forEach(function(v, j) {
+ item[j] = castToNumber.call(this, v);
+ });
+ } else {
+ val[type][i] = castToNumber.call(this, item);
+ }
+ });
+ } else if (val.$geometry) {
+ cast$geometry(val, this);
+ }
+
+ return val;
+}
+
+function cast$geoIntersects(val) {
+ var geo = val.$geometry;
+ if (!geo) {
+ return;
+ }
+
+ cast$geometry(val, this);
+ return val;
+}
+
+function _castMinMaxDistance(self, val) {
+ if (val.$maxDistance) {
+ val.$maxDistance = castToNumber.call(self, val.$maxDistance);
+ }
+ if (val.$minDistance) {
+ val.$minDistance = castToNumber.call(self, val.$minDistance);
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/helpers.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/helpers.js
new file mode 100644
index 0000000..850354a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/operators/helpers.js
@@ -0,0 +1,34 @@
+'use strict';
+
+/*!
+ * Module requirements.
+ */
+
+var Types = {
+ Number: require('../number')
+};
+
+/*!
+ * @ignore
+ */
+
+exports.castToNumber = castToNumber;
+exports.castArraysOfNumbers = castArraysOfNumbers;
+
+/*!
+ * @ignore
+ */
+
+function castToNumber(val) {
+ return Types.Number.prototype.cast.call(this, val);
+}
+
+function castArraysOfNumbers(arr, self) {
+ arr.forEach(function(v, i) {
+ if (Array.isArray(v)) {
+ castArraysOfNumbers(v, self);
+ } else {
+ arr[i] = castToNumber.call(self, v);
+ }
+ });
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/string.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/string.js
new file mode 100644
index 0000000..eae40b8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schema/string.js
@@ -0,0 +1,516 @@
+/*!
+ * Module dependencies.
+ */
+
+var SchemaType = require('../schematype');
+var CastError = SchemaType.CastError;
+var MongooseError = require('../error');
+var utils = require('../utils');
+var Document;
+
+/**
+ * String SchemaType constructor.
+ *
+ * @param {String} key
+ * @param {Object} options
+ * @inherits SchemaType
+ * @api public
+ */
+
+function SchemaString(key, options) {
+ this.enumValues = [];
+ this.regExp = null;
+ SchemaType.call(this, key, options, 'String');
+}
+
+/**
+ * This schema type's name, to defend against minifiers that mangle
+ * function names.
+ *
+ * @api public
+ */
+SchemaString.schemaName = 'String';
+
+/*!
+ * Inherits from SchemaType.
+ */
+SchemaString.prototype = Object.create(SchemaType.prototype);
+SchemaString.prototype.constructor = SchemaString;
+
+/**
+ * Adds an enum validator
+ *
+ * ####Example:
+ *
+ * var states = ['opening', 'open', 'closing', 'closed']
+ * var s = new Schema({ state: { type: String, enum: states }})
+ * var M = db.model('M', s)
+ * var m = new M({ state: 'invalid' })
+ * m.save(function (err) {
+ * console.error(String(err)) // ValidationError: `invalid` is not a valid enum value for path `state`.
+ * m.state = 'open'
+ * m.save(callback) // success
+ * })
+ *
+ * // or with custom error messages
+ * var enum = {
+ * values: ['opening', 'open', 'closing', 'closed'],
+ * message: 'enum validator failed for path `{PATH}` with value `{VALUE}`'
+ * }
+ * var s = new Schema({ state: { type: String, enum: enu })
+ * var M = db.model('M', s)
+ * var m = new M({ state: 'invalid' })
+ * m.save(function (err) {
+ * console.error(String(err)) // ValidationError: enum validator failed for path `state` with value `invalid`
+ * m.state = 'open'
+ * m.save(callback) // success
+ * })
+ *
+ * @param {String|Object} [args...] enumeration values
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaString.prototype.enum = function() {
+ if (this.enumValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.enumValidator;
+ }, this);
+ this.enumValidator = false;
+ }
+
+ if (arguments[0] === void 0 || arguments[0] === false) {
+ return this;
+ }
+
+ var values;
+ var errorMessage;
+
+ if (utils.isObject(arguments[0])) {
+ values = arguments[0].values;
+ errorMessage = arguments[0].message;
+ } else {
+ values = arguments;
+ errorMessage = MongooseError.messages.String.enum;
+ }
+
+ for (var i = 0; i < values.length; i++) {
+ if (undefined !== values[i]) {
+ this.enumValues.push(this.cast(values[i]));
+ }
+ }
+
+ var vals = this.enumValues;
+ this.enumValidator = function(v) {
+ return undefined === v || ~vals.indexOf(v);
+ };
+ this.validators.push({
+ validator: this.enumValidator,
+ message: errorMessage,
+ type: 'enum',
+ enumValues: vals
+ });
+
+ return this;
+};
+
+/**
+ * Adds a lowercase setter.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ email: { type: String, lowercase: true }})
+ * var M = db.model('M', s);
+ * var m = new M({ email: 'SomeEmail@example.COM' });
+ * console.log(m.email) // someemail@example.com
+ *
+ * @api public
+ * @return {SchemaType} this
+ */
+
+SchemaString.prototype.lowercase = function(shouldApply) {
+ if (arguments.length > 0 && !shouldApply) {
+ return this;
+ }
+ return this.set(function(v, self) {
+ if (typeof v !== 'string') {
+ v = self.cast(v);
+ }
+ if (v) {
+ return v.toLowerCase();
+ }
+ return v;
+ });
+};
+
+/**
+ * Adds an uppercase setter.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ caps: { type: String, uppercase: true }})
+ * var M = db.model('M', s);
+ * var m = new M({ caps: 'an example' });
+ * console.log(m.caps) // AN EXAMPLE
+ *
+ * @api public
+ * @return {SchemaType} this
+ */
+
+SchemaString.prototype.uppercase = function(shouldApply) {
+ if (arguments.length > 0 && !shouldApply) {
+ return this;
+ }
+ return this.set(function(v, self) {
+ if (typeof v !== 'string') {
+ v = self.cast(v);
+ }
+ if (v) {
+ return v.toUpperCase();
+ }
+ return v;
+ });
+};
+
+/**
+ * Adds a trim setter.
+ *
+ * The string value will be trimmed when set.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ name: { type: String, trim: true }})
+ * var M = db.model('M', s)
+ * var string = ' some name '
+ * console.log(string.length) // 11
+ * var m = new M({ name: string })
+ * console.log(m.name.length) // 9
+ *
+ * @api public
+ * @return {SchemaType} this
+ */
+
+SchemaString.prototype.trim = function(shouldTrim) {
+ if (arguments.length > 0 && !shouldTrim) {
+ return this;
+ }
+ return this.set(function(v, self) {
+ if (typeof v !== 'string') {
+ v = self.cast(v);
+ }
+ if (v) {
+ return v.trim();
+ }
+ return v;
+ });
+};
+
+/**
+ * Sets a minimum length validator.
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ postalCode: { type: String, minlength: 5 })
+ * var Address = db.model('Address', schema)
+ * var address = new Address({ postalCode: '9512' })
+ * address.save(function (err) {
+ * console.error(err) // validator error
+ * address.postalCode = '95125';
+ * address.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MINLENGTH} token which will be replaced with the minimum allowed length
+ * var minlength = [5, 'The value of path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).'];
+ * var schema = new Schema({ postalCode: { type: String, minlength: minlength })
+ * var Address = mongoose.model('Address', schema);
+ * var address = new Address({ postalCode: '9512' });
+ * address.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `postalCode` (`9512`) is shorter than the minimum length (5).
+ * })
+ *
+ * @param {Number} value minimum string length
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaString.prototype.minlength = function(value, message) {
+ if (this.minlengthValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.minlengthValidator;
+ }, this);
+ }
+
+ if (value !== null && value !== undefined) {
+ var msg = message || MongooseError.messages.String.minlength;
+ msg = msg.replace(/{MINLENGTH}/, value);
+ this.validators.push({
+ validator: this.minlengthValidator = function(v) {
+ return v === null || v.length >= value;
+ },
+ message: msg,
+ type: 'minlength',
+ minlength: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Sets a maximum length validator.
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ postalCode: { type: String, maxlength: 9 })
+ * var Address = db.model('Address', schema)
+ * var address = new Address({ postalCode: '9512512345' })
+ * address.save(function (err) {
+ * console.error(err) // validator error
+ * address.postalCode = '95125';
+ * address.save() // success
+ * })
+ *
+ * // custom error messages
+ * // We can also use the special {MAXLENGTH} token which will be replaced with the maximum allowed length
+ * var maxlength = [9, 'The value of path `{PATH}` (`{VALUE}`) exceeds the maximum allowed length ({MAXLENGTH}).'];
+ * var schema = new Schema({ postalCode: { type: String, maxlength: maxlength })
+ * var Address = mongoose.model('Address', schema);
+ * var address = new Address({ postalCode: '9512512345' });
+ * address.validate(function (err) {
+ * console.log(String(err)) // ValidationError: The value of path `postalCode` (`9512512345`) exceeds the maximum allowed length (9).
+ * })
+ *
+ * @param {Number} value maximum string length
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaString.prototype.maxlength = function(value, message) {
+ if (this.maxlengthValidator) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.maxlengthValidator;
+ }, this);
+ }
+
+ if (value !== null && value !== undefined) {
+ var msg = message || MongooseError.messages.String.maxlength;
+ msg = msg.replace(/{MAXLENGTH}/, value);
+ this.validators.push({
+ validator: this.maxlengthValidator = function(v) {
+ return v === null || v.length <= value;
+ },
+ message: msg,
+ type: 'maxlength',
+ maxlength: value
+ });
+ }
+
+ return this;
+};
+
+/**
+ * Sets a regexp validator.
+ *
+ * Any value that does not pass `regExp`.test(val) will fail validation.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ name: { type: String, match: /^a/ }})
+ * var M = db.model('M', s)
+ * var m = new M({ name: 'I am invalid' })
+ * m.validate(function (err) {
+ * console.error(String(err)) // "ValidationError: Path `name` is invalid (I am invalid)."
+ * m.name = 'apples'
+ * m.validate(function (err) {
+ * assert.ok(err) // success
+ * })
+ * })
+ *
+ * // using a custom error message
+ * var match = [ /\.html$/, "That file doesn't end in .html ({VALUE})" ];
+ * var s = new Schema({ file: { type: String, match: match }})
+ * var M = db.model('M', s);
+ * var m = new M({ file: 'invalid' });
+ * m.validate(function (err) {
+ * console.log(String(err)) // "ValidationError: That file doesn't end in .html (invalid)"
+ * })
+ *
+ * Empty strings, `undefined`, and `null` values always pass the match validator. If you require these values, enable the `required` validator also.
+ *
+ * var s = new Schema({ name: { type: String, match: /^a/, required: true }})
+ *
+ * @param {RegExp} regExp regular expression to test against
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @api public
+ */
+
+SchemaString.prototype.match = function match(regExp, message) {
+ // yes, we allow multiple match validators
+
+ var msg = message || MongooseError.messages.String.match;
+
+ var matchValidator = function(v) {
+ if (!regExp) {
+ return false;
+ }
+
+ var ret = ((v != null && v !== '')
+ ? regExp.test(v)
+ : true);
+ return ret;
+ };
+
+ this.validators.push({
+ validator: matchValidator,
+ message: msg,
+ type: 'regexp',
+ regexp: regExp
+ });
+ return this;
+};
+
+/**
+ * Check if the given value satisfies a required validator.
+ *
+ * @param {Any} value
+ * @param {Document} doc
+ * @return {Boolean}
+ * @api public
+ */
+
+SchemaString.prototype.checkRequired = function checkRequired(value, doc) {
+ if (SchemaType._isRef(this, value, doc, true)) {
+ return !!value;
+ }
+ return (value instanceof String || typeof value === 'string') && value.length;
+};
+
+/**
+ * Casts to String
+ *
+ * @api private
+ */
+
+SchemaString.prototype.cast = function(value, doc, init) {
+ if (SchemaType._isRef(this, value, doc, init)) {
+ // wait! we may need to cast this to a document
+
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ // lazy load
+ Document || (Document = require('./../document'));
+
+ if (value instanceof Document) {
+ value.$__.wasPopulated = true;
+ return value;
+ }
+
+ // setting a populated path
+ if (typeof value === 'string') {
+ return value;
+ } else if (Buffer.isBuffer(value) || !utils.isObject(value)) {
+ throw new CastError('string', value, this.path);
+ }
+
+ // Handle the case where user directly sets a populated
+ // path to a plain object; cast to the Model used in
+ // the population query.
+ var path = doc.$__fullPath(this.path);
+ var owner = doc.ownerDocument ? doc.ownerDocument() : doc;
+ var pop = owner.populated(path, true);
+ var ret = new pop.options.model(value);
+ ret.$__.wasPopulated = true;
+ return ret;
+ }
+
+ // If null or undefined
+ if (value === null || value === undefined) {
+ return value;
+ }
+
+ if (typeof value !== 'undefined') {
+ // handle documents being passed
+ if (value._id && typeof value._id === 'string') {
+ return value._id;
+ }
+
+ // Re: gh-647 and gh-3030, we're ok with casting using `toString()`
+ // **unless** its the default Object.toString, because "[object Object]"
+ // doesn't really qualify as useful data
+ if (value.toString && value.toString !== Object.prototype.toString) {
+ return value.toString();
+ }
+ }
+
+ throw new CastError('string', value, this.path);
+};
+
+/*!
+ * ignore
+ */
+
+function handleSingle(val) {
+ return this.castForQuery(val);
+}
+
+function handleArray(val) {
+ var _this = this;
+ if (!Array.isArray(val)) {
+ return [this.castForQuery(val)];
+ }
+ return val.map(function(m) {
+ return _this.castForQuery(m);
+ });
+}
+
+SchemaString.prototype.$conditionalHandlers =
+ utils.options(SchemaType.prototype.$conditionalHandlers, {
+ $all: handleArray,
+ $gt: handleSingle,
+ $gte: handleSingle,
+ $lt: handleSingle,
+ $lte: handleSingle,
+ $options: handleSingle,
+ $regex: handleSingle,
+ $not: handleSingle
+ });
+
+/**
+ * Casts contents for queries.
+ *
+ * @param {String} $conditional
+ * @param {any} [val]
+ * @api private
+ */
+
+SchemaString.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional + ' with String.');
+ }
+ return handler.call(this, val);
+ }
+ val = $conditional;
+ if (Object.prototype.toString.call(val) === '[object RegExp]') {
+ return val;
+ }
+ return this.cast(val);
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = SchemaString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schematype.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schematype.js
new file mode 100644
index 0000000..3ca3423
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/schematype.js
@@ -0,0 +1,931 @@
+/*!
+ * Module dependencies.
+ */
+
+var utils = require('./utils');
+var MongooseError = require('./error');
+var CastError = MongooseError.CastError;
+var ValidatorError = MongooseError.ValidatorError;
+
+/**
+ * SchemaType constructor
+ *
+ * @param {String} path
+ * @param {Object} [options]
+ * @param {String} [instance]
+ * @api public
+ */
+
+function SchemaType(path, options, instance) {
+ this.path = path;
+ this.instance = instance;
+ this.validators = [];
+ this.setters = [];
+ this.getters = [];
+ this.options = options;
+ this._index = null;
+ this.selected;
+
+ for (var i in options) {
+ if (this[i] && typeof this[i] === 'function') {
+ // { unique: true, index: true }
+ if (i === 'index' && this._index) {
+ continue;
+ }
+
+ var opts = Array.isArray(options[i])
+ ? options[i]
+ : [options[i]];
+
+ this[i].apply(this, opts);
+ }
+ }
+}
+
+/**
+ * Sets a default value for this SchemaType.
+ *
+ * ####Example:
+ *
+ * var schema = new Schema({ n: { type: Number, default: 10 })
+ * var M = db.model('M', schema)
+ * var m = new M;
+ * console.log(m.n) // 10
+ *
+ * Defaults can be either `functions` which return the value to use as the default or the literal value itself. Either way, the value will be cast based on its schema type before being set during document creation.
+ *
+ * ####Example:
+ *
+ * // values are cast:
+ * var schema = new Schema({ aNumber: { type: Number, default: 4.815162342 }})
+ * var M = db.model('M', schema)
+ * var m = new M;
+ * console.log(m.aNumber) // 4.815162342
+ *
+ * // default unique objects for Mixed types:
+ * var schema = new Schema({ mixed: Schema.Types.Mixed });
+ * schema.path('mixed').default(function () {
+ * return {};
+ * });
+ *
+ * // if we don't use a function to return object literals for Mixed defaults,
+ * // each document will receive a reference to the same object literal creating
+ * // a "shared" object instance:
+ * var schema = new Schema({ mixed: Schema.Types.Mixed });
+ * schema.path('mixed').default({});
+ * var M = db.model('M', schema);
+ * var m1 = new M;
+ * m1.mixed.added = 1;
+ * console.log(m1.mixed); // { added: 1 }
+ * var m2 = new M;
+ * console.log(m2.mixed); // { added: 1 }
+ *
+ * @param {Function|any} val the default value
+ * @return {defaultValue}
+ * @api public
+ */
+
+SchemaType.prototype.default = function(val) {
+ if (arguments.length === 1) {
+ if (val === void 0) {
+ this.defaultValue = void 0;
+ return void 0;
+ }
+ this.defaultValue = val;
+ return this.defaultValue;
+ } else if (arguments.length > 1) {
+ this.defaultValue = utils.args(arguments);
+ }
+ return this.defaultValue;
+};
+
+/**
+ * Declares the index options for this schematype.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ name: { type: String, index: true })
+ * var s = new Schema({ loc: { type: [Number], index: 'hashed' })
+ * var s = new Schema({ loc: { type: [Number], index: '2d', sparse: true })
+ * var s = new Schema({ loc: { type: [Number], index: { type: '2dsphere', sparse: true }})
+ * var s = new Schema({ date: { type: Date, index: { unique: true, expires: '1d' }})
+ * Schema.path('my.path').index(true);
+ * Schema.path('my.date').index({ expires: 60 });
+ * Schema.path('my.path').index({ unique: true, sparse: true });
+ *
+ * ####NOTE:
+ *
+ * _Indexes are created in the background by default. Specify `background: false` to override._
+ *
+ * [Direction doesn't matter for single key indexes](http://www.mongodb.org/display/DOCS/Indexes#Indexes-CompoundKeysIndexes)
+ *
+ * @param {Object|Boolean|String} options
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.index = function(options) {
+ this._index = options;
+ utils.expires(this._index);
+ return this;
+};
+
+/**
+ * Declares an unique index.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ name: { type: String, unique: true }});
+ * Schema.path('name').index({ unique: true });
+ *
+ * _NOTE: violating the constraint returns an `E11000` error from MongoDB when saving, not a Mongoose validation error._
+ *
+ * @param {Boolean} bool
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.unique = function(bool) {
+ if (this._index === false) {
+ if (!bool) {
+ return;
+ }
+ throw new Error('Path "' + this.path + '" may not have `index` set to ' +
+ 'false and `unique` set to true');
+ }
+ if (this._index == null || this._index === true) {
+ this._index = {};
+ } else if (typeof this._index === 'string') {
+ this._index = {type: this._index};
+ }
+
+ this._index.unique = bool;
+ return this;
+};
+
+/**
+ * Declares a full text index.
+ *
+ * ###Example:
+ *
+ * var s = new Schema({name : {type: String, text : true })
+ * Schema.path('name').index({text : true});
+ * @param {Boolean} bool
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.text = function(bool) {
+ if (this._index === null || this._index === undefined ||
+ typeof this._index === 'boolean') {
+ this._index = {};
+ } else if (typeof this._index === 'string') {
+ this._index = {type: this._index};
+ }
+
+ this._index.text = bool;
+ return this;
+};
+
+/**
+ * Declares a sparse index.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ name: { type: String, sparse: true })
+ * Schema.path('name').index({ sparse: true });
+ *
+ * @param {Boolean} bool
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.sparse = function(bool) {
+ if (this._index === null || this._index === undefined ||
+ typeof this._index === 'boolean') {
+ this._index = {};
+ } else if (typeof this._index === 'string') {
+ this._index = {type: this._index};
+ }
+
+ this._index.sparse = bool;
+ return this;
+};
+
+/**
+ * Adds a setter to this schematype.
+ *
+ * ####Example:
+ *
+ * function capitalize (val) {
+ * if (typeof val !== 'string') val = '';
+ * return val.charAt(0).toUpperCase() + val.substring(1);
+ * }
+ *
+ * // defining within the schema
+ * var s = new Schema({ name: { type: String, set: capitalize }})
+ *
+ * // or by retreiving its SchemaType
+ * var s = new Schema({ name: String })
+ * s.path('name').set(capitalize)
+ *
+ * Setters allow you to transform the data before it gets to the raw mongodb document and is set as a value on an actual key.
+ *
+ * Suppose you are implementing user registration for a website. Users provide an email and password, which gets saved to mongodb. The email is a string that you will want to normalize to lower case, in order to avoid one email having more than one account -- e.g., otherwise, avenue@q.com can be registered for 2 accounts via avenue@q.com and AvEnUe@Q.CoM.
+ *
+ * You can set up email lower case normalization easily via a Mongoose setter.
+ *
+ * function toLower (v) {
+ * return v.toLowerCase();
+ * }
+ *
+ * var UserSchema = new Schema({
+ * email: { type: String, set: toLower }
+ * })
+ *
+ * var User = db.model('User', UserSchema)
+ *
+ * var user = new User({email: 'AVENUE@Q.COM'})
+ * console.log(user.email); // 'avenue@q.com'
+ *
+ * // or
+ * var user = new User
+ * user.email = 'Avenue@Q.com'
+ * console.log(user.email) // 'avenue@q.com'
+ *
+ * As you can see above, setters allow you to transform the data before it gets to the raw mongodb document and is set as a value on an actual key.
+ *
+ * _NOTE: we could have also just used the built-in `lowercase: true` SchemaType option instead of defining our own function._
+ *
+ * new Schema({ email: { type: String, lowercase: true }})
+ *
+ * Setters are also passed a second argument, the schematype on which the setter was defined. This allows for tailored behavior based on options passed in the schema.
+ *
+ * function inspector (val, schematype) {
+ * if (schematype.options.required) {
+ * return schematype.path + ' is required';
+ * } else {
+ * return val;
+ * }
+ * }
+ *
+ * var VirusSchema = new Schema({
+ * name: { type: String, required: true, set: inspector },
+ * taxonomy: { type: String, set: inspector }
+ * })
+ *
+ * var Virus = db.model('Virus', VirusSchema);
+ * var v = new Virus({ name: 'Parvoviridae', taxonomy: 'Parvovirinae' });
+ *
+ * console.log(v.name); // name is required
+ * console.log(v.taxonomy); // Parvovirinae
+ *
+ * @param {Function} fn
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.set = function(fn) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('A setter must be a function.');
+ }
+ this.setters.push(fn);
+ return this;
+};
+
+/**
+ * Adds a getter to this schematype.
+ *
+ * ####Example:
+ *
+ * function dob (val) {
+ * if (!val) return val;
+ * return (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear();
+ * }
+ *
+ * // defining within the schema
+ * var s = new Schema({ born: { type: Date, get: dob })
+ *
+ * // or by retreiving its SchemaType
+ * var s = new Schema({ born: Date })
+ * s.path('born').get(dob)
+ *
+ * Getters allow you to transform the representation of the data as it travels from the raw mongodb document to the value that you see.
+ *
+ * Suppose you are storing credit card numbers and you want to hide everything except the last 4 digits to the mongoose user. You can do so by defining a getter in the following way:
+ *
+ * function obfuscate (cc) {
+ * return '****-****-****-' + cc.slice(cc.length-4, cc.length);
+ * }
+ *
+ * var AccountSchema = new Schema({
+ * creditCardNumber: { type: String, get: obfuscate }
+ * });
+ *
+ * var Account = db.model('Account', AccountSchema);
+ *
+ * Account.findById(id, function (err, found) {
+ * console.log(found.creditCardNumber); // '****-****-****-1234'
+ * });
+ *
+ * Getters are also passed a second argument, the schematype on which the getter was defined. This allows for tailored behavior based on options passed in the schema.
+ *
+ * function inspector (val, schematype) {
+ * if (schematype.options.required) {
+ * return schematype.path + ' is required';
+ * } else {
+ * return schematype.path + ' is not';
+ * }
+ * }
+ *
+ * var VirusSchema = new Schema({
+ * name: { type: String, required: true, get: inspector },
+ * taxonomy: { type: String, get: inspector }
+ * })
+ *
+ * var Virus = db.model('Virus', VirusSchema);
+ *
+ * Virus.findById(id, function (err, virus) {
+ * console.log(virus.name); // name is required
+ * console.log(virus.taxonomy); // taxonomy is not
+ * })
+ *
+ * @param {Function} fn
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.get = function(fn) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('A getter must be a function.');
+ }
+ this.getters.push(fn);
+ return this;
+};
+
+/**
+ * Adds validator(s) for this document path.
+ *
+ * Validators always receive the value to validate as their first argument and must return `Boolean`. Returning `false` means validation failed.
+ *
+ * The error message argument is optional. If not passed, the [default generic error message template](#error_messages_MongooseError-messages) will be used.
+ *
+ * ####Examples:
+ *
+ * // make sure every value is equal to "something"
+ * function validator (val) {
+ * return val == 'something';
+ * }
+ * new Schema({ name: { type: String, validate: validator }});
+ *
+ * // with a custom error message
+ *
+ * var custom = [validator, 'Uh oh, {PATH} does not equal "something".']
+ * new Schema({ name: { type: String, validate: custom }});
+ *
+ * // adding many validators at a time
+ *
+ * var many = [
+ * { validator: validator, msg: 'uh oh' }
+ * , { validator: anotherValidator, msg: 'failed' }
+ * ]
+ * new Schema({ name: { type: String, validate: many }});
+ *
+ * // or utilizing SchemaType methods directly:
+ *
+ * var schema = new Schema({ name: 'string' });
+ * schema.path('name').validate(validator, 'validation of `{PATH}` failed with value `{VALUE}`');
+ *
+ * ####Error message templates:
+ *
+ * From the examples above, you may have noticed that error messages support basic templating. There are a few other template keywords besides `{PATH}` and `{VALUE}` too. To find out more, details are available [here](#error_messages_MongooseError.messages)
+ *
+ * ####Asynchronous validation:
+ *
+ * Passing a validator function that receives two arguments tells mongoose that the validator is an asynchronous validator. The first argument passed to the validator function is the value being validated. The second argument is a callback function that must called when you finish validating the value and passed either `true` or `false` to communicate either success or failure respectively.
+ *
+ * schema.path('name').validate(function (value, respond) {
+ * doStuff(value, function () {
+ * ...
+ * respond(false); // validation failed
+ * })
+ * }, '{PATH} failed validation.');
+ *
+ * // or with dynamic message
+ *
+ * schema.path('name').validate(function (value, respond) {
+ * doStuff(value, function () {
+ * ...
+ * respond(false, 'this message gets to the validation error');
+ * });
+ * }, 'this message does not matter');
+ *
+ * You might use asynchronous validators to retreive other documents from the database to validate against or to meet other I/O bound validation needs.
+ *
+ * Validation occurs `pre('save')` or whenever you manually execute [document#validate](#document_Document-validate).
+ *
+ * If validation fails during `pre('save')` and no callback was passed to receive the error, an `error` event will be emitted on your Models associated db [connection](#connection_Connection), passing the validation error object along.
+ *
+ * var conn = mongoose.createConnection(..);
+ * conn.on('error', handleError);
+ *
+ * var Product = conn.model('Product', yourSchema);
+ * var dvd = new Product(..);
+ * dvd.save(); // emits error on the `conn` above
+ *
+ * If you desire handling these errors at the Model level, attach an `error` listener to your Model and the event will instead be emitted there.
+ *
+ * // registering an error listener on the Model lets us handle errors more locally
+ * Product.on('error', handleError);
+ *
+ * @param {RegExp|Function|Object} obj validator
+ * @param {String} [errorMsg] optional error message
+ * @param {String} [type] optional validator type
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.validate = function(obj, message, type) {
+ if (typeof obj === 'function' || obj && utils.getFunctionName(obj.constructor) === 'RegExp') {
+ var properties;
+ if (message instanceof Object && !type) {
+ properties = utils.clone(message);
+ if (!properties.message) {
+ properties.message = properties.msg;
+ }
+ properties.validator = obj;
+ properties.type = properties.type || 'user defined';
+ } else {
+ if (!message) {
+ message = MongooseError.messages.general.default;
+ }
+ if (!type) {
+ type = 'user defined';
+ }
+ properties = {message: message, type: type, validator: obj};
+ }
+ this.validators.push(properties);
+ return this;
+ }
+
+ var i,
+ length,
+ arg;
+
+ for (i = 0, length = arguments.length; i < length; i++) {
+ arg = arguments[i];
+ if (!(arg && utils.getFunctionName(arg.constructor) === 'Object')) {
+ var msg = 'Invalid validator. Received (' + typeof arg + ') '
+ + arg
+ + '. See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate';
+
+ throw new Error(msg);
+ }
+ this.validate(arg.validator, arg);
+ }
+
+ return this;
+};
+
+/**
+ * Adds a required validator to this SchemaType. The validator gets added
+ * to the front of this SchemaType's validators array using `unshift()`.
+ *
+ * ####Example:
+ *
+ * var s = new Schema({ born: { type: Date, required: true })
+ *
+ * // or with custom error message
+ *
+ * var s = new Schema({ born: { type: Date, required: '{PATH} is required!' })
+ *
+ * // or through the path API
+ *
+ * Schema.path('name').required(true);
+ *
+ * // with custom error messaging
+ *
+ * Schema.path('name').required(true, 'grrr :( ');
+ *
+ * // or make a path conditionally required based on a function
+ * var isOver18 = function() { return this.age >= 18; };
+ * Schema.path('voterRegistrationId').required(isOver18);
+ *
+ * The required validator uses the SchemaType's `checkRequired` function to
+ * determine whether a given value satisfies the required validator. By default,
+ * a value satisfies the required validator if `val != null` (that is, if
+ * the value is not null nor undefined). However, most built-in mongoose schema
+ * types override the default `checkRequired` function:
+ *
+ * @param {Boolean} required enable/disable the validator
+ * @param {String} [message] optional custom error message
+ * @return {SchemaType} this
+ * @see Customized Error Messages #error_messages_MongooseError-messages
+ * @see SchemaArray#checkRequired #schema_array_SchemaArray.checkRequired
+ * @see SchemaBoolean#checkRequired #schema_boolean_SchemaBoolean-checkRequired
+ * @see SchemaBuffer#checkRequired #schema_buffer_SchemaBuffer.schemaName
+ * @see SchemaNumber#checkRequired #schema_number_SchemaNumber-min
+ * @see SchemaObjectId#checkRequired #schema_objectid_ObjectId-auto
+ * @see SchemaString#checkRequired #schema_string_SchemaString-checkRequired
+ * @api public
+ */
+
+SchemaType.prototype.required = function(required, message) {
+ if (required === false) {
+ this.validators = this.validators.filter(function(v) {
+ return v.validator !== this.requiredValidator;
+ }, this);
+
+ this.isRequired = false;
+ return this;
+ }
+
+ var _this = this;
+ this.isRequired = true;
+
+ this.requiredValidator = function(v) {
+ // in here, `this` refers to the validating document.
+ // no validation when this path wasn't selected in the query.
+ if ('isSelected' in this && !this.isSelected(_this.path) && !this.isModified(_this.path)) {
+ return true;
+ }
+
+ return ((typeof required === 'function') && !required.apply(this)) ||
+ _this.checkRequired(v, this);
+ };
+ this.originalRequiredValue = required;
+
+ if (typeof required === 'string') {
+ message = required;
+ required = undefined;
+ }
+
+ var msg = message || MongooseError.messages.general.required;
+ this.validators.unshift({
+ validator: this.requiredValidator,
+ message: msg,
+ type: 'required'
+ });
+
+ return this;
+};
+
+/**
+ * Gets the default value
+ *
+ * @param {Object} scope the scope which callback are executed
+ * @param {Boolean} init
+ * @api private
+ */
+
+SchemaType.prototype.getDefault = function(scope, init) {
+ var ret = typeof this.defaultValue === 'function'
+ ? this.defaultValue.call(scope)
+ : this.defaultValue;
+
+ if (ret !== null && ret !== undefined) {
+ var casted = this.cast(ret, scope, init);
+ if (casted && casted.$isSingleNested) {
+ casted.$parent = scope;
+ }
+ return casted;
+ }
+ return ret;
+};
+
+/**
+ * Applies setters
+ *
+ * @param {Object} value
+ * @param {Object} scope
+ * @param {Boolean} init
+ * @api private
+ */
+
+SchemaType.prototype.applySetters = function(value, scope, init, priorVal, options) {
+ var v = value,
+ setters = this.setters,
+ len = setters.length,
+ caster = this.caster;
+
+ while (len--) {
+ v = setters[len].call(scope, v, this);
+ }
+
+ if (Array.isArray(v) && caster && caster.setters) {
+ var newVal = [];
+ for (var i = 0; i < v.length; i++) {
+ newVal.push(caster.applySetters(v[i], scope, init, priorVal));
+ }
+ v = newVal;
+ }
+
+ if (v === null || v === undefined) {
+ return v;
+ }
+
+ // do not cast until all setters are applied #665
+ v = this.cast(v, scope, init, priorVal, options);
+
+ return v;
+};
+
+/**
+ * Applies getters to a value
+ *
+ * @param {Object} value
+ * @param {Object} scope
+ * @api private
+ */
+
+SchemaType.prototype.applyGetters = function(value, scope) {
+ var v = value,
+ getters = this.getters,
+ len = getters.length;
+
+ if (!len) {
+ return v;
+ }
+
+ while (len--) {
+ v = getters[len].call(scope, v, this);
+ }
+
+ return v;
+};
+
+/**
+ * Sets default `select()` behavior for this path.
+ *
+ * Set to `true` if this path should always be included in the results, `false` if it should be excluded by default. This setting can be overridden at the query level.
+ *
+ * ####Example:
+ *
+ * T = db.model('T', new Schema({ x: { type: String, select: true }}));
+ * T.find(..); // field x will always be selected ..
+ * // .. unless overridden;
+ * T.find().select('-x').exec(callback);
+ *
+ * @param {Boolean} val
+ * @return {SchemaType} this
+ * @api public
+ */
+
+SchemaType.prototype.select = function select(val) {
+ this.selected = !!val;
+ return this;
+};
+
+/**
+ * Performs a validation of `value` using the validators declared for this SchemaType.
+ *
+ * @param {any} value
+ * @param {Function} callback
+ * @param {Object} scope
+ * @api private
+ */
+
+SchemaType.prototype.doValidate = function(value, fn, scope) {
+ var err = false,
+ path = this.path,
+ count = this.validators.length;
+
+ if (!count) {
+ return fn(null);
+ }
+
+ var validate = function(ok, validatorProperties) {
+ if (err) {
+ return;
+ }
+ if (ok === undefined || ok) {
+ --count || fn(null);
+ } else {
+ err = new ValidatorError(validatorProperties);
+ fn(err);
+ }
+ };
+
+ var _this = this;
+ this.validators.forEach(function(v) {
+ if (err) {
+ return;
+ }
+
+ var validator = v.validator;
+
+ var validatorProperties = utils.clone(v);
+ validatorProperties.path = path;
+ validatorProperties.value = value;
+
+ if (validator instanceof RegExp) {
+ validate(validator.test(value), validatorProperties);
+ } else if (typeof validator === 'function') {
+ if (value === undefined && !_this.isRequired) {
+ validate(true, validatorProperties);
+ return;
+ }
+ if (validator.length === 2) {
+ var returnVal = validator.call(scope, value, function(ok, customMsg) {
+ if (typeof returnVal === 'boolean') {
+ return;
+ }
+ if (customMsg) {
+ validatorProperties.message = customMsg;
+ }
+ validate(ok, validatorProperties);
+ });
+ if (typeof returnVal === 'boolean') {
+ validate(returnVal, validatorProperties);
+ }
+ } else {
+ validate(validator.call(scope, value), validatorProperties);
+ }
+ }
+ });
+};
+
+/**
+ * Performs a validation of `value` using the validators declared for this SchemaType.
+ *
+ * ####Note:
+ *
+ * This method ignores the asynchronous validators.
+ *
+ * @param {any} value
+ * @param {Object} scope
+ * @return {MongooseError|undefined}
+ * @api private
+ */
+
+SchemaType.prototype.doValidateSync = function(value, scope) {
+ var err = null,
+ path = this.path,
+ count = this.validators.length;
+
+ if (!count) {
+ return null;
+ }
+
+ var validate = function(ok, validatorProperties) {
+ if (err) {
+ return;
+ }
+ if (ok !== undefined && !ok) {
+ err = new ValidatorError(validatorProperties);
+ }
+ };
+
+ var validators = this.validators;
+ if (value === void 0) {
+ if (this.validators.length > 0 && this.validators[0].type === 'required') {
+ validators = [this.validators[0]];
+ } else {
+ return null;
+ }
+ }
+
+ validators.forEach(function(v) {
+ if (err) {
+ return;
+ }
+
+ var validator = v.validator;
+ var validatorProperties = utils.clone(v);
+ validatorProperties.path = path;
+ validatorProperties.value = value;
+
+ if (validator instanceof RegExp) {
+ validate(validator.test(value), validatorProperties);
+ } else if (typeof validator === 'function') {
+ // if not async validators
+ if (validator.length !== 2) {
+ validate(validator.call(scope, value), validatorProperties);
+ }
+ }
+ });
+
+ return err;
+};
+
+/**
+ * Determines if value is a valid Reference.
+ *
+ * @param {SchemaType} self
+ * @param {Object} value
+ * @param {Document} doc
+ * @param {Boolean} init
+ * @return {Boolean}
+ * @api private
+ */
+
+SchemaType._isRef = function(self, value, doc, init) {
+ // fast path
+ var ref = init && self.options && self.options.ref;
+
+ if (!ref && doc && doc.$__fullPath) {
+ // checks for
+ // - this populated with adhoc model and no ref was set in schema OR
+ // - setting / pushing values after population
+ var path = doc.$__fullPath(self.path);
+ var owner = doc.ownerDocument ? doc.ownerDocument() : doc;
+ ref = owner.populated(path);
+ }
+
+ if (ref) {
+ if (value == null) {
+ return true;
+ }
+ if (!Buffer.isBuffer(value) && // buffers are objects too
+ value._bsontype !== 'Binary' // raw binary value from the db
+ && utils.isObject(value) // might have deselected _id in population query
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+};
+
+/*!
+ * ignore
+ */
+
+function handleSingle(val) {
+ return this.castForQuery(val);
+}
+
+/*!
+ * ignore
+ */
+
+function handleArray(val) {
+ var _this = this;
+ if (!Array.isArray(val)) {
+ return [this.castForQuery(val)];
+ }
+ return val.map(function(m) {
+ return _this.castForQuery(m);
+ });
+}
+
+/*!
+ * ignore
+ */
+
+SchemaType.prototype.$conditionalHandlers = {
+ $all: handleArray,
+ $eq: handleSingle,
+ $in: handleArray,
+ $ne: handleSingle,
+ $nin: handleArray,
+ $type: function(val) {
+ if (typeof val !== 'number' && typeof val !== 'string') {
+ throw new Error('$type parameter must be number or string');
+ }
+
+ return val;
+ }
+};
+
+/**
+ * Cast the given value with the given optional query operator.
+ *
+ * @param {String} [$conditional] query operator, like `$eq` or `$in`
+ * @param {any} val
+ * @api private
+ */
+
+SchemaType.prototype.castForQuery = function($conditional, val) {
+ var handler;
+ if (arguments.length === 2) {
+ handler = this.$conditionalHandlers[$conditional];
+ if (!handler) {
+ throw new Error('Can\'t use ' + $conditional);
+ }
+ return handler.call(this, val);
+ }
+ val = $conditional;
+ return this.cast(val);
+};
+
+/**
+ * Default check for if this path satisfies the `required` validator.
+ *
+ * @param {any} val
+ * @api private
+ */
+
+SchemaType.prototype.checkRequired = function(val) {
+ return val != null;
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = SchemaType;
+
+exports.CastError = CastError;
+
+exports.ValidatorError = ValidatorError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/common.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/common.js
new file mode 100644
index 0000000..d125987
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/common.js
@@ -0,0 +1,87 @@
+'use strict';
+
+/*!
+ * Module dependencies.
+ */
+
+var ObjectId = require('../types/objectid');
+var utils = require('../utils');
+
+exports.flatten = flatten;
+exports.modifiedPaths = modifiedPaths;
+
+/*!
+ * ignore
+ */
+
+function flatten(update, path, options) {
+ var keys;
+ if (update && utils.isMongooseObject(update) && !Buffer.isBuffer(update)) {
+ keys = Object.keys(update.toObject({ transform: false }));
+ } else {
+ keys = Object.keys(update || {});
+ }
+
+ var numKeys = keys.length;
+ var result = {};
+ path = path ? path + '.' : '';
+
+ for (var i = 0; i < numKeys; ++i) {
+ var key = keys[i];
+ var val = update[key];
+ result[path + key] = val;
+ if (shouldFlatten(val)) {
+ if (options && options.skipArrays && Array.isArray(val)) {
+ continue;
+ }
+ var flat = flatten(val, path + key);
+ for (var k in flat) {
+ result[k] = flat[k];
+ }
+ if (Array.isArray(val)) {
+ result[path + key] = val;
+ }
+ }
+ }
+
+ return result;
+}
+
+/*!
+ * ignore
+ */
+
+function modifiedPaths(update, path, result) {
+ var keys = Object.keys(update || {});
+ var numKeys = keys.length;
+ result = result || {};
+ path = path ? path + '.' : '';
+
+ for (var i = 0; i < numKeys; ++i) {
+ var key = keys[i];
+ var val = update[key];
+
+ result[path + key] = true;
+ if (utils.isMongooseObject(val) && !Buffer.isBuffer(val)) {
+ val = val.toObject({ transform: false });
+ }
+ if (shouldFlatten(val)) {
+ modifiedPaths(val, path + key, result);
+ }
+ }
+
+ return result;
+}
+
+/*!
+ * ignore
+ */
+
+function shouldFlatten(val) {
+ return val &&
+ typeof val === 'object' &&
+ !(val instanceof Date) &&
+ !(val instanceof ObjectId) &&
+ (!Array.isArray(val) || val.length > 0) &&
+ !(val instanceof Buffer);
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/setDefaultsOnInsert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/setDefaultsOnInsert.js
new file mode 100644
index 0000000..36b87d7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/setDefaultsOnInsert.js
@@ -0,0 +1,96 @@
+'use strict';
+
+var modifiedPaths = require('./common').modifiedPaths;
+
+/**
+ * Applies defaults to update and findOneAndUpdate operations.
+ *
+ * @param {Query} query
+ * @param {Schema} schema
+ * @param {Object} castedDoc
+ * @param {Object} options
+ * @method setDefaultsOnInsert
+ * @api private
+ */
+
+module.exports = function(query, schema, castedDoc, options) {
+ var keys = Object.keys(castedDoc || {});
+ var updatedKeys = {};
+ var updatedValues = {};
+ var numKeys = keys.length;
+ var hasDollarUpdate = false;
+ var modified = {};
+
+ if (options && options.upsert) {
+ for (var i = 0; i < numKeys; ++i) {
+ if (keys[i].charAt(0) === '$') {
+ modifiedPaths(castedDoc[keys[i]], '', modified);
+ hasDollarUpdate = true;
+ }
+ }
+
+ if (!hasDollarUpdate) {
+ modifiedPaths(castedDoc, '', modified);
+ }
+
+ var paths = Object.keys(query._conditions);
+ var numPaths = keys.length;
+ for (i = 0; i < numPaths; ++i) {
+ var path = paths[i];
+ var condition = query._conditions[path];
+ if (condition && typeof condition === 'object') {
+ var conditionKeys = Object.keys(condition);
+ var numConditionKeys = conditionKeys.length;
+ var hasDollarKey = false;
+ for (var j = 0; j < numConditionKeys; ++j) {
+ if (conditionKeys[j].charAt(0) === '$') {
+ hasDollarKey = true;
+ break;
+ }
+ }
+ if (hasDollarKey) {
+ continue;
+ }
+ }
+ updatedKeys[path] = true;
+ modified[path] = true;
+ }
+
+ if (options.setDefaultsOnInsert) {
+ schema.eachPath(function(path, schemaType) {
+ if (path === '_id') {
+ // Ignore _id for now because it causes bugs in 2.4
+ return;
+ }
+ if (schemaType.$isSingleNested) {
+ // Only handle nested schemas 1-level deep to avoid infinite
+ // recursion re: https://github.com/mongodb-js/mongoose-autopopulate/issues/11
+ schemaType.schema.eachPath(function(_path, _schemaType) {
+ if (path === '_id') {
+ // Ignore _id for now because it causes bugs in 2.4
+ return;
+ }
+
+ var def = _schemaType.getDefault(null, true);
+ if (!modified[path + '.' + _path] && typeof def !== 'undefined') {
+ castedDoc = castedDoc || {};
+ castedDoc.$setOnInsert = castedDoc.$setOnInsert || {};
+ castedDoc.$setOnInsert[path + '.' + _path] = def;
+ updatedValues[path + '.' + _path] = def;
+ }
+ });
+ } else {
+ var def = schemaType.getDefault(null, true);
+ if (!modified[path] && typeof def !== 'undefined') {
+ castedDoc = castedDoc || {};
+ castedDoc.$setOnInsert = castedDoc.$setOnInsert || {};
+ castedDoc.$setOnInsert[path] = def;
+ updatedValues[path] = def;
+ }
+ }
+ });
+ }
+ }
+
+ return castedDoc;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/updateValidators.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/updateValidators.js
new file mode 100644
index 0000000..162ea73
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/services/updateValidators.js
@@ -0,0 +1,100 @@
+/*!
+ * Module dependencies.
+ */
+
+var Mixed = require('../schema/mixed');
+var ValidationError = require('../error/validation');
+var parallel = require('async/parallel');
+var flatten = require('./common').flatten;
+var modifiedPaths = require('./common').modifiedPaths;
+
+/**
+ * Applies validators and defaults to update and findOneAndUpdate operations,
+ * specifically passing a null doc as `this` to validators and defaults
+ *
+ * @param {Query} query
+ * @param {Schema} schema
+ * @param {Object} castedDoc
+ * @param {Object} options
+ * @method runValidatorsOnUpdate
+ * @api private
+ */
+
+module.exports = function(query, schema, castedDoc, options) {
+ var keys = Object.keys(castedDoc || {});
+ var updatedKeys = {};
+ var updatedValues = {};
+ var numKeys = keys.length;
+ var hasDollarUpdate = false;
+ var modified = {};
+
+ for (var i = 0; i < numKeys; ++i) {
+ if (keys[i].charAt(0) === '$') {
+ modifiedPaths(castedDoc[keys[i]], '', modified);
+ var flat = flatten(castedDoc[keys[i]]);
+ var paths = Object.keys(flat);
+ var numPaths = paths.length;
+ for (var j = 0; j < numPaths; ++j) {
+ var updatedPath = paths[j].replace('.$.', '.0.');
+ updatedPath = updatedPath.replace(/\.\$$/, '.0');
+ if (keys[i] === '$set' || keys[i] === '$setOnInsert') {
+ updatedValues[updatedPath] = flat[paths[j]];
+ } else if (keys[i] === '$unset') {
+ updatedValues[updatedPath] = undefined;
+ }
+ updatedKeys[updatedPath] = true;
+ }
+ hasDollarUpdate = true;
+ }
+ }
+
+ if (!hasDollarUpdate) {
+ modifiedPaths(castedDoc, '', modified);
+ updatedValues = flatten(castedDoc);
+ updatedKeys = Object.keys(updatedValues);
+ }
+
+ var updates = Object.keys(updatedValues);
+ var numUpdates = updates.length;
+ var validatorsToExecute = [];
+ var validationErrors = [];
+ function iter(i) {
+ var schemaPath = schema._getSchema(updates[i]);
+ if (schemaPath) {
+ // gh-4305: `_getSchema()` will report all sub-fields of a 'Mixed' path
+ // as 'Mixed', so avoid double validating them.
+ if (schemaPath instanceof Mixed && schemaPath.$fullPath !== updates[i]) {
+ return;
+ }
+ validatorsToExecute.push(function(callback) {
+ schemaPath.doValidate(
+ updatedValues[updates[i]],
+ function(err) {
+ if (err) {
+ err.path = updates[i];
+ validationErrors.push(err);
+ }
+ callback(null);
+ },
+ options && options.context === 'query' ? query : null,
+ {updateValidator: true});
+ });
+ }
+ }
+ for (i = 0; i < numUpdates; ++i) {
+ iter(i);
+ }
+
+ return function(callback) {
+ parallel(validatorsToExecute, function() {
+ if (validationErrors.length) {
+ var err = new ValidationError(null);
+ for (var i = 0; i < validationErrors.length; ++i) {
+ err.errors[validationErrors[i].path] = validationErrors[i];
+ }
+ return callback(err);
+ }
+ callback(null);
+ });
+ };
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/statemachine.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/statemachine.js
new file mode 100644
index 0000000..3bba519
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/statemachine.js
@@ -0,0 +1,178 @@
+
+/*!
+ * Module dependencies.
+ */
+
+var utils = require('./utils');
+
+/*!
+ * StateMachine represents a minimal `interface` for the
+ * constructors it builds via StateMachine.ctor(...).
+ *
+ * @api private
+ */
+
+var StateMachine = module.exports = exports = function StateMachine() {
+};
+
+/*!
+ * StateMachine.ctor('state1', 'state2', ...)
+ * A factory method for subclassing StateMachine.
+ * The arguments are a list of states. For each state,
+ * the constructor's prototype gets state transition
+ * methods named after each state. These transition methods
+ * place their path argument into the given state.
+ *
+ * @param {String} state
+ * @param {String} [state]
+ * @return {Function} subclass constructor
+ * @private
+ */
+
+StateMachine.ctor = function() {
+ var states = utils.args(arguments);
+
+ var ctor = function() {
+ StateMachine.apply(this, arguments);
+ this.paths = {};
+ this.states = {};
+ this.stateNames = states;
+
+ var i = states.length,
+ state;
+
+ while (i--) {
+ state = states[i];
+ this.states[state] = {};
+ }
+ };
+
+ ctor.prototype = new StateMachine();
+
+ states.forEach(function(state) {
+ // Changes the `path`'s state to `state`.
+ ctor.prototype[state] = function(path) {
+ this._changeState(path, state);
+ };
+ });
+
+ return ctor;
+};
+
+/*!
+ * This function is wrapped by the state change functions:
+ *
+ * - `require(path)`
+ * - `modify(path)`
+ * - `init(path)`
+ *
+ * @api private
+ */
+
+StateMachine.prototype._changeState = function _changeState(path, nextState) {
+ var prevBucket = this.states[this.paths[path]];
+ if (prevBucket) delete prevBucket[path];
+
+ this.paths[path] = nextState;
+ this.states[nextState][path] = true;
+};
+
+/*!
+ * ignore
+ */
+
+StateMachine.prototype.clear = function clear(state) {
+ var keys = Object.keys(this.states[state]),
+ i = keys.length,
+ path;
+
+ while (i--) {
+ path = keys[i];
+ delete this.states[state][path];
+ delete this.paths[path];
+ }
+};
+
+/*!
+ * Checks to see if at least one path is in the states passed in via `arguments`
+ * e.g., this.some('required', 'inited')
+ *
+ * @param {String} state that we want to check for.
+ * @private
+ */
+
+StateMachine.prototype.some = function some() {
+ var _this = this;
+ var what = arguments.length ? arguments : this.stateNames;
+ return Array.prototype.some.call(what, function(state) {
+ return Object.keys(_this.states[state]).length;
+ });
+};
+
+/*!
+ * This function builds the functions that get assigned to `forEach` and `map`,
+ * since both of those methods share a lot of the same logic.
+ *
+ * @param {String} iterMethod is either 'forEach' or 'map'
+ * @return {Function}
+ * @api private
+ */
+
+StateMachine.prototype._iter = function _iter(iterMethod) {
+ return function() {
+ var numArgs = arguments.length,
+ states = utils.args(arguments, 0, numArgs - 1),
+ callback = arguments[numArgs - 1];
+
+ if (!states.length) states = this.stateNames;
+
+ var _this = this;
+
+ var paths = states.reduce(function(paths, state) {
+ return paths.concat(Object.keys(_this.states[state]));
+ }, []);
+
+ return paths[iterMethod](function(path, i, paths) {
+ return callback(path, i, paths);
+ });
+ };
+};
+
+/*!
+ * Iterates over the paths that belong to one of the parameter states.
+ *
+ * The function profile can look like:
+ * this.forEach(state1, fn); // iterates over all paths in state1
+ * this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2
+ * this.forEach(fn); // iterates over all paths in all states
+ *
+ * @param {String} [state]
+ * @param {String} [state]
+ * @param {Function} callback
+ * @private
+ */
+
+StateMachine.prototype.forEach = function forEach() {
+ this.forEach = this._iter('forEach');
+ return this.forEach.apply(this, arguments);
+};
+
+/*!
+ * Maps over the paths that belong to one of the parameter states.
+ *
+ * The function profile can look like:
+ * this.forEach(state1, fn); // iterates over all paths in state1
+ * this.forEach(state1, state2, fn); // iterates over all paths in state1 or state2
+ * this.forEach(fn); // iterates over all paths in all states
+ *
+ * @param {String} [state]
+ * @param {String} [state]
+ * @param {Function} callback
+ * @return {Array}
+ * @private
+ */
+
+StateMachine.prototype.map = function map() {
+ this.map = this._iter('map');
+ return this.map.apply(this, arguments);
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/array.js
new file mode 100644
index 0000000..715b6b6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/array.js
@@ -0,0 +1,778 @@
+/*!
+ * Module dependencies.
+ */
+
+var EmbeddedDocument = require('./embedded');
+var Document = require('../document');
+var ObjectId = require('./objectid');
+var utils = require('../utils');
+var isMongooseObject = utils.isMongooseObject;
+
+/**
+ * Mongoose Array constructor.
+ *
+ * ####NOTE:
+ *
+ * _Values always have to be passed to the constructor to initialize, otherwise `MongooseArray#push` will mark the array as modified._
+ *
+ * @param {Array} values
+ * @param {String} path
+ * @param {Document} doc parent document
+ * @api private
+ * @inherits Array
+ * @see http://bit.ly/f6CnZU
+ */
+
+function MongooseArray(values, path, doc) {
+ var arr = [].concat(values);
+
+ var keysMA = Object.keys(MongooseArray.mixin);
+ var numKeys = keysMA.length;
+ for (var i = 0; i < numKeys; ++i) {
+ arr[keysMA[i]] = MongooseArray.mixin[keysMA[i]];
+ }
+
+ arr._path = path;
+ arr.isMongooseArray = true;
+ arr.validators = [];
+ arr._atomics = {};
+ arr._schema = void 0;
+
+ // Because doc comes from the context of another function, doc === global
+ // can happen if there was a null somewhere up the chain (see #3020)
+ // RB Jun 17, 2015 updated to check for presence of expected paths instead
+ // to make more proof against unusual node environments
+ if (doc && doc instanceof Document) {
+ arr._parent = doc;
+ arr._schema = doc.schema.path(path);
+ }
+
+ return arr;
+}
+
+MongooseArray.mixin = {
+ /*!
+ * ignore
+ */
+ toBSON: function() {
+ return this.toObject({ transform: false });
+ },
+
+ /**
+ * Stores a queue of atomic operations to perform
+ *
+ * @property _atomics
+ * @api private
+ */
+
+ _atomics: undefined,
+
+ /**
+ * Parent owner document
+ *
+ * @property _parent
+ * @api private
+ * @receiver MongooseArray
+ */
+
+ _parent: undefined,
+
+ /**
+ * Casts a member based on this arrays schema.
+ *
+ * @param {any} value
+ * @return value the casted value
+ * @method _cast
+ * @api private
+ * @receiver MongooseArray
+ */
+
+ _cast: function(value) {
+ var populated = false;
+ var Model;
+
+ if (this._parent) {
+ populated = this._parent.populated(this._path, true);
+ }
+
+ if (populated && value !== null && value !== undefined) {
+ // cast to the populated Models schema
+ Model = populated.options.model;
+
+ // only objects are permitted so we can safely assume that
+ // non-objects are to be interpreted as _id
+ if (Buffer.isBuffer(value) ||
+ value instanceof ObjectId || !utils.isObject(value)) {
+ value = {_id: value};
+ }
+
+ // gh-2399
+ // we should cast model only when it's not a discriminator
+ var isDisc = value.schema && value.schema.discriminatorMapping &&
+ value.schema.discriminatorMapping.key !== undefined;
+ if (!isDisc) {
+ value = new Model(value);
+ }
+ return this._schema.caster.cast(value, this._parent, true);
+ }
+
+ return this._schema.caster.cast(value, this._parent, false);
+ },
+
+ /**
+ * Marks this array as modified.
+ *
+ * If it bubbles up from an embedded document change, then it takes the following arguments (otherwise, takes 0 arguments)
+ *
+ * @param {EmbeddedDocument} embeddedDoc the embedded doc that invoked this method on the Array
+ * @param {String} embeddedPath the path which changed in the embeddedDoc
+ * @method _markModified
+ * @api private
+ * @receiver MongooseArray
+ */
+
+ _markModified: function(elem, embeddedPath) {
+ var parent = this._parent,
+ dirtyPath;
+
+ if (parent) {
+ dirtyPath = this._path;
+
+ if (arguments.length) {
+ if (embeddedPath != null) {
+ // an embedded doc bubbled up the change
+ dirtyPath = dirtyPath + '.' + this.indexOf(elem) + '.' + embeddedPath;
+ } else {
+ // directly set an index
+ dirtyPath = dirtyPath + '.' + elem;
+ }
+ }
+
+ parent.markModified(dirtyPath);
+ }
+
+ return this;
+ },
+
+ /**
+ * Register an atomic operation with the parent.
+ *
+ * @param {Array} op operation
+ * @param {any} val
+ * @method _registerAtomic
+ * @api private
+ * @receiver MongooseArray
+ */
+
+ _registerAtomic: function(op, val) {
+ if (op === '$set') {
+ // $set takes precedence over all other ops.
+ // mark entire array modified.
+ this._atomics = {$set: val};
+ return this;
+ }
+
+ var atomics = this._atomics;
+
+ // reset pop/shift after save
+ if (op === '$pop' && !('$pop' in atomics)) {
+ var _this = this;
+ this._parent.once('save', function() {
+ _this._popped = _this._shifted = null;
+ });
+ }
+
+ // check for impossible $atomic combos (Mongo denies more than one
+ // $atomic op on a single path
+ if (this._atomics.$set ||
+ Object.keys(atomics).length && !(op in atomics)) {
+ // a different op was previously registered.
+ // save the entire thing.
+ this._atomics = {$set: this};
+ return this;
+ }
+
+ var selector;
+
+ if (op === '$pullAll' || op === '$pushAll' || op === '$addToSet') {
+ atomics[op] || (atomics[op] = []);
+ atomics[op] = atomics[op].concat(val);
+ } else if (op === '$pullDocs') {
+ var pullOp = atomics['$pull'] || (atomics['$pull'] = {});
+ if (val[0] instanceof EmbeddedDocument) {
+ selector = pullOp['$or'] || (pullOp['$or'] = []);
+ Array.prototype.push.apply(selector, val.map(function(v) {
+ return v.toObject({transform: false});
+ }));
+ } else {
+ selector = pullOp['_id'] || (pullOp['_id'] = {$in: []});
+ selector['$in'] = selector['$in'].concat(val);
+ }
+ } else {
+ atomics[op] = val;
+ }
+
+ return this;
+ },
+
+ /**
+ * Depopulates stored atomic operation values as necessary for direct insertion to MongoDB.
+ *
+ * If no atomics exist, we return all array values after conversion.
+ *
+ * @return {Array}
+ * @method $__getAtomics
+ * @memberOf MongooseArray
+ * @api private
+ */
+
+ $__getAtomics: function() {
+ var ret = [];
+ var keys = Object.keys(this._atomics);
+ var i = keys.length;
+
+ if (i === 0) {
+ ret[0] = ['$set', this.toObject({depopulate: 1, transform: false, _isNested: true})];
+ return ret;
+ }
+
+ while (i--) {
+ var op = keys[i];
+ var val = this._atomics[op];
+
+ // the atomic values which are arrays are not MongooseArrays. we
+ // need to convert their elements as if they were MongooseArrays
+ // to handle populated arrays versus DocumentArrays properly.
+ if (isMongooseObject(val)) {
+ val = val.toObject({depopulate: 1, transform: false, _isNested: true});
+ } else if (Array.isArray(val)) {
+ val = this.toObject.call(val, {depopulate: 1, transform: false, _isNested: true});
+ } else if (val.valueOf) {
+ val = val.valueOf();
+ }
+
+ if (op === '$addToSet') {
+ val = {$each: val};
+ }
+
+ ret.push([op, val]);
+ }
+
+ return ret;
+ },
+
+ /**
+ * Returns the number of pending atomic operations to send to the db for this array.
+ *
+ * @api private
+ * @return {Number}
+ * @method hasAtomics
+ * @receiver MongooseArray
+ */
+
+ hasAtomics: function hasAtomics() {
+ if (!(this._atomics && this._atomics.constructor.name === 'Object')) {
+ return 0;
+ }
+
+ return Object.keys(this._atomics).length;
+ },
+
+ /**
+ * Internal helper for .map()
+ *
+ * @api private
+ * @return {Number}
+ * @method _mapCast
+ * @receiver MongooseArray
+ */
+ _mapCast: function(val, index) {
+ return this._cast(val, this.length + index);
+ },
+
+ /**
+ * Wraps [`Array#push`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/push) with proper change tracking.
+ *
+ * @param {Object} [args...]
+ * @api public
+ * @method push
+ * @receiver MongooseArray
+ */
+
+ push: function() {
+ var values = [].map.call(arguments, this._mapCast, this);
+ values = this._schema.applySetters(values, this._parent, undefined,
+ undefined, {skipDocumentArrayCast: true});
+ var ret = [].push.apply(this, values);
+
+ // $pushAll might be fibbed (could be $push). But it makes it easier to
+ // handle what could have been $push, $pushAll combos
+ this._registerAtomic('$pushAll', values);
+ this._markModified();
+ return ret;
+ },
+
+ /**
+ * Pushes items to the array non-atomically.
+ *
+ * ####NOTE:
+ *
+ * _marks the entire array as modified, which if saved, will store it as a `$set` operation, potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @param {any} [args...]
+ * @api public
+ * @method nonAtomicPush
+ * @receiver MongooseArray
+ */
+
+ nonAtomicPush: function() {
+ var values = [].map.call(arguments, this._mapCast, this);
+ var ret = [].push.apply(this, values);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ return ret;
+ },
+
+ /**
+ * Pops the array atomically at most one time per document `save()`.
+ *
+ * #### NOTE:
+ *
+ * _Calling this mulitple times on an array before saving sends the same command as calling it once._
+ * _This update is implemented using the MongoDB [$pop](http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop) method which enforces this restriction._
+ *
+ * doc.array = [1,2,3];
+ *
+ * var popped = doc.array.$pop();
+ * console.log(popped); // 3
+ * console.log(doc.array); // [1,2]
+ *
+ * // no affect
+ * popped = doc.array.$pop();
+ * console.log(doc.array); // [1,2]
+ *
+ * doc.save(function (err) {
+ * if (err) return handleError(err);
+ *
+ * // we saved, now $pop works again
+ * popped = doc.array.$pop();
+ * console.log(popped); // 2
+ * console.log(doc.array); // [1]
+ * })
+ *
+ * @api public
+ * @method $pop
+ * @memberOf MongooseArray
+ * @see mongodb http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop
+ * @method $pop
+ * @receiver MongooseArray
+ */
+
+ $pop: function() {
+ this._registerAtomic('$pop', 1);
+ this._markModified();
+
+ // only allow popping once
+ if (this._popped) {
+ return;
+ }
+ this._popped = true;
+
+ return [].pop.call(this);
+ },
+
+ /**
+ * Wraps [`Array#pop`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/pop) with proper change tracking.
+ *
+ * ####Note:
+ *
+ * _marks the entire array as modified which will pass the entire thing to $set potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @see MongooseArray#$pop #types_array_MongooseArray-%24pop
+ * @api public
+ * @method pop
+ * @receiver MongooseArray
+ */
+
+ pop: function() {
+ var ret = [].pop.call(this);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ return ret;
+ },
+
+ /**
+ * Atomically shifts the array at most one time per document `save()`.
+ *
+ * ####NOTE:
+ *
+ * _Calling this mulitple times on an array before saving sends the same command as calling it once._
+ * _This update is implemented using the MongoDB [$pop](http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop) method which enforces this restriction._
+ *
+ * doc.array = [1,2,3];
+ *
+ * var shifted = doc.array.$shift();
+ * console.log(shifted); // 1
+ * console.log(doc.array); // [2,3]
+ *
+ * // no affect
+ * shifted = doc.array.$shift();
+ * console.log(doc.array); // [2,3]
+ *
+ * doc.save(function (err) {
+ * if (err) return handleError(err);
+ *
+ * // we saved, now $shift works again
+ * shifted = doc.array.$shift();
+ * console.log(shifted ); // 2
+ * console.log(doc.array); // [3]
+ * })
+ *
+ * @api public
+ * @memberOf MongooseArray
+ * @method $shift
+ * @see mongodb http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pop
+ */
+
+ $shift: function $shift() {
+ this._registerAtomic('$pop', -1);
+ this._markModified();
+
+ // only allow shifting once
+ if (this._shifted) {
+ return;
+ }
+ this._shifted = true;
+
+ return [].shift.call(this);
+ },
+
+ /**
+ * Wraps [`Array#shift`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/unshift) with proper change tracking.
+ *
+ * ####Example:
+ *
+ * doc.array = [2,3];
+ * var res = doc.array.shift();
+ * console.log(res) // 2
+ * console.log(doc.array) // [3]
+ *
+ * ####Note:
+ *
+ * _marks the entire array as modified, which if saved, will store it as a `$set` operation, potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @api public
+ * @method shift
+ * @receiver MongooseArray
+ */
+
+ shift: function() {
+ var ret = [].shift.call(this);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ return ret;
+ },
+
+ /**
+ * Pulls items from the array atomically. Equality is determined by casting
+ * the provided value to an embedded document and comparing using
+ * [the `Document.equals()` function.](./api.html#document_Document-equals)
+ *
+ * ####Examples:
+ *
+ * doc.array.pull(ObjectId)
+ * doc.array.pull({ _id: 'someId' })
+ * doc.array.pull(36)
+ * doc.array.pull('tag 1', 'tag 2')
+ *
+ * To remove a document from a subdocument array we may pass an object with a matching `_id`.
+ *
+ * doc.subdocs.push({ _id: 4815162342 })
+ * doc.subdocs.pull({ _id: 4815162342 }) // removed
+ *
+ * Or we may passing the _id directly and let mongoose take care of it.
+ *
+ * doc.subdocs.push({ _id: 4815162342 })
+ * doc.subdocs.pull(4815162342); // works
+ *
+ * The first pull call will result in a atomic operation on the database, if pull is called repeatedly without saving the document, a $set operation is used on the complete array instead, overwriting possible changes that happened on the database in the meantime.
+ *
+ * @param {any} [args...]
+ * @see mongodb http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pull
+ * @api public
+ * @method pull
+ * @receiver MongooseArray
+ */
+
+ pull: function() {
+ var values = [].map.call(arguments, this._cast, this),
+ cur = this._parent.get(this._path),
+ i = cur.length,
+ mem;
+
+ while (i--) {
+ mem = cur[i];
+ if (mem instanceof Document) {
+ var some = values.some(function(v) {
+ return mem.equals(v);
+ });
+ if (some) {
+ [].splice.call(cur, i, 1);
+ }
+ } else if (~cur.indexOf.call(values, mem)) {
+ [].splice.call(cur, i, 1);
+ }
+ }
+
+ if (values[0] instanceof EmbeddedDocument) {
+ this._registerAtomic('$pullDocs', values.map(function(v) {
+ return v._id || v;
+ }));
+ } else {
+ this._registerAtomic('$pullAll', values);
+ }
+
+ this._markModified();
+ return this;
+ },
+
+ /**
+ * Wraps [`Array#splice`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice) with proper change tracking and casting.
+ *
+ * ####Note:
+ *
+ * _marks the entire array as modified, which if saved, will store it as a `$set` operation, potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @api public
+ * @method splice
+ * @receiver MongooseArray
+ */
+
+ splice: function splice() {
+ var ret, vals, i;
+
+ if (arguments.length) {
+ vals = [];
+ for (i = 0; i < arguments.length; ++i) {
+ vals[i] = i < 2
+ ? arguments[i]
+ : this._cast(arguments[i], arguments[0] + (i - 2));
+ }
+ ret = [].splice.apply(this, vals);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ }
+
+ return ret;
+ },
+
+ /**
+ * Wraps [`Array#unshift`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/unshift) with proper change tracking.
+ *
+ * ####Note:
+ *
+ * _marks the entire array as modified, which if saved, will store it as a `$set` operation, potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @api public
+ * @method unshift
+ * @receiver MongooseArray
+ */
+
+ unshift: function() {
+ var values = [].map.call(arguments, this._cast, this);
+ values = this._schema.applySetters(values, this._parent);
+ [].unshift.apply(this, values);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ return this.length;
+ },
+
+ /**
+ * Wraps [`Array#sort`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort) with proper change tracking.
+ *
+ * ####NOTE:
+ *
+ * _marks the entire array as modified, which if saved, will store it as a `$set` operation, potentially overwritting any changes that happen between when you retrieved the object and when you save it._
+ *
+ * @api public
+ * @method sort
+ * @receiver MongooseArray
+ */
+
+ sort: function() {
+ var ret = [].sort.apply(this, arguments);
+ this._registerAtomic('$set', this);
+ this._markModified();
+ return ret;
+ },
+
+ /**
+ * Adds values to the array if not already present.
+ *
+ * ####Example:
+ *
+ * console.log(doc.array) // [2,3,4]
+ * var added = doc.array.addToSet(4,5);
+ * console.log(doc.array) // [2,3,4,5]
+ * console.log(added) // [5]
+ *
+ * @param {any} [args...]
+ * @return {Array} the values that were added
+ * @receiver MongooseArray
+ * @api public
+ * @method addToSet
+ */
+
+ addToSet: function addToSet() {
+ var values = [].map.call(arguments, this._mapCast, this);
+ values = this._schema.applySetters(values, this._parent);
+ var added = [];
+ var type = '';
+ if (values[0] instanceof EmbeddedDocument) {
+ type = 'doc';
+ } else if (values[0] instanceof Date) {
+ type = 'date';
+ }
+
+ values.forEach(function(v) {
+ var found;
+ switch (type) {
+ case 'doc':
+ found = this.some(function(doc) {
+ return doc.equals(v);
+ });
+ break;
+ case 'date':
+ var val = +v;
+ found = this.some(function(d) {
+ return +d === val;
+ });
+ break;
+ default:
+ found = ~this.indexOf(v);
+ }
+
+ if (!found) {
+ [].push.call(this, v);
+ this._registerAtomic('$addToSet', v);
+ this._markModified();
+ [].push.call(added, v);
+ }
+ }, this);
+
+ return added;
+ },
+
+ /**
+ * Sets the casted `val` at index `i` and marks the array modified.
+ *
+ * ####Example:
+ *
+ * // given documents based on the following
+ * var Doc = mongoose.model('Doc', new Schema({ array: [Number] }));
+ *
+ * var doc = new Doc({ array: [2,3,4] })
+ *
+ * console.log(doc.array) // [2,3,4]
+ *
+ * doc.array.set(1,"5");
+ * console.log(doc.array); // [2,5,4] // properly cast to number
+ * doc.save() // the change is saved
+ *
+ * // VS not using array#set
+ * doc.array[1] = "5";
+ * console.log(doc.array); // [2,"5",4] // no casting
+ * doc.save() // change is not saved
+ *
+ * @return {Array} this
+ * @api public
+ * @method set
+ * @receiver MongooseArray
+ */
+
+ set: function set(i, val) {
+ var value = this._cast(val, i);
+ value = this._schema.caster instanceof EmbeddedDocument ?
+ value :
+ this._schema.caster.applySetters(val, this._parent)
+ ;
+ this[i] = value;
+ this._markModified(i);
+ return this;
+ },
+
+ /**
+ * Returns a native js Array.
+ *
+ * @param {Object} options
+ * @return {Array}
+ * @api public
+ * @method toObject
+ * @receiver MongooseArray
+ */
+
+ toObject: function(options) {
+ if (options && options.depopulate) {
+ options._isNested = true;
+ return this.map(function(doc) {
+ return doc instanceof Document
+ ? doc.toObject(options)
+ : doc;
+ });
+ }
+
+ return this.slice();
+ },
+
+ /**
+ * Helper for console.log
+ *
+ * @api public
+ * @method inspect
+ * @receiver MongooseArray
+ */
+
+ inspect: function() {
+ return JSON.stringify(this);
+ },
+
+ /**
+ * Return the index of `obj` or `-1` if not found.
+ *
+ * @param {Object} obj the item to look for
+ * @return {Number}
+ * @api public
+ * @method indexOf
+ * @receiver MongooseArray
+ */
+
+ indexOf: function indexOf(obj) {
+ if (obj instanceof ObjectId) {
+ obj = obj.toString();
+ }
+ for (var i = 0, len = this.length; i < len; ++i) {
+ if (obj == this[i]) {
+ return i;
+ }
+ }
+ return -1;
+ }
+};
+
+/**
+ * Alias of [pull](#types_array_MongooseArray-pull)
+ *
+ * @see MongooseArray#pull #types_array_MongooseArray-pull
+ * @see mongodb http://www.mongodb.org/display/DOCS/Updating/#Updating-%24pull
+ * @api public
+ * @memberOf MongooseArray
+ * @method remove
+ */
+
+MongooseArray.mixin.remove = MongooseArray.mixin.pull;
+
+/*!
+ * Module exports.
+ */
+
+module.exports = exports = MongooseArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/buffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/buffer.js
new file mode 100644
index 0000000..8be67c8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/buffer.js
@@ -0,0 +1,273 @@
+/*!
+ * Module dependencies.
+ */
+
+var Binary = require('../drivers').Binary,
+ utils = require('../utils');
+
+/**
+ * Mongoose Buffer constructor.
+ *
+ * Values always have to be passed to the constructor to initialize.
+ *
+ * @param {Buffer} value
+ * @param {String} encode
+ * @param {Number} offset
+ * @api private
+ * @inherits Buffer
+ * @see http://bit.ly/f6CnZU
+ */
+
+function MongooseBuffer(value, encode, offset) {
+ var length = arguments.length;
+ var val;
+
+ if (length === 0 || arguments[0] === null || arguments[0] === undefined) {
+ val = 0;
+ } else {
+ val = value;
+ }
+
+ var encoding;
+ var path;
+ var doc;
+
+ if (Array.isArray(encode)) {
+ // internal casting
+ path = encode[0];
+ doc = encode[1];
+ } else {
+ encoding = encode;
+ }
+
+ var buf = new Buffer(val, encoding, offset);
+ utils.decorate(buf, MongooseBuffer.mixin);
+ buf.isMongooseBuffer = true;
+
+ // make sure these internal props don't show up in Object.keys()
+ Object.defineProperties(buf, {
+ validators: {value: []},
+ _path: {value: path},
+ _parent: {value: doc}
+ });
+
+ if (doc && typeof path === 'string') {
+ Object.defineProperty(buf, '_schema', {
+ value: doc.schema.path(path)
+ });
+ }
+
+ buf._subtype = 0;
+ return buf;
+}
+
+/*!
+ * Inherit from Buffer.
+ */
+
+// MongooseBuffer.prototype = new Buffer(0);
+
+MongooseBuffer.mixin = {
+
+ /**
+ * Parent owner document
+ *
+ * @api private
+ * @property _parent
+ * @receiver MongooseBuffer
+ */
+
+ _parent: undefined,
+
+ /**
+ * Default subtype for the Binary representing this Buffer
+ *
+ * @api private
+ * @property _subtype
+ * @receiver MongooseBuffer
+ */
+
+ _subtype: undefined,
+
+ /**
+ * Marks this buffer as modified.
+ *
+ * @api private
+ * @method _markModified
+ * @receiver MongooseBuffer
+ */
+
+ _markModified: function() {
+ var parent = this._parent;
+
+ if (parent) {
+ parent.markModified(this._path);
+ }
+ return this;
+ },
+
+ /**
+ * Writes the buffer.
+ *
+ * @api public
+ * @method write
+ * @receiver MongooseBuffer
+ */
+
+ write: function() {
+ var written = Buffer.prototype.write.apply(this, arguments);
+
+ if (written > 0) {
+ this._markModified();
+ }
+
+ return written;
+ },
+
+ /**
+ * Copies the buffer.
+ *
+ * ####Note:
+ *
+ * `Buffer#copy` does not mark `target` as modified so you must copy from a `MongooseBuffer` for it to work as expected. This is a work around since `copy` modifies the target, not this.
+ *
+ * @return {Number} The number of bytes copied.
+ * @param {Buffer} target
+ * @method copy
+ * @receiver MongooseBuffer
+ */
+
+ copy: function(target) {
+ var ret = Buffer.prototype.copy.apply(this, arguments);
+
+ if (target && target.isMongooseBuffer) {
+ target._markModified();
+ }
+
+ return ret;
+ }
+};
+
+/*!
+ * Compile other Buffer methods marking this buffer as modified.
+ */
+
+(
+// node < 0.5
+ 'writeUInt8 writeUInt16 writeUInt32 writeInt8 writeInt16 writeInt32 ' +
+ 'writeFloat writeDouble fill ' +
+ 'utf8Write binaryWrite asciiWrite set ' +
+
+// node >= 0.5
+ 'writeUInt16LE writeUInt16BE writeUInt32LE writeUInt32BE ' +
+ 'writeInt16LE writeInt16BE writeInt32LE writeInt32BE ' +
+ 'writeFloatLE writeFloatBE writeDoubleLE writeDoubleBE'
+).split(' ').forEach(function(method) {
+ if (!Buffer.prototype[method]) {
+ return;
+ }
+ MongooseBuffer.mixin[method] = function() {
+ var ret = Buffer.prototype[method].apply(this, arguments);
+ this._markModified();
+ return ret;
+ };
+});
+
+/**
+ * Converts this buffer to its Binary type representation.
+ *
+ * ####SubTypes:
+ *
+ * var bson = require('bson')
+ * bson.BSON_BINARY_SUBTYPE_DEFAULT
+ * bson.BSON_BINARY_SUBTYPE_FUNCTION
+ * bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY
+ * bson.BSON_BINARY_SUBTYPE_UUID
+ * bson.BSON_BINARY_SUBTYPE_MD5
+ * bson.BSON_BINARY_SUBTYPE_USER_DEFINED
+ *
+ * doc.buffer.toObject(bson.BSON_BINARY_SUBTYPE_USER_DEFINED);
+ *
+ * @see http://bsonspec.org/#/specification
+ * @param {Hex} [subtype]
+ * @return {Binary}
+ * @api public
+ * @method toObject
+ * @receiver MongooseBuffer
+ */
+
+MongooseBuffer.mixin.toObject = function(options) {
+ var subtype = typeof options === 'number'
+ ? options
+ : (this._subtype || 0);
+ return new Binary(this, subtype);
+};
+
+/**
+ * Determines if this buffer is equals to `other` buffer
+ *
+ * @param {Buffer} other
+ * @return {Boolean}
+ * @method equals
+ * @receiver MongooseBuffer
+ */
+
+MongooseBuffer.mixin.equals = function(other) {
+ if (!Buffer.isBuffer(other)) {
+ return false;
+ }
+
+ if (this.length !== other.length) {
+ return false;
+ }
+
+ for (var i = 0; i < this.length; ++i) {
+ if (this[i] !== other[i]) {
+ return false;
+ }
+ }
+
+ return true;
+};
+
+/**
+ * Sets the subtype option and marks the buffer modified.
+ *
+ * ####SubTypes:
+ *
+ * var bson = require('bson')
+ * bson.BSON_BINARY_SUBTYPE_DEFAULT
+ * bson.BSON_BINARY_SUBTYPE_FUNCTION
+ * bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY
+ * bson.BSON_BINARY_SUBTYPE_UUID
+ * bson.BSON_BINARY_SUBTYPE_MD5
+ * bson.BSON_BINARY_SUBTYPE_USER_DEFINED
+ *
+ * doc.buffer.subtype(bson.BSON_BINARY_SUBTYPE_UUID);
+ *
+ * @see http://bsonspec.org/#/specification
+ * @param {Hex} subtype
+ * @api public
+ * @method subtype
+ * @receiver MongooseBuffer
+ */
+
+MongooseBuffer.mixin.subtype = function(subtype) {
+ if (typeof subtype !== 'number') {
+ throw new TypeError('Invalid subtype. Expected a number');
+ }
+
+ if (this._subtype !== subtype) {
+ this._markModified();
+ }
+
+ this._subtype = subtype;
+};
+
+/*!
+ * Module exports.
+ */
+
+MongooseBuffer.Binary = Binary;
+
+module.exports = MongooseBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/documentarray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/documentarray.js
new file mode 100644
index 0000000..f6fb227
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/documentarray.js
@@ -0,0 +1,256 @@
+/*!
+ * Module dependencies.
+ */
+
+var MongooseArray = require('./array'),
+ ObjectId = require('./objectid'),
+ ObjectIdSchema = require('../schema/objectid'),
+ utils = require('../utils'),
+ Document = require('../document');
+
+/**
+ * DocumentArray constructor
+ *
+ * @param {Array} values
+ * @param {String} path the path to this array
+ * @param {Document} doc parent document
+ * @api private
+ * @return {MongooseDocumentArray}
+ * @inherits MongooseArray
+ * @see http://bit.ly/f6CnZU
+ */
+
+function MongooseDocumentArray(values, path, doc) {
+ var arr = [].concat(values);
+ arr._path = path;
+
+ var props = {
+ isMongooseArray: true,
+ isMongooseDocumentArray: true,
+ validators: [],
+ _atomics: {},
+ _schema: void 0,
+ _handlers: void 0
+ };
+
+ // Values always have to be passed to the constructor to initialize, since
+ // otherwise MongooseArray#push will mark the array as modified to the parent.
+ var keysMA = Object.keys(MongooseArray.mixin);
+ var numKeys = keysMA.length;
+ for (var j = 0; j < numKeys; ++j) {
+ arr[keysMA[j]] = MongooseArray.mixin[keysMA[j]];
+ }
+
+ var keysMDA = Object.keys(MongooseDocumentArray.mixin);
+ numKeys = keysMDA.length;
+ for (var i = 0; i < numKeys; ++i) {
+ arr[keysMDA[i]] = MongooseDocumentArray.mixin[keysMDA[i]];
+ }
+
+ var keysP = Object.keys(props);
+ numKeys = keysP.length;
+ for (var k = 0; k < numKeys; ++k) {
+ arr[keysP[k]] = props[keysP[k]];
+ }
+
+ // Because doc comes from the context of another function, doc === global
+ // can happen if there was a null somewhere up the chain (see #3020 && #3034)
+ // RB Jun 17, 2015 updated to check for presence of expected paths instead
+ // to make more proof against unusual node environments
+ if (doc && doc instanceof Document) {
+ arr._parent = doc;
+ arr._schema = doc.schema.path(path);
+ arr._handlers = {
+ isNew: arr.notify('isNew'),
+ save: arr.notify('save')
+ };
+
+ doc.on('save', arr._handlers.save);
+ doc.on('isNew', arr._handlers.isNew);
+ }
+
+ return arr;
+}
+
+/*!
+ * Inherits from MongooseArray
+ */
+// MongooseDocumentArray.mixin = Object.create( MongooseArray.mixin );
+MongooseDocumentArray.mixin = {
+ /*!
+ * ignore
+ */
+ toBSON: function() {
+ return this.toObject({ transform: false });
+ },
+
+ /**
+ * Overrides MongooseArray#cast
+ *
+ * @method _cast
+ * @api private
+ * @receiver MongooseDocumentArray
+ */
+
+ _cast: function(value, index) {
+ if (value instanceof this._schema.casterConstructor) {
+ if (!(value.__parent && value.__parentArray)) {
+ // value may have been created using array.create()
+ value.__parent = this._parent;
+ value.__parentArray = this;
+ }
+ value.__index = index;
+ return value;
+ }
+
+ if (value === undefined || value === null) {
+ return null;
+ }
+
+ // handle cast('string') or cast(ObjectId) etc.
+ // only objects are permitted so we can safely assume that
+ // non-objects are to be interpreted as _id
+ if (Buffer.isBuffer(value) ||
+ value instanceof ObjectId || !utils.isObject(value)) {
+ value = {_id: value};
+ }
+ return new this._schema.casterConstructor(value, this, undefined, undefined, index);
+ },
+
+ /**
+ * Searches array items for the first document with a matching _id.
+ *
+ * ####Example:
+ *
+ * var embeddedDoc = m.array.id(some_id);
+ *
+ * @return {EmbeddedDocument|null} the subdocument or null if not found.
+ * @param {ObjectId|String|Number|Buffer} id
+ * @TODO cast to the _id based on schema for proper comparison
+ * @method id
+ * @api public
+ * @receiver MongooseDocumentArray
+ */
+
+ id: function(id) {
+ var casted,
+ sid,
+ _id;
+
+ try {
+ var casted_ = ObjectIdSchema.prototype.cast.call({}, id);
+ if (casted_) {
+ casted = String(casted_);
+ }
+ } catch (e) {
+ casted = null;
+ }
+
+ for (var i = 0, l = this.length; i < l; i++) {
+ _id = this[i].get('_id');
+
+ if (_id === null || typeof _id === 'undefined') {
+ continue;
+ } else if (_id instanceof Document) {
+ sid || (sid = String(id));
+ if (sid == _id._id) {
+ return this[i];
+ }
+ } else if (!(id instanceof ObjectId) && !(_id instanceof ObjectId)) {
+ if (utils.deepEqual(id, _id)) {
+ return this[i];
+ }
+ } else if (casted == _id) {
+ return this[i];
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Returns a native js Array of plain js objects
+ *
+ * ####NOTE:
+ *
+ * _Each sub-document is converted to a plain object by calling its `#toObject` method._
+ *
+ * @param {Object} [options] optional options to pass to each documents `toObject` method call during conversion
+ * @return {Array}
+ * @method toObject
+ * @api public
+ * @receiver MongooseDocumentArray
+ */
+
+ toObject: function(options) {
+ return this.map(function(doc) {
+ return doc && doc.toObject(options) || null;
+ });
+ },
+
+ /**
+ * Helper for console.log
+ *
+ * @method inspect
+ * @api public
+ * @receiver MongooseDocumentArray
+ */
+
+ inspect: function() {
+ return Array.prototype.slice.call(this);
+ },
+
+ /**
+ * Creates a subdocument casted to this schema.
+ *
+ * This is the same subdocument constructor used for casting.
+ *
+ * @param {Object} obj the value to cast to this arrays SubDocument schema
+ * @method create
+ * @api public
+ * @receiver MongooseDocumentArray
+ */
+
+ create: function(obj) {
+ return new this._schema.casterConstructor(obj);
+ },
+
+ /**
+ * Creates a fn that notifies all child docs of `event`.
+ *
+ * @param {String} event
+ * @return {Function}
+ * @method notify
+ * @api private
+ * @receiver MongooseDocumentArray
+ */
+
+ notify: function notify(event) {
+ var _this = this;
+ return function notify(val) {
+ var i = _this.length;
+ while (i--) {
+ if (!_this[i]) {
+ continue;
+ }
+ switch (event) {
+ // only swap for save event for now, we may change this to all event types later
+ case 'save':
+ val = _this[i];
+ break;
+ default:
+ // NO-OP
+ break;
+ }
+ _this[i].emit(event, val);
+ }
+ };
+ }
+
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = MongooseDocumentArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/embedded.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/embedded.js
new file mode 100644
index 0000000..fbeaf6a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/embedded.js
@@ -0,0 +1,347 @@
+/* eslint no-func-assign: 1 */
+
+/*!
+ * Module dependencies.
+ */
+
+var Document = require('../document_provider')();
+var PromiseProvider = require('../promise_provider');
+
+/**
+ * EmbeddedDocument constructor.
+ *
+ * @param {Object} obj js object returned from the db
+ * @param {MongooseDocumentArray} parentArr the parent array of this document
+ * @param {Boolean} skipId
+ * @inherits Document
+ * @api private
+ */
+
+function EmbeddedDocument(obj, parentArr, skipId, fields, index) {
+ if (parentArr) {
+ this.__parentArray = parentArr;
+ this.__parent = parentArr._parent;
+ } else {
+ this.__parentArray = undefined;
+ this.__parent = undefined;
+ }
+ this.__index = index;
+
+ Document.call(this, obj, fields, skipId);
+
+ var _this = this;
+ this.on('isNew', function(val) {
+ _this.isNew = val;
+ });
+}
+
+/*!
+ * Inherit from Document
+ */
+EmbeddedDocument.prototype = Object.create(Document.prototype);
+EmbeddedDocument.prototype.constructor = EmbeddedDocument;
+
+EmbeddedDocument.prototype.toBSON = function() {
+ return this.toObject({ transform: false });
+};
+
+/**
+ * Marks the embedded doc modified.
+ *
+ * ####Example:
+ *
+ * var doc = blogpost.comments.id(hexstring);
+ * doc.mixed.type = 'changed';
+ * doc.markModified('mixed.type');
+ *
+ * @param {String} path the path which changed
+ * @api public
+ * @receiver EmbeddedDocument
+ */
+
+EmbeddedDocument.prototype.markModified = function(path) {
+ this.$__.activePaths.modify(path);
+ if (!this.__parentArray) {
+ return;
+ }
+
+ if (this.isNew) {
+ // Mark the WHOLE parent array as modified
+ // if this is a new document (i.e., we are initializing
+ // a document),
+ this.__parentArray._markModified();
+ } else {
+ this.__parentArray._markModified(this, path);
+ }
+};
+
+/*!
+ * ignore
+ */
+
+EmbeddedDocument.prototype.populate = function() {
+ throw new Error('Mongoose does not support calling populate() on nested ' +
+ 'docs. Instead of `doc.arr[0].populate("path")`, use ' +
+ '`doc.populate("arr.0.path")`');
+};
+
+/**
+ * Used as a stub for [hooks.js](https://github.com/bnoguchi/hooks-js/tree/31ec571cef0332e21121ee7157e0cf9728572cc3)
+ *
+ * ####NOTE:
+ *
+ * _This is a no-op. Does not actually save the doc to the db._
+ *
+ * @param {Function} [fn]
+ * @return {Promise} resolved Promise
+ * @api private
+ */
+
+EmbeddedDocument.prototype.save = function(fn) {
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve) {
+ fn && fn();
+ resolve();
+ });
+};
+
+/*!
+ * Registers remove event listeners for triggering
+ * on subdocuments.
+ *
+ * @param {EmbeddedDocument} sub
+ * @api private
+ */
+
+function registerRemoveListener(sub) {
+ var owner = sub.ownerDocument();
+
+ function emitRemove() {
+ owner.removeListener('save', emitRemove);
+ owner.removeListener('remove', emitRemove);
+ sub.emit('remove', sub);
+ owner = sub = null;
+ }
+
+ owner.on('save', emitRemove);
+ owner.on('remove', emitRemove);
+}
+
+/**
+ * Removes the subdocument from its parent array.
+ *
+ * @param {Object} [options]
+ * @param {Function} [fn]
+ * @api public
+ */
+
+EmbeddedDocument.prototype.remove = function(options, fn) {
+ if ( typeof options === 'function' && !fn ) {
+ fn = options;
+ options = undefined;
+ }
+ if (!this.__parentArray || (options && options.noop)) {
+ fn && fn(null);
+ return this;
+ }
+
+ var _id;
+ if (!this.willRemove) {
+ _id = this._doc._id;
+ if (!_id) {
+ throw new Error('For your own good, Mongoose does not know ' +
+ 'how to remove an EmbeddedDocument that has no _id');
+ }
+ this.__parentArray.pull({_id: _id});
+ this.willRemove = true;
+ registerRemoveListener(this);
+ }
+
+ if (fn) {
+ fn(null);
+ }
+
+ return this;
+};
+
+/**
+ * Override #update method of parent documents.
+ * @api private
+ */
+
+EmbeddedDocument.prototype.update = function() {
+ throw new Error('The #update method is not available on EmbeddedDocuments');
+};
+
+/**
+ * Helper for console.log
+ *
+ * @api public
+ */
+
+EmbeddedDocument.prototype.inspect = function() {
+ return this.toObject({ transform: false, retainKeyOrder: true });
+};
+
+/**
+ * Marks a path as invalid, causing validation to fail.
+ *
+ * @param {String} path the field to invalidate
+ * @param {String|Error} err error which states the reason `path` was invalid
+ * @return {Boolean}
+ * @api public
+ */
+
+EmbeddedDocument.prototype.invalidate = function(path, err, val, first) {
+ if (!this.__parent) {
+ Document.prototype.invalidate.call(this, path, err, val);
+ if (err.name === 'ValidatorError') {
+ return true;
+ }
+ throw err;
+ }
+
+ var index = this.__index;
+ if (typeof index !== 'undefined') {
+ var parentPath = this.__parentArray._path;
+ var fullPath = [parentPath, index, path].join('.');
+ this.__parent.invalidate(fullPath, err, val);
+ }
+
+ if (first) {
+ this.$__.validationError = this.ownerDocument().$__.validationError;
+ }
+
+ return true;
+};
+
+/**
+ * Marks a path as valid, removing existing validation errors.
+ *
+ * @param {String} path the field to mark as valid
+ * @api private
+ * @method $markValid
+ * @receiver EmbeddedDocument
+ */
+
+EmbeddedDocument.prototype.$markValid = function(path) {
+ if (!this.__parent) {
+ return;
+ }
+
+ var index = this.__index;
+ if (typeof index !== 'undefined') {
+ var parentPath = this.__parentArray._path;
+ var fullPath = [parentPath, index, path].join('.');
+ this.__parent.$markValid(fullPath);
+ }
+};
+
+/**
+ * Checks if a path is invalid
+ *
+ * @param {String} path the field to check
+ * @api private
+ * @method $isValid
+ * @receiver EmbeddedDocument
+ */
+
+EmbeddedDocument.prototype.$isValid = function(path) {
+ var index = this.__index;
+ if (typeof index !== 'undefined' && this.__parent) {
+ return !this.__parent.$__.validationError ||
+ !this.__parent.$__.validationError.errors[this.$__fullPath(path)];
+ }
+
+ return true;
+};
+
+/**
+ * Returns the top level document of this sub-document.
+ *
+ * @return {Document}
+ */
+
+EmbeddedDocument.prototype.ownerDocument = function() {
+ if (this.$__.ownerDocument) {
+ return this.$__.ownerDocument;
+ }
+
+ var parent = this.__parent;
+ if (!parent) {
+ return this;
+ }
+
+ while (parent.__parent || parent.$parent) {
+ parent = parent.__parent || parent.$parent;
+ }
+
+ this.$__.ownerDocument = parent;
+ return this.$__.ownerDocument;
+};
+
+/**
+ * Returns the full path to this document. If optional `path` is passed, it is appended to the full path.
+ *
+ * @param {String} [path]
+ * @return {String}
+ * @api private
+ * @method $__fullPath
+ * @memberOf EmbeddedDocument
+ */
+
+EmbeddedDocument.prototype.$__fullPath = function(path) {
+ if (!this.$__.fullPath) {
+ var parent = this; // eslint-disable-line consistent-this
+ if (!parent.__parent) {
+ return path;
+ }
+
+ var paths = [];
+ while (parent.__parent || parent.$parent) {
+ if (parent.__parent) {
+ paths.unshift(parent.__parentArray._path);
+ } else {
+ paths.unshift(parent.$basePath);
+ }
+ parent = parent.__parent || parent.$parent;
+ }
+
+ this.$__.fullPath = paths.join('.');
+
+ if (!this.$__.ownerDocument) {
+ // optimization
+ this.$__.ownerDocument = parent;
+ }
+ }
+
+ return path
+ ? this.$__.fullPath + '.' + path
+ : this.$__.fullPath;
+};
+
+/**
+ * Returns this sub-documents parent document.
+ *
+ * @api public
+ */
+
+EmbeddedDocument.prototype.parent = function() {
+ return this.__parent;
+};
+
+/**
+ * Returns this sub-documents parent array.
+ *
+ * @api public
+ */
+
+EmbeddedDocument.prototype.parentArray = function() {
+ return this.__parentArray;
+};
+
+/*!
+ * Module exports.
+ */
+
+module.exports = EmbeddedDocument;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/index.js
new file mode 100644
index 0000000..0d01923
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/index.js
@@ -0,0 +1,15 @@
+
+/*!
+ * Module exports.
+ */
+
+exports.Array = require('./array');
+exports.Buffer = require('./buffer');
+
+exports.Document = // @deprecate
+exports.Embedded = require('./embedded');
+
+exports.DocumentArray = require('./documentarray');
+exports.ObjectId = require('./objectid');
+
+exports.Subdocument = require('./subdocument');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/objectid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/objectid.js
new file mode 100644
index 0000000..9fe0b97
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/objectid.js
@@ -0,0 +1,13 @@
+/**
+ * ObjectId type constructor
+ *
+ * ####Example
+ *
+ * var id = new mongoose.Types.ObjectId;
+ *
+ * @constructor ObjectId
+ */
+
+var ObjectId = require('../drivers').ObjectId;
+
+module.exports = ObjectId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/subdocument.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/subdocument.js
new file mode 100644
index 0000000..911fdf4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/types/subdocument.js
@@ -0,0 +1,152 @@
+var Document = require('../document');
+var PromiseProvider = require('../promise_provider');
+
+module.exports = Subdocument;
+
+/**
+ * Subdocument constructor.
+ *
+ * @inherits Document
+ * @api private
+ */
+
+function Subdocument(value, fields) {
+ this.$isSingleNested = true;
+ Document.call(this, value, fields);
+}
+
+Subdocument.prototype = Object.create(Document.prototype);
+
+Subdocument.prototype.toBSON = function() {
+ return this.toObject({ transform: false });
+};
+
+/**
+ * Used as a stub for [hooks.js](https://github.com/bnoguchi/hooks-js/tree/31ec571cef0332e21121ee7157e0cf9728572cc3)
+ *
+ * ####NOTE:
+ *
+ * _This is a no-op. Does not actually save the doc to the db._
+ *
+ * @param {Function} [fn]
+ * @return {Promise} resolved Promise
+ * @api private
+ */
+
+Subdocument.prototype.save = function(fn) {
+ var Promise = PromiseProvider.get();
+ return new Promise.ES6(function(resolve) {
+ fn && fn();
+ resolve();
+ });
+};
+
+Subdocument.prototype.$isValid = function(path) {
+ if (this.$parent) {
+ return this.$parent.$isValid([this.$basePath, path].join('.'));
+ }
+};
+
+Subdocument.prototype.markModified = function(path) {
+ Document.prototype.markModified.call(this, path);
+ if (this.$parent) {
+ if (this.$parent.isDirectModified(this.$basePath)) {
+ return;
+ }
+ this.$parent.markModified([this.$basePath, path].join('.'));
+ }
+};
+
+Subdocument.prototype.$markValid = function(path) {
+ if (this.$parent) {
+ this.$parent.$markValid([this.$basePath, path].join('.'));
+ }
+};
+
+Subdocument.prototype.invalidate = function(path, err, val) {
+ Document.prototype.invalidate.call(this, path, err, val);
+ if (this.$parent) {
+ this.$parent.invalidate([this.$basePath, path].join('.'), err, val);
+ } else if (err.kind === 'cast' || err.name === 'CastError') {
+ throw err;
+ }
+};
+
+/**
+ * Returns the top level document of this sub-document.
+ *
+ * @return {Document}
+ */
+
+Subdocument.prototype.ownerDocument = function() {
+ if (this.$__.ownerDocument) {
+ return this.$__.ownerDocument;
+ }
+
+ var parent = this.$parent;
+ if (!parent) {
+ return this;
+ }
+
+ while (parent.$parent || parent.__parent) {
+ parent = parent.$parent || parent.__parent;
+ }
+ this.$__.ownerDocument = parent;
+ return this.$__.ownerDocument;
+};
+
+/**
+ * Null-out this subdoc
+ *
+ * @param {Object} [options]
+ * @param {Function} [callback] optional callback for compatibility with Document.prototype.remove
+ */
+
+Subdocument.prototype.remove = function(options, callback) {
+ if (typeof options === 'function') {
+ callback = options;
+ options = null;
+ }
+
+ // If removing entire doc, no need to remove subdoc
+ if (!options || !options.noop) {
+ this.$parent.set(this.$basePath, null);
+ registerRemoveListener(this);
+ }
+
+ if (typeof callback === 'function') {
+ callback(null);
+ }
+};
+
+/*!
+ * ignore
+ */
+
+Subdocument.prototype.populate = function() {
+ throw new Error('Mongoose does not support calling populate() on nested ' +
+ 'docs. Instead of `doc.nested.populate("path")`, use ' +
+ '`doc.populate("nested.path")`');
+};
+
+/*!
+ * Registers remove event listeners for triggering
+ * on subdocuments.
+ *
+ * @param {EmbeddedDocument} sub
+ * @api private
+ */
+
+function registerRemoveListener(sub) {
+ var owner = sub.ownerDocument();
+
+ function emitRemove() {
+ owner.removeListener('save', emitRemove);
+ owner.removeListener('remove', emitRemove);
+ sub.emit('remove', sub);
+ owner = sub = null;
+ }
+
+ owner.on('save', emitRemove);
+ owner.on('remove', emitRemove);
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/utils.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/utils.js
new file mode 100644
index 0000000..391325f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/utils.js
@@ -0,0 +1,868 @@
+/*!
+ * Module dependencies.
+ */
+
+var ObjectId = require('./types/objectid');
+var cloneRegExp = require('regexp-clone');
+var sliced = require('sliced');
+var mpath = require('mpath');
+var ms = require('ms');
+var MongooseBuffer;
+var MongooseArray;
+var Document;
+
+/*!
+ * Produces a collection name from model `name`.
+ *
+ * @param {String} name a model name
+ * @return {String} a collection name
+ * @api private
+ */
+
+exports.toCollectionName = function(name, options) {
+ options = options || {};
+ if (name === 'system.profile') {
+ return name;
+ }
+ if (name === 'system.indexes') {
+ return name;
+ }
+ if (options.pluralization === false) {
+ return name;
+ }
+ return pluralize(name.toLowerCase());
+};
+
+/**
+ * Pluralization rules.
+ *
+ * These rules are applied while processing the argument to `toCollectionName`.
+ *
+ * @deprecated remove in 4.x gh-1350
+ */
+
+exports.pluralization = [
+ [/(m)an$/gi, '$1en'],
+ [/(pe)rson$/gi, '$1ople'],
+ [/(child)$/gi, '$1ren'],
+ [/^(ox)$/gi, '$1en'],
+ [/(ax|test)is$/gi, '$1es'],
+ [/(octop|vir)us$/gi, '$1i'],
+ [/(alias|status)$/gi, '$1es'],
+ [/(bu)s$/gi, '$1ses'],
+ [/(buffal|tomat|potat)o$/gi, '$1oes'],
+ [/([ti])um$/gi, '$1a'],
+ [/sis$/gi, 'ses'],
+ [/(?:([^f])fe|([lr])f)$/gi, '$1$2ves'],
+ [/(hive)$/gi, '$1s'],
+ [/([^aeiouy]|qu)y$/gi, '$1ies'],
+ [/(x|ch|ss|sh)$/gi, '$1es'],
+ [/(matr|vert|ind)ix|ex$/gi, '$1ices'],
+ [/([m|l])ouse$/gi, '$1ice'],
+ [/(kn|w|l)ife$/gi, '$1ives'],
+ [/(quiz)$/gi, '$1zes'],
+ [/s$/gi, 's'],
+ [/([^a-z])$/, '$1'],
+ [/$/gi, 's']
+];
+var rules = exports.pluralization;
+
+/**
+ * Uncountable words.
+ *
+ * These words are applied while processing the argument to `toCollectionName`.
+ * @api public
+ */
+
+exports.uncountables = [
+ 'advice',
+ 'energy',
+ 'excretion',
+ 'digestion',
+ 'cooperation',
+ 'health',
+ 'justice',
+ 'labour',
+ 'machinery',
+ 'equipment',
+ 'information',
+ 'pollution',
+ 'sewage',
+ 'paper',
+ 'money',
+ 'species',
+ 'series',
+ 'rain',
+ 'rice',
+ 'fish',
+ 'sheep',
+ 'moose',
+ 'deer',
+ 'news',
+ 'expertise',
+ 'status',
+ 'media'
+];
+var uncountables = exports.uncountables;
+
+/*!
+ * Pluralize function.
+ *
+ * @author TJ Holowaychuk (extracted from _ext.js_)
+ * @param {String} string to pluralize
+ * @api private
+ */
+
+function pluralize(str) {
+ var found;
+ if (!~uncountables.indexOf(str.toLowerCase())) {
+ found = rules.filter(function(rule) {
+ return str.match(rule[0]);
+ });
+ if (found[0]) {
+ return str.replace(found[0][0], found[0][1]);
+ }
+ }
+ return str;
+}
+
+/*!
+ * Determines if `a` and `b` are deep equal.
+ *
+ * Modified from node/lib/assert.js
+ *
+ * @param {any} a a value to compare to `b`
+ * @param {any} b a value to compare to `a`
+ * @return {Boolean}
+ * @api private
+ */
+
+exports.deepEqual = function deepEqual(a, b) {
+ if (a === b) {
+ return true;
+ }
+
+ if (a instanceof Date && b instanceof Date) {
+ return a.getTime() === b.getTime();
+ }
+
+ if (a instanceof ObjectId && b instanceof ObjectId) {
+ return a.toString() === b.toString();
+ }
+
+ if (a instanceof RegExp && b instanceof RegExp) {
+ return a.source === b.source &&
+ a.ignoreCase === b.ignoreCase &&
+ a.multiline === b.multiline &&
+ a.global === b.global;
+ }
+
+ if (typeof a !== 'object' && typeof b !== 'object') {
+ return a == b;
+ }
+
+ if (a === null || b === null || a === undefined || b === undefined) {
+ return false;
+ }
+
+ if (a.prototype !== b.prototype) {
+ return false;
+ }
+
+ // Handle MongooseNumbers
+ if (a instanceof Number && b instanceof Number) {
+ return a.valueOf() === b.valueOf();
+ }
+
+ if (Buffer.isBuffer(a)) {
+ return exports.buffer.areEqual(a, b);
+ }
+
+ if (isMongooseObject(a)) {
+ a = a.toObject();
+ }
+ if (isMongooseObject(b)) {
+ b = b.toObject();
+ }
+
+ try {
+ var ka = Object.keys(a),
+ kb = Object.keys(b),
+ key, i;
+ } catch (e) {
+ // happens when one is a string literal and the other isn't
+ return false;
+ }
+
+ // having the same number of owned properties (keys incorporates
+ // hasOwnProperty)
+ if (ka.length !== kb.length) {
+ return false;
+ }
+
+ // the same set of keys (although not necessarily the same order),
+ ka.sort();
+ kb.sort();
+
+ // ~~~cheap key test
+ for (i = ka.length - 1; i >= 0; i--) {
+ if (ka[i] !== kb[i]) {
+ return false;
+ }
+ }
+
+ // equivalent values for every corresponding key, and
+ // ~~~possibly expensive deep test
+ for (i = ka.length - 1; i >= 0; i--) {
+ key = ka[i];
+ if (!deepEqual(a[key], b[key])) {
+ return false;
+ }
+ }
+
+ return true;
+};
+
+/*!
+ * Object clone with Mongoose natives support.
+ *
+ * If options.minimize is true, creates a minimal data object. Empty objects and undefined values will not be cloned. This makes the data payload sent to MongoDB as small as possible.
+ *
+ * Functions are never cloned.
+ *
+ * @param {Object} obj the object to clone
+ * @param {Object} options
+ * @return {Object} the cloned object
+ * @api private
+ */
+
+exports.clone = function clone(obj, options) {
+ if (obj === undefined || obj === null) {
+ return obj;
+ }
+
+ if (Array.isArray(obj)) {
+ return cloneArray(obj, options);
+ }
+
+ if (isMongooseObject(obj)) {
+ if (options && options.json && typeof obj.toJSON === 'function') {
+ return obj.toJSON(options);
+ }
+ return obj.toObject(options);
+ }
+
+ if (obj.constructor) {
+ switch (exports.getFunctionName(obj.constructor)) {
+ case 'Object':
+ return cloneObject(obj, options);
+ case 'Date':
+ return new obj.constructor(+obj);
+ case 'RegExp':
+ return cloneRegExp(obj);
+ default:
+ // ignore
+ break;
+ }
+ }
+
+ if (obj instanceof ObjectId) {
+ return new ObjectId(obj.id);
+ }
+
+ if (!obj.constructor && exports.isObject(obj)) {
+ // object created with Object.create(null)
+ return cloneObject(obj, options);
+ }
+
+ if (obj.valueOf) {
+ return obj.valueOf();
+ }
+};
+var clone = exports.clone;
+
+/*!
+ * ignore
+ */
+
+function cloneObject(obj, options) {
+ var retainKeyOrder = options && options.retainKeyOrder,
+ minimize = options && options.minimize,
+ ret = {},
+ hasKeys,
+ keys,
+ val,
+ k,
+ i;
+
+ if (retainKeyOrder) {
+ for (k in obj) {
+ val = clone(obj[k], options);
+
+ if (!minimize || (typeof val !== 'undefined')) {
+ hasKeys || (hasKeys = true);
+ ret[k] = val;
+ }
+ }
+ } else {
+ // faster
+
+ keys = Object.keys(obj);
+ i = keys.length;
+
+ while (i--) {
+ k = keys[i];
+ val = clone(obj[k], options);
+
+ if (!minimize || (typeof val !== 'undefined')) {
+ if (!hasKeys) {
+ hasKeys = true;
+ }
+ ret[k] = val;
+ }
+ }
+ }
+
+ return minimize
+ ? hasKeys && ret
+ : ret;
+}
+
+function cloneArray(arr, options) {
+ var ret = [];
+ for (var i = 0, l = arr.length; i < l; i++) {
+ ret.push(clone(arr[i], options));
+ }
+ return ret;
+}
+
+/*!
+ * Shallow copies defaults into options.
+ *
+ * @param {Object} defaults
+ * @param {Object} options
+ * @return {Object} the merged object
+ * @api private
+ */
+
+exports.options = function(defaults, options) {
+ var keys = Object.keys(defaults),
+ i = keys.length,
+ k;
+
+ options = options || {};
+
+ while (i--) {
+ k = keys[i];
+ if (!(k in options)) {
+ options[k] = defaults[k];
+ }
+ }
+
+ return options;
+};
+
+/*!
+ * Generates a random string
+ *
+ * @api private
+ */
+
+exports.random = function() {
+ return Math.random().toString().substr(3);
+};
+
+/*!
+ * Merges `from` into `to` without overwriting existing properties.
+ *
+ * @param {Object} to
+ * @param {Object} from
+ * @api private
+ */
+
+exports.merge = function merge(to, from, options) {
+ options = options || {};
+ var keys = Object.keys(from);
+ var i = 0;
+ var len = keys.length;
+ var key;
+
+ if (options.retainKeyOrder) {
+ while (i < len) {
+ key = keys[i++];
+ if (typeof to[key] === 'undefined') {
+ to[key] = from[key];
+ } else if (exports.isObject(from[key])) {
+ merge(to[key], from[key]);
+ } else if (options.overwrite) {
+ to[key] = from[key];
+ }
+ }
+ } else {
+ while (len--) {
+ key = keys[len];
+ if (typeof to[key] === 'undefined') {
+ to[key] = from[key];
+ } else if (exports.isObject(from[key])) {
+ merge(to[key], from[key]);
+ } else if (options.overwrite) {
+ to[key] = from[key];
+ }
+ }
+ }
+};
+
+/*!
+ * toString helper
+ */
+
+var toString = Object.prototype.toString;
+
+/*!
+ * Applies toObject recursively.
+ *
+ * @param {Document|Array|Object} obj
+ * @return {Object}
+ * @api private
+ */
+
+exports.toObject = function toObject(obj) {
+ Document || (Document = require('./document'));
+ var ret;
+
+ if (exports.isNullOrUndefined(obj)) {
+ return obj;
+ }
+
+ if (obj instanceof Document) {
+ return obj.toObject();
+ }
+
+ if (Array.isArray(obj)) {
+ ret = [];
+
+ for (var i = 0, len = obj.length; i < len; ++i) {
+ ret.push(toObject(obj[i]));
+ }
+
+ return ret;
+ }
+
+ if ((obj.constructor && exports.getFunctionName(obj.constructor) === 'Object') ||
+ (!obj.constructor && exports.isObject(obj))) {
+ ret = {};
+
+ for (var k in obj) {
+ ret[k] = toObject(obj[k]);
+ }
+
+ return ret;
+ }
+
+ return obj;
+};
+
+/*!
+ * Determines if `arg` is an object.
+ *
+ * @param {Object|Array|String|Function|RegExp|any} arg
+ * @api private
+ * @return {Boolean}
+ */
+
+exports.isObject = function(arg) {
+ if (Buffer.isBuffer(arg)) {
+ return true;
+ }
+ return toString.call(arg) === '[object Object]';
+};
+
+/*!
+ * A faster Array.prototype.slice.call(arguments) alternative
+ * @api private
+ */
+
+exports.args = sliced;
+
+/*!
+ * process.nextTick helper.
+ *
+ * Wraps `callback` in a try/catch + nextTick.
+ *
+ * node-mongodb-native has a habit of state corruption when an error is immediately thrown from within a collection callback.
+ *
+ * @param {Function} callback
+ * @api private
+ */
+
+exports.tick = function tick(callback) {
+ if (typeof callback !== 'function') {
+ return;
+ }
+ return function() {
+ try {
+ callback.apply(this, arguments);
+ } catch (err) {
+ // only nextTick on err to get out of
+ // the event loop and avoid state corruption.
+ process.nextTick(function() {
+ throw err;
+ });
+ }
+ };
+};
+
+/*!
+ * Returns if `v` is a mongoose object that has a `toObject()` method we can use.
+ *
+ * This is for compatibility with libs like Date.js which do foolish things to Natives.
+ *
+ * @param {any} v
+ * @api private
+ */
+
+exports.isMongooseObject = function(v) {
+ Document || (Document = require('./document'));
+ MongooseArray || (MongooseArray = require('./types').Array);
+ MongooseBuffer || (MongooseBuffer = require('./types').Buffer);
+
+ return v instanceof Document ||
+ (v && v.isMongooseArray) ||
+ (v && v.isMongooseBuffer);
+};
+var isMongooseObject = exports.isMongooseObject;
+
+/*!
+ * Converts `expires` options of index objects to `expiresAfterSeconds` options for MongoDB.
+ *
+ * @param {Object} object
+ * @api private
+ */
+
+exports.expires = function expires(object) {
+ if (!(object && object.constructor.name === 'Object')) {
+ return;
+ }
+ if (!('expires' in object)) {
+ return;
+ }
+
+ var when;
+ if (typeof object.expires !== 'string') {
+ when = object.expires;
+ } else {
+ when = Math.round(ms(object.expires) / 1000);
+ }
+ object.expireAfterSeconds = when;
+ delete object.expires;
+};
+
+/*!
+ * Populate options constructor
+ */
+
+function PopulateOptions(path, select, match, options, model, subPopulate) {
+ this.path = path;
+ this.match = match;
+ this.select = select;
+ this.options = options;
+ this.model = model;
+ if (typeof subPopulate === 'object') {
+ this.populate = subPopulate;
+ }
+ this._docs = {};
+}
+
+// make it compatible with utils.clone
+PopulateOptions.prototype.constructor = Object;
+
+// expose
+exports.PopulateOptions = PopulateOptions;
+
+/*!
+ * populate helper
+ */
+
+exports.populate = function populate(path, select, model, match, options, subPopulate) {
+ // The order of select/conditions args is opposite Model.find but
+ // necessary to keep backward compatibility (select could be
+ // an array, string, or object literal).
+
+ // might have passed an object specifying all arguments
+ if (arguments.length === 1) {
+ if (path instanceof PopulateOptions) {
+ return [path];
+ }
+
+ if (Array.isArray(path)) {
+ return path.map(function(o) {
+ return exports.populate(o)[0];
+ });
+ }
+
+ if (exports.isObject(path)) {
+ match = path.match;
+ options = path.options;
+ select = path.select;
+ model = path.model;
+ subPopulate = path.populate;
+ path = path.path;
+ }
+ } else if (typeof model !== 'string' && typeof model !== 'function') {
+ options = match;
+ match = model;
+ model = undefined;
+ }
+
+ if (typeof path !== 'string') {
+ throw new TypeError('utils.populate: invalid path. Expected string. Got typeof `' + typeof path + '`');
+ }
+
+ if (typeof subPopulate === 'object') {
+ subPopulate = exports.populate(subPopulate);
+ }
+
+ var ret = [];
+ var paths = path.split(' ');
+ options = exports.clone(options, { retainKeyOrder: true });
+ for (var i = 0; i < paths.length; ++i) {
+ ret.push(new PopulateOptions(paths[i], select, match, options, model, subPopulate));
+ }
+
+ return ret;
+};
+
+/*!
+ * Return the value of `obj` at the given `path`.
+ *
+ * @param {String} path
+ * @param {Object} obj
+ */
+
+exports.getValue = function(path, obj, map) {
+ return mpath.get(path, obj, '_doc', map);
+};
+
+/*!
+ * Sets the value of `obj` at the given `path`.
+ *
+ * @param {String} path
+ * @param {Anything} val
+ * @param {Object} obj
+ */
+
+exports.setValue = function(path, val, obj, map) {
+ mpath.set(path, val, obj, '_doc', map);
+};
+
+/*!
+ * Returns an array of values from object `o`.
+ *
+ * @param {Object} o
+ * @return {Array}
+ * @private
+ */
+
+exports.object = {};
+exports.object.vals = function vals(o) {
+ var keys = Object.keys(o),
+ i = keys.length,
+ ret = [];
+
+ while (i--) {
+ ret.push(o[keys[i]]);
+ }
+
+ return ret;
+};
+
+/*!
+ * @see exports.options
+ */
+
+exports.object.shallowCopy = exports.options;
+
+/*!
+ * Safer helper for hasOwnProperty checks
+ *
+ * @param {Object} obj
+ * @param {String} prop
+ */
+
+var hop = Object.prototype.hasOwnProperty;
+exports.object.hasOwnProperty = function(obj, prop) {
+ return hop.call(obj, prop);
+};
+
+/*!
+ * Determine if `val` is null or undefined
+ *
+ * @return {Boolean}
+ */
+
+exports.isNullOrUndefined = function(val) {
+ return val === null || val === undefined;
+};
+
+/*!
+ * ignore
+ */
+
+exports.array = {};
+
+/*!
+ * Flattens an array.
+ *
+ * [ 1, [ 2, 3, [4] ]] -> [1,2,3,4]
+ *
+ * @param {Array} arr
+ * @param {Function} [filter] If passed, will be invoked with each item in the array. If `filter` returns a falsey value, the item will not be included in the results.
+ * @return {Array}
+ * @private
+ */
+
+exports.array.flatten = function flatten(arr, filter, ret) {
+ ret || (ret = []);
+
+ arr.forEach(function(item) {
+ if (Array.isArray(item)) {
+ flatten(item, filter, ret);
+ } else {
+ if (!filter || filter(item)) {
+ ret.push(item);
+ }
+ }
+ });
+
+ return ret;
+};
+
+/*!
+ * Removes duplicate values from an array
+ *
+ * [1, 2, 3, 3, 5] => [1, 2, 3, 5]
+ * [ ObjectId("550988ba0c19d57f697dc45e"), ObjectId("550988ba0c19d57f697dc45e") ]
+ * => [ObjectId("550988ba0c19d57f697dc45e")]
+ *
+ * @param {Array} arr
+ * @return {Array}
+ * @private
+ */
+
+exports.array.unique = function(arr) {
+ var primitives = {};
+ var ids = {};
+ var ret = [];
+ var length = arr.length;
+ for (var i = 0; i < length; ++i) {
+ if (typeof arr[i] === 'number' || typeof arr[i] === 'string') {
+ if (primitives[arr[i]]) {
+ continue;
+ }
+ ret.push(arr[i]);
+ primitives[arr[i]] = true;
+ } else if (arr[i] instanceof ObjectId) {
+ if (ids[arr[i].toString()]) {
+ continue;
+ }
+ ret.push(arr[i]);
+ ids[arr[i].toString()] = true;
+ } else {
+ ret.push(arr[i]);
+ }
+ }
+
+ return ret;
+};
+
+/*!
+ * Determines if two buffers are equal.
+ *
+ * @param {Buffer} a
+ * @param {Object} b
+ */
+
+exports.buffer = {};
+exports.buffer.areEqual = function(a, b) {
+ if (!Buffer.isBuffer(a)) {
+ return false;
+ }
+ if (!Buffer.isBuffer(b)) {
+ return false;
+ }
+ if (a.length !== b.length) {
+ return false;
+ }
+ for (var i = 0, len = a.length; i < len; ++i) {
+ if (a[i] !== b[i]) {
+ return false;
+ }
+ }
+ return true;
+};
+
+exports.getFunctionName = function(fn) {
+ if (fn.name) {
+ return fn.name;
+ }
+ return (fn.toString().trim().match(/^function\s*([^\s(]+)/) || [])[1];
+};
+
+exports.decorate = function(destination, source) {
+ for (var key in source) {
+ destination[key] = source[key];
+ }
+};
+
+/**
+ * merges to with a copy of from
+ *
+ * @param {Object} to
+ * @param {Object} fromObj
+ * @api private
+ */
+
+exports.mergeClone = function(to, fromObj) {
+ var keys = Object.keys(fromObj);
+ var len = keys.length;
+ var i = 0;
+ var key;
+
+ while (i < len) {
+ key = keys[i++];
+ if (typeof to[key] === 'undefined') {
+ // make sure to retain key order here because of a bug handling the $each
+ // operator in mongodb 2.4.4
+ to[key] = exports.clone(fromObj[key], {retainKeyOrder: 1});
+ } else {
+ if (exports.isObject(fromObj[key])) {
+ var obj = fromObj[key];
+ if (isMongooseObject(fromObj[key]) && !fromObj[key].isMongooseBuffer) {
+ obj = obj.toObject({ transform: false });
+ }
+ if (fromObj[key].isMongooseBuffer) {
+ obj = new Buffer(obj);
+ }
+ exports.mergeClone(to[key], obj);
+ } else {
+ // make sure to retain key order here because of a bug handling the
+ // $each operator in mongodb 2.4.4
+ to[key] = exports.clone(fromObj[key], {retainKeyOrder: 1});
+ }
+ }
+ }
+};
+
+/**
+ * Executes a function on each element of an array (like _.each)
+ *
+ * @param {Array} arr
+ * @param {Function} fn
+ * @api private
+ */
+
+exports.each = function(arr, fn) {
+ for (var i = 0; i < arr.length; ++i) {
+ fn(arr[i]);
+ }
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/virtualtype.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/virtualtype.js
new file mode 100644
index 0000000..f43cbe2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/lib/virtualtype.js
@@ -0,0 +1,103 @@
+
+/**
+ * VirtualType constructor
+ *
+ * This is what mongoose uses to define virtual attributes via `Schema.prototype.virtual`.
+ *
+ * ####Example:
+ *
+ * var fullname = schema.virtual('fullname');
+ * fullname instanceof mongoose.VirtualType // true
+ *
+ * @parma {Object} options
+ * @api public
+ */
+
+function VirtualType(options, name) {
+ this.path = name;
+ this.getters = [];
+ this.setters = [];
+ this.options = options || {};
+}
+
+/**
+ * Defines a getter.
+ *
+ * ####Example:
+ *
+ * var virtual = schema.virtual('fullname');
+ * virtual.get(function () {
+ * return this.name.first + ' ' + this.name.last;
+ * });
+ *
+ * @param {Function} fn
+ * @return {VirtualType} this
+ * @api public
+ */
+
+VirtualType.prototype.get = function(fn) {
+ this.getters.push(fn);
+ return this;
+};
+
+/**
+ * Defines a setter.
+ *
+ * ####Example:
+ *
+ * var virtual = schema.virtual('fullname');
+ * virtual.set(function (v) {
+ * var parts = v.split(' ');
+ * this.name.first = parts[0];
+ * this.name.last = parts[1];
+ * });
+ *
+ * @param {Function} fn
+ * @return {VirtualType} this
+ * @api public
+ */
+
+VirtualType.prototype.set = function(fn) {
+ this.setters.push(fn);
+ return this;
+};
+
+/**
+ * Applies getters to `value` using optional `scope`.
+ *
+ * @param {Object} value
+ * @param {Object} scope
+ * @return {any} the value after applying all getters
+ * @api public
+ */
+
+VirtualType.prototype.applyGetters = function(value, scope) {
+ var v = value;
+ for (var l = this.getters.length - 1; l >= 0; l--) {
+ v = this.getters[l].call(scope, v, this);
+ }
+ return v;
+};
+
+/**
+ * Applies setters to `value` using optional `scope`.
+ *
+ * @param {Object} value
+ * @param {Object} scope
+ * @return {any} the value after applying all setters
+ * @api public
+ */
+
+VirtualType.prototype.applySetters = function(value, scope) {
+ var v = value;
+ for (var l = this.setters.length - 1; l >= 0; l--) {
+ v = this.setters[l].call(scope, v, this);
+ }
+ return v;
+};
+
+/*!
+ * exports
+ */
+
+module.exports = VirtualType;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/CHANGELOG.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/CHANGELOG.md
new file mode 100644
index 0000000..a82f6fe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/CHANGELOG.md
@@ -0,0 +1,219 @@
+# v2.1.2
+- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs (#1293).
+
+# v2.1.0
+
+- `retry` and `retryable` now support an optional `errorFilter` function that determines if the `task` should retry on the error (#1256, #1261)
+- Optimized array iteration in `race`, `cargo`, `queue`, and `priorityQueue` (#1253)
+- Added alias documentation to doc site (#1251, #1254)
+- Added [BootStrap scrollspy](http://getbootstrap.com/javascript/#scrollspy) to docs to highlight in the sidebar the current method being viewed (#1289, #1300)
+- Various minor doc fixes (#1263, #1264, #1271, #1278, #1280, #1282, #1302)
+
+# v2.0.1
+
+- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc (#1245, #1246, #1247).
+
+# v2.0.0
+
+Lots of changes here!
+
+First and foremost, we have a slick new [site for docs](https://caolan.github.io/async/). Special thanks to [**@hargasinski**](https://github.com/hargasinski) for his work converting our old docs to `jsdoc` format and implementing the new website. Also huge ups to [**@ivanseidel**](https://github.com/ivanseidel) for designing our new logo. It was a long process for both of these tasks, but I think these changes turned out extraordinary well.
+
+The biggest feature is modularization. You can now `require("async/series")` to only require the `series` function. Every Async library function is available this way. You still can `require("async")` to require the entire library, like you could do before.
+
+We also provide Async as a collection of ES2015 modules. You can now `import {each} from 'async-es'` or `import waterfall from 'async-es/waterfall'`. If you are using only a few Async functions, and are using a ES bundler such as Rollup, this can significantly lower your build size.
+
+Major thanks to [**@Kikobeats**](github.com/Kikobeats), [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for doing the majority of the modularization work, as well as [**@jdalton**](github.com/jdalton) and [**@Rich-Harris**](github.com/Rich-Harris) for advisory work on the general modularization strategy.
+
+Another one of the general themes of the 2.0 release is standardization of what an "async" function is. We are now more strictly following the node-style continuation passing style. That is, an async function is a function that:
+
+1. Takes a variable number of arguments
+2. The last argument is always a callback
+3. The callback can accept any number of arguments
+4. The first argument passed to the callback will be treated as an error result, if the argument is truthy
+5. Any number of result arguments can be passed after the "error" argument
+6. The callback is called once and exactly once, either on the same tick or later tick of the JavaScript event loop.
+
+There were several cases where Async accepted some functions that did not strictly have these properties, most notably `auto`, `every`, `some`, and `filter`.
+
+Another theme is performance. We have eliminated internal deferrals in all cases where they make sense. For example, in `waterfall` and `auto`, there was a `setImmediate` between each task -- these deferrals have been removed. A `setImmediate` call can add up to 1ms of delay. This might not seem like a lot, but it can add up if you are using many Async functions in the course of processing a HTTP request, for example. Nearly all asynchronous functions that do I/O already have some sort of deferral built in, so the extra deferral is unnecessary. The trade-off of this change is removing our built-in stack-overflow defense. Many synchronous callback calls in series can quickly overflow the JS call stack. If you do have a function that is sometimes synchronous (calling its callback on the same tick), and are running into stack overflows, wrap it with `async.ensureAsync()`.
+
+Another big performance win has been re-implementing `queue`, `cargo`, and `priorityQueue` with [doubly linked lists](https://en.wikipedia.org/wiki/Doubly_linked_list) instead of arrays. This has lead to queues being an order of [magnitude faster on large sets of tasks](https://github.com/caolan/async/pull/1205).
+
+## New Features
+
+- Async is now modularized. Individual functions can be `require()`d from the main package. (`require('async/auto')`) (#984, #996)
+- Async is also available as a collection of ES2015 modules in the new `async-es` package. (`import {forEachSeries} from 'async-es'`) (#984, #996)
+- Added `race`, analogous to `Promise.race()`. It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. (#568, #1038)
+- Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to `each`, `map`, `parallel`, etc.. (#579, #839, #1074)
+- Added `mapValues`, for mapping over the properties of an object and returning an object with the same keys. (#1157, #1177)
+- Added `timeout`, a wrapper for an async function that will make the task time-out after the specified time. (#1007, #1027)
+- Added `reflect` and `reflectAll`, analagous to [`Promise.reflect()`](http://bluebirdjs.com/docs/api/reflect.html), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. (#942, #1012, #1095)
+- `constant` supports dynamic arguments -- it will now always use its last argument as the callback. (#1016, #1052)
+- `setImmediate` and `nextTick` now support arguments to partially apply to the deferred function, like the node-native versions do. (#940, #1053)
+- `auto` now supports resolving cyclic dependencies using [Kahn's algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) (#1140).
+- Added `autoInject`, a relative of `auto` that automatically spreads a task's dependencies as arguments to the task function. (#608, #1055, #1099, #1100)
+- You can now limit the concurrency of `auto` tasks. (#635, #637)
+- Added `retryable`, a relative of `retry` that wraps an async function, making it retry when called. (#1058)
+- `retry` now supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies. (#1161)
+- `retry` will now pass all of the arguments the task function was resolved with to the callback (#1231).
+- Added `q.unsaturated` -- callback called when a `queue`'s number of running workers falls below a threshold. (#868, #1030, #1033, #1034)
+- Added `q.error` -- a callback called whenever a `queue` task calls its callback with an error. (#1170)
+- `applyEach` and `applyEachSeries` now pass results to the final callback. (#1088)
+
+## Breaking changes
+
+- Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in `waterfall`. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. (#814, #815, #1048, #1050)
+- `auto` task functions now always take the callback as the last argument. If a task has dependencies, the `results` object will be passed as the first argument. To migrate old task functions, wrap them with [`_.flip`](https://lodash.com/docs#flip) (#1036, #1042)
+- Internal `setImmediate` calls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. Use `ensureAsync` to work around this. (#696, #704, #1049, #1050)
+- `map` used to return an object when iterating over an object. `map` now always returns an array, like in other libraries. The previous object behavior has been split out into `mapValues`. (#1157, #1177)
+- `filter`, `reject`, `some`, `every`, and related functions now expect an error as the first callback argument, rather than just a simple boolean. Pass `null` as the first argument, or use `fs.access` instead of `fs.exists`. (#118, #774, #1028, #1041)
+- `{METHOD}` and `{METHOD}Series` are now implemented in terms of `{METHOD}Limit`. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. (#778, #847)
+- `retry`'s callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task to `series` or `auto`. The partially applied "control-flow" behavior has been separated out into `retryable`. (#1054, #1058)
+- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function (#1217, #1224)
+- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs (#1205).
+- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. (#724, #1078)
+- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays (#1237)
+- Dropped support for Component, Jam, SPM, and Volo (#1175, ##176)
+
+## Bug Fixes
+
+- Improved handling of no dependency cases in `auto` & `autoInject` (#1147).
+- Fixed a bug where the callback generated by `asyncify` with `Promises` could resolve twice (#1197).
+- Fixed several documented optional callbacks not actually being optional (#1223).
+
+## Other
+
+- Added `someSeries` and `everySeries` for symmetry, as well as a complete set of `any`/`anyLimit`/`anySeries` and `all`/`/allLmit`/`allSeries` aliases.
+- Added `find` as an alias for `detect. (as well as `findLimit` and `findSeries`).
+- Various doc fixes (#1005, #1008, #1010, #1015, #1021, #1037, #1039, #1051, #1102, #1107, #1121, #1123, #1129, #1135, #1138, #1141, #1153, #1216, #1217, #1232, #1233, #1236, #1238)
+
+Thank you [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for taking the lead on version 2 of async.
+
+------------------------------------------
+
+# v1.5.2
+- Allow using `"constructor"` as an argument in `memoize` (#998)
+- Give a better error messsage when `auto` dependency checking fails (#994)
+- Various doc updates (#936, #956, #979, #1002)
+
+# v1.5.1
+- Fix issue with `pause` in `queue` with concurrency enabled (#946)
+- `while` and `until` now pass the final result to callback (#963)
+- `auto` will properly handle concurrency when there is no callback (#966)
+- `auto` will no. properly stop execution when an error occurs (#988, #993)
+- Various doc fixes (#971, #980)
+
+# v1.5.0
+
+- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) (#892)
+- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. (#873)
+- `auto` now accepts an optional `concurrency` argument to limit the number o. running tasks (#637)
+- Added `queue#workersList()`, to retrieve the lis. of currently running tasks. (#891)
+- Various code simplifications (#896, #904)
+- Various doc fixes :scroll: (#890, #894, #903, #905, #912)
+
+# v1.4.2
+
+- Ensure coverage files don't get published on npm (#879)
+
+# v1.4.1
+
+- Add in overlooked `detectLimit` method (#866)
+- Removed unnecessary files from npm releases (#861)
+- Removed usage of a reserved word to prevent :boom: in older environments (#870)
+
+# v1.4.0
+
+- `asyncify` now supports promises (#840)
+- Added `Limit` versions of `filter` and `reject` (#836)
+- Add `Limit` versions of `detect`, `some` and `every` (#828, #829)
+- `some`, `every` and `detect` now short circuit early (#828, #829)
+- Improve detection of the global object (#804), enabling use in WebWorkers
+- `whilst` now called with arguments from iterator (#823)
+- `during` now gets called with arguments from iterator (#824)
+- Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0))
+
+
+# v1.3.0
+
+New Features:
+- Added `constant`
+- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. (#671, #806)
+- Added `during` and `doDuring`, which are like `whilst` with an async truth test. (#800)
+- `retry` now accepts an `interval` parameter to specify a delay between retries. (#793)
+- `async` should work better in Web Workers due to better `root` detection (#804)
+- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642)
+- Various internal updates (#786, #801, #802, #803)
+- Various doc fixes (#790, #794)
+
+Bug Fixes:
+- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. (#740, #744, #783)
+
+
+# v1.2.1
+
+Bug Fix:
+
+- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782)
+
+
+# v1.2.0
+
+New Features:
+
+- Added `timesLimit` (#743)
+- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. (#747, #772)
+
+Bug Fixes:
+
+- Fixed a regression in `each` and family with empty arrays that have additional properties. (#775, #777)
+
+
+# v1.1.1
+
+Bug Fix:
+
+- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782)
+
+
+# v1.1.0
+
+New Features:
+
+- `cargo` now supports all of the same methods and event callbacks as `queue`.
+- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. (#769)
+- Optimized `map`, `eachOf`, and `waterfall` families of functions
+- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array (#667).
+- The callback is now optional for the composed results of `compose` and `seq`. (#618)
+- Reduced file size by 4kb, (minified version by 1kb)
+- Added code coverage through `nyc` and `coveralls` (#768)
+
+Bug Fixes:
+
+- `forever` will no longer stack overflow with a synchronous iterator (#622)
+- `eachLimit` and other limit functions will stop iterating once an error occurs (#754)
+- Always pass `null` in callbacks when there is no error (#439)
+- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668)
+- `each` and family will properly handle an empty array (#578)
+- `eachSeries` and family will finish if the underlying array is modified during execution (#557)
+- `queue` will throw if a non-function is passed to `q.push()` (#593)
+- Doc fixes (#629, #766)
+
+
+# v1.0.0
+
+No known breaking changes, we are simply complying with semver from here on out.
+
+Changes:
+
+- Start using a changelog!
+- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321)
+- Detect deadlocks in `auto` (#663)
+- Better support for require.js (#527)
+- Throw if queue created with concurrency `0` (#714)
+- Fix unneeded iteration in `queue.resume()` (#758)
+- Guard against timer mocking overriding `setImmediate` (#609 #611)
+- Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729)
+- Use single noop function internally (#546)
+- Optimize internal `_each`, `_map` and `_keys` functions.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/LICENSE
new file mode 100644
index 0000000..9fe85b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010-2016 Caolan McMahon
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/README.md
new file mode 100644
index 0000000..aece509
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/README.md
@@ -0,0 +1,12 @@
+![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg)
+
+[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)
+[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
+[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
+[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
+
+For Documentation, visit <http://caolan.github.io/async/>
+
+*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/apply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/apply.js
new file mode 100644
index 0000000..c0c8840
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/apply.js
@@ -0,0 +1,62 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ * async.apply(fs.writeFile, 'testfile1', 'test1'),
+ * async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ * function(callback) {
+ * fs.writeFile('testfile1', 'test1', callback);
+ * },
+ * function(callback) {
+ * fs.writeFile('testfile2', 'test2', callback);
+ * }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+exports.default = (0, _baseRest2.default)(function (fn, args) {
+ return (0, _baseRest2.default)(function (callArgs) {
+ return fn.apply(null, args.concat(callArgs));
+ });
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEach.js
new file mode 100644
index 0000000..6865996
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEach.js
@@ -0,0 +1,51 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _applyEach = require('./internal/applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ * buckets,
+ * async.applyEach([enableSearch, updateSchema]),
+ * callback
+ * );
+ */
+exports.default = (0, _applyEach2.default)(_map2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEachSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEachSeries.js
new file mode 100644
index 0000000..989f208
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/applyEachSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _applyEach = require('./internal/applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _mapSeries = require('./mapSeries');
+
+var _mapSeries2 = _interopRequireDefault(_mapSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+exports.default = (0, _applyEach2.default)(_mapSeries2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/asyncify.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/asyncify.js
new file mode 100644
index 0000000..a31fa9f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/asyncify.js
@@ -0,0 +1,93 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = asyncify;
+
+var _isObject = require('lodash/isObject');
+
+var _isObject2 = _interopRequireDefault(_isObject);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2016 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function to convert to an
+ * asynchronous function.
+ * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
+ * (callback).
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es6 example
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return (0, _initialParams2.default)(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
+ result.then(function (value) {
+ callback(null, value);
+ }, function (err) {
+ callback(err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/auto.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/auto.js
new file mode 100644
index 0000000..e1572dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/auto.js
@@ -0,0 +1,285 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (tasks, concurrency, callback) {
+ if (typeof concurrency === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
+ }
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var keys = (0, _keys2.default)(tasks);
+ var numTasks = keys.length;
+ if (!numTasks) {
+ return callback(null);
+ }
+ if (!concurrency) {
+ concurrency = numTasks;
+ }
+
+ var results = {};
+ var runningTasks = 0;
+ var hasError = false;
+
+ var listeners = {};
+
+ var readyTasks = [];
+
+ // for cycle detection:
+ var readyToCheck = []; // tasks that have been identified as reachable
+ // without the possibility of returning to an ancestor task
+ var uncheckedDependencies = {};
+
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ if (!(0, _isArray2.default)(task)) {
+ // no dependencies
+ enqueueTask(key, [task]);
+ readyToCheck.push(key);
+ return;
+ }
+
+ var dependencies = task.slice(0, task.length - 1);
+ var remainingDependencies = dependencies.length;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ readyToCheck.push(key);
+ return;
+ }
+ uncheckedDependencies[key] = remainingDependencies;
+
+ (0, _arrayEach2.default)(dependencies, function (dependencyName) {
+ if (!tasks[dependencyName]) {
+ throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
+ }
+ addListener(dependencyName, function () {
+ remainingDependencies--;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ }
+ });
+ });
+ });
+
+ checkForDeadlocks();
+ processQueue();
+
+ function enqueueTask(key, task) {
+ readyTasks.push(function () {
+ runTask(key, task);
+ });
+ }
+
+ function processQueue() {
+ if (readyTasks.length === 0 && runningTasks === 0) {
+ return callback(null, results);
+ }
+ while (readyTasks.length && runningTasks < concurrency) {
+ var run = readyTasks.shift();
+ run();
+ }
+ }
+
+ function addListener(taskName, fn) {
+ var taskListeners = listeners[taskName];
+ if (!taskListeners) {
+ taskListeners = listeners[taskName] = [];
+ }
+
+ taskListeners.push(fn);
+ }
+
+ function taskComplete(taskName) {
+ var taskListeners = listeners[taskName] || [];
+ (0, _arrayEach2.default)(taskListeners, function (fn) {
+ fn();
+ });
+ processQueue();
+ }
+
+ function runTask(key, task) {
+ if (hasError) return;
+
+ var taskCallback = (0, _onlyOnce2.default)((0, _baseRest2.default)(function (err, args) {
+ runningTasks--;
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ if (err) {
+ var safeResults = {};
+ (0, _baseForOwn2.default)(results, function (val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[key] = args;
+ hasError = true;
+ listeners = [];
+
+ callback(err, safeResults);
+ } else {
+ results[key] = args;
+ taskComplete(key);
+ }
+ }));
+
+ runningTasks++;
+ var taskFn = task[task.length - 1];
+ if (task.length > 1) {
+ taskFn(results, taskCallback);
+ } else {
+ taskFn(taskCallback);
+ }
+ }
+
+ function checkForDeadlocks() {
+ // Kahn's algorithm
+ // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+ // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+ var currentTask;
+ var counter = 0;
+ while (readyToCheck.length) {
+ currentTask = readyToCheck.pop();
+ counter++;
+ (0, _arrayEach2.default)(getDependents(currentTask), function (dependent) {
+ if (--uncheckedDependencies[dependent] === 0) {
+ readyToCheck.push(dependent);
+ }
+ });
+ }
+
+ if (counter !== numTasks) {
+ throw new Error('async.auto cannot execute tasks due to a recursive dependency');
+ }
+ }
+
+ function getDependents(taskName) {
+ var result = [];
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ if ((0, _isArray2.default)(task) && (0, _baseIndexOf2.default)(task, taskName, 0) >= 0) {
+ result.push(key);
+ }
+ });
+ return result;
+ }
+};
+
+var _arrayEach = require('lodash/_arrayEach');
+
+var _arrayEach2 = _interopRequireDefault(_arrayEach);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+var _baseIndexOf = require('lodash/_baseIndexOf');
+
+var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _keys = require('lodash/keys');
+
+var _keys2 = _interopRequireDefault(_keys);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * Determines the best order for running the functions in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the functions pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * Functions also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the function itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ * functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ * passing an `error` (which can be `null`) and the result of the function's
+ * execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ * // this function will just be passed a callback
+ * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ * showData: ['readData', function(results, cb) {
+ * // results.readData is the file's contents
+ * // ...
+ * }]
+ * }, callback);
+ *
+ * async.auto({
+ * get_data: function(callback) {
+ * console.log('in get_data');
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * console.log('in make_folder');
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
+ * console.log('in write_file', JSON.stringify(results));
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(results, callback) {
+ * console.log('in email_link', JSON.stringify(results));
+ * // once the file is written let's email a link to it...
+ * // results.write_file contains the filename returned by write_file.
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ * }]
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('results = ', results);
+ * });
+ */ \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/autoInject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/autoInject.js
new file mode 100644
index 0000000..b9d1eaa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/autoInject.js
@@ -0,0 +1,167 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = autoInject;
+
+var _auto = require('./auto');
+
+var _auto2 = _interopRequireDefault(_auto);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _copyArray = require('lodash/_copyArray');
+
+var _copyArray2 = _interopRequireDefault(_copyArray);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _trim = require('lodash/trim');
+
+var _trim2 = _interopRequireDefault(_trim);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+function parseParams(func) {
+ func = func.toString().replace(STRIP_COMMENTS, '');
+ func = func.match(FN_ARGS)[2].replace(' ', '');
+ func = func ? func.split(FN_ARG_SPLIT) : [];
+ func = func.map(function (arg) {
+ return (0, _trim2.default)(arg.replace(FN_ARG, ''));
+ });
+ return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is a function of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ * when finished, passing an `error` (which can be `null`) and the result of
+ * the function's execution. The remaining parameters name other tasks on
+ * which the task is dependent, and the results from those tasks are the
+ * arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * // The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ * get_data: function(callback) {
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: function(get_data, make_folder, callback) {
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * },
+ * email_link: function(write_file, callback) {
+ * // once the file is written let's email a link to it...
+ * // write_file contains the filename returned by write_file.
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier. To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ * //...
+ * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(write_file, callback) {
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }]
+ * //...
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ */
+function autoInject(tasks, callback) {
+ var newTasks = {};
+
+ (0, _baseForOwn2.default)(tasks, function (taskFn, key) {
+ var params;
+
+ if ((0, _isArray2.default)(taskFn)) {
+ params = (0, _copyArray2.default)(taskFn);
+ taskFn = params.pop();
+
+ newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+ } else if (taskFn.length === 1) {
+ // no dependencies, use the function as-is
+ newTasks[key] = taskFn;
+ } else {
+ params = parseParams(taskFn);
+ if (taskFn.length === 0 && params.length === 0) {
+ throw new Error("autoInject task functions require explicit parameters.");
+ }
+
+ params.pop();
+
+ newTasks[key] = params.concat(newTask);
+ }
+
+ function newTask(results, taskCb) {
+ var newArgs = (0, _arrayMap2.default)(params, function (name) {
+ return results[name];
+ });
+ newArgs.push(taskCb);
+ taskFn.apply(null, newArgs);
+ }
+ });
+
+ (0, _auto2.default)(newTasks, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/bower.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/bower.json
new file mode 100644
index 0000000..7dbeb14
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "async",
+ "main": "dist/async.js",
+ "ignore": [
+ "bower_components",
+ "lib",
+ "mocha_test",
+ "node_modules",
+ "perf",
+ "support",
+ "**/.*",
+ "*.config.js",
+ "*.json",
+ "index.js",
+ "Makefile"
+ ]
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/cargo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/cargo.js
new file mode 100644
index 0000000..70e71a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/cargo.js
@@ -0,0 +1,95 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = cargo;
+
+var _queue = require('./internal/queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing an array
+ * of queued tasks, which must call its `callback(err)` argument when finished,
+ * with an optional `err` argument. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ * for (var i=0; i<tasks.length; i++) {
+ * console.log('hello ' + tasks[i].name);
+ * }
+ * callback();
+ * }, 2);
+ *
+ * // add some items
+ * cargo.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * cargo.push({name: 'bar'}, function(err) {
+ * console.log('finished processing bar');
+ * });
+ * cargo.push({name: 'baz'}, function(err) {
+ * console.log('finished processing baz');
+ * });
+ */
+function cargo(worker, payload) {
+ return (0, _queue2.default)(worker, 1, payload);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/compose.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/compose.js
new file mode 100644
index 0000000..65b26bb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/compose.js
@@ -0,0 +1,55 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _seq = require('./seq');
+
+var _seq2 = _interopRequireDefault(_seq);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Creates a function which is a composition of the passed asynchronous
+ * functions. Each function consumes the return value of the function that
+ * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
+ * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name compose
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} an asynchronous function that is the composed
+ * asynchronous `functions`
+ * @example
+ *
+ * function add1(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n + 1);
+ * }, 10);
+ * }
+ *
+ * function mul3(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n * 3);
+ * }, 10);
+ * }
+ *
+ * var add1mul3 = async.compose(mul3, add1);
+ * add1mul3(4, function (err, result) {
+ * // result now equals 15
+ * });
+ */
+exports.default = (0, _baseRest2.default)(function (args) {
+ return _seq2.default.apply(null, args.reverse());
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concat.js
new file mode 100644
index 0000000..8dc741c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concat.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _concat = require('./internal/concat');
+
+var _concat2 = _interopRequireDefault(_concat);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
+ * the concatenated list. The `iteratee`s are called in parallel, and the
+ * results are concatenated as they return. There is no guarantee that the
+ * results array will be returned in the original order of `coll` passed to the
+ * `iteratee` function.
+ *
+ * @name concat
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @example
+ *
+ * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+ * // files is now a list of filenames that exist in the 3 directories
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_concat2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concatSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concatSeries.js
new file mode 100644
index 0000000..9daf0a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/concatSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _concat = require('./internal/concat');
+
+var _concat2 = _interopRequireDefault(_concat);
+
+var _doSeries = require('./internal/doSeries');
+
+var _doSeries2 = _interopRequireDefault(_doSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
+ *
+ * @name concatSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ */
+exports.default = (0, _doSeries2.default)(_concat2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/constant.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/constant.js
new file mode 100644
index 0000000..d130ca6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/constant.js
@@ -0,0 +1,65 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns a function that when called, calls-back with the values provided.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
+ *
+ * @name constant
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {...*} arguments... - Any number of arguments to automatically invoke
+ * callback with.
+ * @returns {Function} Returns a function that when invoked, automatically
+ * invokes the callback with the previous given arguments.
+ * @example
+ *
+ * async.waterfall([
+ * async.constant(42),
+ * function (value, next) {
+ * // value === 42
+ * },
+ * //...
+ * ], callback);
+ *
+ * async.waterfall([
+ * async.constant(filename, "utf8"),
+ * fs.readFile,
+ * function (fileData, next) {
+ * //...
+ * }
+ * //...
+ * ], callback);
+ *
+ * async.auto({
+ * hostname: async.constant("https://server.net/"),
+ * port: findFreePort,
+ * launchServer: ["hostname", "port", function (options, cb) {
+ * startServer(options, cb);
+ * }],
+ * //...
+ * }, callback);
+ */
+exports.default = (0, _baseRest2.default)(function (values) {
+ var args = [null].concat(values);
+ return (0, _initialParams2.default)(function (ignoredArgs, callback) {
+ return callback.apply(this, args);
+ });
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detect.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detect.js
new file mode 100644
index 0000000..2539ba5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detect.js
@@ -0,0 +1,61 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _findGetResult = require('./internal/findGetResult');
+
+var _findGetResult2 = _interopRequireDefault(_findGetResult);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // result now equals the first file in the list that exists
+ * });
+ */
+exports.default = (0, _createTester2.default)(_eachOf2.default, _identity2.default, _findGetResult2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectLimit.js
new file mode 100644
index 0000000..37aaf53
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectLimit.js
@@ -0,0 +1,48 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _findGetResult = require('./internal/findGetResult');
+
+var _findGetResult2 = _interopRequireDefault(_findGetResult);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+exports.default = (0, _createTester2.default)(_eachOfLimit2.default, _identity2.default, _findGetResult2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectSeries.js
new file mode 100644
index 0000000..686b1ae
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/detectSeries.js
@@ -0,0 +1,46 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _findGetResult = require('./internal/findGetResult');
+
+var _findGetResult2 = _interopRequireDefault(_findGetResult);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+exports.default = (0, _createTester2.default)(_eachOfSeries2.default, _identity2.default, _findGetResult2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dir.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dir.js
new file mode 100644
index 0000000..bfdf41c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dir.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _consoleFunc = require('./internal/consoleFunc');
+
+var _consoleFunc2 = _interopRequireDefault(_consoleFunc);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Logs the result of an `async` function to the `console` using `console.dir`
+ * to display the properties of the resulting object. Only works in Node.js or
+ * in browsers that support `console.dir` and `console.error` (such as FF and
+ * Chrome). If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, {hello: name});
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+exports.default = (0, _consoleFunc2.default)('dir');
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.js
new file mode 100644
index 0000000..bb95651
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.js
@@ -0,0 +1,5427 @@
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.async = global.async || {})));
+}(this, (function (exports) { 'use strict';
+
+/**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+function identity(value) {
+ return value;
+}
+
+/**
+ * A faster alternative to `Function#apply`, this function invokes `func`
+ * with the `this` binding of `thisArg` and the arguments of `args`.
+ *
+ * @private
+ * @param {Function} func The function to invoke.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} args The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+function apply(func, thisArg, args) {
+ switch (args.length) {
+ case 0: return func.call(thisArg);
+ case 1: return func.call(thisArg, args[0]);
+ case 2: return func.call(thisArg, args[0], args[1]);
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
+ }
+ return func.apply(thisArg, args);
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
+}
+
+/**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+function constant(value) {
+ return function() {
+ return value;
+ };
+}
+
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+}
+
+/** `Object#toString` result references. */
+var funcTag = '[object Function]';
+var genTag = '[object GeneratorFunction]';
+var proxyTag = '[object Proxy]';
+
+/** Used for built-in method references. */
+var objectProto$1 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString = objectProto$1.toString;
+
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+function isFunction(value) {
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed array and other constructors.
+ var tag = isObject(value) ? objectToString.call(value) : '';
+ return tag == funcTag || tag == genTag || tag == proxyTag;
+}
+
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+/** Used to detect overreaching core-js shims. */
+var coreJsData = root['__core-js_shared__'];
+
+/** Used to detect methods masquerading as native. */
+var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+}());
+
+/**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+}
+
+/** Used for built-in method references. */
+var funcProto$1 = Function.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString$1 = funcProto$1.toString;
+
+/**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to process.
+ * @returns {string} Returns the source code.
+ */
+function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString$1.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
+ }
+ return '';
+}
+
+/**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
+
+/** Used to detect host constructors (Safari). */
+var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype;
+var objectProto = Object.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Used to detect if a method is native. */
+var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+);
+
+/**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
+ }
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+}
+
+/**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+function getValue(object, key) {
+ return object == null ? undefined : object[key];
+}
+
+/**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+}
+
+var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+}());
+
+/**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
+ });
+};
+
+/** Used to detect hot functions by number of calls within a span of milliseconds. */
+var HOT_COUNT = 500;
+var HOT_SPAN = 16;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeNow = Date.now;
+
+/**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+function shortOut(func) {
+ var count = 0,
+ lastCalled = 0;
+
+ return function() {
+ var stamp = nativeNow(),
+ remaining = HOT_SPAN - (stamp - lastCalled);
+
+ lastCalled = stamp;
+ if (remaining > 0) {
+ if (++count >= HOT_COUNT) {
+ return arguments[0];
+ }
+ } else {
+ count = 0;
+ }
+ return func.apply(undefined, arguments);
+ };
+}
+
+/**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var setToString = shortOut(baseSetToString);
+
+/**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+function baseRest$1(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+}
+
+var initialParams = function (fn) {
+ return baseRest$1(function (args /*..., callback*/) {
+ var callback = args.pop();
+ fn.call(this, args, callback);
+ });
+};
+
+function applyEach$1(eachfn) {
+ return baseRest$1(function (fns, args) {
+ var go = initialParams(function (args, callback) {
+ var that = this;
+ return eachfn(fns, function (fn, cb) {
+ fn.apply(that, args.concat([cb]));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ } else {
+ return go;
+ }
+ });
+}
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+}
+
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop() {
+ // No operation performed.
+}
+
+function once(fn) {
+ return function () {
+ if (fn === null) return;
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+
+var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
+
+var getIterator = function (coll) {
+ return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
+};
+
+/**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+}
+
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+}
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]';
+
+/** Used for built-in method references. */
+var objectProto$4 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$1 = objectProto$4.toString;
+
+/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+function baseIsArguments(value) {
+ return isObjectLike(value) && objectToString$1.call(value) == argsTag;
+}
+
+/** Used for built-in method references. */
+var objectProto$3 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
+
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+};
+
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray = Array.isArray;
+
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse() {
+ return false;
+}
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
+
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+var isBuffer = nativeIsBuffer || stubFalse;
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER$1 = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+/** `Object#toString` result references. */
+var argsTag$1 = '[object Arguments]';
+var arrayTag = '[object Array]';
+var boolTag = '[object Boolean]';
+var dateTag = '[object Date]';
+var errorTag = '[object Error]';
+var funcTag$1 = '[object Function]';
+var mapTag = '[object Map]';
+var numberTag = '[object Number]';
+var objectTag = '[object Object]';
+var regexpTag = '[object RegExp]';
+var setTag = '[object Set]';
+var stringTag = '[object String]';
+var weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]';
+var dataViewTag = '[object DataView]';
+var float32Tag = '[object Float32Array]';
+var float64Tag = '[object Float64Array]';
+var int8Tag = '[object Int8Array]';
+var int16Tag = '[object Int16Array]';
+var int32Tag = '[object Int32Array]';
+var uint8Tag = '[object Uint8Array]';
+var uint8ClampedTag = '[object Uint8ClampedArray]';
+var uint16Tag = '[object Uint16Array]';
+var uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values of typed arrays. */
+var typedArrayTags = {};
+typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+typedArrayTags[uint32Tag] = true;
+typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
+typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
+typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+typedArrayTags[setTag] = typedArrayTags[stringTag] =
+typedArrayTags[weakMapTag] = false;
+
+/** Used for built-in method references. */
+var objectProto$5 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$2 = objectProto$5.toString;
+
+/**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[objectToString$2.call(value)];
+}
+
+/**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+}
+
+/** Detect free variable `exports`. */
+var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
+
+/** Detect free variable `process` from Node.js. */
+var freeProcess = moduleExports$1 && freeGlobal.process;
+
+/** Used to access faster Node.js helpers. */
+var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding('util');
+ } catch (e) {}
+}());
+
+/* Node.js helper references. */
+var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+/** Used for built-in method references. */
+var objectProto$2 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
+
+/**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty$1.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+/** Used for built-in method references. */
+var objectProto$7 = Object.prototype;
+
+/**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
+
+ return value === proto;
+}
+
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeKeys = overArg(Object.keys, Object);
+
+/** Used for built-in method references. */
+var objectProto$6 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$3 = objectProto$6.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+}
+
+function createArrayIterator(coll) {
+ var i = -1;
+ var len = coll.length;
+ return function next() {
+ return ++i < len ? { value: coll[i], key: i } : null;
+ };
+}
+
+function createES2015Iterator(iterator) {
+ var i = -1;
+ return function next() {
+ var item = iterator.next();
+ if (item.done) return null;
+ i++;
+ return { value: item.value, key: i };
+ };
+}
+
+function createObjectIterator(obj) {
+ var okeys = keys(obj);
+ var i = -1;
+ var len = okeys.length;
+ return function next() {
+ var key = okeys[++i];
+ return i < len ? { value: obj[key], key: key } : null;
+ };
+}
+
+function iterator(coll) {
+ if (isArrayLike(coll)) {
+ return createArrayIterator(coll);
+ }
+
+ var iterator = getIterator(coll);
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
+}
+
+function onlyOnce(fn) {
+ return function () {
+ if (fn === null) throw new Error("Callback was already called.");
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+var breakLoop = {};
+
+function _eachOfLimit(limit) {
+ return function (obj, iteratee, callback) {
+ callback = once(callback || noop);
+ if (limit <= 0 || !obj) {
+ return callback(null);
+ }
+ var nextElem = iterator(obj);
+ var done = false;
+ var running = 0;
+
+ function iterateeCallback(err, value) {
+ running -= 1;
+ if (err) {
+ done = true;
+ callback(err);
+ } else if (value === breakLoop || done && running <= 0) {
+ done = true;
+ return callback(null);
+ } else {
+ replenish();
+ }
+ }
+
+ function replenish() {
+ while (running < limit && !done) {
+ var elem = nextElem();
+ if (elem === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
+ }
+ }
+
+ replenish();
+ };
+}
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, iteratee, callback);
+}
+
+function doLimit(fn, limit) {
+ return function (iterable, iteratee, callback) {
+ return fn(iterable, limit, iteratee, callback);
+ };
+}
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = once(callback || noop);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
+ }
+
+ function iteratorCallback(err) {
+ if (err) {
+ callback(err);
+ } else if (++completed === length) {
+ callback(null);
+ }
+ }
+
+ for (; index < length; index++) {
+ iteratee(coll[index], index, onlyOnce(iteratorCallback));
+ }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = doLimit(eachOfLimit, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+var eachOf = function (coll, iteratee, callback) {
+ var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, iteratee, callback);
+};
+
+function doParallel(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(eachOf, obj, iteratee, callback);
+ };
+}
+
+function _asyncMap(eachfn, arr, iteratee, callback) {
+ callback = once(callback || noop);
+ arr = arr || [];
+ var results = [];
+ var counter = 0;
+
+ eachfn(arr, function (value, _, callback) {
+ var index = counter++;
+ iteratee(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array. The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines)
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ * // results is now an array of stats for each file
+ * });
+ */
+var map = doParallel(_asyncMap);
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ * buckets,
+ * async.applyEach([enableSearch, updateSchema]),
+ * callback
+ * );
+ */
+var applyEach = applyEach$1(map);
+
+function doParallelLimit(fn) {
+ return function (obj, limit, iteratee, callback) {
+ return fn(_eachOfLimit(limit), obj, iteratee, callback);
+ };
+}
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a transformed
+ * item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapLimit = doParallelLimit(_asyncMap);
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapSeries = doLimit(mapLimit, 1);
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+var applyEachSeries = applyEach$1(mapSeries);
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ * async.apply(fs.writeFile, 'testfile1', 'test1'),
+ * async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ * function(callback) {
+ * fs.writeFile('testfile1', 'test1', callback);
+ * },
+ * function(callback) {
+ * fs.writeFile('testfile2', 'test2', callback);
+ * }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+var apply$2 = baseRest$1(function (fn, args) {
+ return baseRest$1(function (callArgs) {
+ return fn.apply(null, args.concat(callArgs));
+ });
+});
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2016 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function to convert to an
+ * asynchronous function.
+ * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
+ * (callback).
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es6 example
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return initialParams(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if (isObject(result) && typeof result.then === 'function') {
+ result.then(function (value) {
+ callback(null, value);
+ }, function (err) {
+ callback(err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+
+/**
+ * A specialized version of `_.forEach` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+function arrayEach(array, iteratee) {
+ var index = -1,
+ length = array ? array.length : 0;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
+ }
+ }
+ return array;
+}
+
+/**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+}
+
+/**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+var baseFor = createBaseFor();
+
+/**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+}
+
+/**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+function baseIsNaN(value) {
+ return value !== value;
+}
+
+/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+/**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+}
+
+/**
+ * Determines the best order for running the functions in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the functions pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * Functions also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the function itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ * functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ * passing an `error` (which can be `null`) and the result of the function's
+ * execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ * // this function will just be passed a callback
+ * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ * showData: ['readData', function(results, cb) {
+ * // results.readData is the file's contents
+ * // ...
+ * }]
+ * }, callback);
+ *
+ * async.auto({
+ * get_data: function(callback) {
+ * console.log('in get_data');
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * console.log('in make_folder');
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
+ * console.log('in write_file', JSON.stringify(results));
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(results, callback) {
+ * console.log('in email_link', JSON.stringify(results));
+ * // once the file is written let's email a link to it...
+ * // results.write_file contains the filename returned by write_file.
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ * }]
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('results = ', results);
+ * });
+ */
+var auto = function (tasks, concurrency, callback) {
+ if (typeof concurrency === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
+ }
+ callback = once(callback || noop);
+ var keys$$1 = keys(tasks);
+ var numTasks = keys$$1.length;
+ if (!numTasks) {
+ return callback(null);
+ }
+ if (!concurrency) {
+ concurrency = numTasks;
+ }
+
+ var results = {};
+ var runningTasks = 0;
+ var hasError = false;
+
+ var listeners = {};
+
+ var readyTasks = [];
+
+ // for cycle detection:
+ var readyToCheck = []; // tasks that have been identified as reachable
+ // without the possibility of returning to an ancestor task
+ var uncheckedDependencies = {};
+
+ baseForOwn(tasks, function (task, key) {
+ if (!isArray(task)) {
+ // no dependencies
+ enqueueTask(key, [task]);
+ readyToCheck.push(key);
+ return;
+ }
+
+ var dependencies = task.slice(0, task.length - 1);
+ var remainingDependencies = dependencies.length;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ readyToCheck.push(key);
+ return;
+ }
+ uncheckedDependencies[key] = remainingDependencies;
+
+ arrayEach(dependencies, function (dependencyName) {
+ if (!tasks[dependencyName]) {
+ throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
+ }
+ addListener(dependencyName, function () {
+ remainingDependencies--;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ }
+ });
+ });
+ });
+
+ checkForDeadlocks();
+ processQueue();
+
+ function enqueueTask(key, task) {
+ readyTasks.push(function () {
+ runTask(key, task);
+ });
+ }
+
+ function processQueue() {
+ if (readyTasks.length === 0 && runningTasks === 0) {
+ return callback(null, results);
+ }
+ while (readyTasks.length && runningTasks < concurrency) {
+ var run = readyTasks.shift();
+ run();
+ }
+ }
+
+ function addListener(taskName, fn) {
+ var taskListeners = listeners[taskName];
+ if (!taskListeners) {
+ taskListeners = listeners[taskName] = [];
+ }
+
+ taskListeners.push(fn);
+ }
+
+ function taskComplete(taskName) {
+ var taskListeners = listeners[taskName] || [];
+ arrayEach(taskListeners, function (fn) {
+ fn();
+ });
+ processQueue();
+ }
+
+ function runTask(key, task) {
+ if (hasError) return;
+
+ var taskCallback = onlyOnce(baseRest$1(function (err, args) {
+ runningTasks--;
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ if (err) {
+ var safeResults = {};
+ baseForOwn(results, function (val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[key] = args;
+ hasError = true;
+ listeners = [];
+
+ callback(err, safeResults);
+ } else {
+ results[key] = args;
+ taskComplete(key);
+ }
+ }));
+
+ runningTasks++;
+ var taskFn = task[task.length - 1];
+ if (task.length > 1) {
+ taskFn(results, taskCallback);
+ } else {
+ taskFn(taskCallback);
+ }
+ }
+
+ function checkForDeadlocks() {
+ // Kahn's algorithm
+ // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+ // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+ var currentTask;
+ var counter = 0;
+ while (readyToCheck.length) {
+ currentTask = readyToCheck.pop();
+ counter++;
+ arrayEach(getDependents(currentTask), function (dependent) {
+ if (--uncheckedDependencies[dependent] === 0) {
+ readyToCheck.push(dependent);
+ }
+ });
+ }
+
+ if (counter !== numTasks) {
+ throw new Error('async.auto cannot execute tasks due to a recursive dependency');
+ }
+ }
+
+ function getDependents(taskName) {
+ var result = [];
+ baseForOwn(tasks, function (task, key) {
+ if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
+ result.push(key);
+ }
+ });
+ return result;
+ }
+};
+
+/**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array ? array.length : 0,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+}
+
+/**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+function copyArray(source, array) {
+ var index = -1,
+ length = source.length;
+
+ array || (array = Array(length));
+ while (++index < length) {
+ array[index] = source[index];
+ }
+ return array;
+}
+
+/** Built-in value references. */
+var Symbol$1 = root.Symbol;
+
+/** `Object#toString` result references. */
+var symbolTag = '[object Symbol]';
+
+/** Used for built-in method references. */
+var objectProto$8 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var objectToString$3 = objectProto$8.toString;
+
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && objectToString$3.call(value) == symbolTag);
+}
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
+var symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+/**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+/**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
+ }
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
+
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
+ }
+ return result;
+}
+
+/**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+}
+
+/**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the last unmatched string symbol.
+ */
+function charsEndIndex(strSymbols, chrSymbols) {
+ var index = strSymbols.length;
+
+ while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the first unmatched string symbol.
+ */
+function charsStartIndex(strSymbols, chrSymbols) {
+ var index = -1,
+ length = strSymbols.length;
+
+ while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function asciiToArray(string) {
+ return string.split('');
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff';
+var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
+var rsComboSymbolsRange = '\\u20d0-\\u20f0';
+var rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsZWJ = '\\u200d';
+
+/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
+var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+
+/**
+ * Checks if `string` contains Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
+ */
+function hasUnicode(string) {
+ return reHasUnicode.test(string);
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange$1 = '\\ud800-\\udfff';
+var rsComboMarksRange$1 = '\\u0300-\\u036f\\ufe20-\\ufe23';
+var rsComboSymbolsRange$1 = '\\u20d0-\\u20f0';
+var rsVarRange$1 = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsAstral = '[' + rsAstralRange$1 + ']';
+var rsCombo = '[' + rsComboMarksRange$1 + rsComboSymbolsRange$1 + ']';
+var rsFitz = '\\ud83c[\\udffb-\\udfff]';
+var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
+var rsNonAstral = '[^' + rsAstralRange$1 + ']';
+var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
+var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
+var rsZWJ$1 = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var reOptMod = rsModifier + '?';
+var rsOptVar = '[' + rsVarRange$1 + ']?';
+var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
+var rsSeq = rsOptVar + reOptMod + rsOptJoin;
+var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+/**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+}
+
+/**
+ * Converts `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function stringToArray(string) {
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
+}
+
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+
+/** Used to match leading and trailing whitespace. */
+var reTrim = /^\s+|\s+$/g;
+
+/**
+ * Removes leading and trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trim(' abc ');
+ * // => 'abc'
+ *
+ * _.trim('-_-abc-_-', '_-');
+ * // => 'abc'
+ *
+ * _.map([' foo ', ' bar '], _.trim);
+ * // => ['foo', 'bar']
+ */
+function trim(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrim, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
+
+ return castSlice(strSymbols, start, end).join('');
+}
+
+var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+function parseParams(func) {
+ func = func.toString().replace(STRIP_COMMENTS, '');
+ func = func.match(FN_ARGS)[2].replace(' ', '');
+ func = func ? func.split(FN_ARG_SPLIT) : [];
+ func = func.map(function (arg) {
+ return trim(arg.replace(FN_ARG, ''));
+ });
+ return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is a function of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ * when finished, passing an `error` (which can be `null`) and the result of
+ * the function's execution. The remaining parameters name other tasks on
+ * which the task is dependent, and the results from those tasks are the
+ * arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * // The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ * get_data: function(callback) {
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: function(get_data, make_folder, callback) {
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * },
+ * email_link: function(write_file, callback) {
+ * // once the file is written let's email a link to it...
+ * // write_file contains the filename returned by write_file.
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier. To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ * //...
+ * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(write_file, callback) {
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }]
+ * //...
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ */
+function autoInject(tasks, callback) {
+ var newTasks = {};
+
+ baseForOwn(tasks, function (taskFn, key) {
+ var params;
+
+ if (isArray(taskFn)) {
+ params = copyArray(taskFn);
+ taskFn = params.pop();
+
+ newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+ } else if (taskFn.length === 1) {
+ // no dependencies, use the function as-is
+ newTasks[key] = taskFn;
+ } else {
+ params = parseParams(taskFn);
+ if (taskFn.length === 0 && params.length === 0) {
+ throw new Error("autoInject task functions require explicit parameters.");
+ }
+
+ params.pop();
+
+ newTasks[key] = params.concat(newTask);
+ }
+
+ function newTask(results, taskCb) {
+ var newArgs = arrayMap(params, function (name) {
+ return results[name];
+ });
+ newArgs.push(taskCb);
+ taskFn.apply(null, newArgs);
+ }
+ });
+
+ auto(newTasks, callback);
+}
+
+var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
+var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
+
+function fallback(fn) {
+ setTimeout(fn, 0);
+}
+
+function wrap(defer) {
+ return baseRest$1(function (fn, args) {
+ defer(function () {
+ fn.apply(null, args);
+ });
+ });
+}
+
+var _defer;
+
+if (hasSetImmediate) {
+ _defer = setImmediate;
+} else if (hasNextTick) {
+ _defer = process.nextTick;
+} else {
+ _defer = fallback;
+}
+
+var setImmediate$1 = wrap(_defer);
+
+// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
+// used for queues. This implementation assumes that the node provided by the user can be modified
+// to adjust the next and last properties. We implement only the minimal functionality
+// for queue support.
+function DLL() {
+ this.head = this.tail = null;
+ this.length = 0;
+}
+
+function setInitial(dll, node) {
+ dll.length = 1;
+ dll.head = dll.tail = node;
+}
+
+DLL.prototype.removeLink = function (node) {
+ if (node.prev) node.prev.next = node.next;else this.head = node.next;
+ if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
+
+ node.prev = node.next = null;
+ this.length -= 1;
+ return node;
+};
+
+DLL.prototype.empty = DLL;
+
+DLL.prototype.insertAfter = function (node, newNode) {
+ newNode.prev = node;
+ newNode.next = node.next;
+ if (node.next) node.next.prev = newNode;else this.tail = newNode;
+ node.next = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.insertBefore = function (node, newNode) {
+ newNode.prev = node.prev;
+ newNode.next = node;
+ if (node.prev) node.prev.next = newNode;else this.head = newNode;
+ node.prev = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.unshift = function (node) {
+ if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
+};
+
+DLL.prototype.push = function (node) {
+ if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
+};
+
+DLL.prototype.shift = function () {
+ return this.head && this.removeLink(this.head);
+};
+
+DLL.prototype.pop = function () {
+ return this.tail && this.removeLink(this.tail);
+};
+
+function queue(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ } else if (concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
+ }
+
+ function _insert(data, insertAtFront, callback) {
+ if (callback != null && typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0 && q.idle()) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function () {
+ q.drain();
+ });
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ callback: callback || noop
+ };
+
+ if (insertAtFront) {
+ q._tasks.unshift(item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ setImmediate$1(q.process);
+ }
+
+ function _next(tasks) {
+ return baseRest$1(function (args) {
+ workers -= 1;
+
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ var task = tasks[i];
+ var index = baseIndexOf(workersList, task, 0);
+ if (index >= 0) {
+ workersList.splice(index);
+ }
+
+ task.callback.apply(task, args);
+
+ if (args[0] != null) {
+ q.error(args[0], task.data);
+ }
+ }
+
+ if (workers <= q.concurrency - q.buffer) {
+ q.unsaturated();
+ }
+
+ if (q.idle()) {
+ q.drain();
+ }
+ q.process();
+ });
+ }
+
+ var workers = 0;
+ var workersList = [];
+ var q = {
+ _tasks: new DLL(),
+ concurrency: concurrency,
+ payload: payload,
+ saturated: noop,
+ unsaturated: noop,
+ buffer: concurrency / 4,
+ empty: noop,
+ drain: noop,
+ error: noop,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(data, false, callback);
+ },
+ kill: function () {
+ q.drain = noop;
+ q._tasks.empty();
+ },
+ unshift: function (data, callback) {
+ _insert(data, true, callback);
+ },
+ process: function () {
+ while (!q.paused && workers < q.concurrency && q._tasks.length) {
+ var tasks = [],
+ data = [];
+ var l = q._tasks.length;
+ if (q.payload) l = Math.min(l, q.payload);
+ for (var i = 0; i < l; i++) {
+ var node = q._tasks.shift();
+ tasks.push(node);
+ data.push(node.data);
+ }
+
+ if (q._tasks.length === 0) {
+ q.empty();
+ }
+ workers += 1;
+ workersList.push(tasks[0]);
+
+ if (workers === q.concurrency) {
+ q.saturated();
+ }
+
+ var cb = onlyOnce(_next(tasks));
+ worker(data, cb);
+ }
+ },
+ length: function () {
+ return q._tasks.length;
+ },
+ running: function () {
+ return workers;
+ },
+ workersList: function () {
+ return workersList;
+ },
+ idle: function () {
+ return q._tasks.length + workers === 0;
+ },
+ pause: function () {
+ q.paused = true;
+ },
+ resume: function () {
+ if (q.paused === false) {
+ return;
+ }
+ q.paused = false;
+ var resumeCount = Math.min(q.concurrency, q._tasks.length);
+ // Need to call q.process once per concurrent
+ // worker to preserve full concurrency after pause
+ for (var w = 1; w <= resumeCount; w++) {
+ setImmediate$1(q.process);
+ }
+ }
+ };
+ return q;
+}
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing an array
+ * of queued tasks, which must call its `callback(err)` argument when finished,
+ * with an optional `err` argument. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ * for (var i=0; i<tasks.length; i++) {
+ * console.log('hello ' + tasks[i].name);
+ * }
+ * callback();
+ * }, 2);
+ *
+ * // add some items
+ * cargo.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * cargo.push({name: 'bar'}, function(err) {
+ * console.log('finished processing bar');
+ * });
+ * cargo.push({name: 'baz'}, function(err) {
+ * console.log('finished processing baz');
+ * });
+ */
+function cargo(worker, payload) {
+ return queue(worker, 1, payload);
+}
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * `key` is the item's key, or index in the case of an array. The iteratee is
+ * passed a `callback(err)` which must be called once it has completed. If no
+ * error has occurred, the callback should be run without arguments or with an
+ * explicit `null` argument. Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+var eachOfSeries = doLimit(eachOfLimit, 1);
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = once(callback || noop);
+ eachOfSeries(coll, function (x, i, callback) {
+ iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ * var User = request.models.User;
+ * async.seq(
+ * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
+ * function(user, fn) {
+ * user.getCats(fn); // 'getCats' has signature (callback(err, data))
+ * }
+ * )(req.session.user_id, function (err, cats) {
+ * if (err) {
+ * console.error(err);
+ * response.json({ status: 'error', message: err.message });
+ * } else {
+ * response.json({ status: 'ok', message: 'Cats found', data: cats });
+ * }
+ * });
+ * });
+ */
+var seq$1 = baseRest$1(function seq(functions) {
+ return baseRest$1(function (args) {
+ var that = this;
+
+ var cb = args[args.length - 1];
+ if (typeof cb == 'function') {
+ args.pop();
+ } else {
+ cb = noop;
+ }
+
+ reduce(functions, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat([baseRest$1(function (err, nextargs) {
+ cb(err, nextargs);
+ })]));
+ }, function (err, results) {
+ cb.apply(that, [err].concat(results));
+ });
+ });
+});
+
+/**
+ * Creates a function which is a composition of the passed asynchronous
+ * functions. Each function consumes the return value of the function that
+ * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
+ * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name compose
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} an asynchronous function that is the composed
+ * asynchronous `functions`
+ * @example
+ *
+ * function add1(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n + 1);
+ * }, 10);
+ * }
+ *
+ * function mul3(n, callback) {
+ * setTimeout(function () {
+ * callback(null, n * 3);
+ * }, 10);
+ * }
+ *
+ * var add1mul3 = async.compose(mul3, add1);
+ * add1mul3(4, function (err, result) {
+ * // result now equals 15
+ * });
+ */
+var compose = baseRest$1(function (args) {
+ return seq$1.apply(null, args.reverse());
+});
+
+function concat$1(eachfn, arr, fn, callback) {
+ var result = [];
+ eachfn(arr, function (x, index, cb) {
+ fn(x, function (err, y) {
+ result = result.concat(y || []);
+ cb(err);
+ });
+ }, function (err) {
+ callback(err, result);
+ });
+}
+
+/**
+ * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
+ * the concatenated list. The `iteratee`s are called in parallel, and the
+ * results are concatenated as they return. There is no guarantee that the
+ * results array will be returned in the original order of `coll` passed to the
+ * `iteratee` function.
+ *
+ * @name concat
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @example
+ *
+ * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+ * // files is now a list of filenames that exist in the 3 directories
+ * });
+ */
+var concat = doParallel(concat$1);
+
+function doSeries(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(eachOfSeries, obj, iteratee, callback);
+ };
+}
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
+ *
+ * @name concatSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, results)` which must be called once
+ * it has completed with an error (which can be `null`) and an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ */
+var concatSeries = doSeries(concat$1);
+
+/**
+ * Returns a function that when called, calls-back with the values provided.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
+ *
+ * @name constant
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {...*} arguments... - Any number of arguments to automatically invoke
+ * callback with.
+ * @returns {Function} Returns a function that when invoked, automatically
+ * invokes the callback with the previous given arguments.
+ * @example
+ *
+ * async.waterfall([
+ * async.constant(42),
+ * function (value, next) {
+ * // value === 42
+ * },
+ * //...
+ * ], callback);
+ *
+ * async.waterfall([
+ * async.constant(filename, "utf8"),
+ * fs.readFile,
+ * function (fileData, next) {
+ * //...
+ * }
+ * //...
+ * ], callback);
+ *
+ * async.auto({
+ * hostname: async.constant("https://server.net/"),
+ * port: findFreePort,
+ * launchServer: ["hostname", "port", function (options, cb) {
+ * startServer(options, cb);
+ * }],
+ * //...
+ * }, callback);
+ */
+var constant$2 = baseRest$1(function (values) {
+ var args = [null].concat(values);
+ return initialParams(function (ignoredArgs, callback) {
+ return callback.apply(this, args);
+ });
+});
+
+function _createTester(eachfn, check, getResult) {
+ return function (arr, limit, iteratee, cb) {
+ function done() {
+ if (cb) {
+ cb(null, getResult(false));
+ }
+ }
+ function wrappedIteratee(x, _, callback) {
+ if (!cb) return callback();
+ iteratee(x, function (err, v) {
+ // Check cb as another iteratee may have resolved with a
+ // value or error since we started this iteratee
+ if (cb && (err || check(v))) {
+ if (err) cb(err);else cb(err, getResult(true, x));
+ cb = iteratee = false;
+ callback(err, breakLoop);
+ } else {
+ callback();
+ }
+ });
+ }
+ if (arguments.length > 3) {
+ cb = cb || noop;
+ eachfn(arr, limit, wrappedIteratee, done);
+ } else {
+ cb = iteratee;
+ cb = cb || noop;
+ iteratee = limit;
+ eachfn(arr, wrappedIteratee, done);
+ }
+ };
+}
+
+function _findGetResult(v, x) {
+ return x;
+}
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // result now equals the first file in the list that exists
+ * });
+ */
+var detect = _createTester(eachOf, identity, _findGetResult);
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, truthValue)` which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
+
+function consoleFunc(name) {
+ return baseRest$1(function (fn, args) {
+ fn.apply(null, args.concat([baseRest$1(function (err, args) {
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ } else if (console[name]) {
+ arrayEach(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ })]));
+ });
+}
+
+/**
+ * Logs the result of an `async` function to the `console` using `console.dir`
+ * to display the properties of the resulting object. Only works in Node.js or
+ * in browsers that support `console.dir` and `console.error` (such as FF and
+ * Chrome). If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, {hello: name});
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+var dir = consoleFunc('dir');
+
+/**
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
+ * the order of operations, the arguments `test` and `fn` are switched.
+ *
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
+ * @name doDuring
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error if one occured, otherwise `null`.
+ */
+function doDuring(fn, test, callback) {
+ callback = onlyOnce(callback || noop);
+
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ args.push(check);
+ test.apply(this, args);
+ });
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
+
+ check(null, true);
+}
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} iteratee - A function which is called each time `test`
+ * passes. The function is passed a `callback(err)`, which must be called once
+ * it has completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with the non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ */
+function doWhilst(iteratee, test, callback) {
+ callback = onlyOnce(callback || noop);
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ if (test.apply(this, args)) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `fn`. Invoked with the non-error callback results of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function doUntil(fn, test, callback) {
+ doWhilst(fn, function () {
+ return !test.apply(this, arguments);
+ }, callback);
+}
+
+/**
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
+ * is passed a callback in the form of `function (err, truth)`. If error is
+ * passed to `test` or `fn`, the main callback is immediately called with the
+ * value of the error.
+ *
+ * @name during
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (callback).
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error, if one occured, otherwise `null`.
+ * @example
+ *
+ * var count = 0;
+ *
+ * async.during(
+ * function (callback) {
+ * return callback(null, count < 5);
+ * },
+ * function (callback) {
+ * count++;
+ * setTimeout(callback, 1000);
+ * },
+ * function (err) {
+ * // 5 seconds have passed
+ * }
+ * );
+ */
+function during(test, fn, callback) {
+ callback = onlyOnce(callback || noop);
+
+ function next(err) {
+ if (err) return callback(err);
+ test(check);
+ }
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
+
+ test(check);
+}
+
+function _withoutIndex(iteratee) {
+ return function (value, index, callback) {
+ return iteratee(value, callback);
+ };
+}
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item
+ * in `coll`. The iteratee is passed a `callback(err)` which must be called once
+ * it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is not
+ * passed to the iteratee. Invoked with (item, callback). If you need the index,
+ * use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ * // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ * // Perform operation on file here.
+ * console.log('Processing file ' + file);
+ *
+ * if( file.length > 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ eachOf(coll, _withoutIndex(iteratee), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * iteratee is passed a `callback(err)` which must be called once it has
+ * completed. If no error has occurred, the `callback` should be run without
+ * arguments or with an explicit `null` argument. The array index is not passed
+ * to the iteratee. Invoked with (item, callback). If you need the index, use
+ * `eachOfLimit`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit$1(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, _withoutIndex(iteratee), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The iteratee is passed a `callback(err)` which must be called
+ * once it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is
+ * not passed to the iteratee. Invoked with (item, callback). If you need the
+ * index, use `eachOfSeries`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+var eachSeries = doLimit(eachLimit$1, 1);
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop. If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {Function} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ * if (cache[arg]) {
+ * return callback(null, cache[arg]); // this would be synchronous!!
+ * } else {
+ * doSomeIO(arg, callback); // this IO would be asynchronous
+ * }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+function ensureAsync(fn) {
+ return initialParams(function (args, callback) {
+ var sync = true;
+ args.push(function () {
+ var innerArgs = arguments;
+ if (sync) {
+ setImmediate$1(function () {
+ callback.apply(null, innerArgs);
+ });
+ } else {
+ callback.apply(null, innerArgs);
+ }
+ });
+ fn.apply(this, args);
+ sync = false;
+ });
+}
+
+function notId(v) {
+ return !v;
+}
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+var every = _createTester(eachOf, notId, notId);
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everyLimit = _createTester(eachOfLimit, notId, notId);
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everySeries = doLimit(everyLimit, 1);
+
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+function _filter(eachfn, arr, iteratee, callback) {
+ callback = once(callback || noop);
+ var results = [];
+ eachfn(arr, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ if (err) {
+ callback(err);
+ } else {
+ if (v) {
+ results.push({ index: index, value: x });
+ }
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ callback(null, arrayMap(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), baseProperty('value')));
+ }
+ });
+}
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+var filter = doParallel(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var filterLimit = doParallelLimit(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+var filterSeries = doLimit(filterLimit, 1);
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the
+ * callback then `errback` is called with the error, and execution stops,
+ * otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} fn - a function to call repeatedly. Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ * function(next) {
+ * // next is suitable for passing to things that need a callback(err [, whatever]);
+ * // it will result in this function being called again.
+ * },
+ * function(err) {
+ * // if next is called with a value in its first parameter, it will appear
+ * // in here as 'err', and execution will stop.
+ * }
+ * );
+ */
+function forever(fn, errback) {
+ var done = onlyOnce(errback || noop);
+ var task = ensureAsync(fn);
+
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+}
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, 'hello ' + name);
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+var log = consoleFunc('log');
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+ callback = once(callback || noop);
+ var newObj = {};
+ eachOfLimit(obj, limit, function (val, key, next) {
+ iteratee(val, key, function (err, result) {
+ if (err) return next(err);
+ newObj[key] = result;
+ next();
+ });
+ }, function (err) {
+ callback(err, newObj);
+ });
+}
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed. The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value and key in
+ * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
+ * called once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ * f1: 'file1',
+ * f2: 'file2',
+ * f3: 'file3'
+ * }, function (file, key, callback) {
+ * fs.stat(file, callback);
+ * }, function(err, result) {
+ * // result is now a map of stats for each file, e.g.
+ * // {
+ * // f1: [stats for file1],
+ * // f2: [stats for file2],
+ * // f3: [stats for file3]
+ * // }
+ * });
+ */
+
+var mapValues = doLimit(mapValuesLimit, Infinity);
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+var mapValuesSeries = doLimit(mapValuesLimit, 1);
+
+function has(obj, key) {
+ return key in obj;
+}
+
+/**
+ * Caches the results of an `async` function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {Function} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ * // do something
+ * callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ * // callback
+ * });
+ */
+function memoize(fn, hasher) {
+ var memo = Object.create(null);
+ var queues = Object.create(null);
+ hasher = hasher || identity;
+ var memoized = initialParams(function memoized(args, callback) {
+ var key = hasher.apply(null, args);
+ if (has(memo, key)) {
+ setImmediate$1(function () {
+ callback.apply(null, memo[key]);
+ });
+ } else if (has(queues, key)) {
+ queues[key].push(callback);
+ } else {
+ queues[key] = [callback];
+ fn.apply(null, args.concat([baseRest$1(function (args) {
+ memo[key] = args;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, args);
+ }
+ })]));
+ }
+ });
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+}
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias setImmediate
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer$1;
+
+if (hasNextTick) {
+ _defer$1 = process.nextTick;
+} else if (hasSetImmediate) {
+ _defer$1 = setImmediate;
+} else {
+ _defer$1 = fallback;
+}
+
+var nextTick = wrap(_defer$1);
+
+function _parallel(eachfn, tasks, callback) {
+ callback = callback || noop;
+ var results = isArrayLike(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ task(baseRest$1(function (err, args) {
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[key] = args;
+ callback(err);
+ }));
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code. If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series. Any synchronous setup
+ * sections for each task will happen one after the other. JavaScript remains
+ * single-threaded.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ * @example
+ * async.parallel([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // the results array will equal ['one','two'] even though
+ * // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+function parallelLimit(tasks, callback) {
+ _parallel(eachOf, tasks, callback);
+}
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Collection} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+function parallelLimit$1(tasks, limit, callback) {
+ _parallel(_eachOfLimit(limit), tasks, callback);
+}
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel. If omitted, the concurrency
+ * defaults to `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ * console.log('hello ' + task.name);
+ * callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ * console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ * console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ */
+var queue$1 = function (worker, concurrency) {
+ return queue(function (items, cb) {
+ worker(items[0], cb);
+ }, concurrency, 1);
+};
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel. If omitted, the concurrency defaults to
+ * `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ * array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */
+var priorityQueue = function (worker, concurrency) {
+ // Start with a normal queue
+ var q = queue$1(worker, concurrency);
+
+ // Override push to accept second parameter representing priority
+ q.push = function (data, priority, callback) {
+ if (callback == null) callback = noop;
+ if (typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function () {
+ q.drain();
+ });
+ }
+
+ priority = priority || 0;
+ var nextNode = q._tasks.head;
+ while (nextNode && priority >= nextNode.priority) {
+ nextNode = nextNode.next;
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ priority: priority,
+ callback: callback
+ };
+
+ if (nextNode) {
+ q._tasks.insertBefore(nextNode, item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ setImmediate$1(q.process);
+ };
+
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+};
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing functions to run. Each function
+ * is passed a `callback(err, result)` which it must call on completion with an
+ * error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // main callback
+ * function(err, result) {
+ * // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+ callback = once(callback || noop);
+ if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+ if (!tasks.length) return callback();
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ tasks[i](callback);
+ }
+}
+
+var slice = Array.prototype.slice;
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight(array, memo, iteratee, callback) {
+ var reversed = slice.call(array).reverse();
+ reduce(reversed, memo, iteratee, callback);
+}
+
+/**
+ * Wraps the function in another function that always returns data even when it
+ * errors.
+ *
+ * The object returned has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ * async.reflect(function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff but error ...
+ * callback('bad stuff happened');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = 'bad stuff happened'
+ * // results[2].value = 'two'
+ * });
+ */
+function reflect(fn) {
+ return initialParams(function reflectOn(args, reflectCallback) {
+ args.push(baseRest$1(function callback(err, cbArgs) {
+ if (err) {
+ reflectCallback(null, {
+ error: err
+ });
+ } else {
+ var value = null;
+ if (cbArgs.length === 1) {
+ value = cbArgs[0];
+ } else if (cbArgs.length > 1) {
+ value = cbArgs;
+ }
+ reflectCallback(null, {
+ value: value
+ });
+ }
+ }));
+
+ return fn.apply(this, args);
+ });
+}
+
+function reject$1(eachfn, arr, iteratee, callback) {
+ _filter(eachfn, arr, function (value, cb) {
+ iteratee(value, function (err, v) {
+ if (err) {
+ cb(err);
+ } else {
+ cb(null, !v);
+ }
+ });
+ }, callback);
+}
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of missing files
+ * createFiles(results);
+ * });
+ */
+var reject = doParallel(reject$1);
+
+/**
+ * A helper function that wraps an array or an object of functions with reflect.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of functions, each function wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * // do some more stuff but error ...
+ * callback(new Error('bad stuff happened'));
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = Error('bad stuff happened')
+ * // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * callback('two');
+ * },
+ * three: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'three');
+ * }, 100);
+ * }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results.one.value = 'one'
+ * // results.two.error = 'two'
+ * // results.three.value = 'three'
+ * });
+ */
+function reflectAll(tasks) {
+ var results;
+ if (isArray(tasks)) {
+ results = arrayMap(tasks, reflect);
+ } else {
+ results = {};
+ baseForOwn(tasks, function (task, key) {
+ results[key] = reflect.call(this, task);
+ });
+ }
+ return results;
+}
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectLimit = doParallelLimit(reject$1);
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectSeries = doLimit(rejectLimit, 1);
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up. The default
+ * is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds. The
+ * default is `0`. The interval may also be specified as a function of the
+ * retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ * erroneous result. If it returns `true` the retry attempts will continue;
+ * if the function returns `false` the retry flow is aborted with the current
+ * attempt's error and result being returned to the final callback.
+ * Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ * with the default interval of `0`.
+ * @param {Function} task - A function which receives two arguments: (1) a
+ * `callback(err, result)` which must be called when finished, passing `err`
+ * (which can be `null`) and the `result` of the function's execution, and (2)
+ * a `results` object, containing the results of the previously executed
+ * functions (if nested inside another control flow). Invoked with
+ * (callback, results).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ * times: 10,
+ * interval: function(retryCount) {
+ * return 50 * Math.pow(2, retryCount);
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ * errorFilter: function(err) {
+ * return err.message === 'Temporary error'; // only retry on a specific error
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // It can also be embedded within other control flow functions to retry
+ * // individual methods that are not as reliable, like this:
+ * async.auto({
+ * users: api.getUsers.bind(api),
+ * payments: async.retry(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ * // do something with the results
+ * });
+ *
+ */
+function retry(opts, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
+
+ var options = {
+ times: DEFAULT_TIMES,
+ intervalFunc: constant(DEFAULT_INTERVAL)
+ };
+
+ function parseTimes(acc, t) {
+ if (typeof t === 'object') {
+ acc.times = +t.times || DEFAULT_TIMES;
+
+ acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant(+t.interval || DEFAULT_INTERVAL);
+
+ acc.errorFilter = t.errorFilter;
+ } else if (typeof t === 'number' || typeof t === 'string') {
+ acc.times = +t || DEFAULT_TIMES;
+ } else {
+ throw new Error("Invalid arguments for async.retry");
+ }
+ }
+
+ if (arguments.length < 3 && typeof opts === 'function') {
+ callback = task || noop;
+ task = opts;
+ } else {
+ parseTimes(options, opts);
+ callback = callback || noop;
+ }
+
+ if (typeof task !== 'function') {
+ throw new Error("Invalid arguments for async.retry");
+ }
+
+ var attempt = 1;
+ function retryAttempt() {
+ task(function (err) {
+ if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
+ setTimeout(retryAttempt, options.intervalFunc(attempt));
+ } else {
+ callback.apply(null, arguments);
+ }
+ });
+ }
+
+ retryAttempt();
+}
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
+ * retryable, rather than immediately calling it with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {Function} task - the asynchronous function to wrap
+ * @returns {Functions} The wrapped function, which when invoked, will retry on
+ * an error, based on the parameters specified in `opts`.
+ * @example
+ *
+ * async.auto({
+ * dep1: async.retryable(3, getFromFlakyService),
+ * process: ["dep1", async.retryable(3, function (results, cb) {
+ * maybeProcessData(results.dep1, cb);
+ * })]
+ * }, callback);
+ */
+var retryable = function (opts, task) {
+ if (!task) {
+ task = opts;
+ opts = null;
+ }
+ return initialParams(function (args, callback) {
+ function taskFn(cb) {
+ task.apply(null, args.concat([cb]));
+ }
+
+ if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
+ });
+};
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each
+ * function is passed a `callback(err, result)` it must call on completion with
+ * an error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ * function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * },
+ * function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback){
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+function series(tasks, callback) {
+ _parallel(eachOfSeries, tasks, callback);
+}
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+var some = _createTester(eachOf, Boolean, identity);
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someLimit = _createTester(eachOfLimit, Boolean, identity);
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someSeries = doLimit(someLimit, 1);
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, sortValue)` which must be called once
+ * it has completed with an error (which can be `null`) and a value to use as
+ * the sort criteria. Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ * fs.stat(file, function(err, stats) {
+ * callback(err, stats.mtime);
+ * });
+ * }, function(err, results) {
+ * // results is now the original array of files sorted by
+ * // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x);
+ * }, function(err,result) {
+ * // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ * // result callback
+ * });
+ */
+function sortBy(coll, iteratee, callback) {
+ map(coll, function (x, callback) {
+ iteratee(x, function (err, criteria) {
+ if (err) return callback(err);
+ callback(null, { value: x, criteria: criteria });
+ });
+ }, function (err, results) {
+ if (err) return callback(err);
+ callback(null, arrayMap(results.sort(comparator), baseProperty('value')));
+ });
+
+ function comparator(left, right) {
+ var a = left.criteria,
+ b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+}
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} asyncFn - The asynchronous function you want to set the
+ * time limit.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {Function} Returns a wrapped function that can be used with any of
+ * the control flow functions. Invoke this function with the same
+ * parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ * doAsyncTask(foo, function(err, data) {
+ * // handle errors
+ * if (err) return callback(err);
+ *
+ * // do some stuff ...
+ *
+ * // return processed data
+ * return callback(null, data);
+ * });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ * // if `myFunction` takes < 1000 ms to execute, `err`
+ * // and `data` will have their expected values
+ *
+ * // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+function timeout(asyncFn, milliseconds, info) {
+ var originalCallback, timer;
+ var timedOut = false;
+
+ function injectedCallback() {
+ if (!timedOut) {
+ originalCallback.apply(null, arguments);
+ clearTimeout(timer);
+ }
+ }
+
+ function timeoutCallback() {
+ var name = asyncFn.name || 'anonymous';
+ var error = new Error('Callback function "' + name + '" timed out.');
+ error.code = 'ETIMEDOUT';
+ if (info) {
+ error.info = info;
+ }
+ timedOut = true;
+ originalCallback(error);
+ }
+
+ return initialParams(function (args, origCallback) {
+ originalCallback = origCallback;
+ // setup timer and call original function
+ timer = setTimeout(timeoutCallback, milliseconds);
+ asyncFn.apply(null, args.concat(injectedCallback));
+ });
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil;
+var nativeMax$1 = Math.max;
+
+/**
+ * The base implementation of `_.range` and `_.rangeRight` which doesn't
+ * coerce arguments.
+ *
+ * @private
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} step The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the range of numbers.
+ */
+function baseRange(start, end, step, fromRight) {
+ var index = -1,
+ length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
+
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
+ }
+ return result;
+}
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+function timeLimit(count, limit, iteratee, callback) {
+ mapLimit(baseRange(0, count, 1), limit, iteratee, callback);
+}
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ * callback(null, {
+ * id: 'user' + id
+ * });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ * createUser(n, function(err, user) {
+ * next(err, user);
+ * });
+ * }, function(err, users) {
+ * // we should now have 5 users
+ * });
+ */
+var times = doLimit(timeLimit, Infinity);
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+var timesSeries = doLimit(timeLimit, 1);
+
+/**
+ * A relative of `reduce`. Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform. If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {Function} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator. The `iteratee` is
+ * passed a `callback(err)` which accepts an optional error as its first
+ * argument. If an error is passed to the callback, the transform is stopped
+ * and the main `callback` is immediately called with the error.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * acc.push(item * 2)
+ * callback(null)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ * setImmediate(function () {
+ * obj[key] = val * 2;
+ * callback();
+ * })
+ * }, function (err, result) {
+ * // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+function transform(coll, accumulator, iteratee, callback) {
+ if (arguments.length === 3) {
+ callback = iteratee;
+ iteratee = accumulator;
+ accumulator = isArray(coll) ? [] : {};
+ }
+ callback = once(callback || noop);
+
+ eachOf(coll, function (v, k, cb) {
+ iteratee(accumulator, v, k, cb);
+ }, function (err) {
+ callback(err, accumulator);
+ });
+}
+
+/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {Function} fn - the memoized function
+ * @returns {Function} a function that calls the original unmemoized function
+ */
+function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+}
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {Function} iteratee - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ * function() { return count < 5; },
+ * function(callback) {
+ * count++;
+ * setTimeout(function() {
+ * callback(null, count);
+ * }, 1000);
+ * },
+ * function (err, n) {
+ * // 5 seconds have passed, n = 5
+ * }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+ callback = onlyOnce(callback || noop);
+ if (!test()) return callback(null);
+ var next = baseRest$1(function (err, args) {
+ if (err) return callback(err);
+ if (test()) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+
+/**
+ * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `fn`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `fn`. Invoked with ().
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function until(test, fn, callback) {
+ whilst(function () {
+ return !test.apply(this, arguments);
+ }, fn, callback);
+}
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of functions to run, each function is passed
+ * a `callback(err, result1, result2, ...)` it must call on completion. The
+ * first argument is an error (which can be `null`) and any further arguments
+ * will be passed as arguments in order to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ * function(callback) {
+ * callback(null, 'one', 'two');
+ * },
+ * function(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * },
+ * function(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ * myFirstFunction,
+ * mySecondFunction,
+ * myLastFunction,
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ * callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ */
+var waterfall = function (tasks, callback) {
+ callback = once(callback || noop);
+ if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+ if (!tasks.length) return callback();
+ var taskIndex = 0;
+
+ function nextTask(args) {
+ if (taskIndex === tasks.length) {
+ return callback.apply(null, [null].concat(args));
+ }
+
+ var taskCallback = onlyOnce(baseRest$1(function (err, args) {
+ if (err) {
+ return callback.apply(null, [err].concat(args));
+ }
+ nextTask(args);
+ }));
+
+ args.push(taskCallback);
+
+ var task = tasks[taskIndex++];
+ task.apply(null, args);
+ }
+
+ nextTask([]);
+};
+
+/**
+ * Async is a utility module which provides straight-forward, powerful functions
+ * for working with asynchronous JavaScript. Although originally designed for
+ * use with [Node.js](http://nodejs.org) and installable via
+ * `npm install --save async`, it can also be used directly in the browser.
+ * @module async
+ */
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+/**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
+var index = {
+ applyEach: applyEach,
+ applyEachSeries: applyEachSeries,
+ apply: apply$2,
+ asyncify: asyncify,
+ auto: auto,
+ autoInject: autoInject,
+ cargo: cargo,
+ compose: compose,
+ concat: concat,
+ concatSeries: concatSeries,
+ constant: constant$2,
+ detect: detect,
+ detectLimit: detectLimit,
+ detectSeries: detectSeries,
+ dir: dir,
+ doDuring: doDuring,
+ doUntil: doUntil,
+ doWhilst: doWhilst,
+ during: during,
+ each: eachLimit,
+ eachLimit: eachLimit$1,
+ eachOf: eachOf,
+ eachOfLimit: eachOfLimit,
+ eachOfSeries: eachOfSeries,
+ eachSeries: eachSeries,
+ ensureAsync: ensureAsync,
+ every: every,
+ everyLimit: everyLimit,
+ everySeries: everySeries,
+ filter: filter,
+ filterLimit: filterLimit,
+ filterSeries: filterSeries,
+ forever: forever,
+ log: log,
+ map: map,
+ mapLimit: mapLimit,
+ mapSeries: mapSeries,
+ mapValues: mapValues,
+ mapValuesLimit: mapValuesLimit,
+ mapValuesSeries: mapValuesSeries,
+ memoize: memoize,
+ nextTick: nextTick,
+ parallel: parallelLimit,
+ parallelLimit: parallelLimit$1,
+ priorityQueue: priorityQueue,
+ queue: queue$1,
+ race: race,
+ reduce: reduce,
+ reduceRight: reduceRight,
+ reflect: reflect,
+ reflectAll: reflectAll,
+ reject: reject,
+ rejectLimit: rejectLimit,
+ rejectSeries: rejectSeries,
+ retry: retry,
+ retryable: retryable,
+ seq: seq$1,
+ series: series,
+ setImmediate: setImmediate$1,
+ some: some,
+ someLimit: someLimit,
+ someSeries: someSeries,
+ sortBy: sortBy,
+ timeout: timeout,
+ times: times,
+ timesLimit: timeLimit,
+ timesSeries: timesSeries,
+ transform: transform,
+ unmemoize: unmemoize,
+ until: until,
+ waterfall: waterfall,
+ whilst: whilst,
+
+ // aliases
+ all: every,
+ any: some,
+ forEach: eachLimit,
+ forEachSeries: eachSeries,
+ forEachLimit: eachLimit$1,
+ forEachOf: eachOf,
+ forEachOfSeries: eachOfSeries,
+ forEachOfLimit: eachOfLimit,
+ inject: reduce,
+ foldl: reduce,
+ foldr: reduceRight,
+ select: filter,
+ selectLimit: filterLimit,
+ selectSeries: filterSeries,
+ wrapSync: asyncify
+};
+
+exports['default'] = index;
+exports.applyEach = applyEach;
+exports.applyEachSeries = applyEachSeries;
+exports.apply = apply$2;
+exports.asyncify = asyncify;
+exports.auto = auto;
+exports.autoInject = autoInject;
+exports.cargo = cargo;
+exports.compose = compose;
+exports.concat = concat;
+exports.concatSeries = concatSeries;
+exports.constant = constant$2;
+exports.detect = detect;
+exports.detectLimit = detectLimit;
+exports.detectSeries = detectSeries;
+exports.dir = dir;
+exports.doDuring = doDuring;
+exports.doUntil = doUntil;
+exports.doWhilst = doWhilst;
+exports.during = during;
+exports.each = eachLimit;
+exports.eachLimit = eachLimit$1;
+exports.eachOf = eachOf;
+exports.eachOfLimit = eachOfLimit;
+exports.eachOfSeries = eachOfSeries;
+exports.eachSeries = eachSeries;
+exports.ensureAsync = ensureAsync;
+exports.every = every;
+exports.everyLimit = everyLimit;
+exports.everySeries = everySeries;
+exports.filter = filter;
+exports.filterLimit = filterLimit;
+exports.filterSeries = filterSeries;
+exports.forever = forever;
+exports.log = log;
+exports.map = map;
+exports.mapLimit = mapLimit;
+exports.mapSeries = mapSeries;
+exports.mapValues = mapValues;
+exports.mapValuesLimit = mapValuesLimit;
+exports.mapValuesSeries = mapValuesSeries;
+exports.memoize = memoize;
+exports.nextTick = nextTick;
+exports.parallel = parallelLimit;
+exports.parallelLimit = parallelLimit$1;
+exports.priorityQueue = priorityQueue;
+exports.queue = queue$1;
+exports.race = race;
+exports.reduce = reduce;
+exports.reduceRight = reduceRight;
+exports.reflect = reflect;
+exports.reflectAll = reflectAll;
+exports.reject = reject;
+exports.rejectLimit = rejectLimit;
+exports.rejectSeries = rejectSeries;
+exports.retry = retry;
+exports.retryable = retryable;
+exports.seq = seq$1;
+exports.series = series;
+exports.setImmediate = setImmediate$1;
+exports.some = some;
+exports.someLimit = someLimit;
+exports.someSeries = someSeries;
+exports.sortBy = sortBy;
+exports.timeout = timeout;
+exports.times = times;
+exports.timesLimit = timeLimit;
+exports.timesSeries = timesSeries;
+exports.transform = transform;
+exports.unmemoize = unmemoize;
+exports.until = until;
+exports.waterfall = waterfall;
+exports.whilst = whilst;
+exports.all = every;
+exports.allLimit = everyLimit;
+exports.allSeries = everySeries;
+exports.any = some;
+exports.anyLimit = someLimit;
+exports.anySeries = someSeries;
+exports.find = detect;
+exports.findLimit = detectLimit;
+exports.findSeries = detectSeries;
+exports.forEach = eachLimit;
+exports.forEachSeries = eachSeries;
+exports.forEachLimit = eachLimit$1;
+exports.forEachOf = eachOf;
+exports.forEachOfSeries = eachOfSeries;
+exports.forEachOfLimit = eachOfLimit;
+exports.inject = reduce;
+exports.foldl = reduce;
+exports.foldr = reduceRight;
+exports.select = filter;
+exports.selectLimit = filterLimit;
+exports.selectSeries = filterSeries;
+exports.wrapSync = asyncify;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.min.js
new file mode 100644
index 0000000..15c4a33
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/dist/async.min.js
@@ -0,0 +1,2 @@
+!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n){return n}function e(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function r(n,t,r){return t=ot(void 0===t?n.length-1:t,0),function(){for(var u=arguments,o=-1,i=ot(u.length-t,0),c=Array(i);++o<i;)c[o]=u[t+o];o=-1;for(var f=Array(t+1);++o<t;)f[o]=u[o];return f[t]=r(c),e(n,this,f)}}function u(n){return function(){return n}}function o(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function i(n){var t=o(n)?lt.call(n):"";return t==it||t==ct||t==ft}function c(n){return!!vt&&vt in n}function f(n){if(null!=n){try{return mt.call(n)}catch(n){}try{return n+""}catch(n){}}return""}function a(n){if(!o(n)||c(n))return!1;var t=i(n)?wt:bt;return t.test(f(n))}function l(n,t){return null==n?void 0:n[t]}function s(n,t){var e=l(n,t);return a(e)?e:void 0}function p(n){var t=0,e=0;return function(){var r=_t(),u=At-(r-e);if(e=r,u>0){if(++t>=Lt)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function h(n,e){return Tt(r(n,e,t),n+"")}function y(n){return h(function(t,e){var r=Ft(function(e,r){var u=this;return n(t,function(n,t){n.apply(u,e.concat([t]))},r)});return e.length?r.apply(this,e):r})}function v(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=It}function d(n){return null!=n&&v(n.length)&&!i(n)}function m(){}function g(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function b(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}function j(n){return null!=n&&"object"==typeof n}function S(n){return j(n)&&zt.call(n)==Mt}function k(){return!1}function O(n,t){return t=null==t?Jt:t,!!t&&("number"==typeof n||Kt.test(n))&&n>-1&&n%1==0&&n<t}function w(n){return j(n)&&v(n.length)&&!!Se[we.call(n)]}function x(n){return function(t){return n(t)}}function E(n,t){var e=qt(n),r=!e&&Dt(n),u=!e&&!r&&Ht(n),o=!e&&!r&&!u&&Fe(n),i=e||r||u||o,c=i?b(n.length,String):[],f=c.length;for(var a in n)!t&&!Be.call(n,a)||i&&("length"==a||u&&("offset"==a||"parent"==a)||o&&("buffer"==a||"byteLength"==a||"byteOffset"==a)||O(a,f))||c.push(a);return c}function L(n){var t=n&&n.constructor,e="function"==typeof t&&t.prototype||$e;return n===e}function A(n,t){return function(e){return n(t(e))}}function _(n){if(!L(n))return Me(n);var t=[];for(var e in Object(n))ze.call(n,e)&&"constructor"!=e&&t.push(e);return t}function T(n){return d(n)?E(n):_(n)}function F(n){var t=-1,e=n.length;return function(){return++t<e?{value:n[t],key:t}:null}}function I(n){var t=-1;return function(){var e=n.next();return e.done?null:(t++,{value:e.value,key:t})}}function B(n){var t=T(n),e=-1,r=t.length;return function(){var u=t[++e];return e<r?{value:n[u],key:u}:null}}function $(n){if(d(n))return F(n);var t=$t(n);return t?I(t):B(n)}function M(n){return function(){if(null===n)throw new Error("Callback was already called.");var t=n;n=null,t.apply(this,arguments)}}function P(n){return function(t,e,r){function u(n,t){if(f-=1,n)c=!0,r(n);else{if(t===Re||c&&f<=0)return c=!0,r(null);o()}}function o(){for(;f<n&&!c;){var t=i();if(null===t)return c=!0,void(f<=0&&r(null));f+=1,e(t.value,t.key,M(u))}}if(r=g(r||m),n<=0||!t)return r(null);var i=$(t),c=!1,f=0;o()}}function z(n,t,e,r){P(t)(n,e,r)}function R(n,t){return function(e,r,u){return n(e,t,r,u)}}function U(n,t,e){function r(n){n?e(n):++o===i&&e(null)}e=g(e||m);var u=0,o=0,i=n.length;for(0===i&&e(null);u<i;u++)t(n[u],u,M(r))}function V(n){return function(t,e,r){return n(Ve,t,e,r)}}function D(n,t,e,r){r=g(r||m),t=t||[];var u=[],o=0;n(t,function(n,t,r){var i=o++;e(n,function(n,t){u[i]=t,r(n)})},function(n){r(n,u)})}function q(n){return function(t,e,r,u){return n(P(e),t,r,u)}}function C(n){return Ft(function(t,e){var r;try{r=n.apply(this,t)}catch(n){return e(n)}o(r)&&"function"==typeof r.then?r.then(function(n){e(null,n)},function(n){e(n.message?n:new Error(n))}):e(null,r)})}function W(n,t){for(var e=-1,r=n?n.length:0;++e<r&&t(n[e],e,n)!==!1;);return n}function Q(n){return function(t,e,r){for(var u=-1,o=Object(t),i=r(t),c=i.length;c--;){var f=i[n?c:++u];if(e(o[f],f,o)===!1)break}return t}}function G(n,t){return n&&Ne(n,t,T)}function N(n,t,e,r){for(var u=n.length,o=e+(r?1:-1);r?o--:++o<u;)if(t(n[o],o,n))return o;return-1}function H(n){return n!==n}function J(n,t,e){for(var r=e-1,u=n.length;++r<u;)if(n[r]===t)return r;return-1}function K(n,t,e){return t===t?J(n,t,e):N(n,H,e)}function X(n,t){for(var e=-1,r=n?n.length:0,u=Array(r);++e<r;)u[e]=t(n[e],e,n);return u}function Y(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}function Z(n){return"symbol"==typeof n||j(n)&&Ye.call(n)==Ke}function nn(n){if("string"==typeof n)return n;if(qt(n))return X(n,nn)+"";if(Z(n))return tr?tr.call(n):"";var t=n+"";return"0"==t&&1/n==-Ze?"-0":t}function tn(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(u);++r<u;)o[r]=n[r+t];return o}function en(n,t,e){var r=n.length;return e=void 0===e?r:e,!t&&e>=r?n:tn(n,t,e)}function rn(n,t){for(var e=n.length;e--&&K(t,n[e],0)>-1;);return e}function un(n,t){for(var e=-1,r=n.length;++e<r&&K(t,n[e],0)>-1;);return e}function on(n){return n.split("")}function cn(n){return cr.test(n)}function fn(n){return n.match(xr)||[]}function an(n){return cn(n)?fn(n):on(n)}function ln(n){return null==n?"":nn(n)}function sn(n,t,e){if(n=ln(n),n&&(e||void 0===t))return n.replace(Er,"");if(!n||!(t=nn(t)))return n;var r=an(n),u=an(t),o=un(r,u),i=rn(r,u)+1;return en(r,o,i).join("")}function pn(n){return n=n.toString().replace(Tr,""),n=n.match(Lr)[2].replace(" ",""),n=n?n.split(Ar):[],n=n.map(function(n){return sn(n.replace(_r,""))})}function hn(n,t){var e={};G(n,function(n,t){function r(t,e){var r=X(u,function(n){return t[n]});r.push(e),n.apply(null,r)}var u;if(qt(n))u=Y(n),n=u.pop(),e[t]=u.concat(u.length>0?r:n);else if(1===n.length)e[t]=n;else{if(u=pn(n),0===n.length&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");u.pop(),e[t]=u.concat(r)}}),He(e,t)}function yn(n){setTimeout(n,0)}function vn(n){return h(function(t,e){n(function(){t.apply(null,e)})})}function dn(){this.head=this.tail=null,this.length=0}function mn(n,t){n.length=1,n.head=n.tail=t}function gn(n,t,e){function r(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");if(c.started=!0,qt(n)||(n=[n]),0===n.length&&c.idle())return Br(function(){c.drain()});for(var r=0,u=n.length;r<u;r++){var o={data:n[r],callback:e||m};t?c._tasks.unshift(o):c._tasks.push(o)}Br(c.process)}function u(n){return h(function(t){o-=1;for(var e=0,r=n.length;e<r;e++){var u=n[e],f=K(i,u,0);f>=0&&i.splice(f),u.callback.apply(u,t),null!=t[0]&&c.error(t[0],u.data)}o<=c.concurrency-c.buffer&&c.unsaturated(),c.idle()&&c.drain(),c.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,i=[],c={_tasks:new dn,concurrency:t,payload:e,saturated:m,unsaturated:m,buffer:t/4,empty:m,drain:m,error:m,started:!1,paused:!1,push:function(n,t){r(n,!1,t)},kill:function(){c.drain=m,c._tasks.empty()},unshift:function(n,t){r(n,!0,t)},process:function(){for(;!c.paused&&o<c.concurrency&&c._tasks.length;){var t=[],e=[],r=c._tasks.length;c.payload&&(r=Math.min(r,c.payload));for(var f=0;f<r;f++){var a=c._tasks.shift();t.push(a),e.push(a.data)}0===c._tasks.length&&c.empty(),o+=1,i.push(t[0]),o===c.concurrency&&c.saturated();var l=M(u(t));n(e,l)}},length:function(){return c._tasks.length},running:function(){return o},workersList:function(){return i},idle:function(){return c._tasks.length+o===0},pause:function(){c.paused=!0},resume:function(){if(c.paused!==!1){c.paused=!1;for(var n=Math.min(c.concurrency,c._tasks.length),t=1;t<=n;t++)Br(c.process)}}};return c}function bn(n,t){return gn(n,1,t)}function jn(n,t,e,r){r=g(r||m),Mr(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})}function Sn(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function kn(n){return function(t,e,r){return n(Mr,t,e,r)}}function On(n,t,e){return function(r,u,o,i){function c(){i&&i(null,e(!1))}function f(n,r,u){return i?void o(n,function(r,c){i&&(r||t(c))?(r?i(r):i(r,e(!0,n)),i=o=!1,u(r,Re)):u()}):u()}arguments.length>3?(i=i||m,n(r,u,f,c)):(i=o,i=i||m,o=u,n(r,f,c))}}function wn(n,t){return t}function xn(n){return h(function(t,e){t.apply(null,e.concat([h(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&W(e,function(t){console[n](t)}))})]))})}function En(n,t,e){function r(t,r){return t?e(t):r?void n(u):e(null)}e=M(e||m);var u=h(function(n,u){return n?e(n):(u.push(r),void t.apply(this,u))});r(null,!0)}function Ln(n,t,e){e=M(e||m);var r=h(function(u,o){return u?e(u):t.apply(this,o)?n(r):void e.apply(null,[null].concat(o))});n(r)}function An(n,t,e){Ln(n,function(){return!t.apply(this,arguments)},e)}function _n(n,t,e){function r(t){return t?e(t):void n(u)}function u(n,u){return n?e(n):u?void t(r):e(null)}e=M(e||m),n(u)}function Tn(n){return function(t,e,r){return n(t,r)}}function Fn(n,t,e){Ve(n,Tn(t),e)}function In(n,t,e,r){P(t)(n,Tn(e),r)}function Bn(n){return Ft(function(t,e){var r=!0;t.push(function(){var n=arguments;r?Br(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function $n(n){return!n}function Mn(n){return function(t){return null==t?void 0:t[n]}}function Pn(n,t,e,r){r=g(r||m);var u=[];n(t,function(n,t,r){e(n,function(e,o){e?r(e):(o&&u.push({index:t,value:n}),r())})},function(n){n?r(n):r(null,X(u.sort(function(n,t){return n.index-t.index}),Mn("value")))})}function zn(n,t){function e(n){return n?r(n):void u(e)}var r=M(t||m),u=Bn(n);e()}function Rn(n,t,e,r){r=g(r||m);var u={};z(n,t,function(n,t,r){e(n,t,function(n,e){return n?r(n):(u[t]=e,void r())})},function(n){r(n,u)})}function Un(n,t){return t in n}function Vn(n,e){var r=Object.create(null),u=Object.create(null);e=e||t;var o=Ft(function(t,o){var i=e.apply(null,t);Un(r,i)?Br(function(){o.apply(null,r[i])}):Un(u,i)?u[i].push(o):(u[i]=[o],n.apply(null,t.concat([h(function(n){r[i]=n;var t=u[i];delete u[i];for(var e=0,o=t.length;e<o;e++)t[e].apply(null,n)})])))});return o.memo=r,o.unmemoized=n,o}function Dn(n,t,e){e=e||m;var r=d(t)?[]:{};n(t,function(n,t,e){n(h(function(n,u){u.length<=1&&(u=u[0]),r[t]=u,e(n)}))},function(n){e(n,r)})}function qn(n,t){Dn(Ve,n,t)}function Cn(n,t,e){Dn(P(t),n,e)}function Wn(n,t){if(t=g(t||m),!qt(n))return t(new TypeError("First argument to race must be an array of functions"));if(!n.length)return t();for(var e=0,r=n.length;e<r;e++)n[e](t)}function Qn(n,t,e,r){var u=uu.call(n).reverse();jn(u,t,e,r)}function Gn(n){return Ft(function(t,e){return t.push(h(function(n,t){if(n)e(null,{error:n});else{var r=null;1===t.length?r=t[0]:t.length>1&&(r=t),e(null,{value:r})}})),n.apply(this,t)})}function Nn(n,t,e,r){Pn(n,t,function(n,t){e(n,function(n,e){n?t(n):t(null,!e)})},r)}function Hn(n){var t;return qt(n)?t=X(n,Gn):(t={},G(n,function(n,e){t[e]=Gn.call(this,n)})),t}function Jn(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||i,n.intervalFunc="function"==typeof t.interval?t.interval:u(+t.interval||c),n.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||i}}function o(){t(function(n){n&&a++<f.times&&("function"!=typeof f.errorFilter||f.errorFilter(n))?setTimeout(o,f.intervalFunc(a)):e.apply(null,arguments)})}var i=5,c=0,f={times:i,intervalFunc:u(c)};if(arguments.length<3&&"function"==typeof n?(e=t||m,t=n):(r(f,n),e=e||m),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var a=1;o()}function Kn(n,t){Dn(Mr,n,t)}function Xn(n,t,e){function r(n,t){var e=n.criteria,r=t.criteria;return e<r?-1:e>r?1:0}De(n,function(n,e){t(n,function(t,r){return t?e(t):void e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,X(t.sort(r),Mn("value")))})}function Yn(n,t,e){function r(){c||(o.apply(null,arguments),clearTimeout(i))}function u(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),c=!0,o(r)}var o,i,c=!1;return Ft(function(e,c){o=c,i=setTimeout(u,t),n.apply(null,e.concat(r))})}function Zn(n,t,e,r){for(var u=-1,o=hu(pu((t-n)/(e||1)),0),i=Array(o);o--;)i[r?o:++u]=n,n+=e;return i}function nt(n,t,e,r){Ce(Zn(0,n,1),t,e,r)}function tt(n,t,e,r){3===arguments.length&&(r=e,e=t,t=qt(n)?[]:{}),r=g(r||m),Ve(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})}function et(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function rt(n,t,e){if(e=M(e||m),!n())return e(null);var r=h(function(u,o){return u?e(u):n()?t(r):void e.apply(null,[null].concat(o))});t(r)}function ut(n,t,e){rt(function(){return!n.apply(this,arguments)},t,e)}var ot=Math.max,it="[object Function]",ct="[object GeneratorFunction]",ft="[object Proxy]",at=Object.prototype,lt=at.toString,st="object"==typeof global&&global&&global.Object===Object&&global,pt="object"==typeof self&&self&&self.Object===Object&&self,ht=st||pt||Function("return this")(),yt=ht["__core-js_shared__"],vt=function(){var n=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),dt=Function.prototype,mt=dt.toString,gt=/[\\^$.*+?()[\]{}|]/g,bt=/^\[object .+?Constructor\]$/,jt=Function.prototype,St=Object.prototype,kt=jt.toString,Ot=St.hasOwnProperty,wt=RegExp("^"+kt.call(Ot).replace(gt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xt=function(){try{var n=s(Object,"defineProperty");return n({},"",{}),n}catch(n){}}(),Et=xt?function(n,t){return xt(n,"toString",{configurable:!0,enumerable:!1,value:u(t),writable:!0})}:t,Lt=500,At=16,_t=Date.now,Tt=p(Et),Ft=function(n){return h(function(t){var e=t.pop();n.call(this,t,e)})},It=9007199254740991,Bt="function"==typeof Symbol&&Symbol.iterator,$t=function(n){return Bt&&n[Bt]&&n[Bt]()},Mt="[object Arguments]",Pt=Object.prototype,zt=Pt.toString,Rt=Object.prototype,Ut=Rt.hasOwnProperty,Vt=Rt.propertyIsEnumerable,Dt=S(function(){return arguments}())?S:function(n){return j(n)&&Ut.call(n,"callee")&&!Vt.call(n,"callee")},qt=Array.isArray,Ct="object"==typeof n&&n&&!n.nodeType&&n,Wt=Ct&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=Wt&&Wt.exports===Ct,Gt=Qt?ht.Buffer:void 0,Nt=Gt?Gt.isBuffer:void 0,Ht=Nt||k,Jt=9007199254740991,Kt=/^(?:0|[1-9]\d*)$/,Xt="[object Arguments]",Yt="[object Array]",Zt="[object Boolean]",ne="[object Date]",te="[object Error]",ee="[object Function]",re="[object Map]",ue="[object Number]",oe="[object Object]",ie="[object RegExp]",ce="[object Set]",fe="[object String]",ae="[object WeakMap]",le="[object ArrayBuffer]",se="[object DataView]",pe="[object Float32Array]",he="[object Float64Array]",ye="[object Int8Array]",ve="[object Int16Array]",de="[object Int32Array]",me="[object Uint8Array]",ge="[object Uint8ClampedArray]",be="[object Uint16Array]",je="[object Uint32Array]",Se={};Se[pe]=Se[he]=Se[ye]=Se[ve]=Se[de]=Se[me]=Se[ge]=Se[be]=Se[je]=!0,Se[Xt]=Se[Yt]=Se[le]=Se[Zt]=Se[se]=Se[ne]=Se[te]=Se[ee]=Se[re]=Se[ue]=Se[oe]=Se[ie]=Se[ce]=Se[fe]=Se[ae]=!1;var ke,Oe=Object.prototype,we=Oe.toString,xe="object"==typeof n&&n&&!n.nodeType&&n,Ee=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Le=Ee&&Ee.exports===xe,Ae=Le&&st.process,_e=function(){try{return Ae&&Ae.binding("util")}catch(n){}}(),Te=_e&&_e.isTypedArray,Fe=Te?x(Te):w,Ie=Object.prototype,Be=Ie.hasOwnProperty,$e=Object.prototype,Me=A(Object.keys,Object),Pe=Object.prototype,ze=Pe.hasOwnProperty,Re={},Ue=R(z,1/0),Ve=function(n,t,e){var r=d(n)?U:Ue;r(n,t,e)},De=V(D),qe=y(De),Ce=q(D),We=R(Ce,1),Qe=y(We),Ge=h(function(n,t){return h(function(e){return n.apply(null,t.concat(e))})}),Ne=Q(),He=function(n,t,e){function r(n,t){b.push(function(){c(n,t)})}function u(){if(0===b.length&&0===y)return e(null,p);for(;b.length&&y<t;){var n=b.shift();n()}}function o(n,t){var e=d[n];e||(e=d[n]=[]),e.push(t)}function i(n){var t=d[n]||[];W(t,function(n){n()}),u()}function c(n,t){if(!v){var r=M(h(function(t,r){if(y--,r.length<=1&&(r=r[0]),t){var u={};G(p,function(n,t){u[t]=n}),u[n]=r,v=!0,d=[],e(t,u)}else p[n]=r,i(n)}));y++;var u=t[t.length-1];t.length>1?u(p,r):u(r)}}function f(){for(var n,t=0;j.length;)n=j.pop(),t++,W(a(n),function(n){0===--S[n]&&j.push(n)});if(t!==s)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function a(t){var e=[];return G(n,function(n,r){qt(n)&&K(n,t,0)>=0&&e.push(r)}),e}"function"==typeof t&&(e=t,t=null),e=g(e||m);var l=T(n),s=l.length;if(!s)return e(null);t||(t=s);var p={},y=0,v=!1,d={},b=[],j=[],S={};G(n,function(t,e){if(!qt(t))return r(e,[t]),void j.push(e);var u=t.slice(0,t.length-1),i=u.length;return 0===i?(r(e,t),void j.push(e)):(S[e]=i,void W(u,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency in "+u.join(", "));o(c,function(){i--,0===i&&r(e,t)})}))}),f(),u()},Je=ht.Symbol,Ke="[object Symbol]",Xe=Object.prototype,Ye=Xe.toString,Ze=1/0,nr=Je?Je.prototype:void 0,tr=nr?nr.toString:void 0,er="\\ud800-\\udfff",rr="\\u0300-\\u036f\\ufe20-\\ufe23",ur="\\u20d0-\\u20f0",or="\\ufe0e\\ufe0f",ir="\\u200d",cr=RegExp("["+ir+er+rr+ur+or+"]"),fr="\\ud800-\\udfff",ar="\\u0300-\\u036f\\ufe20-\\ufe23",lr="\\u20d0-\\u20f0",sr="\\ufe0e\\ufe0f",pr="["+fr+"]",hr="["+ar+lr+"]",yr="\\ud83c[\\udffb-\\udfff]",vr="(?:"+hr+"|"+yr+")",dr="[^"+fr+"]",mr="(?:\\ud83c[\\udde6-\\uddff]){2}",gr="[\\ud800-\\udbff][\\udc00-\\udfff]",br="\\u200d",jr=vr+"?",Sr="["+sr+"]?",kr="(?:"+br+"(?:"+[dr,mr,gr].join("|")+")"+Sr+jr+")*",Or=Sr+jr+kr,wr="(?:"+[dr+hr+"?",hr,mr,gr,pr].join("|")+")",xr=RegExp(yr+"(?="+yr+")|"+wr+Or,"g"),Er=/^\s+|\s+$/g,Lr=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Ar=/,/,_r=/(=.+)?(\s*)$/,Tr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,Fr="function"==typeof setImmediate&&setImmediate,Ir="object"==typeof process&&"function"==typeof process.nextTick;ke=Fr?setImmediate:Ir?process.nextTick:yn;var Br=vn(ke);dn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},dn.prototype.empty=dn,dn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},dn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},dn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):mn(this,n)},dn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):mn(this,n)},dn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},dn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var $r,Mr=R(z,1),Pr=h(function(n){return h(function(t){var e=this,r=t[t.length-1];"function"==typeof r?t.pop():r=m,jn(n,t,function(n,t,r){t.apply(e,n.concat([h(function(n,t){r(n,t)})]))},function(n,t){r.apply(e,[n].concat(t))})})}),zr=h(function(n){return Pr.apply(null,n.reverse())}),Rr=V(Sn),Ur=kn(Sn),Vr=h(function(n){var t=[null].concat(n);return Ft(function(n,e){return e.apply(this,t)})}),Dr=On(Ve,t,wn),qr=On(z,t,wn),Cr=On(Mr,t,wn),Wr=xn("dir"),Qr=R(In,1),Gr=On(Ve,$n,$n),Nr=On(z,$n,$n),Hr=R(Nr,1),Jr=V(Pn),Kr=q(Pn),Xr=R(Kr,1),Yr=xn("log"),Zr=R(Rn,1/0),nu=R(Rn,1);$r=Ir?process.nextTick:Fr?setImmediate:yn;var tu=vn($r),eu=function(n,t){return gn(function(t,e){n(t[0],e)},t,1)},ru=function(n,t){var e=eu(n,t);return e.push=function(n,t,r){if(null==r&&(r=m),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,qt(n)||(n=[n]),0===n.length)return Br(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;for(var o=0,i=n.length;o<i;o++){var c={data:n[o],priority:t,callback:r};u?e._tasks.insertBefore(u,c):e._tasks.push(c)}Br(e.process)},delete e.unshift,e},uu=Array.prototype.slice,ou=V(Nn),iu=q(Nn),cu=R(iu,1),fu=function(n,t){return t||(t=n,n=null),Ft(function(e,r){function u(n){t.apply(null,e.concat([n]))}n?Jn(n,u,r):Jn(u,r)})},au=On(Ve,Boolean,t),lu=On(z,Boolean,t),su=R(lu,1),pu=Math.ceil,hu=Math.max,yu=R(nt,1/0),vu=R(nt,1),du=function(n,t){function e(u){if(r===n.length)return t.apply(null,[null].concat(u));var o=M(h(function(n,r){return n?t.apply(null,[n].concat(r)):void e(r)}));u.push(o);var i=n[r++];i.apply(null,u)}if(t=g(t||m),!qt(n))return t(new Error("First argument to waterfall must be an array of functions"));if(!n.length)return t();var r=0;e([])},mu={applyEach:qe,applyEachSeries:Qe,apply:Ge,asyncify:C,auto:He,autoInject:hn,cargo:bn,compose:zr,concat:Rr,concatSeries:Ur,constant:Vr,detect:Dr,detectLimit:qr,detectSeries:Cr,dir:Wr,doDuring:En,doUntil:An,doWhilst:Ln,during:_n,each:Fn,eachLimit:In,eachOf:Ve,eachOfLimit:z,eachOfSeries:Mr,eachSeries:Qr,ensureAsync:Bn,every:Gr,everyLimit:Nr,everySeries:Hr,filter:Jr,filterLimit:Kr,filterSeries:Xr,forever:zn,log:Yr,map:De,mapLimit:Ce,mapSeries:We,mapValues:Zr,mapValuesLimit:Rn,mapValuesSeries:nu,memoize:Vn,nextTick:tu,parallel:qn,parallelLimit:Cn,priorityQueue:ru,queue:eu,race:Wn,reduce:jn,reduceRight:Qn,reflect:Gn,reflectAll:Hn,reject:ou,rejectLimit:iu,rejectSeries:cu,retry:Jn,retryable:fu,seq:Pr,series:Kn,setImmediate:Br,some:au,someLimit:lu,someSeries:su,sortBy:Xn,timeout:Yn,times:yu,timesLimit:nt,timesSeries:vu,transform:tt,unmemoize:et,until:ut,waterfall:du,whilst:rt,all:Gr,any:au,forEach:Fn,forEachSeries:Qr,forEachLimit:In,forEachOf:Ve,forEachOfSeries:Mr,forEachOfLimit:z,inject:jn,foldl:jn,foldr:Qn,select:Jr,selectLimit:Kr,selectSeries:Xr,wrapSync:C};n.default=mu,n.applyEach=qe,n.applyEachSeries=Qe,n.apply=Ge,n.asyncify=C,n.auto=He,n.autoInject=hn,n.cargo=bn,n.compose=zr,n.concat=Rr,n.concatSeries=Ur,n.constant=Vr,n.detect=Dr,n.detectLimit=qr,n.detectSeries=Cr,n.dir=Wr,n.doDuring=En,n.doUntil=An,n.doWhilst=Ln,n.during=_n,n.each=Fn,n.eachLimit=In,n.eachOf=Ve,n.eachOfLimit=z,n.eachOfSeries=Mr,n.eachSeries=Qr,n.ensureAsync=Bn,n.every=Gr,n.everyLimit=Nr,n.everySeries=Hr,n.filter=Jr,n.filterLimit=Kr,n.filterSeries=Xr,n.forever=zn,n.log=Yr,n.map=De,n.mapLimit=Ce,n.mapSeries=We,n.mapValues=Zr,n.mapValuesLimit=Rn,n.mapValuesSeries=nu,n.memoize=Vn,n.nextTick=tu,n.parallel=qn,n.parallelLimit=Cn,n.priorityQueue=ru,n.queue=eu,n.race=Wn,n.reduce=jn,n.reduceRight=Qn,n.reflect=Gn,n.reflectAll=Hn,n.reject=ou,n.rejectLimit=iu,n.rejectSeries=cu,n.retry=Jn,n.retryable=fu,n.seq=Pr,n.series=Kn,n.setImmediate=Br,n.some=au,n.someLimit=lu,n.someSeries=su,n.sortBy=Xn,n.timeout=Yn,n.times=yu,n.timesLimit=nt,n.timesSeries=vu,n.transform=tt,n.unmemoize=et,n.until=ut,n.waterfall=du,n.whilst=rt,n.all=Gr,n.allLimit=Nr,n.allSeries=Hr,n.any=au,n.anyLimit=lu,n.anySeries=su,n.find=Dr,n.findLimit=qr,n.findSeries=Cr,n.forEach=Fn,n.forEachSeries=Qr,n.forEachLimit=In,n.forEachOf=Ve,n.forEachOfSeries=Mr,n.forEachOfLimit=z,n.inject=jn,n.foldl=jn,n.foldr=Qn,n.select=Jr,n.selectLimit=Kr,n.selectSeries=Xr,n.wrapSync=C,Object.defineProperty(n,"__esModule",{value:!0})});
+//# sourceMappingURL=async.min.map \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doDuring.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doDuring.js
new file mode 100644
index 0000000..c962895
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doDuring.js
@@ -0,0 +1,60 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doDuring;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
+ * the order of operations, the arguments `test` and `fn` are switched.
+ *
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
+ * @name doDuring
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error if one occured, otherwise `null`.
+ */
+function doDuring(fn, test, callback) {
+ callback = (0, _onlyOnce2.default)(callback || _noop2.default);
+
+ var next = (0, _baseRest2.default)(function (err, args) {
+ if (err) return callback(err);
+ args.push(check);
+ test.apply(this, args);
+ });
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
+
+ check(null, true);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doUntil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doUntil.js
new file mode 100644
index 0000000..e7b5ee7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doUntil.js
@@ -0,0 +1,39 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doUntil;
+
+var _doWhilst = require('./doWhilst');
+
+var _doWhilst2 = _interopRequireDefault(_doWhilst);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `fn`. Invoked with the non-error callback results of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function doUntil(fn, test, callback) {
+ (0, _doWhilst2.default)(fn, function () {
+ return !test.apply(this, arguments);
+ }, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doWhilst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doWhilst.js
new file mode 100644
index 0000000..088b2cf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/doWhilst.js
@@ -0,0 +1,54 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doWhilst;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} iteratee - A function which is called each time `test`
+ * passes. The function is passed a `callback(err)`, which must be called once
+ * it has completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with the non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ */
+function doWhilst(iteratee, test, callback) {
+ callback = (0, _onlyOnce2.default)(callback || _noop2.default);
+ var next = (0, _baseRest2.default)(function (err, args) {
+ if (err) return callback(err);
+ if (test.apply(this, args)) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/during.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/during.js
new file mode 100644
index 0000000..f605ada
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/during.js
@@ -0,0 +1,71 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = during;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
+ * is passed a callback in the form of `function (err, truth)`. If error is
+ * passed to `test` or `fn`, the main callback is immediately called with the
+ * value of the error.
+ *
+ * @name during
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (callback).
+ * @param {Function} fn - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error, if one occured, otherwise `null`.
+ * @example
+ *
+ * var count = 0;
+ *
+ * async.during(
+ * function (callback) {
+ * return callback(null, count < 5);
+ * },
+ * function (callback) {
+ * count++;
+ * setTimeout(callback, 1000);
+ * },
+ * function (err) {
+ * // 5 seconds have passed
+ * }
+ * );
+ */
+function during(test, fn, callback) {
+ callback = (0, _onlyOnce2.default)(callback || _noop2.default);
+
+ function next(err) {
+ if (err) return callback(err);
+ test(check);
+ }
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ fn(next);
+ }
+
+ test(check);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/each.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/each.js
new file mode 100644
index 0000000..222a176
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/each.js
@@ -0,0 +1,80 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachLimit;
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _withoutIndex = require('./internal/withoutIndex');
+
+var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item
+ * in `coll`. The iteratee is passed a `callback(err)` which must be called once
+ * it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is not
+ * passed to the iteratee. Invoked with (item, callback). If you need the index,
+ * use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ * // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ * // Perform operation on file here.
+ * console.log('Processing file ' + file);
+ *
+ * if( file.length > 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)(iteratee), callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachLimit.js
new file mode 100644
index 0000000..674c135
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachLimit.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachLimit;
+
+var _eachOfLimit = require('./internal/eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _withoutIndex = require('./internal/withoutIndex');
+
+var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * iteratee is passed a `callback(err)` which must be called once it has
+ * completed. If no error has occurred, the `callback` should be run without
+ * arguments or with an explicit `null` argument. The array index is not passed
+ * to the iteratee. Invoked with (item, callback). If you need the index, use
+ * `eachOfLimit`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)(iteratee), callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOf.js
new file mode 100644
index 0000000..4ab9a54
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOf.js
@@ -0,0 +1,105 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll, iteratee, callback) {
+ var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, iteratee, callback);
+};
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
+ }
+
+ function iteratorCallback(err) {
+ if (err) {
+ callback(err);
+ } else if (++completed === length) {
+ callback(null);
+ }
+ }
+
+ for (; index < length; index++) {
+ iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
+ }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfLimit.js
new file mode 100644
index 0000000..a2ece1b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfLimit.js
@@ -0,0 +1,39 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachOfLimit;
+
+var _eachOfLimit2 = require('./internal/eachOfLimit');
+
+var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array. The iteratee is passed a `callback(err)` which must be called once it
+ * has completed. If no error has occurred, the callback should be run without
+ * arguments or with an explicit `null` argument. Invoked with
+ * (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit3.default)(limit)(coll, iteratee, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfSeries.js
new file mode 100644
index 0000000..968db26
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachOfSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`. The
+ * `key` is the item's key, or index in the case of an array. The iteratee is
+ * passed a `callback(err)` which must be called once it has completed. If no
+ * error has occurred, the callback should be run without arguments or with an
+ * explicit `null` argument. Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachSeries.js
new file mode 100644
index 0000000..31a7456
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/eachSeries.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachLimit = require('./eachLimit');
+
+var _eachLimit2 = _interopRequireDefault(_eachLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each
+ * item in `coll`. The iteratee is passed a `callback(err)` which must be called
+ * once it has completed. If no error has occurred, the `callback` should be run
+ * without arguments or with an explicit `null` argument. The array index is
+ * not passed to the iteratee. Invoked with (item, callback). If you need the
+ * index, use `eachOfSeries`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/ensureAsync.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/ensureAsync.js
new file mode 100644
index 0000000..08e0829
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/ensureAsync.js
@@ -0,0 +1,69 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = ensureAsync;
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop. If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {Function} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ * if (cache[arg]) {
+ * return callback(null, cache[arg]); // this would be synchronous!!
+ * } else {
+ * doSomeIO(arg, callback); // this IO would be asynchronous
+ * }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+function ensureAsync(fn) {
+ return (0, _initialParams2.default)(function (args, callback) {
+ var sync = true;
+ args.push(function () {
+ var innerArgs = arguments;
+ if (sync) {
+ (0, _setImmediate2.default)(function () {
+ callback.apply(null, innerArgs);
+ });
+ } else {
+ callback.apply(null, innerArgs);
+ }
+ });
+ fn.apply(this, args);
+ sync = false;
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/every.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/every.js
new file mode 100644
index 0000000..edaa7ed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/every.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+exports.default = (0, _createTester2.default)(_eachOf2.default, _notId2.default, _notId2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everyLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everyLimit.js
new file mode 100644
index 0000000..ef6c35a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everyLimit.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _createTester2.default)(_eachOfLimit2.default, _notId2.default, _notId2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everySeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everySeries.js
new file mode 100644
index 0000000..5ed1c1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/everySeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _everyLimit = require('./everyLimit');
+
+var _everyLimit2 = _interopRequireDefault(_everyLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the
+ * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
+ * which must be called with a boolean argument once it has completed. Invoked
+ * with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filter.js
new file mode 100644
index 0000000..54772d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filter.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_filter2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterLimit.js
new file mode 100644
index 0000000..06216f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_filter2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterSeries.js
new file mode 100644
index 0000000..e48d966
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/filterSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filterLimit = require('./filterLimit');
+
+var _filterLimit2 = _interopRequireDefault(_filterLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+exports.default = (0, _doLimit2.default)(_filterLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/forever.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/forever.js
new file mode 100644
index 0000000..87156d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/forever.js
@@ -0,0 +1,61 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = forever;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _ensureAsync = require('./ensureAsync');
+
+var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the
+ * callback then `errback` is called with the error, and execution stops,
+ * otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} fn - a function to call repeatedly. Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ * function(next) {
+ * // next is suitable for passing to things that need a callback(err [, whatever]);
+ * // it will result in this function being called again.
+ * },
+ * function(err) {
+ * // if next is called with a value in its first parameter, it will appear
+ * // in here as 'err', and execution will stop.
+ * }
+ * );
+ */
+function forever(fn, errback) {
+ var done = (0, _onlyOnce2.default)(errback || _noop2.default);
+ var task = (0, _ensureAsync2.default)(fn);
+
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/index.js
new file mode 100644
index 0000000..b3595c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/index.js
@@ -0,0 +1,505 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.wrapSync = exports.selectSeries = exports.selectLimit = exports.select = exports.foldr = exports.foldl = exports.inject = exports.forEachOfLimit = exports.forEachOfSeries = exports.forEachOf = exports.forEachLimit = exports.forEachSeries = exports.forEach = exports.findSeries = exports.findLimit = exports.find = exports.anySeries = exports.anyLimit = exports.any = exports.allSeries = exports.allLimit = exports.all = exports.whilst = exports.waterfall = exports.until = exports.unmemoize = exports.transform = exports.timesSeries = exports.timesLimit = exports.times = exports.timeout = exports.sortBy = exports.someSeries = exports.someLimit = exports.some = exports.setImmediate = exports.series = exports.seq = exports.retryable = exports.retry = exports.rejectSeries = exports.rejectLimit = exports.reject = exports.reflectAll = exports.reflect = exports.reduceRight = exports.reduce = exports.race = exports.queue = exports.priorityQueue = exports.parallelLimit = exports.parallel = exports.nextTick = exports.memoize = exports.mapValuesSeries = exports.mapValuesLimit = exports.mapValues = exports.mapSeries = exports.mapLimit = exports.map = exports.log = exports.forever = exports.filterSeries = exports.filterLimit = exports.filter = exports.everySeries = exports.everyLimit = exports.every = exports.ensureAsync = exports.eachSeries = exports.eachOfSeries = exports.eachOfLimit = exports.eachOf = exports.eachLimit = exports.each = exports.during = exports.doWhilst = exports.doUntil = exports.doDuring = exports.dir = exports.detectSeries = exports.detectLimit = exports.detect = exports.constant = exports.concatSeries = exports.concat = exports.compose = exports.cargo = exports.autoInject = exports.auto = exports.asyncify = exports.apply = exports.applyEachSeries = exports.applyEach = undefined;
+
+var _applyEach = require('./applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _applyEachSeries = require('./applyEachSeries');
+
+var _applyEachSeries2 = _interopRequireDefault(_applyEachSeries);
+
+var _apply = require('./apply');
+
+var _apply2 = _interopRequireDefault(_apply);
+
+var _asyncify = require('./asyncify');
+
+var _asyncify2 = _interopRequireDefault(_asyncify);
+
+var _auto = require('./auto');
+
+var _auto2 = _interopRequireDefault(_auto);
+
+var _autoInject = require('./autoInject');
+
+var _autoInject2 = _interopRequireDefault(_autoInject);
+
+var _cargo = require('./cargo');
+
+var _cargo2 = _interopRequireDefault(_cargo);
+
+var _compose = require('./compose');
+
+var _compose2 = _interopRequireDefault(_compose);
+
+var _concat = require('./concat');
+
+var _concat2 = _interopRequireDefault(_concat);
+
+var _concatSeries = require('./concatSeries');
+
+var _concatSeries2 = _interopRequireDefault(_concatSeries);
+
+var _constant = require('./constant');
+
+var _constant2 = _interopRequireDefault(_constant);
+
+var _detect = require('./detect');
+
+var _detect2 = _interopRequireDefault(_detect);
+
+var _detectLimit = require('./detectLimit');
+
+var _detectLimit2 = _interopRequireDefault(_detectLimit);
+
+var _detectSeries = require('./detectSeries');
+
+var _detectSeries2 = _interopRequireDefault(_detectSeries);
+
+var _dir = require('./dir');
+
+var _dir2 = _interopRequireDefault(_dir);
+
+var _doDuring = require('./doDuring');
+
+var _doDuring2 = _interopRequireDefault(_doDuring);
+
+var _doUntil = require('./doUntil');
+
+var _doUntil2 = _interopRequireDefault(_doUntil);
+
+var _doWhilst = require('./doWhilst');
+
+var _doWhilst2 = _interopRequireDefault(_doWhilst);
+
+var _during = require('./during');
+
+var _during2 = _interopRequireDefault(_during);
+
+var _each = require('./each');
+
+var _each2 = _interopRequireDefault(_each);
+
+var _eachLimit = require('./eachLimit');
+
+var _eachLimit2 = _interopRequireDefault(_eachLimit);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _eachSeries = require('./eachSeries');
+
+var _eachSeries2 = _interopRequireDefault(_eachSeries);
+
+var _ensureAsync = require('./ensureAsync');
+
+var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
+
+var _every = require('./every');
+
+var _every2 = _interopRequireDefault(_every);
+
+var _everyLimit = require('./everyLimit');
+
+var _everyLimit2 = _interopRequireDefault(_everyLimit);
+
+var _everySeries = require('./everySeries');
+
+var _everySeries2 = _interopRequireDefault(_everySeries);
+
+var _filter = require('./filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _filterLimit = require('./filterLimit');
+
+var _filterLimit2 = _interopRequireDefault(_filterLimit);
+
+var _filterSeries = require('./filterSeries');
+
+var _filterSeries2 = _interopRequireDefault(_filterSeries);
+
+var _forever = require('./forever');
+
+var _forever2 = _interopRequireDefault(_forever);
+
+var _log = require('./log');
+
+var _log2 = _interopRequireDefault(_log);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _mapSeries = require('./mapSeries');
+
+var _mapSeries2 = _interopRequireDefault(_mapSeries);
+
+var _mapValues = require('./mapValues');
+
+var _mapValues2 = _interopRequireDefault(_mapValues);
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _mapValuesSeries = require('./mapValuesSeries');
+
+var _mapValuesSeries2 = _interopRequireDefault(_mapValuesSeries);
+
+var _memoize = require('./memoize');
+
+var _memoize2 = _interopRequireDefault(_memoize);
+
+var _nextTick = require('./nextTick');
+
+var _nextTick2 = _interopRequireDefault(_nextTick);
+
+var _parallel = require('./parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+var _parallelLimit = require('./parallelLimit');
+
+var _parallelLimit2 = _interopRequireDefault(_parallelLimit);
+
+var _priorityQueue = require('./priorityQueue');
+
+var _priorityQueue2 = _interopRequireDefault(_priorityQueue);
+
+var _queue = require('./queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+var _race = require('./race');
+
+var _race2 = _interopRequireDefault(_race);
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+var _reduceRight = require('./reduceRight');
+
+var _reduceRight2 = _interopRequireDefault(_reduceRight);
+
+var _reflect = require('./reflect');
+
+var _reflect2 = _interopRequireDefault(_reflect);
+
+var _reject = require('./reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _reflectAll = require('./reflectAll');
+
+var _reflectAll2 = _interopRequireDefault(_reflectAll);
+
+var _rejectLimit = require('./rejectLimit');
+
+var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
+
+var _rejectSeries = require('./rejectSeries');
+
+var _rejectSeries2 = _interopRequireDefault(_rejectSeries);
+
+var _retry = require('./retry');
+
+var _retry2 = _interopRequireDefault(_retry);
+
+var _retryable = require('./retryable');
+
+var _retryable2 = _interopRequireDefault(_retryable);
+
+var _seq = require('./seq');
+
+var _seq2 = _interopRequireDefault(_seq);
+
+var _series = require('./series');
+
+var _series2 = _interopRequireDefault(_series);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _some = require('./some');
+
+var _some2 = _interopRequireDefault(_some);
+
+var _someLimit = require('./someLimit');
+
+var _someLimit2 = _interopRequireDefault(_someLimit);
+
+var _someSeries = require('./someSeries');
+
+var _someSeries2 = _interopRequireDefault(_someSeries);
+
+var _sortBy = require('./sortBy');
+
+var _sortBy2 = _interopRequireDefault(_sortBy);
+
+var _timeout = require('./timeout');
+
+var _timeout2 = _interopRequireDefault(_timeout);
+
+var _times = require('./times');
+
+var _times2 = _interopRequireDefault(_times);
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _timesSeries = require('./timesSeries');
+
+var _timesSeries2 = _interopRequireDefault(_timesSeries);
+
+var _transform = require('./transform');
+
+var _transform2 = _interopRequireDefault(_transform);
+
+var _unmemoize = require('./unmemoize');
+
+var _unmemoize2 = _interopRequireDefault(_unmemoize);
+
+var _until = require('./until');
+
+var _until2 = _interopRequireDefault(_until);
+
+var _waterfall = require('./waterfall');
+
+var _waterfall2 = _interopRequireDefault(_waterfall);
+
+var _whilst = require('./whilst');
+
+var _whilst2 = _interopRequireDefault(_whilst);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Async is a utility module which provides straight-forward, powerful functions
+ * for working with asynchronous JavaScript. Although originally designed for
+ * use with [Node.js](http://nodejs.org) and installable via
+ * `npm install --save async`, it can also be used directly in the browser.
+ * @module async
+ */
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+/**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
+exports.default = {
+ applyEach: _applyEach2.default,
+ applyEachSeries: _applyEachSeries2.default,
+ apply: _apply2.default,
+ asyncify: _asyncify2.default,
+ auto: _auto2.default,
+ autoInject: _autoInject2.default,
+ cargo: _cargo2.default,
+ compose: _compose2.default,
+ concat: _concat2.default,
+ concatSeries: _concatSeries2.default,
+ constant: _constant2.default,
+ detect: _detect2.default,
+ detectLimit: _detectLimit2.default,
+ detectSeries: _detectSeries2.default,
+ dir: _dir2.default,
+ doDuring: _doDuring2.default,
+ doUntil: _doUntil2.default,
+ doWhilst: _doWhilst2.default,
+ during: _during2.default,
+ each: _each2.default,
+ eachLimit: _eachLimit2.default,
+ eachOf: _eachOf2.default,
+ eachOfLimit: _eachOfLimit2.default,
+ eachOfSeries: _eachOfSeries2.default,
+ eachSeries: _eachSeries2.default,
+ ensureAsync: _ensureAsync2.default,
+ every: _every2.default,
+ everyLimit: _everyLimit2.default,
+ everySeries: _everySeries2.default,
+ filter: _filter2.default,
+ filterLimit: _filterLimit2.default,
+ filterSeries: _filterSeries2.default,
+ forever: _forever2.default,
+ log: _log2.default,
+ map: _map2.default,
+ mapLimit: _mapLimit2.default,
+ mapSeries: _mapSeries2.default,
+ mapValues: _mapValues2.default,
+ mapValuesLimit: _mapValuesLimit2.default,
+ mapValuesSeries: _mapValuesSeries2.default,
+ memoize: _memoize2.default,
+ nextTick: _nextTick2.default,
+ parallel: _parallel2.default,
+ parallelLimit: _parallelLimit2.default,
+ priorityQueue: _priorityQueue2.default,
+ queue: _queue2.default,
+ race: _race2.default,
+ reduce: _reduce2.default,
+ reduceRight: _reduceRight2.default,
+ reflect: _reflect2.default,
+ reflectAll: _reflectAll2.default,
+ reject: _reject2.default,
+ rejectLimit: _rejectLimit2.default,
+ rejectSeries: _rejectSeries2.default,
+ retry: _retry2.default,
+ retryable: _retryable2.default,
+ seq: _seq2.default,
+ series: _series2.default,
+ setImmediate: _setImmediate2.default,
+ some: _some2.default,
+ someLimit: _someLimit2.default,
+ someSeries: _someSeries2.default,
+ sortBy: _sortBy2.default,
+ timeout: _timeout2.default,
+ times: _times2.default,
+ timesLimit: _timesLimit2.default,
+ timesSeries: _timesSeries2.default,
+ transform: _transform2.default,
+ unmemoize: _unmemoize2.default,
+ until: _until2.default,
+ waterfall: _waterfall2.default,
+ whilst: _whilst2.default,
+
+ // aliases
+ all: _every2.default,
+ any: _some2.default,
+ forEach: _each2.default,
+ forEachSeries: _eachSeries2.default,
+ forEachLimit: _eachLimit2.default,
+ forEachOf: _eachOf2.default,
+ forEachOfSeries: _eachOfSeries2.default,
+ forEachOfLimit: _eachOfLimit2.default,
+ inject: _reduce2.default,
+ foldl: _reduce2.default,
+ foldr: _reduceRight2.default,
+ select: _filter2.default,
+ selectLimit: _filterLimit2.default,
+ selectSeries: _filterSeries2.default,
+ wrapSync: _asyncify2.default
+};
+exports.applyEach = _applyEach2.default;
+exports.applyEachSeries = _applyEachSeries2.default;
+exports.apply = _apply2.default;
+exports.asyncify = _asyncify2.default;
+exports.auto = _auto2.default;
+exports.autoInject = _autoInject2.default;
+exports.cargo = _cargo2.default;
+exports.compose = _compose2.default;
+exports.concat = _concat2.default;
+exports.concatSeries = _concatSeries2.default;
+exports.constant = _constant2.default;
+exports.detect = _detect2.default;
+exports.detectLimit = _detectLimit2.default;
+exports.detectSeries = _detectSeries2.default;
+exports.dir = _dir2.default;
+exports.doDuring = _doDuring2.default;
+exports.doUntil = _doUntil2.default;
+exports.doWhilst = _doWhilst2.default;
+exports.during = _during2.default;
+exports.each = _each2.default;
+exports.eachLimit = _eachLimit2.default;
+exports.eachOf = _eachOf2.default;
+exports.eachOfLimit = _eachOfLimit2.default;
+exports.eachOfSeries = _eachOfSeries2.default;
+exports.eachSeries = _eachSeries2.default;
+exports.ensureAsync = _ensureAsync2.default;
+exports.every = _every2.default;
+exports.everyLimit = _everyLimit2.default;
+exports.everySeries = _everySeries2.default;
+exports.filter = _filter2.default;
+exports.filterLimit = _filterLimit2.default;
+exports.filterSeries = _filterSeries2.default;
+exports.forever = _forever2.default;
+exports.log = _log2.default;
+exports.map = _map2.default;
+exports.mapLimit = _mapLimit2.default;
+exports.mapSeries = _mapSeries2.default;
+exports.mapValues = _mapValues2.default;
+exports.mapValuesLimit = _mapValuesLimit2.default;
+exports.mapValuesSeries = _mapValuesSeries2.default;
+exports.memoize = _memoize2.default;
+exports.nextTick = _nextTick2.default;
+exports.parallel = _parallel2.default;
+exports.parallelLimit = _parallelLimit2.default;
+exports.priorityQueue = _priorityQueue2.default;
+exports.queue = _queue2.default;
+exports.race = _race2.default;
+exports.reduce = _reduce2.default;
+exports.reduceRight = _reduceRight2.default;
+exports.reflect = _reflect2.default;
+exports.reflectAll = _reflectAll2.default;
+exports.reject = _reject2.default;
+exports.rejectLimit = _rejectLimit2.default;
+exports.rejectSeries = _rejectSeries2.default;
+exports.retry = _retry2.default;
+exports.retryable = _retryable2.default;
+exports.seq = _seq2.default;
+exports.series = _series2.default;
+exports.setImmediate = _setImmediate2.default;
+exports.some = _some2.default;
+exports.someLimit = _someLimit2.default;
+exports.someSeries = _someSeries2.default;
+exports.sortBy = _sortBy2.default;
+exports.timeout = _timeout2.default;
+exports.times = _times2.default;
+exports.timesLimit = _timesLimit2.default;
+exports.timesSeries = _timesSeries2.default;
+exports.transform = _transform2.default;
+exports.unmemoize = _unmemoize2.default;
+exports.until = _until2.default;
+exports.waterfall = _waterfall2.default;
+exports.whilst = _whilst2.default;
+exports.all = _every2.default;
+exports.allLimit = _everyLimit2.default;
+exports.allSeries = _everySeries2.default;
+exports.any = _some2.default;
+exports.anyLimit = _someLimit2.default;
+exports.anySeries = _someSeries2.default;
+exports.find = _detect2.default;
+exports.findLimit = _detectLimit2.default;
+exports.findSeries = _detectSeries2.default;
+exports.forEach = _each2.default;
+exports.forEachSeries = _eachSeries2.default;
+exports.forEachLimit = _eachLimit2.default;
+exports.forEachOf = _eachOf2.default;
+exports.forEachOfSeries = _eachOfSeries2.default;
+exports.forEachOfLimit = _eachOfLimit2.default;
+exports.inject = _reduce2.default;
+exports.foldl = _reduce2.default;
+exports.foldr = _reduceRight2.default;
+exports.select = _filter2.default;
+exports.selectLimit = _filterLimit2.default;
+exports.selectSeries = _filterSeries2.default;
+exports.wrapSync = _asyncify2.default; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/DoublyLinkedList.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/DoublyLinkedList.js
new file mode 100644
index 0000000..796d123
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/DoublyLinkedList.js
@@ -0,0 +1,63 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = DLL;
+// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
+// used for queues. This implementation assumes that the node provided by the user can be modified
+// to adjust the next and last properties. We implement only the minimal functionality
+// for queue support.
+function DLL() {
+ this.head = this.tail = null;
+ this.length = 0;
+}
+
+function setInitial(dll, node) {
+ dll.length = 1;
+ dll.head = dll.tail = node;
+}
+
+DLL.prototype.removeLink = function (node) {
+ if (node.prev) node.prev.next = node.next;else this.head = node.next;
+ if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
+
+ node.prev = node.next = null;
+ this.length -= 1;
+ return node;
+};
+
+DLL.prototype.empty = DLL;
+
+DLL.prototype.insertAfter = function (node, newNode) {
+ newNode.prev = node;
+ newNode.next = node.next;
+ if (node.next) node.next.prev = newNode;else this.tail = newNode;
+ node.next = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.insertBefore = function (node, newNode) {
+ newNode.prev = node.prev;
+ newNode.next = node;
+ if (node.prev) node.prev.next = newNode;else this.head = newNode;
+ node.prev = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.unshift = function (node) {
+ if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
+};
+
+DLL.prototype.push = function (node) {
+ if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
+};
+
+DLL.prototype.shift = function () {
+ return this.head && this.removeLink(this.head);
+};
+
+DLL.prototype.pop = function () {
+ return this.tail && this.removeLink(this.tail);
+};
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/applyEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/applyEach.js
new file mode 100644
index 0000000..bfe97e6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/applyEach.js
@@ -0,0 +1,33 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = applyEach;
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _initialParams = require('./initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function applyEach(eachfn) {
+ return (0, _baseRest2.default)(function (fns, args) {
+ var go = (0, _initialParams2.default)(function (args, callback) {
+ var that = this;
+ return eachfn(fns, function (fn, cb) {
+ fn.apply(that, args.concat([cb]));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ } else {
+ return go;
+ }
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/breakLoop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/breakLoop.js
new file mode 100644
index 0000000..1065058
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/breakLoop.js
@@ -0,0 +1,9 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+exports.default = {};
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/concat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/concat.js
new file mode 100644
index 0000000..f2ffb53
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/concat.js
@@ -0,0 +1,18 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = concat;
+function concat(eachfn, arr, fn, callback) {
+ var result = [];
+ eachfn(arr, function (x, index, cb) {
+ fn(x, function (err, y) {
+ result = result.concat(y || []);
+ cb(err);
+ });
+ }, function (err) {
+ callback(err, result);
+ });
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/consoleFunc.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/consoleFunc.js
new file mode 100644
index 0000000..0fdab2f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/consoleFunc.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = consoleFunc;
+
+var _arrayEach = require('lodash/_arrayEach');
+
+var _arrayEach2 = _interopRequireDefault(_arrayEach);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function consoleFunc(name) {
+ return (0, _baseRest2.default)(function (fn, args) {
+ fn.apply(null, args.concat([(0, _baseRest2.default)(function (err, args) {
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ } else if (console[name]) {
+ (0, _arrayEach2.default)(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ })]));
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/createTester.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/createTester.js
new file mode 100644
index 0000000..5330c38
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/createTester.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _createTester;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _breakLoop = require('./breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _createTester(eachfn, check, getResult) {
+ return function (arr, limit, iteratee, cb) {
+ function done() {
+ if (cb) {
+ cb(null, getResult(false));
+ }
+ }
+ function wrappedIteratee(x, _, callback) {
+ if (!cb) return callback();
+ iteratee(x, function (err, v) {
+ // Check cb as another iteratee may have resolved with a
+ // value or error since we started this iteratee
+ if (cb && (err || check(v))) {
+ if (err) cb(err);else cb(err, getResult(true, x));
+ cb = iteratee = false;
+ callback(err, _breakLoop2.default);
+ } else {
+ callback();
+ }
+ });
+ }
+ if (arguments.length > 3) {
+ cb = cb || _noop2.default;
+ eachfn(arr, limit, wrappedIteratee, done);
+ } else {
+ cb = iteratee;
+ cb = cb || _noop2.default;
+ iteratee = limit;
+ eachfn(arr, wrappedIteratee, done);
+ }
+ };
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doLimit.js
new file mode 100644
index 0000000..963c608
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doLimit.js
@@ -0,0 +1,12 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doLimit;
+function doLimit(fn, limit) {
+ return function (iterable, iteratee, callback) {
+ return fn(iterable, limit, iteratee, callback);
+ };
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallel.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallel.js
new file mode 100644
index 0000000..f4a30ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallel.js
@@ -0,0 +1,19 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doParallel;
+
+var _eachOf = require('../eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function doParallel(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(_eachOf2.default, obj, iteratee, callback);
+ };
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallelLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallelLimit.js
new file mode 100644
index 0000000..4c4d3b4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doParallelLimit.js
@@ -0,0 +1,19 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doParallelLimit;
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function doParallelLimit(fn) {
+ return function (obj, limit, iteratee, callback) {
+ return fn((0, _eachOfLimit2.default)(limit), obj, iteratee, callback);
+ };
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doSeries.js
new file mode 100644
index 0000000..b149d95
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/doSeries.js
@@ -0,0 +1,19 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doSeries;
+
+var _eachOfSeries = require('../eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function doSeries(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(_eachOfSeries2.default, obj, iteratee, callback);
+ };
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/eachOfLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/eachOfLimit.js
new file mode 100644
index 0000000..e4c74bb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/eachOfLimit.js
@@ -0,0 +1,71 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _eachOfLimit;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _iterator = require('./iterator');
+
+var _iterator2 = _interopRequireDefault(_iterator);
+
+var _onlyOnce = require('./onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _breakLoop = require('./breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _eachOfLimit(limit) {
+ return function (obj, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (limit <= 0 || !obj) {
+ return callback(null);
+ }
+ var nextElem = (0, _iterator2.default)(obj);
+ var done = false;
+ var running = 0;
+
+ function iterateeCallback(err, value) {
+ running -= 1;
+ if (err) {
+ done = true;
+ callback(err);
+ } else if (value === _breakLoop2.default || done && running <= 0) {
+ done = true;
+ return callback(null);
+ } else {
+ replenish();
+ }
+ }
+
+ function replenish() {
+ while (running < limit && !done) {
+ var elem = nextElem();
+ if (elem === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
+ }
+ }
+
+ replenish();
+ };
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/filter.js
new file mode 100644
index 0000000..ff163e9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/filter.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _filter;
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _baseProperty = require('lodash/_baseProperty');
+
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _filter(eachfn, arr, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var results = [];
+ eachfn(arr, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ if (err) {
+ callback(err);
+ } else {
+ if (v) {
+ results.push({ index: index, value: x });
+ }
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ callback(null, (0, _arrayMap2.default)(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), (0, _baseProperty2.default)('value')));
+ }
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/findGetResult.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/findGetResult.js
new file mode 100644
index 0000000..f8d3fe0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/findGetResult.js
@@ -0,0 +1,10 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _findGetResult;
+function _findGetResult(v, x) {
+ return x;
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/getIterator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/getIterator.js
new file mode 100644
index 0000000..3eadd24
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/getIterator.js
@@ -0,0 +1,13 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll) {
+ return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
+};
+
+var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
+
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/initialParams.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/initialParams.js
new file mode 100644
index 0000000..0142132
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/initialParams.js
@@ -0,0 +1,20 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (fn) {
+ return (0, _baseRest2.default)(function (args /*..., callback*/) {
+ var callback = args.pop();
+ fn.call(this, args, callback);
+ });
+};
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/iterator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/iterator.js
new file mode 100644
index 0000000..3d32942
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/iterator.js
@@ -0,0 +1,58 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = iterator;
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _getIterator = require('./getIterator');
+
+var _getIterator2 = _interopRequireDefault(_getIterator);
+
+var _keys = require('lodash/keys');
+
+var _keys2 = _interopRequireDefault(_keys);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function createArrayIterator(coll) {
+ var i = -1;
+ var len = coll.length;
+ return function next() {
+ return ++i < len ? { value: coll[i], key: i } : null;
+ };
+}
+
+function createES2015Iterator(iterator) {
+ var i = -1;
+ return function next() {
+ var item = iterator.next();
+ if (item.done) return null;
+ i++;
+ return { value: item.value, key: i };
+ };
+}
+
+function createObjectIterator(obj) {
+ var okeys = (0, _keys2.default)(obj);
+ var i = -1;
+ var len = okeys.length;
+ return function next() {
+ var key = okeys[++i];
+ return i < len ? { value: obj[key], key: key } : null;
+ };
+}
+
+function iterator(coll) {
+ if ((0, _isArrayLike2.default)(coll)) {
+ return createArrayIterator(coll);
+ }
+
+ var iterator = (0, _getIterator2.default)(coll);
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/map.js
new file mode 100644
index 0000000..e303d83
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/map.js
@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _asyncMap;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _asyncMap(eachfn, arr, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ arr = arr || [];
+ var results = [];
+ var counter = 0;
+
+ eachfn(arr, function (value, _, callback) {
+ var index = counter++;
+ iteratee(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/notId.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/notId.js
new file mode 100644
index 0000000..0106c92
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/notId.js
@@ -0,0 +1,10 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = notId;
+function notId(v) {
+ return !v;
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/once.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/once.js
new file mode 100644
index 0000000..f0c379f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/once.js
@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = once;
+function once(fn) {
+ return function () {
+ if (fn === null) return;
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/onlyOnce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/onlyOnce.js
new file mode 100644
index 0000000..f2e3001
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/onlyOnce.js
@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = onlyOnce;
+function onlyOnce(fn) {
+ return function () {
+ if (fn === null) throw new Error("Callback was already called.");
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/parallel.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/parallel.js
new file mode 100644
index 0000000..3915b20
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/parallel.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _parallel;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _parallel(eachfn, tasks, callback) {
+ callback = callback || _noop2.default;
+ var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ task((0, _baseRest2.default)(function (err, args) {
+ if (args.length <= 1) {
+ args = args[0];
+ }
+ results[key] = args;
+ callback(err);
+ }));
+ }, function (err) {
+ callback(err, results);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/queue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/queue.js
new file mode 100644
index 0000000..6d53cc2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/queue.js
@@ -0,0 +1,184 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = queue;
+
+var _baseIndexOf = require('lodash/_baseIndexOf');
+
+var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _onlyOnce = require('./onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _DoublyLinkedList = require('./DoublyLinkedList');
+
+var _DoublyLinkedList2 = _interopRequireDefault(_DoublyLinkedList);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function queue(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ } else if (concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
+ }
+
+ function _insert(data, insertAtFront, callback) {
+ if (callback != null && typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!(0, _isArray2.default)(data)) {
+ data = [data];
+ }
+ if (data.length === 0 && q.idle()) {
+ // call drain immediately if there are no tasks
+ return (0, _setImmediate2.default)(function () {
+ q.drain();
+ });
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ callback: callback || _noop2.default
+ };
+
+ if (insertAtFront) {
+ q._tasks.unshift(item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ (0, _setImmediate2.default)(q.process);
+ }
+
+ function _next(tasks) {
+ return (0, _baseRest2.default)(function (args) {
+ workers -= 1;
+
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ var task = tasks[i];
+ var index = (0, _baseIndexOf2.default)(workersList, task, 0);
+ if (index >= 0) {
+ workersList.splice(index);
+ }
+
+ task.callback.apply(task, args);
+
+ if (args[0] != null) {
+ q.error(args[0], task.data);
+ }
+ }
+
+ if (workers <= q.concurrency - q.buffer) {
+ q.unsaturated();
+ }
+
+ if (q.idle()) {
+ q.drain();
+ }
+ q.process();
+ });
+ }
+
+ var workers = 0;
+ var workersList = [];
+ var q = {
+ _tasks: new _DoublyLinkedList2.default(),
+ concurrency: concurrency,
+ payload: payload,
+ saturated: _noop2.default,
+ unsaturated: _noop2.default,
+ buffer: concurrency / 4,
+ empty: _noop2.default,
+ drain: _noop2.default,
+ error: _noop2.default,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(data, false, callback);
+ },
+ kill: function () {
+ q.drain = _noop2.default;
+ q._tasks.empty();
+ },
+ unshift: function (data, callback) {
+ _insert(data, true, callback);
+ },
+ process: function () {
+ while (!q.paused && workers < q.concurrency && q._tasks.length) {
+ var tasks = [],
+ data = [];
+ var l = q._tasks.length;
+ if (q.payload) l = Math.min(l, q.payload);
+ for (var i = 0; i < l; i++) {
+ var node = q._tasks.shift();
+ tasks.push(node);
+ data.push(node.data);
+ }
+
+ if (q._tasks.length === 0) {
+ q.empty();
+ }
+ workers += 1;
+ workersList.push(tasks[0]);
+
+ if (workers === q.concurrency) {
+ q.saturated();
+ }
+
+ var cb = (0, _onlyOnce2.default)(_next(tasks));
+ worker(data, cb);
+ }
+ },
+ length: function () {
+ return q._tasks.length;
+ },
+ running: function () {
+ return workers;
+ },
+ workersList: function () {
+ return workersList;
+ },
+ idle: function () {
+ return q._tasks.length + workers === 0;
+ },
+ pause: function () {
+ q.paused = true;
+ },
+ resume: function () {
+ if (q.paused === false) {
+ return;
+ }
+ q.paused = false;
+ var resumeCount = Math.min(q.concurrency, q._tasks.length);
+ // Need to call q.process once per concurrent
+ // worker to preserve full concurrency after pause
+ for (var w = 1; w <= resumeCount; w++) {
+ (0, _setImmediate2.default)(q.process);
+ }
+ }
+ };
+ return q;
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/reject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/reject.js
new file mode 100644
index 0000000..b20cc3b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/reject.js
@@ -0,0 +1,25 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reject;
+
+var _filter = require('./filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function reject(eachfn, arr, iteratee, callback) {
+ (0, _filter2.default)(eachfn, arr, function (value, cb) {
+ iteratee(value, function (err, v) {
+ if (err) {
+ cb(err);
+ } else {
+ cb(null, !v);
+ }
+ });
+ }, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/setImmediate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/setImmediate.js
new file mode 100644
index 0000000..18f170d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/setImmediate.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.hasNextTick = exports.hasSetImmediate = undefined;
+exports.fallback = fallback;
+exports.wrap = wrap;
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
+var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
+
+function fallback(fn) {
+ setTimeout(fn, 0);
+}
+
+function wrap(defer) {
+ return (0, _baseRest2.default)(function (fn, args) {
+ defer(function () {
+ fn.apply(null, args);
+ });
+ });
+}
+
+var _defer;
+
+if (hasSetImmediate) {
+ _defer = setImmediate;
+} else if (hasNextTick) {
+ _defer = process.nextTick;
+} else {
+ _defer = fallback;
+}
+
+exports.default = wrap(_defer); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/withoutIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/withoutIndex.js
new file mode 100644
index 0000000..2bd3579
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/internal/withoutIndex.js
@@ -0,0 +1,12 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _withoutIndex;
+function _withoutIndex(iteratee) {
+ return function (value, index, callback) {
+ return iteratee(value, callback);
+ };
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/log.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/log.js
new file mode 100644
index 0000000..ac04693
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/log.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _consoleFunc = require('./internal/consoleFunc');
+
+var _consoleFunc2 = _interopRequireDefault(_consoleFunc);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} function - The function you want to eventually apply all
+ * arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, 'hello ' + name);
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+exports.default = (0, _consoleFunc2.default)('log');
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/map.js
new file mode 100644
index 0000000..37e0b01
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/map.js
@@ -0,0 +1,54 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _map = require('./internal/map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array. The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines)
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ * // results is now an array of stats for each file
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_map2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapLimit.js
new file mode 100644
index 0000000..9165e0a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _map = require('./internal/map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a transformed
+ * item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_map2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapSeries.js
new file mode 100644
index 0000000..b3894ad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapSeries.js
@@ -0,0 +1,36 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed item. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+exports.default = (0, _doLimit2.default)(_mapLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValues.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValues.js
new file mode 100644
index 0000000..6677637
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValues.js
@@ -0,0 +1,63 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed. The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value and key in
+ * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
+ * called once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ * f1: 'file1',
+ * f2: 'file2',
+ * f3: 'file3'
+ * }, function (file, key, callback) {
+ * fs.stat(file, callback);
+ * }, function(err, result) {
+ * // result is now a map of stats for each file, e.g.
+ * // {
+ * // f1: [stats for file1],
+ * // f2: [stats for file2],
+ * // f3: [stats for file3]
+ * // }
+ * });
+ */
+
+exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, Infinity);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesLimit.js
new file mode 100644
index 0000000..f331fa0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesLimit.js
@@ -0,0 +1,56 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = mapValuesLimit;
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var newObj = {};
+ (0, _eachOfLimit2.default)(obj, limit, function (val, key, next) {
+ iteratee(val, key, function (err, result) {
+ if (err) return next(err);
+ newObj[key] = result;
+ next();
+ });
+ }, function (err) {
+ callback(err, newObj);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesSeries.js
new file mode 100644
index 0000000..6385719
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/mapValuesSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each value in `obj`.
+ * The iteratee is passed a `callback(err, transformed)` which must be called
+ * once it has completed with an error (which can be `null`) and a
+ * transformed value. Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/memoize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/memoize.js
new file mode 100644
index 0000000..4c757ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/memoize.js
@@ -0,0 +1,95 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = memoize;
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function has(obj, key) {
+ return key in obj;
+}
+
+/**
+ * Caches the results of an `async` function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {Function} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ * // do something
+ * callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ * // callback
+ * });
+ */
+function memoize(fn, hasher) {
+ var memo = Object.create(null);
+ var queues = Object.create(null);
+ hasher = hasher || _identity2.default;
+ var memoized = (0, _initialParams2.default)(function memoized(args, callback) {
+ var key = hasher.apply(null, args);
+ if (has(memo, key)) {
+ (0, _setImmediate2.default)(function () {
+ callback.apply(null, memo[key]);
+ });
+ } else if (has(queues, key)) {
+ queues[key].push(callback);
+ } else {
+ queues[key] = [callback];
+ fn.apply(null, args.concat([(0, _baseRest2.default)(function (args) {
+ memo[key] = args;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, args);
+ }
+ })]));
+ }
+ });
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/nextTick.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/nextTick.js
new file mode 100644
index 0000000..fa48e32
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/nextTick.js
@@ -0,0 +1,51 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _setImmediate = require('./internal/setImmediate');
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias setImmediate
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer;
+
+if (_setImmediate.hasNextTick) {
+ _defer = process.nextTick;
+} else if (_setImmediate.hasSetImmediate) {
+ _defer = setImmediate;
+} else {
+ _defer = _setImmediate.fallback;
+}
+
+exports.default = (0, _setImmediate.wrap)(_defer);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/LICENSE
new file mode 100644
index 0000000..c6f2f61
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/LICENSE
@@ -0,0 +1,47 @@
+Copyright JS Foundation and other contributors <https://js.foundation/>
+
+Based on Underscore.js, copyright Jeremy Ashkenas,
+DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
+
+This software consists of voluntary contributions made by many
+individuals. For exact contribution history, see the revision history
+available at https://github.com/lodash/lodash
+
+The following license applies to all parts of this software except as
+documented below:
+
+====
+
+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.
+
+====
+
+Copyright and related rights for sample code are waived via CC0. Sample
+code is defined as all source code displayed within the prose of the
+documentation.
+
+CC0: http://creativecommons.org/publicdomain/zero/1.0/
+
+====
+
+Files located in the node_modules and vendor directories are externally
+maintained libraries used by this software which have their own
+licenses; we recommend you read them, as their terms may differ from the
+terms above.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/README.md
new file mode 100644
index 0000000..382e740
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/README.md
@@ -0,0 +1,39 @@
+# lodash v4.17.2
+
+The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
+
+## Installation
+
+Using npm:
+```shell
+$ npm i -g npm
+$ npm i --save lodash
+```
+
+In Node.js:
+```js
+// Load the full build.
+var _ = require('lodash');
+// Load the core build.
+var _ = require('lodash/core');
+// Load the FP build for immutable auto-curried iteratee-first data-last methods.
+var fp = require('lodash/fp');
+
+// Load method categories.
+var array = require('lodash/array');
+var object = require('lodash/fp/object');
+
+// Cherry-pick methods for smaller browserify/rollup/webpack bundles.
+var at = require('lodash/at');
+var curryN = require('lodash/fp/curryN');
+```
+
+See the [package source](https://github.com/lodash/lodash/tree/4.17.2-npm) for more details.
+
+**Note:**<br>
+Install [n_](https://www.npmjs.com/package/n_) for Lodash use in the Node.js < 6 REPL.
+
+## Support
+
+Tested in Chrome 53-54, Firefox 48-49, IE 11, Edge 14, Safari 9-10, Node.js 6-7, & PhantomJS 2.1.1.<br>
+Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_DataView.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_DataView.js
new file mode 100644
index 0000000..ac2d57c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_DataView.js
@@ -0,0 +1,7 @@
+var getNative = require('./_getNative'),
+ root = require('./_root');
+
+/* Built-in method references that are verified to be native. */
+var DataView = getNative(root, 'DataView');
+
+module.exports = DataView;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Hash.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Hash.js
new file mode 100644
index 0000000..b504fe3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Hash.js
@@ -0,0 +1,32 @@
+var hashClear = require('./_hashClear'),
+ hashDelete = require('./_hashDelete'),
+ hashGet = require('./_hashGet'),
+ hashHas = require('./_hashHas'),
+ hashSet = require('./_hashSet');
+
+/**
+ * Creates a hash object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function Hash(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `Hash`.
+Hash.prototype.clear = hashClear;
+Hash.prototype['delete'] = hashDelete;
+Hash.prototype.get = hashGet;
+Hash.prototype.has = hashHas;
+Hash.prototype.set = hashSet;
+
+module.exports = Hash;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LazyWrapper.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LazyWrapper.js
new file mode 100644
index 0000000..81786c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LazyWrapper.js
@@ -0,0 +1,28 @@
+var baseCreate = require('./_baseCreate'),
+ baseLodash = require('./_baseLodash');
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295;
+
+/**
+ * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
+ *
+ * @private
+ * @constructor
+ * @param {*} value The value to wrap.
+ */
+function LazyWrapper(value) {
+ this.__wrapped__ = value;
+ this.__actions__ = [];
+ this.__dir__ = 1;
+ this.__filtered__ = false;
+ this.__iteratees__ = [];
+ this.__takeCount__ = MAX_ARRAY_LENGTH;
+ this.__views__ = [];
+}
+
+// Ensure `LazyWrapper` is an instance of `baseLodash`.
+LazyWrapper.prototype = baseCreate(baseLodash.prototype);
+LazyWrapper.prototype.constructor = LazyWrapper;
+
+module.exports = LazyWrapper;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_ListCache.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_ListCache.js
new file mode 100644
index 0000000..26895c3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_ListCache.js
@@ -0,0 +1,32 @@
+var listCacheClear = require('./_listCacheClear'),
+ listCacheDelete = require('./_listCacheDelete'),
+ listCacheGet = require('./_listCacheGet'),
+ listCacheHas = require('./_listCacheHas'),
+ listCacheSet = require('./_listCacheSet');
+
+/**
+ * Creates an list cache object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function ListCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `ListCache`.
+ListCache.prototype.clear = listCacheClear;
+ListCache.prototype['delete'] = listCacheDelete;
+ListCache.prototype.get = listCacheGet;
+ListCache.prototype.has = listCacheHas;
+ListCache.prototype.set = listCacheSet;
+
+module.exports = ListCache;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LodashWrapper.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LodashWrapper.js
new file mode 100644
index 0000000..c1e4d9d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_LodashWrapper.js
@@ -0,0 +1,22 @@
+var baseCreate = require('./_baseCreate'),
+ baseLodash = require('./_baseLodash');
+
+/**
+ * The base constructor for creating `lodash` wrapper objects.
+ *
+ * @private
+ * @param {*} value The value to wrap.
+ * @param {boolean} [chainAll] Enable explicit method chain sequences.
+ */
+function LodashWrapper(value, chainAll) {
+ this.__wrapped__ = value;
+ this.__actions__ = [];
+ this.__chain__ = !!chainAll;
+ this.__index__ = 0;
+ this.__values__ = undefined;
+}
+
+LodashWrapper.prototype = baseCreate(baseLodash.prototype);
+LodashWrapper.prototype.constructor = LodashWrapper;
+
+module.exports = LodashWrapper;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Map.js
new file mode 100644
index 0000000..b73f29a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Map.js
@@ -0,0 +1,7 @@
+var getNative = require('./_getNative'),
+ root = require('./_root');
+
+/* Built-in method references that are verified to be native. */
+var Map = getNative(root, 'Map');
+
+module.exports = Map;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_MapCache.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_MapCache.js
new file mode 100644
index 0000000..4a4eea7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_MapCache.js
@@ -0,0 +1,32 @@
+var mapCacheClear = require('./_mapCacheClear'),
+ mapCacheDelete = require('./_mapCacheDelete'),
+ mapCacheGet = require('./_mapCacheGet'),
+ mapCacheHas = require('./_mapCacheHas'),
+ mapCacheSet = require('./_mapCacheSet');
+
+/**
+ * Creates a map cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function MapCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+}
+
+// Add methods to `MapCache`.
+MapCache.prototype.clear = mapCacheClear;
+MapCache.prototype['delete'] = mapCacheDelete;
+MapCache.prototype.get = mapCacheGet;
+MapCache.prototype.has = mapCacheHas;
+MapCache.prototype.set = mapCacheSet;
+
+module.exports = MapCache;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Promise.js
new file mode 100644
index 0000000..247b9e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Promise.js
@@ -0,0 +1,7 @@
+var getNative = require('./_getNative'),
+ root = require('./_root');
+
+/* Built-in method references that are verified to be native. */
+var Promise = getNative(root, 'Promise');
+
+module.exports = Promise;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Set.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Set.js
new file mode 100644
index 0000000..b3c8dcb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Set.js
@@ -0,0 +1,7 @@
+var getNative = require('./_getNative'),
+ root = require('./_root');
+
+/* Built-in method references that are verified to be native. */
+var Set = getNative(root, 'Set');
+
+module.exports = Set;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_SetCache.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_SetCache.js
new file mode 100644
index 0000000..6468b06
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_SetCache.js
@@ -0,0 +1,27 @@
+var MapCache = require('./_MapCache'),
+ setCacheAdd = require('./_setCacheAdd'),
+ setCacheHas = require('./_setCacheHas');
+
+/**
+ *
+ * Creates an array cache object to store unique values.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [values] The values to cache.
+ */
+function SetCache(values) {
+ var index = -1,
+ length = values == null ? 0 : values.length;
+
+ this.__data__ = new MapCache;
+ while (++index < length) {
+ this.add(values[index]);
+ }
+}
+
+// Add methods to `SetCache`.
+SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
+SetCache.prototype.has = setCacheHas;
+
+module.exports = SetCache;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Stack.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Stack.js
new file mode 100644
index 0000000..80b2cf1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Stack.js
@@ -0,0 +1,27 @@
+var ListCache = require('./_ListCache'),
+ stackClear = require('./_stackClear'),
+ stackDelete = require('./_stackDelete'),
+ stackGet = require('./_stackGet'),
+ stackHas = require('./_stackHas'),
+ stackSet = require('./_stackSet');
+
+/**
+ * Creates a stack cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+function Stack(entries) {
+ var data = this.__data__ = new ListCache(entries);
+ this.size = data.size;
+}
+
+// Add methods to `Stack`.
+Stack.prototype.clear = stackClear;
+Stack.prototype['delete'] = stackDelete;
+Stack.prototype.get = stackGet;
+Stack.prototype.has = stackHas;
+Stack.prototype.set = stackSet;
+
+module.exports = Stack;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Symbol.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Symbol.js
new file mode 100644
index 0000000..a013f7c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Symbol.js
@@ -0,0 +1,6 @@
+var root = require('./_root');
+
+/** Built-in value references. */
+var Symbol = root.Symbol;
+
+module.exports = Symbol;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Uint8Array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Uint8Array.js
new file mode 100644
index 0000000..2fb30e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_Uint8Array.js
@@ -0,0 +1,6 @@
+var root = require('./_root');
+
+/** Built-in value references. */
+var Uint8Array = root.Uint8Array;
+
+module.exports = Uint8Array;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_WeakMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_WeakMap.js
new file mode 100644
index 0000000..567f86c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_WeakMap.js
@@ -0,0 +1,7 @@
+var getNative = require('./_getNative'),
+ root = require('./_root');
+
+/* Built-in method references that are verified to be native. */
+var WeakMap = getNative(root, 'WeakMap');
+
+module.exports = WeakMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addMapEntry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addMapEntry.js
new file mode 100644
index 0000000..5a69212
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addMapEntry.js
@@ -0,0 +1,15 @@
+/**
+ * Adds the key-value `pair` to `map`.
+ *
+ * @private
+ * @param {Object} map The map to modify.
+ * @param {Array} pair The key-value pair to add.
+ * @returns {Object} Returns `map`.
+ */
+function addMapEntry(map, pair) {
+ // Don't return `map.set` because it's not chainable in IE 11.
+ map.set(pair[0], pair[1]);
+ return map;
+}
+
+module.exports = addMapEntry;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addSetEntry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addSetEntry.js
new file mode 100644
index 0000000..1a07b70
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_addSetEntry.js
@@ -0,0 +1,15 @@
+/**
+ * Adds `value` to `set`.
+ *
+ * @private
+ * @param {Object} set The set to modify.
+ * @param {*} value The value to add.
+ * @returns {Object} Returns `set`.
+ */
+function addSetEntry(set, value) {
+ // Don't return `set.add` because it's not chainable in IE 11.
+ set.add(value);
+ return set;
+}
+
+module.exports = addSetEntry;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_apply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_apply.js
new file mode 100644
index 0000000..36436dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_apply.js
@@ -0,0 +1,21 @@
+/**
+ * A faster alternative to `Function#apply`, this function invokes `func`
+ * with the `this` binding of `thisArg` and the arguments of `args`.
+ *
+ * @private
+ * @param {Function} func The function to invoke.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} args The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+function apply(func, thisArg, args) {
+ switch (args.length) {
+ case 0: return func.call(thisArg);
+ case 1: return func.call(thisArg, args[0]);
+ case 2: return func.call(thisArg, args[0], args[1]);
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
+ }
+ return func.apply(thisArg, args);
+}
+
+module.exports = apply;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayAggregator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayAggregator.js
new file mode 100644
index 0000000..d96c3ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayAggregator.js
@@ -0,0 +1,22 @@
+/**
+ * A specialized version of `baseAggregator` for arrays.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform keys.
+ * @param {Object} accumulator The initial aggregated object.
+ * @returns {Function} Returns `accumulator`.
+ */
+function arrayAggregator(array, setter, iteratee, accumulator) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ var value = array[index];
+ setter(accumulator, value, iteratee(value), array);
+ }
+ return accumulator;
+}
+
+module.exports = arrayAggregator;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEach.js
new file mode 100644
index 0000000..2c5f579
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEach.js
@@ -0,0 +1,22 @@
+/**
+ * A specialized version of `_.forEach` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+function arrayEach(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
+ }
+ }
+ return array;
+}
+
+module.exports = arrayEach;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEachRight.js
new file mode 100644
index 0000000..976ca5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEachRight.js
@@ -0,0 +1,21 @@
+/**
+ * A specialized version of `_.forEachRight` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+function arrayEachRight(array, iteratee) {
+ var length = array == null ? 0 : array.length;
+
+ while (length--) {
+ if (iteratee(array[length], length, array) === false) {
+ break;
+ }
+ }
+ return array;
+}
+
+module.exports = arrayEachRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEvery.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEvery.js
new file mode 100644
index 0000000..e26a918
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayEvery.js
@@ -0,0 +1,23 @@
+/**
+ * A specialized version of `_.every` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`.
+ */
+function arrayEvery(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (!predicate(array[index], index, array)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+module.exports = arrayEvery;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayFilter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayFilter.js
new file mode 100644
index 0000000..75ea254
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayFilter.js
@@ -0,0 +1,25 @@
+/**
+ * A specialized version of `_.filter` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+function arrayFilter(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value, index, array)) {
+ result[resIndex++] = value;
+ }
+ }
+ return result;
+}
+
+module.exports = arrayFilter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludes.js
new file mode 100644
index 0000000..3737a6d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludes.js
@@ -0,0 +1,17 @@
+var baseIndexOf = require('./_baseIndexOf');
+
+/**
+ * A specialized version of `_.includes` for arrays without support for
+ * specifying an index to search from.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+function arrayIncludes(array, value) {
+ var length = array == null ? 0 : array.length;
+ return !!length && baseIndexOf(array, value, 0) > -1;
+}
+
+module.exports = arrayIncludes;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludesWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludesWith.js
new file mode 100644
index 0000000..235fd97
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayIncludesWith.js
@@ -0,0 +1,22 @@
+/**
+ * This function is like `arrayIncludes` except that it accepts a comparator.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @param {Function} comparator The comparator invoked per element.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+function arrayIncludesWith(array, value, comparator) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (comparator(value, array[index])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+module.exports = arrayIncludesWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayLikeKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayLikeKeys.js
new file mode 100644
index 0000000..b2ec9ce
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayLikeKeys.js
@@ -0,0 +1,49 @@
+var baseTimes = require('./_baseTimes'),
+ isArguments = require('./isArguments'),
+ isArray = require('./isArray'),
+ isBuffer = require('./isBuffer'),
+ isIndex = require('./_isIndex'),
+ isTypedArray = require('./isTypedArray');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = arrayLikeKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayMap.js
new file mode 100644
index 0000000..22b2246
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayMap.js
@@ -0,0 +1,21 @@
+/**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+}
+
+module.exports = arrayMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayPush.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayPush.js
new file mode 100644
index 0000000..7d742b3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayPush.js
@@ -0,0 +1,20 @@
+/**
+ * Appends the elements of `values` to `array`.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to append.
+ * @returns {Array} Returns `array`.
+ */
+function arrayPush(array, values) {
+ var index = -1,
+ length = values.length,
+ offset = array.length;
+
+ while (++index < length) {
+ array[offset + index] = values[index];
+ }
+ return array;
+}
+
+module.exports = arrayPush;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduce.js
new file mode 100644
index 0000000..de8b79b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduce.js
@@ -0,0 +1,26 @@
+/**
+ * A specialized version of `_.reduce` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
+ * the initial value.
+ * @returns {*} Returns the accumulated value.
+ */
+function arrayReduce(array, iteratee, accumulator, initAccum) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ if (initAccum && length) {
+ accumulator = array[++index];
+ }
+ while (++index < length) {
+ accumulator = iteratee(accumulator, array[index], index, array);
+ }
+ return accumulator;
+}
+
+module.exports = arrayReduce;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduceRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduceRight.js
new file mode 100644
index 0000000..22d8976
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayReduceRight.js
@@ -0,0 +1,24 @@
+/**
+ * A specialized version of `_.reduceRight` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @param {boolean} [initAccum] Specify using the last element of `array` as
+ * the initial value.
+ * @returns {*} Returns the accumulated value.
+ */
+function arrayReduceRight(array, iteratee, accumulator, initAccum) {
+ var length = array == null ? 0 : array.length;
+ if (initAccum && length) {
+ accumulator = array[--length];
+ }
+ while (length--) {
+ accumulator = iteratee(accumulator, array[length], length, array);
+ }
+ return accumulator;
+}
+
+module.exports = arrayReduceRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySample.js
new file mode 100644
index 0000000..fcab010
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySample.js
@@ -0,0 +1,15 @@
+var baseRandom = require('./_baseRandom');
+
+/**
+ * A specialized version of `_.sample` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @returns {*} Returns the random element.
+ */
+function arraySample(array) {
+ var length = array.length;
+ return length ? array[baseRandom(0, length - 1)] : undefined;
+}
+
+module.exports = arraySample;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySampleSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySampleSize.js
new file mode 100644
index 0000000..8c7e364
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySampleSize.js
@@ -0,0 +1,17 @@
+var baseClamp = require('./_baseClamp'),
+ copyArray = require('./_copyArray'),
+ shuffleSelf = require('./_shuffleSelf');
+
+/**
+ * A specialized version of `_.sampleSize` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+function arraySampleSize(array, n) {
+ return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
+}
+
+module.exports = arraySampleSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayShuffle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayShuffle.js
new file mode 100644
index 0000000..46313a3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arrayShuffle.js
@@ -0,0 +1,15 @@
+var copyArray = require('./_copyArray'),
+ shuffleSelf = require('./_shuffleSelf');
+
+/**
+ * A specialized version of `_.shuffle` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+function arrayShuffle(array) {
+ return shuffleSelf(copyArray(array));
+}
+
+module.exports = arrayShuffle;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySome.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySome.js
new file mode 100644
index 0000000..6fd02fd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_arraySome.js
@@ -0,0 +1,23 @@
+/**
+ * A specialized version of `_.some` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+function arraySome(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (predicate(array[index], index, array)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+module.exports = arraySome;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiSize.js
new file mode 100644
index 0000000..11d29c3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiSize.js
@@ -0,0 +1,12 @@
+var baseProperty = require('./_baseProperty');
+
+/**
+ * Gets the size of an ASCII `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+var asciiSize = baseProperty('length');
+
+module.exports = asciiSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiToArray.js
new file mode 100644
index 0000000..8e3dd5b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiToArray.js
@@ -0,0 +1,12 @@
+/**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function asciiToArray(string) {
+ return string.split('');
+}
+
+module.exports = asciiToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiWords.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiWords.js
new file mode 100644
index 0000000..d765f0f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_asciiWords.js
@@ -0,0 +1,15 @@
+/** Used to match words composed of alphanumeric characters. */
+var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
+
+/**
+ * Splits an ASCII `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+function asciiWords(string) {
+ return string.match(reAsciiWord) || [];
+}
+
+module.exports = asciiWords;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignInDefaults.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignInDefaults.js
new file mode 100644
index 0000000..ea6b0e3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignInDefaults.js
@@ -0,0 +1,27 @@
+var eq = require('./eq');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Used by `_.defaults` to customize its `_.assignIn` use.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to assign.
+ * @param {Object} object The parent object of `objValue`.
+ * @returns {*} Returns the value to assign.
+ */
+function assignInDefaults(objValue, srcValue, key, object) {
+ if (objValue === undefined ||
+ (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
+ return srcValue;
+ }
+ return objValue;
+}
+
+module.exports = assignInDefaults;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignMergeValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignMergeValue.js
new file mode 100644
index 0000000..cb1185e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignMergeValue.js
@@ -0,0 +1,20 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ eq = require('./eq');
+
+/**
+ * This function is like `assignValue` except that it doesn't assign
+ * `undefined` values.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+function assignMergeValue(object, key, value) {
+ if ((value !== undefined && !eq(object[key], value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+}
+
+module.exports = assignMergeValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignValue.js
new file mode 100644
index 0000000..4083957
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assignValue.js
@@ -0,0 +1,28 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ eq = require('./eq');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+function assignValue(object, key, value) {
+ var objValue = object[key];
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+}
+
+module.exports = assignValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assocIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assocIndexOf.js
new file mode 100644
index 0000000..5b77a2b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_assocIndexOf.js
@@ -0,0 +1,21 @@
+var eq = require('./eq');
+
+/**
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} key The key to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function assocIndexOf(array, key) {
+ var length = array.length;
+ while (length--) {
+ if (eq(array[length][0], key)) {
+ return length;
+ }
+ }
+ return -1;
+}
+
+module.exports = assocIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAggregator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAggregator.js
new file mode 100644
index 0000000..4bc9e91
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAggregator.js
@@ -0,0 +1,21 @@
+var baseEach = require('./_baseEach');
+
+/**
+ * Aggregates elements of `collection` on `accumulator` with keys transformed
+ * by `iteratee` and values set by `setter`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform keys.
+ * @param {Object} accumulator The initial aggregated object.
+ * @returns {Function} Returns `accumulator`.
+ */
+function baseAggregator(collection, setter, iteratee, accumulator) {
+ baseEach(collection, function(value, key, collection) {
+ setter(accumulator, value, iteratee(value), collection);
+ });
+ return accumulator;
+}
+
+module.exports = baseAggregator;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssign.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssign.js
new file mode 100644
index 0000000..e5c4a1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssign.js
@@ -0,0 +1,17 @@
+var copyObject = require('./_copyObject'),
+ keys = require('./keys');
+
+/**
+ * The base implementation of `_.assign` without support for multiple sources
+ * or `customizer` functions.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @returns {Object} Returns `object`.
+ */
+function baseAssign(object, source) {
+ return object && copyObject(source, keys(source), object);
+}
+
+module.exports = baseAssign;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignIn.js
new file mode 100644
index 0000000..6624f90
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignIn.js
@@ -0,0 +1,17 @@
+var copyObject = require('./_copyObject'),
+ keysIn = require('./keysIn');
+
+/**
+ * The base implementation of `_.assignIn` without support for multiple sources
+ * or `customizer` functions.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @returns {Object} Returns `object`.
+ */
+function baseAssignIn(object, source) {
+ return object && copyObject(source, keysIn(source), object);
+}
+
+module.exports = baseAssignIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignValue.js
new file mode 100644
index 0000000..d6f66ef
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAssignValue.js
@@ -0,0 +1,25 @@
+var defineProperty = require('./_defineProperty');
+
+/**
+ * The base implementation of `assignValue` and `assignMergeValue` without
+ * value checks.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+function baseAssignValue(object, key, value) {
+ if (key == '__proto__' && defineProperty) {
+ defineProperty(object, key, {
+ 'configurable': true,
+ 'enumerable': true,
+ 'value': value,
+ 'writable': true
+ });
+ } else {
+ object[key] = value;
+ }
+}
+
+module.exports = baseAssignValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAt.js
new file mode 100644
index 0000000..90e4237
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseAt.js
@@ -0,0 +1,23 @@
+var get = require('./get');
+
+/**
+ * The base implementation of `_.at` without support for individual paths.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {string[]} paths The property paths to pick.
+ * @returns {Array} Returns the picked elements.
+ */
+function baseAt(object, paths) {
+ var index = -1,
+ length = paths.length,
+ result = Array(length),
+ skip = object == null;
+
+ while (++index < length) {
+ result[index] = skip ? undefined : get(object, paths[index]);
+ }
+ return result;
+}
+
+module.exports = baseAt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClamp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClamp.js
new file mode 100644
index 0000000..a1c5692
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClamp.js
@@ -0,0 +1,22 @@
+/**
+ * The base implementation of `_.clamp` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {number} number The number to clamp.
+ * @param {number} [lower] The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the clamped number.
+ */
+function baseClamp(number, lower, upper) {
+ if (number === number) {
+ if (upper !== undefined) {
+ number = number <= upper ? number : upper;
+ }
+ if (lower !== undefined) {
+ number = number >= lower ? number : lower;
+ }
+ }
+ return number;
+}
+
+module.exports = baseClamp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClone.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClone.js
new file mode 100644
index 0000000..7c27a37
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseClone.js
@@ -0,0 +1,153 @@
+var Stack = require('./_Stack'),
+ arrayEach = require('./_arrayEach'),
+ assignValue = require('./_assignValue'),
+ baseAssign = require('./_baseAssign'),
+ baseAssignIn = require('./_baseAssignIn'),
+ cloneBuffer = require('./_cloneBuffer'),
+ copyArray = require('./_copyArray'),
+ copySymbols = require('./_copySymbols'),
+ copySymbolsIn = require('./_copySymbolsIn'),
+ getAllKeys = require('./_getAllKeys'),
+ getAllKeysIn = require('./_getAllKeysIn'),
+ getTag = require('./_getTag'),
+ initCloneArray = require('./_initCloneArray'),
+ initCloneByTag = require('./_initCloneByTag'),
+ initCloneObject = require('./_initCloneObject'),
+ isArray = require('./isArray'),
+ isBuffer = require('./isBuffer'),
+ isObject = require('./isObject'),
+ keys = require('./keys');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1,
+ CLONE_FLAT_FLAG = 2,
+ CLONE_SYMBOLS_FLAG = 4;
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ objectTag = '[object Object]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ symbolTag = '[object Symbol]',
+ weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values supported by `_.clone`. */
+var cloneableTags = {};
+cloneableTags[argsTag] = cloneableTags[arrayTag] =
+cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
+cloneableTags[boolTag] = cloneableTags[dateTag] =
+cloneableTags[float32Tag] = cloneableTags[float64Tag] =
+cloneableTags[int8Tag] = cloneableTags[int16Tag] =
+cloneableTags[int32Tag] = cloneableTags[mapTag] =
+cloneableTags[numberTag] = cloneableTags[objectTag] =
+cloneableTags[regexpTag] = cloneableTags[setTag] =
+cloneableTags[stringTag] = cloneableTags[symbolTag] =
+cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
+cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
+cloneableTags[errorTag] = cloneableTags[funcTag] =
+cloneableTags[weakMapTag] = false;
+
+/**
+ * The base implementation of `_.clone` and `_.cloneDeep` which tracks
+ * traversed objects.
+ *
+ * @private
+ * @param {*} value The value to clone.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Deep clone
+ * 2 - Flatten inherited properties
+ * 4 - Clone symbols
+ * @param {Function} [customizer] The function to customize cloning.
+ * @param {string} [key] The key of `value`.
+ * @param {Object} [object] The parent object of `value`.
+ * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
+ * @returns {*} Returns the cloned value.
+ */
+function baseClone(value, bitmask, customizer, key, object, stack) {
+ var result,
+ isDeep = bitmask & CLONE_DEEP_FLAG,
+ isFlat = bitmask & CLONE_FLAT_FLAG,
+ isFull = bitmask & CLONE_SYMBOLS_FLAG;
+
+ if (customizer) {
+ result = object ? customizer(value, key, object, stack) : customizer(value);
+ }
+ if (result !== undefined) {
+ return result;
+ }
+ if (!isObject(value)) {
+ return value;
+ }
+ var isArr = isArray(value);
+ if (isArr) {
+ result = initCloneArray(value);
+ if (!isDeep) {
+ return copyArray(value, result);
+ }
+ } else {
+ var tag = getTag(value),
+ isFunc = tag == funcTag || tag == genTag;
+
+ if (isBuffer(value)) {
+ return cloneBuffer(value, isDeep);
+ }
+ if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
+ result = (isFlat || isFunc) ? {} : initCloneObject(value);
+ if (!isDeep) {
+ return isFlat
+ ? copySymbolsIn(value, baseAssignIn(result, value))
+ : copySymbols(value, baseAssign(result, value));
+ }
+ } else {
+ if (!cloneableTags[tag]) {
+ return object ? value : {};
+ }
+ result = initCloneByTag(value, tag, baseClone, isDeep);
+ }
+ }
+ // Check for circular references and return its corresponding clone.
+ stack || (stack = new Stack);
+ var stacked = stack.get(value);
+ if (stacked) {
+ return stacked;
+ }
+ stack.set(value, result);
+
+ var keysFunc = isFull
+ ? (isFlat ? getAllKeysIn : getAllKeys)
+ : (isFlat ? keysIn : keys);
+
+ var props = isArr ? undefined : keysFunc(value);
+ arrayEach(props || value, function(subValue, key) {
+ if (props) {
+ key = subValue;
+ subValue = value[key];
+ }
+ // Recursively populate clone (susceptible to call stack limits).
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
+ });
+ return result;
+}
+
+module.exports = baseClone;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConforms.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConforms.js
new file mode 100644
index 0000000..947e20d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConforms.js
@@ -0,0 +1,18 @@
+var baseConformsTo = require('./_baseConformsTo'),
+ keys = require('./keys');
+
+/**
+ * The base implementation of `_.conforms` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {Function} Returns the new spec function.
+ */
+function baseConforms(source) {
+ var props = keys(source);
+ return function(object) {
+ return baseConformsTo(object, source, props);
+ };
+}
+
+module.exports = baseConforms;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConformsTo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConformsTo.js
new file mode 100644
index 0000000..e449cb8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseConformsTo.js
@@ -0,0 +1,27 @@
+/**
+ * The base implementation of `_.conformsTo` which accepts `props` to check.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
+ */
+function baseConformsTo(object, source, props) {
+ var length = props.length;
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (length--) {
+ var key = props[length],
+ predicate = source[key],
+ value = object[key];
+
+ if ((value === undefined && !(key in object)) || !predicate(value)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+module.exports = baseConformsTo;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseCreate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseCreate.js
new file mode 100644
index 0000000..ffa6a52
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseCreate.js
@@ -0,0 +1,30 @@
+var isObject = require('./isObject');
+
+/** Built-in value references. */
+var objectCreate = Object.create;
+
+/**
+ * The base implementation of `_.create` without support for assigning
+ * properties to the created object.
+ *
+ * @private
+ * @param {Object} proto The object to inherit from.
+ * @returns {Object} Returns the new object.
+ */
+var baseCreate = (function() {
+ function object() {}
+ return function(proto) {
+ if (!isObject(proto)) {
+ return {};
+ }
+ if (objectCreate) {
+ return objectCreate(proto);
+ }
+ object.prototype = proto;
+ var result = new object;
+ object.prototype = undefined;
+ return result;
+ };
+}());
+
+module.exports = baseCreate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDelay.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDelay.js
new file mode 100644
index 0000000..1486d69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDelay.js
@@ -0,0 +1,21 @@
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * The base implementation of `_.delay` and `_.defer` which accepts `args`
+ * to provide to `func`.
+ *
+ * @private
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {Array} args The arguments to provide to `func`.
+ * @returns {number|Object} Returns the timer id or timeout object.
+ */
+function baseDelay(func, wait, args) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return setTimeout(function() { func.apply(undefined, args); }, wait);
+}
+
+module.exports = baseDelay;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDifference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDifference.js
new file mode 100644
index 0000000..343ac19
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseDifference.js
@@ -0,0 +1,67 @@
+var SetCache = require('./_SetCache'),
+ arrayIncludes = require('./_arrayIncludes'),
+ arrayIncludesWith = require('./_arrayIncludesWith'),
+ arrayMap = require('./_arrayMap'),
+ baseUnary = require('./_baseUnary'),
+ cacheHas = require('./_cacheHas');
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/**
+ * The base implementation of methods like `_.difference` without support
+ * for excluding multiple arrays or iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Array} values The values to exclude.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ */
+function baseDifference(array, values, iteratee, comparator) {
+ var index = -1,
+ includes = arrayIncludes,
+ isCommon = true,
+ length = array.length,
+ result = [],
+ valuesLength = values.length;
+
+ if (!length) {
+ return result;
+ }
+ if (iteratee) {
+ values = arrayMap(values, baseUnary(iteratee));
+ }
+ if (comparator) {
+ includes = arrayIncludesWith;
+ isCommon = false;
+ }
+ else if (values.length >= LARGE_ARRAY_SIZE) {
+ includes = cacheHas;
+ isCommon = false;
+ values = new SetCache(values);
+ }
+ outer:
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee == null ? value : iteratee(value);
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (isCommon && computed === computed) {
+ var valuesIndex = valuesLength;
+ while (valuesIndex--) {
+ if (values[valuesIndex] === computed) {
+ continue outer;
+ }
+ }
+ result.push(value);
+ }
+ else if (!includes(values, computed, comparator)) {
+ result.push(value);
+ }
+ }
+ return result;
+}
+
+module.exports = baseDifference;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEach.js
new file mode 100644
index 0000000..512c067
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEach.js
@@ -0,0 +1,14 @@
+var baseForOwn = require('./_baseForOwn'),
+ createBaseEach = require('./_createBaseEach');
+
+/**
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ */
+var baseEach = createBaseEach(baseForOwn);
+
+module.exports = baseEach;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEachRight.js
new file mode 100644
index 0000000..0a8feec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEachRight.js
@@ -0,0 +1,14 @@
+var baseForOwnRight = require('./_baseForOwnRight'),
+ createBaseEach = require('./_createBaseEach');
+
+/**
+ * The base implementation of `_.forEachRight` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ */
+var baseEachRight = createBaseEach(baseForOwnRight, true);
+
+module.exports = baseEachRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEvery.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEvery.js
new file mode 100644
index 0000000..fa52f7b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseEvery.js
@@ -0,0 +1,21 @@
+var baseEach = require('./_baseEach');
+
+/**
+ * The base implementation of `_.every` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`
+ */
+function baseEvery(collection, predicate) {
+ var result = true;
+ baseEach(collection, function(value, index, collection) {
+ result = !!predicate(value, index, collection);
+ return result;
+ });
+ return result;
+}
+
+module.exports = baseEvery;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseExtremum.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseExtremum.js
new file mode 100644
index 0000000..9d6aa77
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseExtremum.js
@@ -0,0 +1,32 @@
+var isSymbol = require('./isSymbol');
+
+/**
+ * The base implementation of methods like `_.max` and `_.min` which accepts a
+ * `comparator` to determine the extremum value.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The iteratee invoked per iteration.
+ * @param {Function} comparator The comparator used to compare values.
+ * @returns {*} Returns the extremum value.
+ */
+function baseExtremum(array, iteratee, comparator) {
+ var index = -1,
+ length = array.length;
+
+ while (++index < length) {
+ var value = array[index],
+ current = iteratee(value);
+
+ if (current != null && (computed === undefined
+ ? (current === current && !isSymbol(current))
+ : comparator(current, computed)
+ )) {
+ var computed = current,
+ result = value;
+ }
+ }
+ return result;
+}
+
+module.exports = baseExtremum;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFill.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFill.js
new file mode 100644
index 0000000..46ef9c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFill.js
@@ -0,0 +1,32 @@
+var toInteger = require('./toInteger'),
+ toLength = require('./toLength');
+
+/**
+ * The base implementation of `_.fill` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to fill.
+ * @param {*} value The value to fill `array` with.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns `array`.
+ */
+function baseFill(array, value, start, end) {
+ var length = array.length;
+
+ start = toInteger(start);
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = (end === undefined || end > length) ? length : toInteger(end);
+ if (end < 0) {
+ end += length;
+ }
+ end = start > end ? 0 : toLength(end);
+ while (start < end) {
+ array[start++] = value;
+ }
+ return array;
+}
+
+module.exports = baseFill;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFilter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFilter.js
new file mode 100644
index 0000000..4678477
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFilter.js
@@ -0,0 +1,21 @@
+var baseEach = require('./_baseEach');
+
+/**
+ * The base implementation of `_.filter` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+function baseFilter(collection, predicate) {
+ var result = [];
+ baseEach(collection, function(value, index, collection) {
+ if (predicate(value, index, collection)) {
+ result.push(value);
+ }
+ });
+ return result;
+}
+
+module.exports = baseFilter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindIndex.js
new file mode 100644
index 0000000..e3f5d8a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindIndex.js
@@ -0,0 +1,24 @@
+/**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = baseFindIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindKey.js
new file mode 100644
index 0000000..2e430f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFindKey.js
@@ -0,0 +1,23 @@
+/**
+ * The base implementation of methods like `_.findKey` and `_.findLastKey`,
+ * without support for iteratee shorthands, which iterates over `collection`
+ * using `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @returns {*} Returns the found element or its key, else `undefined`.
+ */
+function baseFindKey(collection, predicate, eachFunc) {
+ var result;
+ eachFunc(collection, function(value, key, collection) {
+ if (predicate(value, key, collection)) {
+ result = key;
+ return false;
+ }
+ });
+ return result;
+}
+
+module.exports = baseFindKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFlatten.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFlatten.js
new file mode 100644
index 0000000..4b1e009
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFlatten.js
@@ -0,0 +1,38 @@
+var arrayPush = require('./_arrayPush'),
+ isFlattenable = require('./_isFlattenable');
+
+/**
+ * The base implementation of `_.flatten` with support for restricting flattening.
+ *
+ * @private
+ * @param {Array} array The array to flatten.
+ * @param {number} depth The maximum recursion depth.
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
+ * @param {Array} [result=[]] The initial result value.
+ * @returns {Array} Returns the new flattened array.
+ */
+function baseFlatten(array, depth, predicate, isStrict, result) {
+ var index = -1,
+ length = array.length;
+
+ predicate || (predicate = isFlattenable);
+ result || (result = []);
+
+ while (++index < length) {
+ var value = array[index];
+ if (depth > 0 && predicate(value)) {
+ if (depth > 1) {
+ // Recursively flatten arrays (susceptible to call stack limits).
+ baseFlatten(value, depth - 1, predicate, isStrict, result);
+ } else {
+ arrayPush(result, value);
+ }
+ } else if (!isStrict) {
+ result[result.length] = value;
+ }
+ }
+ return result;
+}
+
+module.exports = baseFlatten;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFor.js
new file mode 100644
index 0000000..d946590
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFor.js
@@ -0,0 +1,16 @@
+var createBaseFor = require('./_createBaseFor');
+
+/**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+var baseFor = createBaseFor();
+
+module.exports = baseFor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwn.js
new file mode 100644
index 0000000..503d523
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwn.js
@@ -0,0 +1,16 @@
+var baseFor = require('./_baseFor'),
+ keys = require('./keys');
+
+/**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+}
+
+module.exports = baseForOwn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwnRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwnRight.js
new file mode 100644
index 0000000..a4b10e6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForOwnRight.js
@@ -0,0 +1,16 @@
+var baseForRight = require('./_baseForRight'),
+ keys = require('./keys');
+
+/**
+ * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+function baseForOwnRight(object, iteratee) {
+ return object && baseForRight(object, iteratee, keys);
+}
+
+module.exports = baseForOwnRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForRight.js
new file mode 100644
index 0000000..32842cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseForRight.js
@@ -0,0 +1,15 @@
+var createBaseFor = require('./_createBaseFor');
+
+/**
+ * This function is like `baseFor` except that it iterates over properties
+ * in the opposite order.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+var baseForRight = createBaseFor(true);
+
+module.exports = baseForRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFunctions.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFunctions.js
new file mode 100644
index 0000000..d23bc9b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseFunctions.js
@@ -0,0 +1,19 @@
+var arrayFilter = require('./_arrayFilter'),
+ isFunction = require('./isFunction');
+
+/**
+ * The base implementation of `_.functions` which creates an array of
+ * `object` function property names filtered from `props`.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Array} props The property names to filter.
+ * @returns {Array} Returns the function names.
+ */
+function baseFunctions(object, props) {
+ return arrayFilter(props, function(key) {
+ return isFunction(object[key]);
+ });
+}
+
+module.exports = baseFunctions;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGet.js
new file mode 100644
index 0000000..a194913
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGet.js
@@ -0,0 +1,24 @@
+var castPath = require('./_castPath'),
+ toKey = require('./_toKey');
+
+/**
+ * The base implementation of `_.get` without support for default values.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @returns {*} Returns the resolved value.
+ */
+function baseGet(object, path) {
+ path = castPath(path, object);
+
+ var index = 0,
+ length = path.length;
+
+ while (object != null && index < length) {
+ object = object[toKey(path[index++])];
+ }
+ return (index && index == length) ? object : undefined;
+}
+
+module.exports = baseGet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetAllKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetAllKeys.js
new file mode 100644
index 0000000..8ad204e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetAllKeys.js
@@ -0,0 +1,20 @@
+var arrayPush = require('./_arrayPush'),
+ isArray = require('./isArray');
+
+/**
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
+ * symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+function baseGetAllKeys(object, keysFunc, symbolsFunc) {
+ var result = keysFunc(object);
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
+}
+
+module.exports = baseGetAllKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetTag.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetTag.js
new file mode 100644
index 0000000..cf869ac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGetTag.js
@@ -0,0 +1,29 @@
+var Symbol = require('./_Symbol'),
+ getRawTag = require('./_getRawTag'),
+ objectToString = require('./_objectToString');
+
+/** `Object#toString` result references. */
+var nullTag = '[object Null]',
+ undefinedTag = '[object Undefined]';
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+/**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ value = Object(value);
+ return (symToStringTag && symToStringTag in value)
+ ? getRawTag(value)
+ : objectToString(value);
+}
+
+module.exports = baseGetTag;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGt.js
new file mode 100644
index 0000000..502d273
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseGt.js
@@ -0,0 +1,14 @@
+/**
+ * The base implementation of `_.gt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than `other`,
+ * else `false`.
+ */
+function baseGt(value, other) {
+ return value > other;
+}
+
+module.exports = baseGt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHas.js
new file mode 100644
index 0000000..1b73032
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHas.js
@@ -0,0 +1,19 @@
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * The base implementation of `_.has` without support for deep paths.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {Array|string} key The key to check.
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
+ */
+function baseHas(object, key) {
+ return object != null && hasOwnProperty.call(object, key);
+}
+
+module.exports = baseHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHasIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHasIn.js
new file mode 100644
index 0000000..2e0d042
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseHasIn.js
@@ -0,0 +1,13 @@
+/**
+ * The base implementation of `_.hasIn` without support for deep paths.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {Array|string} key The key to check.
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
+ */
+function baseHasIn(object, key) {
+ return object != null && key in Object(object);
+}
+
+module.exports = baseHasIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInRange.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInRange.js
new file mode 100644
index 0000000..ec95666
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInRange.js
@@ -0,0 +1,18 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+/**
+ * The base implementation of `_.inRange` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {number} number The number to check.
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
+ */
+function baseInRange(number, start, end) {
+ return number >= nativeMin(start, end) && number < nativeMax(start, end);
+}
+
+module.exports = baseInRange;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOf.js
new file mode 100644
index 0000000..167e706
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOf.js
@@ -0,0 +1,20 @@
+var baseFindIndex = require('./_baseFindIndex'),
+ baseIsNaN = require('./_baseIsNaN'),
+ strictIndexOf = require('./_strictIndexOf');
+
+/**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+}
+
+module.exports = baseIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOfWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOfWith.js
new file mode 100644
index 0000000..f815fe0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIndexOfWith.js
@@ -0,0 +1,23 @@
+/**
+ * This function is like `baseIndexOf` except that it accepts a comparator.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @param {Function} comparator The comparator invoked per element.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOfWith(array, value, fromIndex, comparator) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (comparator(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = baseIndexOfWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIntersection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIntersection.js
new file mode 100644
index 0000000..c1d250c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIntersection.js
@@ -0,0 +1,74 @@
+var SetCache = require('./_SetCache'),
+ arrayIncludes = require('./_arrayIncludes'),
+ arrayIncludesWith = require('./_arrayIncludesWith'),
+ arrayMap = require('./_arrayMap'),
+ baseUnary = require('./_baseUnary'),
+ cacheHas = require('./_cacheHas');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * The base implementation of methods like `_.intersection`, without support
+ * for iteratee shorthands, that accepts an array of arrays to inspect.
+ *
+ * @private
+ * @param {Array} arrays The arrays to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of shared values.
+ */
+function baseIntersection(arrays, iteratee, comparator) {
+ var includes = comparator ? arrayIncludesWith : arrayIncludes,
+ length = arrays[0].length,
+ othLength = arrays.length,
+ othIndex = othLength,
+ caches = Array(othLength),
+ maxLength = Infinity,
+ result = [];
+
+ while (othIndex--) {
+ var array = arrays[othIndex];
+ if (othIndex && iteratee) {
+ array = arrayMap(array, baseUnary(iteratee));
+ }
+ maxLength = nativeMin(array.length, maxLength);
+ caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
+ ? new SetCache(othIndex && array)
+ : undefined;
+ }
+ array = arrays[0];
+
+ var index = -1,
+ seen = caches[0];
+
+ outer:
+ while (++index < length && result.length < maxLength) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (!(seen
+ ? cacheHas(seen, computed)
+ : includes(result, computed, comparator)
+ )) {
+ othIndex = othLength;
+ while (--othIndex) {
+ var cache = caches[othIndex];
+ if (!(cache
+ ? cacheHas(cache, computed)
+ : includes(arrays[othIndex], computed, comparator))
+ ) {
+ continue outer;
+ }
+ }
+ if (seen) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ }
+ return result;
+}
+
+module.exports = baseIntersection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInverter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInverter.js
new file mode 100644
index 0000000..fbc337f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInverter.js
@@ -0,0 +1,21 @@
+var baseForOwn = require('./_baseForOwn');
+
+/**
+ * The base implementation of `_.invert` and `_.invertBy` which inverts
+ * `object` with values transformed by `iteratee` and set by `setter`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform values.
+ * @param {Object} accumulator The initial inverted object.
+ * @returns {Function} Returns `accumulator`.
+ */
+function baseInverter(object, setter, iteratee, accumulator) {
+ baseForOwn(object, function(value, key, object) {
+ setter(accumulator, iteratee(value), key, object);
+ });
+ return accumulator;
+}
+
+module.exports = baseInverter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInvoke.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInvoke.js
new file mode 100644
index 0000000..49bcf3c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseInvoke.js
@@ -0,0 +1,24 @@
+var apply = require('./_apply'),
+ castPath = require('./_castPath'),
+ last = require('./last'),
+ parent = require('./_parent'),
+ toKey = require('./_toKey');
+
+/**
+ * The base implementation of `_.invoke` without support for individual
+ * method arguments.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {Array} args The arguments to invoke the method with.
+ * @returns {*} Returns the result of the invoked method.
+ */
+function baseInvoke(object, path, args) {
+ path = castPath(path, object);
+ object = parent(object, path);
+ var func = object == null ? object : object[toKey(last(path))];
+ return func == null ? undefined : apply(func, object, args);
+}
+
+module.exports = baseInvoke;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArguments.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArguments.js
new file mode 100644
index 0000000..b3562cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArguments.js
@@ -0,0 +1,18 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]';
+
+/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+}
+
+module.exports = baseIsArguments;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArrayBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArrayBuffer.js
new file mode 100644
index 0000000..a2c4f30
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsArrayBuffer.js
@@ -0,0 +1,17 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+var arrayBufferTag = '[object ArrayBuffer]';
+
+/**
+ * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
+ */
+function baseIsArrayBuffer(value) {
+ return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
+}
+
+module.exports = baseIsArrayBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsDate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsDate.js
new file mode 100644
index 0000000..ba67c78
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsDate.js
@@ -0,0 +1,18 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var dateTag = '[object Date]';
+
+/**
+ * The base implementation of `_.isDate` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ */
+function baseIsDate(value) {
+ return isObjectLike(value) && baseGetTag(value) == dateTag;
+}
+
+module.exports = baseIsDate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqual.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqual.js
new file mode 100644
index 0000000..0c4212e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqual.js
@@ -0,0 +1,29 @@
+var baseIsEqualDeep = require('./_baseIsEqualDeep'),
+ isObject = require('./isObject'),
+ isObjectLike = require('./isObjectLike');
+
+/**
+ * The base implementation of `_.isEqual` which supports partial comparisons
+ * and tracks traversed objects.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Unordered comparison
+ * 2 - Partial comparison
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ */
+function baseIsEqual(value, other, bitmask, customizer, stack) {
+ if (value === other) {
+ return true;
+ }
+ if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
+ return value !== value && other !== other;
+ }
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
+}
+
+module.exports = baseIsEqual;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqualDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqualDeep.js
new file mode 100644
index 0000000..b32f1f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsEqualDeep.js
@@ -0,0 +1,88 @@
+var Stack = require('./_Stack'),
+ equalArrays = require('./_equalArrays'),
+ equalByTag = require('./_equalByTag'),
+ equalObjects = require('./_equalObjects'),
+ getTag = require('./_getTag'),
+ isArray = require('./isArray'),
+ isBuffer = require('./isBuffer'),
+ isTypedArray = require('./isTypedArray');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1;
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ objectTag = '[object Object]';
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
+ * deep comparisons and tracks traversed objects enabling objects with circular
+ * references to be compared.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
+ var objIsArr = isArray(object),
+ othIsArr = isArray(other),
+ objTag = arrayTag,
+ othTag = arrayTag;
+
+ if (!objIsArr) {
+ objTag = getTag(object);
+ objTag = objTag == argsTag ? objectTag : objTag;
+ }
+ if (!othIsArr) {
+ othTag = getTag(other);
+ othTag = othTag == argsTag ? objectTag : othTag;
+ }
+ var objIsObj = objTag == objectTag,
+ othIsObj = othTag == objectTag,
+ isSameTag = objTag == othTag;
+
+ if (isSameTag && isBuffer(object)) {
+ if (!isBuffer(other)) {
+ return false;
+ }
+ objIsArr = true;
+ objIsObj = false;
+ }
+ if (isSameTag && !objIsObj) {
+ stack || (stack = new Stack);
+ return (objIsArr || isTypedArray(object))
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
+ }
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
+
+ if (objIsWrapped || othIsWrapped) {
+ var objUnwrapped = objIsWrapped ? object.value() : object,
+ othUnwrapped = othIsWrapped ? other.value() : other;
+
+ stack || (stack = new Stack);
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
+ }
+ }
+ if (!isSameTag) {
+ return false;
+ }
+ stack || (stack = new Stack);
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
+}
+
+module.exports = baseIsEqualDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMap.js
new file mode 100644
index 0000000..02a4021
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMap.js
@@ -0,0 +1,18 @@
+var getTag = require('./_getTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]';
+
+/**
+ * The base implementation of `_.isMap` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ */
+function baseIsMap(value) {
+ return isObjectLike(value) && getTag(value) == mapTag;
+}
+
+module.exports = baseIsMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMatch.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMatch.js
new file mode 100644
index 0000000..72494be
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsMatch.js
@@ -0,0 +1,62 @@
+var Stack = require('./_Stack'),
+ baseIsEqual = require('./_baseIsEqual');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @param {Array} matchData The property names, values, and compare flags to match.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ */
+function baseIsMatch(object, source, matchData, customizer) {
+ var index = matchData.length,
+ length = index,
+ noCustomizer = !customizer;
+
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (index--) {
+ var data = matchData[index];
+ if ((noCustomizer && data[2])
+ ? data[1] !== object[data[0]]
+ : !(data[0] in object)
+ ) {
+ return false;
+ }
+ }
+ while (++index < length) {
+ data = matchData[index];
+ var key = data[0],
+ objValue = object[key],
+ srcValue = data[1];
+
+ if (noCustomizer && data[2]) {
+ if (objValue === undefined && !(key in object)) {
+ return false;
+ }
+ } else {
+ var stack = new Stack;
+ if (customizer) {
+ var result = customizer(objValue, srcValue, key, object, source, stack);
+ }
+ if (!(result === undefined
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
+ : result
+ )) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+module.exports = baseIsMatch;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNaN.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNaN.js
new file mode 100644
index 0000000..316f1eb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNaN.js
@@ -0,0 +1,12 @@
+/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+function baseIsNaN(value) {
+ return value !== value;
+}
+
+module.exports = baseIsNaN;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNative.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNative.js
new file mode 100644
index 0000000..8702330
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsNative.js
@@ -0,0 +1,47 @@
+var isFunction = require('./isFunction'),
+ isMasked = require('./_isMasked'),
+ isObject = require('./isObject'),
+ toSource = require('./_toSource');
+
+/**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
+
+/** Used to detect host constructors (Safari). */
+var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype,
+ objectProto = Object.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Used to detect if a method is native. */
+var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+);
+
+/**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
+ }
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+}
+
+module.exports = baseIsNative;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsRegExp.js
new file mode 100644
index 0000000..6cd7c1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsRegExp.js
@@ -0,0 +1,18 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var regexpTag = '[object RegExp]';
+
+/**
+ * The base implementation of `_.isRegExp` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ */
+function baseIsRegExp(value) {
+ return isObjectLike(value) && baseGetTag(value) == regexpTag;
+}
+
+module.exports = baseIsRegExp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsSet.js
new file mode 100644
index 0000000..6dee367
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsSet.js
@@ -0,0 +1,18 @@
+var getTag = require('./_getTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var setTag = '[object Set]';
+
+/**
+ * The base implementation of `_.isSet` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ */
+function baseIsSet(value) {
+ return isObjectLike(value) && getTag(value) == setTag;
+}
+
+module.exports = baseIsSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsTypedArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsTypedArray.js
new file mode 100644
index 0000000..1edb32f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIsTypedArray.js
@@ -0,0 +1,60 @@
+var baseGetTag = require('./_baseGetTag'),
+ isLength = require('./isLength'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ objectTag = '[object Object]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values of typed arrays. */
+var typedArrayTags = {};
+typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+typedArrayTags[uint32Tag] = true;
+typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
+typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+typedArrayTags[errorTag] = typedArrayTags[funcTag] =
+typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+typedArrayTags[setTag] = typedArrayTags[stringTag] =
+typedArrayTags[weakMapTag] = false;
+
+/**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+}
+
+module.exports = baseIsTypedArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIteratee.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIteratee.js
new file mode 100644
index 0000000..995c257
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseIteratee.js
@@ -0,0 +1,31 @@
+var baseMatches = require('./_baseMatches'),
+ baseMatchesProperty = require('./_baseMatchesProperty'),
+ identity = require('./identity'),
+ isArray = require('./isArray'),
+ property = require('./property');
+
+/**
+ * The base implementation of `_.iteratee`.
+ *
+ * @private
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
+ * @returns {Function} Returns the iteratee.
+ */
+function baseIteratee(value) {
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
+ if (typeof value == 'function') {
+ return value;
+ }
+ if (value == null) {
+ return identity;
+ }
+ if (typeof value == 'object') {
+ return isArray(value)
+ ? baseMatchesProperty(value[0], value[1])
+ : baseMatches(value);
+ }
+ return property(value);
+}
+
+module.exports = baseIteratee;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeys.js
new file mode 100644
index 0000000..45e9e6f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeys.js
@@ -0,0 +1,30 @@
+var isPrototype = require('./_isPrototype'),
+ nativeKeys = require('./_nativeKeys');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = baseKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeysIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeysIn.js
new file mode 100644
index 0000000..ea8a0a1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseKeysIn.js
@@ -0,0 +1,33 @@
+var isObject = require('./isObject'),
+ isPrototype = require('./_isPrototype'),
+ nativeKeysIn = require('./_nativeKeysIn');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeysIn(object) {
+ if (!isObject(object)) {
+ return nativeKeysIn(object);
+ }
+ var isProto = isPrototype(object),
+ result = [];
+
+ for (var key in object) {
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = baseKeysIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLodash.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLodash.js
new file mode 100644
index 0000000..f76c790
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLodash.js
@@ -0,0 +1,10 @@
+/**
+ * The function whose prototype chain sequence wrappers inherit from.
+ *
+ * @private
+ */
+function baseLodash() {
+ // No operation performed.
+}
+
+module.exports = baseLodash;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLt.js
new file mode 100644
index 0000000..8674d29
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseLt.js
@@ -0,0 +1,14 @@
+/**
+ * The base implementation of `_.lt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than `other`,
+ * else `false`.
+ */
+function baseLt(value, other) {
+ return value < other;
+}
+
+module.exports = baseLt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMap.js
new file mode 100644
index 0000000..0bf5cea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMap.js
@@ -0,0 +1,22 @@
+var baseEach = require('./_baseEach'),
+ isArrayLike = require('./isArrayLike');
+
+/**
+ * The base implementation of `_.map` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function baseMap(collection, iteratee) {
+ var index = -1,
+ result = isArrayLike(collection) ? Array(collection.length) : [];
+
+ baseEach(collection, function(value, key, collection) {
+ result[++index] = iteratee(value, key, collection);
+ });
+ return result;
+}
+
+module.exports = baseMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatches.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatches.js
new file mode 100644
index 0000000..e56582a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatches.js
@@ -0,0 +1,22 @@
+var baseIsMatch = require('./_baseIsMatch'),
+ getMatchData = require('./_getMatchData'),
+ matchesStrictComparable = require('./_matchesStrictComparable');
+
+/**
+ * The base implementation of `_.matches` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function baseMatches(source) {
+ var matchData = getMatchData(source);
+ if (matchData.length == 1 && matchData[0][2]) {
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
+ }
+ return function(object) {
+ return object === source || baseIsMatch(object, source, matchData);
+ };
+}
+
+module.exports = baseMatches;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatchesProperty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatchesProperty.js
new file mode 100644
index 0000000..24afd89
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMatchesProperty.js
@@ -0,0 +1,33 @@
+var baseIsEqual = require('./_baseIsEqual'),
+ get = require('./get'),
+ hasIn = require('./hasIn'),
+ isKey = require('./_isKey'),
+ isStrictComparable = require('./_isStrictComparable'),
+ matchesStrictComparable = require('./_matchesStrictComparable'),
+ toKey = require('./_toKey');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
+ *
+ * @private
+ * @param {string} path The path of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function baseMatchesProperty(path, srcValue) {
+ if (isKey(path) && isStrictComparable(srcValue)) {
+ return matchesStrictComparable(toKey(path), srcValue);
+ }
+ return function(object) {
+ var objValue = get(object, path);
+ return (objValue === undefined && objValue === srcValue)
+ ? hasIn(object, path)
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
+ };
+}
+
+module.exports = baseMatchesProperty;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMean.js
new file mode 100644
index 0000000..fa9e00a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMean.js
@@ -0,0 +1,20 @@
+var baseSum = require('./_baseSum');
+
+/** Used as references for various `Number` constants. */
+var NAN = 0 / 0;
+
+/**
+ * The base implementation of `_.mean` and `_.meanBy` without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {number} Returns the mean.
+ */
+function baseMean(array, iteratee) {
+ var length = array == null ? 0 : array.length;
+ return length ? (baseSum(array, iteratee) / length) : NAN;
+}
+
+module.exports = baseMean;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMerge.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMerge.js
new file mode 100644
index 0000000..f4cb8c6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMerge.js
@@ -0,0 +1,41 @@
+var Stack = require('./_Stack'),
+ assignMergeValue = require('./_assignMergeValue'),
+ baseFor = require('./_baseFor'),
+ baseMergeDeep = require('./_baseMergeDeep'),
+ isObject = require('./isObject'),
+ keysIn = require('./keysIn');
+
+/**
+ * The base implementation of `_.merge` without support for multiple sources.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} [customizer] The function to customize merged values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+function baseMerge(object, source, srcIndex, customizer, stack) {
+ if (object === source) {
+ return;
+ }
+ baseFor(source, function(srcValue, key) {
+ if (isObject(srcValue)) {
+ stack || (stack = new Stack);
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
+ }
+ else {
+ var newValue = customizer
+ ? customizer(object[key], srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = srcValue;
+ }
+ assignMergeValue(object, key, newValue);
+ }
+ }, keysIn);
+}
+
+module.exports = baseMerge;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMergeDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMergeDeep.js
new file mode 100644
index 0000000..42b405a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseMergeDeep.js
@@ -0,0 +1,93 @@
+var assignMergeValue = require('./_assignMergeValue'),
+ cloneBuffer = require('./_cloneBuffer'),
+ cloneTypedArray = require('./_cloneTypedArray'),
+ copyArray = require('./_copyArray'),
+ initCloneObject = require('./_initCloneObject'),
+ isArguments = require('./isArguments'),
+ isArray = require('./isArray'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ isBuffer = require('./isBuffer'),
+ isFunction = require('./isFunction'),
+ isObject = require('./isObject'),
+ isPlainObject = require('./isPlainObject'),
+ isTypedArray = require('./isTypedArray'),
+ toPlainObject = require('./toPlainObject');
+
+/**
+ * A specialized version of `baseMerge` for arrays and objects which performs
+ * deep merges and tracks traversed objects enabling objects with circular
+ * references to be merged.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {string} key The key of the value to merge.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} mergeFunc The function to merge values.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
+ var objValue = object[key],
+ srcValue = source[key],
+ stacked = stack.get(srcValue);
+
+ if (stacked) {
+ assignMergeValue(object, key, stacked);
+ return;
+ }
+ var newValue = customizer
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ var isCommon = newValue === undefined;
+
+ if (isCommon) {
+ var isArr = isArray(srcValue),
+ isBuff = !isArr && isBuffer(srcValue),
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
+
+ newValue = srcValue;
+ if (isArr || isBuff || isTyped) {
+ if (isArray(objValue)) {
+ newValue = objValue;
+ }
+ else if (isArrayLikeObject(objValue)) {
+ newValue = copyArray(objValue);
+ }
+ else if (isBuff) {
+ isCommon = false;
+ newValue = cloneBuffer(srcValue, true);
+ }
+ else if (isTyped) {
+ isCommon = false;
+ newValue = cloneTypedArray(srcValue, true);
+ }
+ else {
+ newValue = [];
+ }
+ }
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
+ newValue = objValue;
+ if (isArguments(objValue)) {
+ newValue = toPlainObject(objValue);
+ }
+ else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
+ newValue = initCloneObject(srcValue);
+ }
+ }
+ else {
+ isCommon = false;
+ }
+ }
+ if (isCommon) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, newValue);
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
+ stack['delete'](srcValue);
+ }
+ assignMergeValue(object, key, newValue);
+}
+
+module.exports = baseMergeDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseNth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseNth.js
new file mode 100644
index 0000000..0403c2a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseNth.js
@@ -0,0 +1,20 @@
+var isIndex = require('./_isIndex');
+
+/**
+ * The base implementation of `_.nth` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {Array} array The array to query.
+ * @param {number} n The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ */
+function baseNth(array, n) {
+ var length = array.length;
+ if (!length) {
+ return;
+ }
+ n += n < 0 ? length : 0;
+ return isIndex(n, length) ? array[n] : undefined;
+}
+
+module.exports = baseNth;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseOrderBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseOrderBy.js
new file mode 100644
index 0000000..d8a46ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseOrderBy.js
@@ -0,0 +1,34 @@
+var arrayMap = require('./_arrayMap'),
+ baseIteratee = require('./_baseIteratee'),
+ baseMap = require('./_baseMap'),
+ baseSortBy = require('./_baseSortBy'),
+ baseUnary = require('./_baseUnary'),
+ compareMultiple = require('./_compareMultiple'),
+ identity = require('./identity');
+
+/**
+ * The base implementation of `_.orderBy` without param guards.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
+ * @param {string[]} orders The sort orders of `iteratees`.
+ * @returns {Array} Returns the new sorted array.
+ */
+function baseOrderBy(collection, iteratees, orders) {
+ var index = -1;
+ iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
+
+ var result = baseMap(collection, function(value, key, collection) {
+ var criteria = arrayMap(iteratees, function(iteratee) {
+ return iteratee(value);
+ });
+ return { 'criteria': criteria, 'index': ++index, 'value': value };
+ });
+
+ return baseSortBy(result, function(object, other) {
+ return compareMultiple(object, other, orders);
+ });
+}
+
+module.exports = baseOrderBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePick.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePick.js
new file mode 100644
index 0000000..6afce40
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePick.js
@@ -0,0 +1,20 @@
+var basePickBy = require('./_basePickBy'),
+ hasIn = require('./hasIn');
+
+/**
+ * The base implementation of `_.pick` without support for individual
+ * property identifiers.
+ *
+ * @private
+ * @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
+ * @returns {Object} Returns the new object.
+ */
+function basePick(object, paths) {
+ object = Object(object);
+ return basePickBy(object, paths, function(value, path) {
+ return hasIn(object, path);
+ });
+}
+
+module.exports = basePick;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePickBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePickBy.js
new file mode 100644
index 0000000..85be68c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePickBy.js
@@ -0,0 +1,30 @@
+var baseGet = require('./_baseGet'),
+ baseSet = require('./_baseSet'),
+ castPath = require('./_castPath');
+
+/**
+ * The base implementation of `_.pickBy` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
+ * @param {Function} predicate The function invoked per property.
+ * @returns {Object} Returns the new object.
+ */
+function basePickBy(object, paths, predicate) {
+ var index = -1,
+ length = paths.length,
+ result = {};
+
+ while (++index < length) {
+ var path = paths[index],
+ value = baseGet(object, path);
+
+ if (predicate(value, path)) {
+ baseSet(result, castPath(path, object), value);
+ }
+ }
+ return result;
+}
+
+module.exports = basePickBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseProperty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseProperty.js
new file mode 100644
index 0000000..496281e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseProperty.js
@@ -0,0 +1,14 @@
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+module.exports = baseProperty;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyDeep.js
new file mode 100644
index 0000000..1e5aae5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyDeep.js
@@ -0,0 +1,16 @@
+var baseGet = require('./_baseGet');
+
+/**
+ * A specialized version of `baseProperty` which supports deep paths.
+ *
+ * @private
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function basePropertyDeep(path) {
+ return function(object) {
+ return baseGet(object, path);
+ };
+}
+
+module.exports = basePropertyDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyOf.js
new file mode 100644
index 0000000..4617399
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePropertyOf.js
@@ -0,0 +1,14 @@
+/**
+ * The base implementation of `_.propertyOf` without support for deep paths.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ */
+function basePropertyOf(object) {
+ return function(key) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+module.exports = basePropertyOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAll.js
new file mode 100644
index 0000000..305720e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAll.js
@@ -0,0 +1,51 @@
+var arrayMap = require('./_arrayMap'),
+ baseIndexOf = require('./_baseIndexOf'),
+ baseIndexOfWith = require('./_baseIndexOfWith'),
+ baseUnary = require('./_baseUnary'),
+ copyArray = require('./_copyArray');
+
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/** Built-in value references. */
+var splice = arrayProto.splice;
+
+/**
+ * The base implementation of `_.pullAllBy` without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns `array`.
+ */
+function basePullAll(array, values, iteratee, comparator) {
+ var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
+ index = -1,
+ length = values.length,
+ seen = array;
+
+ if (array === values) {
+ values = copyArray(values);
+ }
+ if (iteratee) {
+ seen = arrayMap(array, baseUnary(iteratee));
+ }
+ while (++index < length) {
+ var fromIndex = 0,
+ value = values[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
+ if (seen !== array) {
+ splice.call(seen, fromIndex, 1);
+ }
+ splice.call(array, fromIndex, 1);
+ }
+ }
+ return array;
+}
+
+module.exports = basePullAll;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAt.js
new file mode 100644
index 0000000..c3e9e71
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_basePullAt.js
@@ -0,0 +1,37 @@
+var baseUnset = require('./_baseUnset'),
+ isIndex = require('./_isIndex');
+
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/** Built-in value references. */
+var splice = arrayProto.splice;
+
+/**
+ * The base implementation of `_.pullAt` without support for individual
+ * indexes or capturing the removed elements.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {number[]} indexes The indexes of elements to remove.
+ * @returns {Array} Returns `array`.
+ */
+function basePullAt(array, indexes) {
+ var length = array ? indexes.length : 0,
+ lastIndex = length - 1;
+
+ while (length--) {
+ var index = indexes[length];
+ if (length == lastIndex || index !== previous) {
+ var previous = index;
+ if (isIndex(index)) {
+ splice.call(array, index, 1);
+ } else {
+ baseUnset(array, index);
+ }
+ }
+ }
+ return array;
+}
+
+module.exports = basePullAt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRandom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRandom.js
new file mode 100644
index 0000000..94f76a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRandom.js
@@ -0,0 +1,18 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeFloor = Math.floor,
+ nativeRandom = Math.random;
+
+/**
+ * The base implementation of `_.random` without support for returning
+ * floating-point numbers.
+ *
+ * @private
+ * @param {number} lower The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the random number.
+ */
+function baseRandom(lower, upper) {
+ return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
+}
+
+module.exports = baseRandom;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRange.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRange.js
new file mode 100644
index 0000000..0fb8e41
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRange.js
@@ -0,0 +1,28 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil,
+ nativeMax = Math.max;
+
+/**
+ * The base implementation of `_.range` and `_.rangeRight` which doesn't
+ * coerce arguments.
+ *
+ * @private
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} step The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the range of numbers.
+ */
+function baseRange(start, end, step, fromRight) {
+ var index = -1,
+ length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
+
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
+ }
+ return result;
+}
+
+module.exports = baseRange;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseReduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseReduce.js
new file mode 100644
index 0000000..5a1f8b5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseReduce.js
@@ -0,0 +1,23 @@
+/**
+ * The base implementation of `_.reduce` and `_.reduceRight`, without support
+ * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} accumulator The initial value.
+ * @param {boolean} initAccum Specify using the first or last element of
+ * `collection` as the initial value.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @returns {*} Returns the accumulated value.
+ */
+function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
+ eachFunc(collection, function(value, index, collection) {
+ accumulator = initAccum
+ ? (initAccum = false, value)
+ : iteratee(accumulator, value, index, collection);
+ });
+ return accumulator;
+}
+
+module.exports = baseReduce;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRepeat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRepeat.js
new file mode 100644
index 0000000..ee44c31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRepeat.js
@@ -0,0 +1,35 @@
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeFloor = Math.floor;
+
+/**
+ * The base implementation of `_.repeat` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {string} string The string to repeat.
+ * @param {number} n The number of times to repeat the string.
+ * @returns {string} Returns the repeated string.
+ */
+function baseRepeat(string, n) {
+ var result = '';
+ if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
+ return result;
+ }
+ // Leverage the exponentiation by squaring algorithm for a faster repeat.
+ // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
+ do {
+ if (n % 2) {
+ result += string;
+ }
+ n = nativeFloor(n / 2);
+ if (n) {
+ string += string;
+ }
+ } while (n);
+
+ return result;
+}
+
+module.exports = baseRepeat;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRest.js
new file mode 100644
index 0000000..d0dc4bd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseRest.js
@@ -0,0 +1,17 @@
+var identity = require('./identity'),
+ overRest = require('./_overRest'),
+ setToString = require('./_setToString');
+
+/**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+function baseRest(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+}
+
+module.exports = baseRest;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSample.js
new file mode 100644
index 0000000..58582b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSample.js
@@ -0,0 +1,15 @@
+var arraySample = require('./_arraySample'),
+ values = require('./values');
+
+/**
+ * The base implementation of `_.sample`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @returns {*} Returns the random element.
+ */
+function baseSample(collection) {
+ return arraySample(values(collection));
+}
+
+module.exports = baseSample;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSampleSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSampleSize.js
new file mode 100644
index 0000000..5c90ec5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSampleSize.js
@@ -0,0 +1,18 @@
+var baseClamp = require('./_baseClamp'),
+ shuffleSelf = require('./_shuffleSelf'),
+ values = require('./values');
+
+/**
+ * The base implementation of `_.sampleSize` without param guards.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+function baseSampleSize(collection, n) {
+ var array = values(collection);
+ return shuffleSelf(array, baseClamp(n, 0, array.length));
+}
+
+module.exports = baseSampleSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSet.js
new file mode 100644
index 0000000..612a24c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSet.js
@@ -0,0 +1,47 @@
+var assignValue = require('./_assignValue'),
+ castPath = require('./_castPath'),
+ isIndex = require('./_isIndex'),
+ isObject = require('./isObject'),
+ toKey = require('./_toKey');
+
+/**
+ * The base implementation of `_.set`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @param {Function} [customizer] The function to customize path creation.
+ * @returns {Object} Returns `object`.
+ */
+function baseSet(object, path, value, customizer) {
+ if (!isObject(object)) {
+ return object;
+ }
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length,
+ lastIndex = length - 1,
+ nested = object;
+
+ while (nested != null && ++index < length) {
+ var key = toKey(path[index]),
+ newValue = value;
+
+ if (index != lastIndex) {
+ var objValue = nested[key];
+ newValue = customizer ? customizer(objValue, key, nested) : undefined;
+ if (newValue === undefined) {
+ newValue = isObject(objValue)
+ ? objValue
+ : (isIndex(path[index + 1]) ? [] : {});
+ }
+ }
+ assignValue(nested, key, newValue);
+ nested = nested[key];
+ }
+ return object;
+}
+
+module.exports = baseSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetData.js
new file mode 100644
index 0000000..c409947
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetData.js
@@ -0,0 +1,17 @@
+var identity = require('./identity'),
+ metaMap = require('./_metaMap');
+
+/**
+ * The base implementation of `setData` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to associate metadata with.
+ * @param {*} data The metadata.
+ * @returns {Function} Returns `func`.
+ */
+var baseSetData = !metaMap ? identity : function(func, data) {
+ metaMap.set(func, data);
+ return func;
+};
+
+module.exports = baseSetData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetToString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetToString.js
new file mode 100644
index 0000000..89eaca3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSetToString.js
@@ -0,0 +1,22 @@
+var constant = require('./constant'),
+ defineProperty = require('./_defineProperty'),
+ identity = require('./identity');
+
+/**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
+ });
+};
+
+module.exports = baseSetToString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseShuffle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseShuffle.js
new file mode 100644
index 0000000..023077a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseShuffle.js
@@ -0,0 +1,15 @@
+var shuffleSelf = require('./_shuffleSelf'),
+ values = require('./values');
+
+/**
+ * The base implementation of `_.shuffle`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+function baseShuffle(collection) {
+ return shuffleSelf(values(collection));
+}
+
+module.exports = baseShuffle;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSlice.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSlice.js
new file mode 100644
index 0000000..786f6c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSlice.js
@@ -0,0 +1,31 @@
+/**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
+ }
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
+
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
+ }
+ return result;
+}
+
+module.exports = baseSlice;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSome.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSome.js
new file mode 100644
index 0000000..58f3f44
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSome.js
@@ -0,0 +1,22 @@
+var baseEach = require('./_baseEach');
+
+/**
+ * The base implementation of `_.some` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+function baseSome(collection, predicate) {
+ var result;
+
+ baseEach(collection, function(value, index, collection) {
+ result = predicate(value, index, collection);
+ return !result;
+ });
+ return !!result;
+}
+
+module.exports = baseSome;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortBy.js
new file mode 100644
index 0000000..a25c92e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortBy.js
@@ -0,0 +1,21 @@
+/**
+ * The base implementation of `_.sortBy` which uses `comparer` to define the
+ * sort order of `array` and replaces criteria objects with their corresponding
+ * values.
+ *
+ * @private
+ * @param {Array} array The array to sort.
+ * @param {Function} comparer The function to define sort order.
+ * @returns {Array} Returns `array`.
+ */
+function baseSortBy(array, comparer) {
+ var length = array.length;
+
+ array.sort(comparer);
+ while (length--) {
+ array[length] = array[length].value;
+ }
+ return array;
+}
+
+module.exports = baseSortBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndex.js
new file mode 100644
index 0000000..638c366
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndex.js
@@ -0,0 +1,42 @@
+var baseSortedIndexBy = require('./_baseSortedIndexBy'),
+ identity = require('./identity'),
+ isSymbol = require('./isSymbol');
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295,
+ HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
+
+/**
+ * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
+ * performs a binary search of `array` to determine the index at which `value`
+ * should be inserted into `array` in order to maintain its sort order.
+ *
+ * @private
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ */
+function baseSortedIndex(array, value, retHighest) {
+ var low = 0,
+ high = array == null ? low : array.length;
+
+ if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
+ while (low < high) {
+ var mid = (low + high) >>> 1,
+ computed = array[mid];
+
+ if (computed !== null && !isSymbol(computed) &&
+ (retHighest ? (computed <= value) : (computed < value))) {
+ low = mid + 1;
+ } else {
+ high = mid;
+ }
+ }
+ return high;
+ }
+ return baseSortedIndexBy(array, value, identity, retHighest);
+}
+
+module.exports = baseSortedIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndexBy.js
new file mode 100644
index 0000000..bb22e36
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedIndexBy.js
@@ -0,0 +1,64 @@
+var isSymbol = require('./isSymbol');
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295,
+ MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeFloor = Math.floor,
+ nativeMin = Math.min;
+
+/**
+ * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
+ * which invokes `iteratee` for `value` and each element of `array` to compute
+ * their sort ranking. The iteratee is invoked with one argument; (value).
+ *
+ * @private
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} iteratee The iteratee invoked per element.
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ */
+function baseSortedIndexBy(array, value, iteratee, retHighest) {
+ value = iteratee(value);
+
+ var low = 0,
+ high = array == null ? 0 : array.length,
+ valIsNaN = value !== value,
+ valIsNull = value === null,
+ valIsSymbol = isSymbol(value),
+ valIsUndefined = value === undefined;
+
+ while (low < high) {
+ var mid = nativeFloor((low + high) / 2),
+ computed = iteratee(array[mid]),
+ othIsDefined = computed !== undefined,
+ othIsNull = computed === null,
+ othIsReflexive = computed === computed,
+ othIsSymbol = isSymbol(computed);
+
+ if (valIsNaN) {
+ var setLow = retHighest || othIsReflexive;
+ } else if (valIsUndefined) {
+ setLow = othIsReflexive && (retHighest || othIsDefined);
+ } else if (valIsNull) {
+ setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
+ } else if (valIsSymbol) {
+ setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
+ } else if (othIsNull || othIsSymbol) {
+ setLow = false;
+ } else {
+ setLow = retHighest ? (computed <= value) : (computed < value);
+ }
+ if (setLow) {
+ low = mid + 1;
+ } else {
+ high = mid;
+ }
+ }
+ return nativeMin(high, MAX_ARRAY_INDEX);
+}
+
+module.exports = baseSortedIndexBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedUniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedUniq.js
new file mode 100644
index 0000000..802159a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSortedUniq.js
@@ -0,0 +1,30 @@
+var eq = require('./eq');
+
+/**
+ * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ */
+function baseSortedUniq(array, iteratee) {
+ var index = -1,
+ length = array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ if (!index || !eq(computed, seen)) {
+ var seen = computed;
+ result[resIndex++] = value === 0 ? 0 : value;
+ }
+ }
+ return result;
+}
+
+module.exports = baseSortedUniq;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSum.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSum.js
new file mode 100644
index 0000000..a9e84c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseSum.js
@@ -0,0 +1,24 @@
+/**
+ * The base implementation of `_.sum` and `_.sumBy` without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {number} Returns the sum.
+ */
+function baseSum(array, iteratee) {
+ var result,
+ index = -1,
+ length = array.length;
+
+ while (++index < length) {
+ var current = iteratee(array[index]);
+ if (current !== undefined) {
+ result = result === undefined ? current : (result + current);
+ }
+ }
+ return result;
+}
+
+module.exports = baseSum;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseTimes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseTimes.js
new file mode 100644
index 0000000..0603fc3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseTimes.js
@@ -0,0 +1,20 @@
+/**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+}
+
+module.exports = baseTimes;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToNumber.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToNumber.js
new file mode 100644
index 0000000..04859f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToNumber.js
@@ -0,0 +1,24 @@
+var isSymbol = require('./isSymbol');
+
+/** Used as references for various `Number` constants. */
+var NAN = 0 / 0;
+
+/**
+ * The base implementation of `_.toNumber` which doesn't ensure correct
+ * conversions of binary, hexadecimal, or octal string values.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ */
+function baseToNumber(value) {
+ if (typeof value == 'number') {
+ return value;
+ }
+ if (isSymbol(value)) {
+ return NAN;
+ }
+ return +value;
+}
+
+module.exports = baseToNumber;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToPairs.js
new file mode 100644
index 0000000..bff1991
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToPairs.js
@@ -0,0 +1,18 @@
+var arrayMap = require('./_arrayMap');
+
+/**
+ * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
+ * of key-value pairs for `object` corresponding to the property names of `props`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} props The property names to get values for.
+ * @returns {Object} Returns the key-value pairs.
+ */
+function baseToPairs(object, props) {
+ return arrayMap(props, function(key) {
+ return [key, object[key]];
+ });
+}
+
+module.exports = baseToPairs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToString.js
new file mode 100644
index 0000000..ada6ad2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseToString.js
@@ -0,0 +1,37 @@
+var Symbol = require('./_Symbol'),
+ arrayMap = require('./_arrayMap'),
+ isArray = require('./isArray'),
+ isSymbol = require('./isSymbol');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+/**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+module.exports = baseToString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnary.js
new file mode 100644
index 0000000..98639e9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnary.js
@@ -0,0 +1,14 @@
+/**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+}
+
+module.exports = baseUnary;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUniq.js
new file mode 100644
index 0000000..aea459d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUniq.js
@@ -0,0 +1,72 @@
+var SetCache = require('./_SetCache'),
+ arrayIncludes = require('./_arrayIncludes'),
+ arrayIncludesWith = require('./_arrayIncludesWith'),
+ cacheHas = require('./_cacheHas'),
+ createSet = require('./_createSet'),
+ setToArray = require('./_setToArray');
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/**
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ */
+function baseUniq(array, iteratee, comparator) {
+ var index = -1,
+ includes = arrayIncludes,
+ length = array.length,
+ isCommon = true,
+ result = [],
+ seen = result;
+
+ if (comparator) {
+ isCommon = false;
+ includes = arrayIncludesWith;
+ }
+ else if (length >= LARGE_ARRAY_SIZE) {
+ var set = iteratee ? null : createSet(array);
+ if (set) {
+ return setToArray(set);
+ }
+ isCommon = false;
+ includes = cacheHas;
+ seen = new SetCache;
+ }
+ else {
+ seen = iteratee ? [] : result;
+ }
+ outer:
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (isCommon && computed === computed) {
+ var seenIndex = seen.length;
+ while (seenIndex--) {
+ if (seen[seenIndex] === computed) {
+ continue outer;
+ }
+ }
+ if (iteratee) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ else if (!includes(seen, computed, comparator)) {
+ if (seen !== result) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ }
+ return result;
+}
+
+module.exports = baseUniq;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnset.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnset.js
new file mode 100644
index 0000000..eefc6e3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUnset.js
@@ -0,0 +1,20 @@
+var castPath = require('./_castPath'),
+ last = require('./last'),
+ parent = require('./_parent'),
+ toKey = require('./_toKey');
+
+/**
+ * The base implementation of `_.unset`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The property path to unset.
+ * @returns {boolean} Returns `true` if the property is deleted, else `false`.
+ */
+function baseUnset(object, path) {
+ path = castPath(path, object);
+ object = parent(object, path);
+ return object == null || delete object[toKey(last(path))];
+}
+
+module.exports = baseUnset;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUpdate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUpdate.js
new file mode 100644
index 0000000..92a6237
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseUpdate.js
@@ -0,0 +1,18 @@
+var baseGet = require('./_baseGet'),
+ baseSet = require('./_baseSet');
+
+/**
+ * The base implementation of `_.update`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to update.
+ * @param {Function} updater The function to produce the updated value.
+ * @param {Function} [customizer] The function to customize path creation.
+ * @returns {Object} Returns `object`.
+ */
+function baseUpdate(object, path, updater, customizer) {
+ return baseSet(object, path, updater(baseGet(object, path)), customizer);
+}
+
+module.exports = baseUpdate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseValues.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseValues.js
new file mode 100644
index 0000000..b95faad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseValues.js
@@ -0,0 +1,19 @@
+var arrayMap = require('./_arrayMap');
+
+/**
+ * The base implementation of `_.values` and `_.valuesIn` which creates an
+ * array of `object` property values corresponding to the property names
+ * of `props`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} props The property names to get values for.
+ * @returns {Object} Returns the array of property values.
+ */
+function baseValues(object, props) {
+ return arrayMap(props, function(key) {
+ return object[key];
+ });
+}
+
+module.exports = baseValues;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWhile.js
new file mode 100644
index 0000000..07eac61
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWhile.js
@@ -0,0 +1,26 @@
+var baseSlice = require('./_baseSlice');
+
+/**
+ * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
+ * without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to query.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function baseWhile(array, predicate, isDrop, fromRight) {
+ var length = array.length,
+ index = fromRight ? length : -1;
+
+ while ((fromRight ? index-- : ++index < length) &&
+ predicate(array[index], index, array)) {}
+
+ return isDrop
+ ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
+ : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
+}
+
+module.exports = baseWhile;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWrapperValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWrapperValue.js
new file mode 100644
index 0000000..443e0df
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseWrapperValue.js
@@ -0,0 +1,25 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ arrayPush = require('./_arrayPush'),
+ arrayReduce = require('./_arrayReduce');
+
+/**
+ * The base implementation of `wrapperValue` which returns the result of
+ * performing a sequence of actions on the unwrapped `value`, where each
+ * successive action is supplied the return value of the previous.
+ *
+ * @private
+ * @param {*} value The unwrapped value.
+ * @param {Array} actions Actions to perform to resolve the unwrapped value.
+ * @returns {*} Returns the resolved value.
+ */
+function baseWrapperValue(value, actions) {
+ var result = value;
+ if (result instanceof LazyWrapper) {
+ result = result.value();
+ }
+ return arrayReduce(actions, function(result, action) {
+ return action.func.apply(action.thisArg, arrayPush([result], action.args));
+ }, result);
+}
+
+module.exports = baseWrapperValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseXor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseXor.js
new file mode 100644
index 0000000..8e69338
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseXor.js
@@ -0,0 +1,36 @@
+var baseDifference = require('./_baseDifference'),
+ baseFlatten = require('./_baseFlatten'),
+ baseUniq = require('./_baseUniq');
+
+/**
+ * The base implementation of methods like `_.xor`, without support for
+ * iteratee shorthands, that accepts an array of arrays to inspect.
+ *
+ * @private
+ * @param {Array} arrays The arrays to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of values.
+ */
+function baseXor(arrays, iteratee, comparator) {
+ var length = arrays.length;
+ if (length < 2) {
+ return length ? baseUniq(arrays[0]) : [];
+ }
+ var index = -1,
+ result = Array(length);
+
+ while (++index < length) {
+ var array = arrays[index],
+ othIndex = -1;
+
+ while (++othIndex < length) {
+ if (othIndex != index) {
+ result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
+ }
+ }
+ }
+ return baseUniq(baseFlatten(result, 1), iteratee, comparator);
+}
+
+module.exports = baseXor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseZipObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseZipObject.js
new file mode 100644
index 0000000..401f85b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_baseZipObject.js
@@ -0,0 +1,23 @@
+/**
+ * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
+ *
+ * @private
+ * @param {Array} props The property identifiers.
+ * @param {Array} values The property values.
+ * @param {Function} assignFunc The function to assign values.
+ * @returns {Object} Returns the new object.
+ */
+function baseZipObject(props, values, assignFunc) {
+ var index = -1,
+ length = props.length,
+ valsLength = values.length,
+ result = {};
+
+ while (++index < length) {
+ var value = index < valsLength ? values[index] : undefined;
+ assignFunc(result, props[index], value);
+ }
+ return result;
+}
+
+module.exports = baseZipObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cacheHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cacheHas.js
new file mode 100644
index 0000000..2dec892
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cacheHas.js
@@ -0,0 +1,13 @@
+/**
+ * Checks if a `cache` value for `key` exists.
+ *
+ * @private
+ * @param {Object} cache The cache to query.
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function cacheHas(cache, key) {
+ return cache.has(key);
+}
+
+module.exports = cacheHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castArrayLikeObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castArrayLikeObject.js
new file mode 100644
index 0000000..92c75fa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castArrayLikeObject.js
@@ -0,0 +1,14 @@
+var isArrayLikeObject = require('./isArrayLikeObject');
+
+/**
+ * Casts `value` to an empty array if it's not an array like object.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array|Object} Returns the cast array-like object.
+ */
+function castArrayLikeObject(value) {
+ return isArrayLikeObject(value) ? value : [];
+}
+
+module.exports = castArrayLikeObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castFunction.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castFunction.js
new file mode 100644
index 0000000..98c91ae
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castFunction.js
@@ -0,0 +1,14 @@
+var identity = require('./identity');
+
+/**
+ * Casts `value` to `identity` if it's not a function.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Function} Returns cast function.
+ */
+function castFunction(value) {
+ return typeof value == 'function' ? value : identity;
+}
+
+module.exports = castFunction;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castPath.js
new file mode 100644
index 0000000..017e4c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castPath.js
@@ -0,0 +1,21 @@
+var isArray = require('./isArray'),
+ isKey = require('./_isKey'),
+ stringToPath = require('./_stringToPath'),
+ toString = require('./toString');
+
+/**
+ * Casts `value` to a path array if it's not one.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {Array} Returns the cast property path array.
+ */
+function castPath(value, object) {
+ if (isArray(value)) {
+ return value;
+ }
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
+}
+
+module.exports = castPath;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castRest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castRest.js
new file mode 100644
index 0000000..213c66f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castRest.js
@@ -0,0 +1,14 @@
+var baseRest = require('./_baseRest');
+
+/**
+ * A `baseRest` alias which can be replaced with `identity` by module
+ * replacement plugins.
+ *
+ * @private
+ * @type {Function}
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+var castRest = baseRest;
+
+module.exports = castRest;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castSlice.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castSlice.js
new file mode 100644
index 0000000..071faeb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_castSlice.js
@@ -0,0 +1,18 @@
+var baseSlice = require('./_baseSlice');
+
+/**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+}
+
+module.exports = castSlice;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsEndIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsEndIndex.js
new file mode 100644
index 0000000..07908ff
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsEndIndex.js
@@ -0,0 +1,19 @@
+var baseIndexOf = require('./_baseIndexOf');
+
+/**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the last unmatched string symbol.
+ */
+function charsEndIndex(strSymbols, chrSymbols) {
+ var index = strSymbols.length;
+
+ while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+module.exports = charsEndIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsStartIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsStartIndex.js
new file mode 100644
index 0000000..b17afd2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_charsStartIndex.js
@@ -0,0 +1,20 @@
+var baseIndexOf = require('./_baseIndexOf');
+
+/**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the first unmatched string symbol.
+ */
+function charsStartIndex(strSymbols, chrSymbols) {
+ var index = -1,
+ length = strSymbols.length;
+
+ while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+module.exports = charsStartIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneArrayBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneArrayBuffer.js
new file mode 100644
index 0000000..c3d8f6e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneArrayBuffer.js
@@ -0,0 +1,16 @@
+var Uint8Array = require('./_Uint8Array');
+
+/**
+ * Creates a clone of `arrayBuffer`.
+ *
+ * @private
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
+ */
+function cloneArrayBuffer(arrayBuffer) {
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
+ return result;
+}
+
+module.exports = cloneArrayBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneBuffer.js
new file mode 100644
index 0000000..27c4810
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneBuffer.js
@@ -0,0 +1,35 @@
+var root = require('./_root');
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined,
+ allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
+
+/**
+ * Creates a clone of `buffer`.
+ *
+ * @private
+ * @param {Buffer} buffer The buffer to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Buffer} Returns the cloned buffer.
+ */
+function cloneBuffer(buffer, isDeep) {
+ if (isDeep) {
+ return buffer.slice();
+ }
+ var length = buffer.length,
+ result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
+
+ buffer.copy(result);
+ return result;
+}
+
+module.exports = cloneBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneDataView.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneDataView.js
new file mode 100644
index 0000000..9c9b7b0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneDataView.js
@@ -0,0 +1,16 @@
+var cloneArrayBuffer = require('./_cloneArrayBuffer');
+
+/**
+ * Creates a clone of `dataView`.
+ *
+ * @private
+ * @param {Object} dataView The data view to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned data view.
+ */
+function cloneDataView(dataView, isDeep) {
+ var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
+}
+
+module.exports = cloneDataView;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneMap.js
new file mode 100644
index 0000000..334b73e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneMap.js
@@ -0,0 +1,22 @@
+var addMapEntry = require('./_addMapEntry'),
+ arrayReduce = require('./_arrayReduce'),
+ mapToArray = require('./_mapToArray');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a clone of `map`.
+ *
+ * @private
+ * @param {Object} map The map to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned map.
+ */
+function cloneMap(map, isDeep, cloneFunc) {
+ var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
+ return arrayReduce(array, addMapEntry, new map.constructor);
+}
+
+module.exports = cloneMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneRegExp.js
new file mode 100644
index 0000000..64a30df
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneRegExp.js
@@ -0,0 +1,17 @@
+/** Used to match `RegExp` flags from their coerced string values. */
+var reFlags = /\w*$/;
+
+/**
+ * Creates a clone of `regexp`.
+ *
+ * @private
+ * @param {Object} regexp The regexp to clone.
+ * @returns {Object} Returns the cloned regexp.
+ */
+function cloneRegExp(regexp) {
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
+ result.lastIndex = regexp.lastIndex;
+ return result;
+}
+
+module.exports = cloneRegExp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSet.js
new file mode 100644
index 0000000..713a2f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSet.js
@@ -0,0 +1,22 @@
+var addSetEntry = require('./_addSetEntry'),
+ arrayReduce = require('./_arrayReduce'),
+ setToArray = require('./_setToArray');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a clone of `set`.
+ *
+ * @private
+ * @param {Object} set The set to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned set.
+ */
+function cloneSet(set, isDeep, cloneFunc) {
+ var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
+ return arrayReduce(array, addSetEntry, new set.constructor);
+}
+
+module.exports = cloneSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSymbol.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSymbol.js
new file mode 100644
index 0000000..bede39f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneSymbol.js
@@ -0,0 +1,18 @@
+var Symbol = require('./_Symbol');
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
+
+/**
+ * Creates a clone of the `symbol` object.
+ *
+ * @private
+ * @param {Object} symbol The symbol object to clone.
+ * @returns {Object} Returns the cloned symbol object.
+ */
+function cloneSymbol(symbol) {
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
+}
+
+module.exports = cloneSymbol;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneTypedArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneTypedArray.js
new file mode 100644
index 0000000..7aad84d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_cloneTypedArray.js
@@ -0,0 +1,16 @@
+var cloneArrayBuffer = require('./_cloneArrayBuffer');
+
+/**
+ * Creates a clone of `typedArray`.
+ *
+ * @private
+ * @param {Object} typedArray The typed array to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned typed array.
+ */
+function cloneTypedArray(typedArray, isDeep) {
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
+}
+
+module.exports = cloneTypedArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareAscending.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareAscending.js
new file mode 100644
index 0000000..8dc2791
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareAscending.js
@@ -0,0 +1,41 @@
+var isSymbol = require('./isSymbol');
+
+/**
+ * Compares values to sort them in ascending order.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {number} Returns the sort order indicator for `value`.
+ */
+function compareAscending(value, other) {
+ if (value !== other) {
+ var valIsDefined = value !== undefined,
+ valIsNull = value === null,
+ valIsReflexive = value === value,
+ valIsSymbol = isSymbol(value);
+
+ var othIsDefined = other !== undefined,
+ othIsNull = other === null,
+ othIsReflexive = other === other,
+ othIsSymbol = isSymbol(other);
+
+ if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
+ (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
+ (valIsNull && othIsDefined && othIsReflexive) ||
+ (!valIsDefined && othIsReflexive) ||
+ !valIsReflexive) {
+ return 1;
+ }
+ if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
+ (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
+ (othIsNull && valIsDefined && valIsReflexive) ||
+ (!othIsDefined && valIsReflexive) ||
+ !othIsReflexive) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+module.exports = compareAscending;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareMultiple.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareMultiple.js
new file mode 100644
index 0000000..ad61f0f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_compareMultiple.js
@@ -0,0 +1,44 @@
+var compareAscending = require('./_compareAscending');
+
+/**
+ * Used by `_.orderBy` to compare multiple properties of a value to another
+ * and stable sort them.
+ *
+ * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
+ * specify an order of "desc" for descending or "asc" for ascending sort order
+ * of corresponding values.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {boolean[]|string[]} orders The order to sort by for each property.
+ * @returns {number} Returns the sort order indicator for `object`.
+ */
+function compareMultiple(object, other, orders) {
+ var index = -1,
+ objCriteria = object.criteria,
+ othCriteria = other.criteria,
+ length = objCriteria.length,
+ ordersLength = orders.length;
+
+ while (++index < length) {
+ var result = compareAscending(objCriteria[index], othCriteria[index]);
+ if (result) {
+ if (index >= ordersLength) {
+ return result;
+ }
+ var order = orders[index];
+ return result * (order == 'desc' ? -1 : 1);
+ }
+ }
+ // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
+ // that causes it, under certain circumstances, to provide the same value for
+ // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
+ // for more details.
+ //
+ // This also ensures a stable sort in V8 and other engines.
+ // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
+ return object.index - other.index;
+}
+
+module.exports = compareMultiple;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgs.js
new file mode 100644
index 0000000..1ce40f4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgs.js
@@ -0,0 +1,39 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * Creates an array that is the composition of partially applied arguments,
+ * placeholders, and provided arguments into a single array of arguments.
+ *
+ * @private
+ * @param {Array} args The provided arguments.
+ * @param {Array} partials The arguments to prepend to those provided.
+ * @param {Array} holders The `partials` placeholder indexes.
+ * @params {boolean} [isCurried] Specify composing for a curried function.
+ * @returns {Array} Returns the new array of composed arguments.
+ */
+function composeArgs(args, partials, holders, isCurried) {
+ var argsIndex = -1,
+ argsLength = args.length,
+ holdersLength = holders.length,
+ leftIndex = -1,
+ leftLength = partials.length,
+ rangeLength = nativeMax(argsLength - holdersLength, 0),
+ result = Array(leftLength + rangeLength),
+ isUncurried = !isCurried;
+
+ while (++leftIndex < leftLength) {
+ result[leftIndex] = partials[leftIndex];
+ }
+ while (++argsIndex < holdersLength) {
+ if (isUncurried || argsIndex < argsLength) {
+ result[holders[argsIndex]] = args[argsIndex];
+ }
+ }
+ while (rangeLength--) {
+ result[leftIndex++] = args[argsIndex++];
+ }
+ return result;
+}
+
+module.exports = composeArgs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgsRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgsRight.js
new file mode 100644
index 0000000..8dc588d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_composeArgsRight.js
@@ -0,0 +1,41 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * This function is like `composeArgs` except that the arguments composition
+ * is tailored for `_.partialRight`.
+ *
+ * @private
+ * @param {Array} args The provided arguments.
+ * @param {Array} partials The arguments to append to those provided.
+ * @param {Array} holders The `partials` placeholder indexes.
+ * @params {boolean} [isCurried] Specify composing for a curried function.
+ * @returns {Array} Returns the new array of composed arguments.
+ */
+function composeArgsRight(args, partials, holders, isCurried) {
+ var argsIndex = -1,
+ argsLength = args.length,
+ holdersIndex = -1,
+ holdersLength = holders.length,
+ rightIndex = -1,
+ rightLength = partials.length,
+ rangeLength = nativeMax(argsLength - holdersLength, 0),
+ result = Array(rangeLength + rightLength),
+ isUncurried = !isCurried;
+
+ while (++argsIndex < rangeLength) {
+ result[argsIndex] = args[argsIndex];
+ }
+ var offset = argsIndex;
+ while (++rightIndex < rightLength) {
+ result[offset + rightIndex] = partials[rightIndex];
+ }
+ while (++holdersIndex < holdersLength) {
+ if (isUncurried || argsIndex < argsLength) {
+ result[offset + holders[holdersIndex]] = args[argsIndex++];
+ }
+ }
+ return result;
+}
+
+module.exports = composeArgsRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyArray.js
new file mode 100644
index 0000000..cd94d5d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyArray.js
@@ -0,0 +1,20 @@
+/**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+function copyArray(source, array) {
+ var index = -1,
+ length = source.length;
+
+ array || (array = Array(length));
+ while (++index < length) {
+ array[index] = source[index];
+ }
+ return array;
+}
+
+module.exports = copyArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyObject.js
new file mode 100644
index 0000000..2f2a5c2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copyObject.js
@@ -0,0 +1,40 @@
+var assignValue = require('./_assignValue'),
+ baseAssignValue = require('./_baseAssignValue');
+
+/**
+ * Copies properties of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy properties from.
+ * @param {Array} props The property identifiers to copy.
+ * @param {Object} [object={}] The object to copy properties to.
+ * @param {Function} [customizer] The function to customize copied values.
+ * @returns {Object} Returns `object`.
+ */
+function copyObject(source, props, object, customizer) {
+ var isNew = !object;
+ object || (object = {});
+
+ var index = -1,
+ length = props.length;
+
+ while (++index < length) {
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = source[key];
+ }
+ if (isNew) {
+ baseAssignValue(object, key, newValue);
+ } else {
+ assignValue(object, key, newValue);
+ }
+ }
+ return object;
+}
+
+module.exports = copyObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbols.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbols.js
new file mode 100644
index 0000000..c35944a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbols.js
@@ -0,0 +1,16 @@
+var copyObject = require('./_copyObject'),
+ getSymbols = require('./_getSymbols');
+
+/**
+ * Copies own symbols of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy symbols from.
+ * @param {Object} [object={}] The object to copy symbols to.
+ * @returns {Object} Returns `object`.
+ */
+function copySymbols(source, object) {
+ return copyObject(source, getSymbols(source), object);
+}
+
+module.exports = copySymbols;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbolsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbolsIn.js
new file mode 100644
index 0000000..fdf20a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_copySymbolsIn.js
@@ -0,0 +1,16 @@
+var copyObject = require('./_copyObject'),
+ getSymbolsIn = require('./_getSymbolsIn');
+
+/**
+ * Copies own and inherited symbols of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy symbols from.
+ * @param {Object} [object={}] The object to copy symbols to.
+ * @returns {Object} Returns `object`.
+ */
+function copySymbolsIn(source, object) {
+ return copyObject(source, getSymbolsIn(source), object);
+}
+
+module.exports = copySymbolsIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_coreJsData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_coreJsData.js
new file mode 100644
index 0000000..f8e5b4e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_coreJsData.js
@@ -0,0 +1,6 @@
+var root = require('./_root');
+
+/** Used to detect overreaching core-js shims. */
+var coreJsData = root['__core-js_shared__'];
+
+module.exports = coreJsData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_countHolders.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_countHolders.js
new file mode 100644
index 0000000..718fcda
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_countHolders.js
@@ -0,0 +1,21 @@
+/**
+ * Gets the number of `placeholder` occurrences in `array`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} placeholder The placeholder to search for.
+ * @returns {number} Returns the placeholder count.
+ */
+function countHolders(array, placeholder) {
+ var length = array.length,
+ result = 0;
+
+ while (length--) {
+ if (array[length] === placeholder) {
+ ++result;
+ }
+ }
+ return result;
+}
+
+module.exports = countHolders;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAggregator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAggregator.js
new file mode 100644
index 0000000..0be42c4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAggregator.js
@@ -0,0 +1,23 @@
+var arrayAggregator = require('./_arrayAggregator'),
+ baseAggregator = require('./_baseAggregator'),
+ baseIteratee = require('./_baseIteratee'),
+ isArray = require('./isArray');
+
+/**
+ * Creates a function like `_.groupBy`.
+ *
+ * @private
+ * @param {Function} setter The function to set accumulator values.
+ * @param {Function} [initializer] The accumulator object initializer.
+ * @returns {Function} Returns the new aggregator function.
+ */
+function createAggregator(setter, initializer) {
+ return function(collection, iteratee) {
+ var func = isArray(collection) ? arrayAggregator : baseAggregator,
+ accumulator = initializer ? initializer() : {};
+
+ return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
+ };
+}
+
+module.exports = createAggregator;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAssigner.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAssigner.js
new file mode 100644
index 0000000..1f904c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createAssigner.js
@@ -0,0 +1,37 @@
+var baseRest = require('./_baseRest'),
+ isIterateeCall = require('./_isIterateeCall');
+
+/**
+ * Creates a function like `_.assign`.
+ *
+ * @private
+ * @param {Function} assigner The function to assign values.
+ * @returns {Function} Returns the new assigner function.
+ */
+function createAssigner(assigner) {
+ return baseRest(function(object, sources) {
+ var index = -1,
+ length = sources.length,
+ customizer = length > 1 ? sources[length - 1] : undefined,
+ guard = length > 2 ? sources[2] : undefined;
+
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
+ ? (length--, customizer)
+ : undefined;
+
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
+ customizer = length < 3 ? undefined : customizer;
+ length = 1;
+ }
+ object = Object(object);
+ while (++index < length) {
+ var source = sources[index];
+ if (source) {
+ assigner(object, source, index, customizer);
+ }
+ }
+ return object;
+ });
+}
+
+module.exports = createAssigner;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseEach.js
new file mode 100644
index 0000000..d24fdd1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseEach.js
@@ -0,0 +1,32 @@
+var isArrayLike = require('./isArrayLike');
+
+/**
+ * Creates a `baseEach` or `baseEachRight` function.
+ *
+ * @private
+ * @param {Function} eachFunc The function to iterate over a collection.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseEach(eachFunc, fromRight) {
+ return function(collection, iteratee) {
+ if (collection == null) {
+ return collection;
+ }
+ if (!isArrayLike(collection)) {
+ return eachFunc(collection, iteratee);
+ }
+ var length = collection.length,
+ index = fromRight ? length : -1,
+ iterable = Object(collection);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (iteratee(iterable[index], index, iterable) === false) {
+ break;
+ }
+ }
+ return collection;
+ };
+}
+
+module.exports = createBaseEach;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseFor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseFor.js
new file mode 100644
index 0000000..94cbf29
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBaseFor.js
@@ -0,0 +1,25 @@
+/**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+}
+
+module.exports = createBaseFor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBind.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBind.js
new file mode 100644
index 0000000..07cb99f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createBind.js
@@ -0,0 +1,28 @@
+var createCtor = require('./_createCtor'),
+ root = require('./_root');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1;
+
+/**
+ * Creates a function that wraps `func` to invoke it with the optional `this`
+ * binding of `thisArg`.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createBind(func, bitmask, thisArg) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
+
+ function wrapper() {
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(isBind ? thisArg : this, arguments);
+ }
+ return wrapper;
+}
+
+module.exports = createBind;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCaseFirst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCaseFirst.js
new file mode 100644
index 0000000..fe8ea48
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCaseFirst.js
@@ -0,0 +1,33 @@
+var castSlice = require('./_castSlice'),
+ hasUnicode = require('./_hasUnicode'),
+ stringToArray = require('./_stringToArray'),
+ toString = require('./toString');
+
+/**
+ * Creates a function like `_.lowerFirst`.
+ *
+ * @private
+ * @param {string} methodName The name of the `String` case method to use.
+ * @returns {Function} Returns the new case function.
+ */
+function createCaseFirst(methodName) {
+ return function(string) {
+ string = toString(string);
+
+ var strSymbols = hasUnicode(string)
+ ? stringToArray(string)
+ : undefined;
+
+ var chr = strSymbols
+ ? strSymbols[0]
+ : string.charAt(0);
+
+ var trailing = strSymbols
+ ? castSlice(strSymbols, 1).join('')
+ : string.slice(1);
+
+ return chr[methodName]() + trailing;
+ };
+}
+
+module.exports = createCaseFirst;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCompounder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCompounder.js
new file mode 100644
index 0000000..8d4cee2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCompounder.js
@@ -0,0 +1,24 @@
+var arrayReduce = require('./_arrayReduce'),
+ deburr = require('./deburr'),
+ words = require('./words');
+
+/** Used to compose unicode capture groups. */
+var rsApos = "['\u2019]";
+
+/** Used to match apostrophes. */
+var reApos = RegExp(rsApos, 'g');
+
+/**
+ * Creates a function like `_.camelCase`.
+ *
+ * @private
+ * @param {Function} callback The function to combine each word.
+ * @returns {Function} Returns the new compounder function.
+ */
+function createCompounder(callback) {
+ return function(string) {
+ return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
+ };
+}
+
+module.exports = createCompounder;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCtor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCtor.js
new file mode 100644
index 0000000..9047aa5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCtor.js
@@ -0,0 +1,37 @@
+var baseCreate = require('./_baseCreate'),
+ isObject = require('./isObject');
+
+/**
+ * Creates a function that produces an instance of `Ctor` regardless of
+ * whether it was invoked as part of a `new` expression or by `call` or `apply`.
+ *
+ * @private
+ * @param {Function} Ctor The constructor to wrap.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createCtor(Ctor) {
+ return function() {
+ // Use a `switch` statement to work with class constructors. See
+ // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
+ // for more details.
+ var args = arguments;
+ switch (args.length) {
+ case 0: return new Ctor;
+ case 1: return new Ctor(args[0]);
+ case 2: return new Ctor(args[0], args[1]);
+ case 3: return new Ctor(args[0], args[1], args[2]);
+ case 4: return new Ctor(args[0], args[1], args[2], args[3]);
+ case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
+ case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
+ case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+ }
+ var thisBinding = baseCreate(Ctor.prototype),
+ result = Ctor.apply(thisBinding, args);
+
+ // Mimic the constructor's `return` behavior.
+ // See https://es5.github.io/#x13.2.2 for more details.
+ return isObject(result) ? result : thisBinding;
+ };
+}
+
+module.exports = createCtor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCurry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCurry.js
new file mode 100644
index 0000000..f06c2cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createCurry.js
@@ -0,0 +1,46 @@
+var apply = require('./_apply'),
+ createCtor = require('./_createCtor'),
+ createHybrid = require('./_createHybrid'),
+ createRecurry = require('./_createRecurry'),
+ getHolder = require('./_getHolder'),
+ replaceHolders = require('./_replaceHolders'),
+ root = require('./_root');
+
+/**
+ * Creates a function that wraps `func` to enable currying.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {number} arity The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createCurry(func, bitmask, arity) {
+ var Ctor = createCtor(func);
+
+ function wrapper() {
+ var length = arguments.length,
+ args = Array(length),
+ index = length,
+ placeholder = getHolder(wrapper);
+
+ while (index--) {
+ args[index] = arguments[index];
+ }
+ var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
+ ? []
+ : replaceHolders(args, placeholder);
+
+ length -= holders.length;
+ if (length < arity) {
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, undefined,
+ args, holders, undefined, undefined, arity - length);
+ }
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return apply(fn, this, args);
+ }
+ return wrapper;
+}
+
+module.exports = createCurry;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFind.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFind.js
new file mode 100644
index 0000000..8859ff8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFind.js
@@ -0,0 +1,25 @@
+var baseIteratee = require('./_baseIteratee'),
+ isArrayLike = require('./isArrayLike'),
+ keys = require('./keys');
+
+/**
+ * Creates a `_.find` or `_.findLast` function.
+ *
+ * @private
+ * @param {Function} findIndexFunc The function to find the collection index.
+ * @returns {Function} Returns the new find function.
+ */
+function createFind(findIndexFunc) {
+ return function(collection, predicate, fromIndex) {
+ var iterable = Object(collection);
+ if (!isArrayLike(collection)) {
+ var iteratee = baseIteratee(predicate, 3);
+ collection = keys(collection);
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
+ }
+ var index = findIndexFunc(collection, predicate, fromIndex);
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
+ };
+}
+
+module.exports = createFind;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFlow.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFlow.js
new file mode 100644
index 0000000..c6b43f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createFlow.js
@@ -0,0 +1,82 @@
+var LodashWrapper = require('./_LodashWrapper'),
+ flatRest = require('./_flatRest'),
+ getData = require('./_getData'),
+ getFuncName = require('./_getFuncName'),
+ isArray = require('./isArray'),
+ isLaziable = require('./_isLaziable');
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_CURRY_FLAG = 8,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_ARY_FLAG = 128,
+ WRAP_REARG_FLAG = 256;
+
+/**
+ * Creates a `_.flow` or `_.flowRight` function.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new flow function.
+ */
+function createFlow(fromRight) {
+ return flatRest(function(funcs) {
+ var length = funcs.length,
+ index = length,
+ prereq = LodashWrapper.prototype.thru;
+
+ if (fromRight) {
+ funcs.reverse();
+ }
+ while (index--) {
+ var func = funcs[index];
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
+ var wrapper = new LodashWrapper([], true);
+ }
+ }
+ index = wrapper ? index : length;
+ while (++index < length) {
+ func = funcs[index];
+
+ var funcName = getFuncName(func),
+ data = funcName == 'wrapper' ? getData(func) : undefined;
+
+ if (data && isLaziable(data[0]) &&
+ data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
+ !data[4].length && data[9] == 1
+ ) {
+ wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
+ } else {
+ wrapper = (func.length == 1 && isLaziable(func))
+ ? wrapper[funcName]()
+ : wrapper.thru(func);
+ }
+ }
+ return function() {
+ var args = arguments,
+ value = args[0];
+
+ if (wrapper && args.length == 1 &&
+ isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
+ return wrapper.plant(value).value();
+ }
+ var index = 0,
+ result = length ? funcs[index].apply(this, args) : value;
+
+ while (++index < length) {
+ result = funcs[index].call(this, result);
+ }
+ return result;
+ };
+ });
+}
+
+module.exports = createFlow;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createHybrid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createHybrid.js
new file mode 100644
index 0000000..b671bd1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createHybrid.js
@@ -0,0 +1,92 @@
+var composeArgs = require('./_composeArgs'),
+ composeArgsRight = require('./_composeArgsRight'),
+ countHolders = require('./_countHolders'),
+ createCtor = require('./_createCtor'),
+ createRecurry = require('./_createRecurry'),
+ getHolder = require('./_getHolder'),
+ reorder = require('./_reorder'),
+ replaceHolders = require('./_replaceHolders'),
+ root = require('./_root');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_CURRY_RIGHT_FLAG = 16,
+ WRAP_ARY_FLAG = 128,
+ WRAP_FLIP_FLAG = 512;
+
+/**
+ * Creates a function that wraps `func` to invoke it with optional `this`
+ * binding of `thisArg`, partial application, and currying.
+ *
+ * @private
+ * @param {Function|string} func The function or method name to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to prepend to those provided to
+ * the new function.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [partialsRight] The arguments to append to those provided
+ * to the new function.
+ * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
+ var isAry = bitmask & WRAP_ARY_FLAG,
+ isBind = bitmask & WRAP_BIND_FLAG,
+ isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
+ isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
+ isFlip = bitmask & WRAP_FLIP_FLAG,
+ Ctor = isBindKey ? undefined : createCtor(func);
+
+ function wrapper() {
+ var length = arguments.length,
+ args = Array(length),
+ index = length;
+
+ while (index--) {
+ args[index] = arguments[index];
+ }
+ if (isCurried) {
+ var placeholder = getHolder(wrapper),
+ holdersCount = countHolders(args, placeholder);
+ }
+ if (partials) {
+ args = composeArgs(args, partials, holders, isCurried);
+ }
+ if (partialsRight) {
+ args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
+ }
+ length -= holdersCount;
+ if (isCurried && length < arity) {
+ var newHolders = replaceHolders(args, placeholder);
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, thisArg,
+ args, newHolders, argPos, ary, arity - length
+ );
+ }
+ var thisBinding = isBind ? thisArg : this,
+ fn = isBindKey ? thisBinding[func] : func;
+
+ length = args.length;
+ if (argPos) {
+ args = reorder(args, argPos);
+ } else if (isFlip && length > 1) {
+ args.reverse();
+ }
+ if (isAry && ary < length) {
+ args.length = ary;
+ }
+ if (this && this !== root && this instanceof wrapper) {
+ fn = Ctor || createCtor(fn);
+ }
+ return fn.apply(thisBinding, args);
+ }
+ return wrapper;
+}
+
+module.exports = createHybrid;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createInverter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createInverter.js
new file mode 100644
index 0000000..6c0c562
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createInverter.js
@@ -0,0 +1,17 @@
+var baseInverter = require('./_baseInverter');
+
+/**
+ * Creates a function like `_.invertBy`.
+ *
+ * @private
+ * @param {Function} setter The function to set accumulator values.
+ * @param {Function} toIteratee The function to resolve iteratees.
+ * @returns {Function} Returns the new inverter function.
+ */
+function createInverter(setter, toIteratee) {
+ return function(object, iteratee) {
+ return baseInverter(object, setter, toIteratee(iteratee), {});
+ };
+}
+
+module.exports = createInverter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createMathOperation.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createMathOperation.js
new file mode 100644
index 0000000..f1e238a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createMathOperation.js
@@ -0,0 +1,38 @@
+var baseToNumber = require('./_baseToNumber'),
+ baseToString = require('./_baseToString');
+
+/**
+ * Creates a function that performs a mathematical operation on two values.
+ *
+ * @private
+ * @param {Function} operator The function to perform the operation.
+ * @param {number} [defaultValue] The value used for `undefined` arguments.
+ * @returns {Function} Returns the new mathematical operation function.
+ */
+function createMathOperation(operator, defaultValue) {
+ return function(value, other) {
+ var result;
+ if (value === undefined && other === undefined) {
+ return defaultValue;
+ }
+ if (value !== undefined) {
+ result = value;
+ }
+ if (other !== undefined) {
+ if (result === undefined) {
+ return other;
+ }
+ if (typeof value == 'string' || typeof other == 'string') {
+ value = baseToString(value);
+ other = baseToString(other);
+ } else {
+ value = baseToNumber(value);
+ other = baseToNumber(other);
+ }
+ result = operator(value, other);
+ }
+ return result;
+ };
+}
+
+module.exports = createMathOperation;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createOver.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createOver.js
new file mode 100644
index 0000000..3b94551
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createOver.js
@@ -0,0 +1,27 @@
+var apply = require('./_apply'),
+ arrayMap = require('./_arrayMap'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ baseUnary = require('./_baseUnary'),
+ flatRest = require('./_flatRest');
+
+/**
+ * Creates a function like `_.over`.
+ *
+ * @private
+ * @param {Function} arrayFunc The function to iterate over iteratees.
+ * @returns {Function} Returns the new over function.
+ */
+function createOver(arrayFunc) {
+ return flatRest(function(iteratees) {
+ iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
+ return baseRest(function(args) {
+ var thisArg = this;
+ return arrayFunc(iteratees, function(iteratee) {
+ return apply(iteratee, thisArg, args);
+ });
+ });
+ });
+}
+
+module.exports = createOver;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPadding.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPadding.js
new file mode 100644
index 0000000..2124612
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPadding.js
@@ -0,0 +1,33 @@
+var baseRepeat = require('./_baseRepeat'),
+ baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ hasUnicode = require('./_hasUnicode'),
+ stringSize = require('./_stringSize'),
+ stringToArray = require('./_stringToArray');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil;
+
+/**
+ * Creates the padding for `string` based on `length`. The `chars` string
+ * is truncated if the number of characters exceeds `length`.
+ *
+ * @private
+ * @param {number} length The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padding for `string`.
+ */
+function createPadding(length, chars) {
+ chars = chars === undefined ? ' ' : baseToString(chars);
+
+ var charsLength = chars.length;
+ if (charsLength < 2) {
+ return charsLength ? baseRepeat(chars, length) : chars;
+ }
+ var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
+ return hasUnicode(chars)
+ ? castSlice(stringToArray(result), 0, length).join('')
+ : result.slice(0, length);
+}
+
+module.exports = createPadding;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPartial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPartial.js
new file mode 100644
index 0000000..e16c248
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createPartial.js
@@ -0,0 +1,43 @@
+var apply = require('./_apply'),
+ createCtor = require('./_createCtor'),
+ root = require('./_root');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1;
+
+/**
+ * Creates a function that wraps `func` to invoke it with the `this` binding
+ * of `thisArg` and `partials` prepended to the arguments it receives.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} partials The arguments to prepend to those provided to
+ * the new function.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createPartial(func, bitmask, thisArg, partials) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
+
+ function wrapper() {
+ var argsIndex = -1,
+ argsLength = arguments.length,
+ leftIndex = -1,
+ leftLength = partials.length,
+ args = Array(leftLength + argsLength),
+ fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+
+ while (++leftIndex < leftLength) {
+ args[leftIndex] = partials[leftIndex];
+ }
+ while (argsLength--) {
+ args[leftIndex++] = arguments[++argsIndex];
+ }
+ return apply(fn, isBind ? thisArg : this, args);
+ }
+ return wrapper;
+}
+
+module.exports = createPartial;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRange.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRange.js
new file mode 100644
index 0000000..9f52c77
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRange.js
@@ -0,0 +1,30 @@
+var baseRange = require('./_baseRange'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toFinite = require('./toFinite');
+
+/**
+ * Creates a `_.range` or `_.rangeRight` function.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new range function.
+ */
+function createRange(fromRight) {
+ return function(start, end, step) {
+ if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
+ end = step = undefined;
+ }
+ // Ensure the sign of `-0` is preserved.
+ start = toFinite(start);
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ } else {
+ end = toFinite(end);
+ }
+ step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
+ return baseRange(start, end, step, fromRight);
+ };
+}
+
+module.exports = createRange;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRecurry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRecurry.js
new file mode 100644
index 0000000..eb29fb2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRecurry.js
@@ -0,0 +1,56 @@
+var isLaziable = require('./_isLaziable'),
+ setData = require('./_setData'),
+ setWrapToString = require('./_setWrapToString');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_BOUND_FLAG = 4,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_PARTIAL_RIGHT_FLAG = 64;
+
+/**
+ * Creates a function that wraps `func` to continue currying.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {Function} wrapFunc The function to create the `func` wrapper.
+ * @param {*} placeholder The placeholder value.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to prepend to those provided to
+ * the new function.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
+ var isCurry = bitmask & WRAP_CURRY_FLAG,
+ newHolders = isCurry ? holders : undefined,
+ newHoldersRight = isCurry ? undefined : holders,
+ newPartials = isCurry ? partials : undefined,
+ newPartialsRight = isCurry ? undefined : partials;
+
+ bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
+ bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
+
+ if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
+ bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
+ }
+ var newData = [
+ func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
+ newHoldersRight, argPos, ary, arity
+ ];
+
+ var result = wrapFunc.apply(undefined, newData);
+ if (isLaziable(func)) {
+ setData(result, newData);
+ }
+ result.placeholder = placeholder;
+ return setWrapToString(result, func, bitmask);
+}
+
+module.exports = createRecurry;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRelationalOperation.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRelationalOperation.js
new file mode 100644
index 0000000..a17c6b5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRelationalOperation.js
@@ -0,0 +1,20 @@
+var toNumber = require('./toNumber');
+
+/**
+ * Creates a function that performs a relational operation on two values.
+ *
+ * @private
+ * @param {Function} operator The function to perform the operation.
+ * @returns {Function} Returns the new relational operation function.
+ */
+function createRelationalOperation(operator) {
+ return function(value, other) {
+ if (!(typeof value == 'string' && typeof other == 'string')) {
+ value = toNumber(value);
+ other = toNumber(other);
+ }
+ return operator(value, other);
+ };
+}
+
+module.exports = createRelationalOperation;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRound.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRound.js
new file mode 100644
index 0000000..74b20d4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createRound.js
@@ -0,0 +1,33 @@
+var toInteger = require('./toInteger'),
+ toNumber = require('./toNumber'),
+ toString = require('./toString');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Creates a function like `_.round`.
+ *
+ * @private
+ * @param {string} methodName The name of the `Math` method to use when rounding.
+ * @returns {Function} Returns the new round function.
+ */
+function createRound(methodName) {
+ var func = Math[methodName];
+ return function(number, precision) {
+ number = toNumber(number);
+ precision = nativeMin(toInteger(precision), 292);
+ if (precision) {
+ // Shift with exponential notation to avoid floating-point issues.
+ // See [MDN](https://mdn.io/round#Examples) for more details.
+ var pair = (toString(number) + 'e').split('e'),
+ value = func(pair[0] + 'e' + (+pair[1] + precision));
+
+ pair = (toString(value) + 'e').split('e');
+ return +(pair[0] + 'e' + (+pair[1] - precision));
+ }
+ return func(number);
+ };
+}
+
+module.exports = createRound;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createSet.js
new file mode 100644
index 0000000..0f644ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createSet.js
@@ -0,0 +1,19 @@
+var Set = require('./_Set'),
+ noop = require('./noop'),
+ setToArray = require('./_setToArray');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * Creates a set object of `values`.
+ *
+ * @private
+ * @param {Array} values The values to add to the set.
+ * @returns {Object} Returns the new set.
+ */
+var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
+ return new Set(values);
+};
+
+module.exports = createSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createToPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createToPairs.js
new file mode 100644
index 0000000..568417a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createToPairs.js
@@ -0,0 +1,30 @@
+var baseToPairs = require('./_baseToPairs'),
+ getTag = require('./_getTag'),
+ mapToArray = require('./_mapToArray'),
+ setToPairs = require('./_setToPairs');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ setTag = '[object Set]';
+
+/**
+ * Creates a `_.toPairs` or `_.toPairsIn` function.
+ *
+ * @private
+ * @param {Function} keysFunc The function to get the keys of a given object.
+ * @returns {Function} Returns the new pairs function.
+ */
+function createToPairs(keysFunc) {
+ return function(object) {
+ var tag = getTag(object);
+ if (tag == mapTag) {
+ return mapToArray(object);
+ }
+ if (tag == setTag) {
+ return setToPairs(object);
+ }
+ return baseToPairs(object, keysFunc(object));
+ };
+}
+
+module.exports = createToPairs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createWrap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createWrap.js
new file mode 100644
index 0000000..f14b968
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_createWrap.js
@@ -0,0 +1,106 @@
+var baseSetData = require('./_baseSetData'),
+ createBind = require('./_createBind'),
+ createCurry = require('./_createCurry'),
+ createHybrid = require('./_createHybrid'),
+ createPartial = require('./_createPartial'),
+ getData = require('./_getData'),
+ mergeData = require('./_mergeData'),
+ setData = require('./_setData'),
+ setWrapToString = require('./_setWrapToString'),
+ toInteger = require('./toInteger');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_CURRY_RIGHT_FLAG = 16,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_PARTIAL_RIGHT_FLAG = 64;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * Creates a function that either curries or invokes `func` with optional
+ * `this` binding and partially applied arguments.
+ *
+ * @private
+ * @param {Function|string} func The function or method name to wrap.
+ * @param {number} bitmask The bitmask flags.
+ * 1 - `_.bind`
+ * 2 - `_.bindKey`
+ * 4 - `_.curry` or `_.curryRight` of a bound function
+ * 8 - `_.curry`
+ * 16 - `_.curryRight`
+ * 32 - `_.partial`
+ * 64 - `_.partialRight`
+ * 128 - `_.rearg`
+ * 256 - `_.ary`
+ * 512 - `_.flip`
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to be partially applied.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
+ var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
+ if (!isBindKey && typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var length = partials ? partials.length : 0;
+ if (!length) {
+ bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
+ partials = holders = undefined;
+ }
+ ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
+ arity = arity === undefined ? arity : toInteger(arity);
+ length -= holders ? holders.length : 0;
+
+ if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
+ var partialsRight = partials,
+ holdersRight = holders;
+
+ partials = holders = undefined;
+ }
+ var data = isBindKey ? undefined : getData(func);
+
+ var newData = [
+ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
+ argPos, ary, arity
+ ];
+
+ if (data) {
+ mergeData(newData, data);
+ }
+ func = newData[0];
+ bitmask = newData[1];
+ thisArg = newData[2];
+ partials = newData[3];
+ holders = newData[4];
+ arity = newData[9] = newData[9] == null
+ ? (isBindKey ? 0 : func.length)
+ : nativeMax(newData[9] - length, 0);
+
+ if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
+ bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
+ }
+ if (!bitmask || bitmask == WRAP_BIND_FLAG) {
+ var result = createBind(func, bitmask, thisArg);
+ } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
+ result = createCurry(func, bitmask, arity);
+ } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
+ result = createPartial(func, bitmask, thisArg, partials);
+ } else {
+ result = createHybrid.apply(undefined, newData);
+ }
+ var setter = data ? baseSetData : setData;
+ return setWrapToString(setter(result, newData), func, bitmask);
+}
+
+module.exports = createWrap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_deburrLetter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_deburrLetter.js
new file mode 100644
index 0000000..3e531ed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_deburrLetter.js
@@ -0,0 +1,71 @@
+var basePropertyOf = require('./_basePropertyOf');
+
+/** Used to map Latin Unicode letters to basic Latin letters. */
+var deburredLetters = {
+ // Latin-1 Supplement block.
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
+ '\xc7': 'C', '\xe7': 'c',
+ '\xd0': 'D', '\xf0': 'd',
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
+ '\xd1': 'N', '\xf1': 'n',
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
+ '\xc6': 'Ae', '\xe6': 'ae',
+ '\xde': 'Th', '\xfe': 'th',
+ '\xdf': 'ss',
+ // Latin Extended-A block.
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
+ '\u0134': 'J', '\u0135': 'j',
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
+ '\u0174': 'W', '\u0175': 'w',
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
+ '\u0132': 'IJ', '\u0133': 'ij',
+ '\u0152': 'Oe', '\u0153': 'oe',
+ '\u0149': "'n", '\u017f': 's'
+};
+
+/**
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
+ * letters to basic Latin letters.
+ *
+ * @private
+ * @param {string} letter The matched letter to deburr.
+ * @returns {string} Returns the deburred letter.
+ */
+var deburrLetter = basePropertyOf(deburredLetters);
+
+module.exports = deburrLetter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_defineProperty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_defineProperty.js
new file mode 100644
index 0000000..b6116d9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_defineProperty.js
@@ -0,0 +1,11 @@
+var getNative = require('./_getNative');
+
+var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+}());
+
+module.exports = defineProperty;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalArrays.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalArrays.js
new file mode 100644
index 0000000..f6a3b7c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalArrays.js
@@ -0,0 +1,83 @@
+var SetCache = require('./_SetCache'),
+ arraySome = require('./_arraySome'),
+ cacheHas = require('./_cacheHas');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Array} array The array to compare.
+ * @param {Array} other The other array to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
+ */
+function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ arrLength = array.length,
+ othLength = other.length;
+
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(array);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var index = -1,
+ result = true,
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
+
+ stack.set(array, other);
+ stack.set(other, array);
+
+ // Ignore non-index properties.
+ while (++index < arrLength) {
+ var arrValue = array[index],
+ othValue = other[index];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, arrValue, index, other, array, stack)
+ : customizer(arrValue, othValue, index, array, other, stack);
+ }
+ if (compared !== undefined) {
+ if (compared) {
+ continue;
+ }
+ result = false;
+ break;
+ }
+ // Recursively compare arrays (susceptible to call stack limits).
+ if (seen) {
+ if (!arraySome(other, function(othValue, othIndex) {
+ if (!cacheHas(seen, othIndex) &&
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
+ return seen.push(othIndex);
+ }
+ })) {
+ result = false;
+ break;
+ }
+ } else if (!(
+ arrValue === othValue ||
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
+ )) {
+ result = false;
+ break;
+ }
+ }
+ stack['delete'](array);
+ stack['delete'](other);
+ return result;
+}
+
+module.exports = equalArrays;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalByTag.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalByTag.js
new file mode 100644
index 0000000..71919e8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalByTag.js
@@ -0,0 +1,112 @@
+var Symbol = require('./_Symbol'),
+ Uint8Array = require('./_Uint8Array'),
+ eq = require('./eq'),
+ equalArrays = require('./_equalArrays'),
+ mapToArray = require('./_mapToArray'),
+ setToArray = require('./_setToArray');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+/** `Object#toString` result references. */
+var boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ symbolTag = '[object Symbol]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]';
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
+ * the same `toStringTag`.
+ *
+ * **Note:** This function only supports comparing values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {string} tag The `toStringTag` of the objects to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
+ switch (tag) {
+ case dataViewTag:
+ if ((object.byteLength != other.byteLength) ||
+ (object.byteOffset != other.byteOffset)) {
+ return false;
+ }
+ object = object.buffer;
+ other = other.buffer;
+
+ case arrayBufferTag:
+ if ((object.byteLength != other.byteLength) ||
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
+ return false;
+ }
+ return true;
+
+ case boolTag:
+ case dateTag:
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
+
+ case errorTag:
+ return object.name == other.name && object.message == other.message;
+
+ case regexpTag:
+ case stringTag:
+ // Coerce regexes to strings and treat strings, primitives and objects,
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
+ // for more details.
+ return object == (other + '');
+
+ case mapTag:
+ var convert = mapToArray;
+
+ case setTag:
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
+ convert || (convert = setToArray);
+
+ if (object.size != other.size && !isPartial) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked) {
+ return stacked == other;
+ }
+ bitmask |= COMPARE_UNORDERED_FLAG;
+
+ // Recursively compare objects (susceptible to call stack limits).
+ stack.set(object, other);
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
+ stack['delete'](object);
+ return result;
+
+ case symbolTag:
+ if (symbolValueOf) {
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
+ }
+ }
+ return false;
+}
+
+module.exports = equalByTag;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalObjects.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalObjects.js
new file mode 100644
index 0000000..7044ae9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_equalObjects.js
@@ -0,0 +1,89 @@
+var keys = require('./keys');
+
+/** Used to compose bitmasks for value comparisons. */
+var COMPARE_PARTIAL_FLAG = 1;
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * A specialized version of `baseIsEqualDeep` for objects with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ objProps = keys(object),
+ objLength = objProps.length,
+ othProps = keys(other),
+ othLength = othProps.length;
+
+ if (objLength != othLength && !isPartial) {
+ return false;
+ }
+ var index = objLength;
+ while (index--) {
+ var key = objProps[index];
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
+ return false;
+ }
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var result = true;
+ stack.set(object, other);
+ stack.set(other, object);
+
+ var skipCtor = isPartial;
+ while (++index < objLength) {
+ key = objProps[index];
+ var objValue = object[key],
+ othValue = other[key];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, objValue, key, other, object, stack)
+ : customizer(objValue, othValue, key, object, other, stack);
+ }
+ // Recursively compare objects (susceptible to call stack limits).
+ if (!(compared === undefined
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
+ : compared
+ )) {
+ result = false;
+ break;
+ }
+ skipCtor || (skipCtor = key == 'constructor');
+ }
+ if (result && !skipCtor) {
+ var objCtor = object.constructor,
+ othCtor = other.constructor;
+
+ // Non `Object` object instances with different constructors are not equal.
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ result = false;
+ }
+ }
+ stack['delete'](object);
+ stack['delete'](other);
+ return result;
+}
+
+module.exports = equalObjects;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeHtmlChar.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeHtmlChar.js
new file mode 100644
index 0000000..7ca68ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeHtmlChar.js
@@ -0,0 +1,21 @@
+var basePropertyOf = require('./_basePropertyOf');
+
+/** Used to map characters to HTML entities. */
+var htmlEscapes = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#39;'
+};
+
+/**
+ * Used by `_.escape` to convert characters to HTML entities.
+ *
+ * @private
+ * @param {string} chr The matched character to escape.
+ * @returns {string} Returns the escaped character.
+ */
+var escapeHtmlChar = basePropertyOf(htmlEscapes);
+
+module.exports = escapeHtmlChar;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeStringChar.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeStringChar.js
new file mode 100644
index 0000000..44eca96
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_escapeStringChar.js
@@ -0,0 +1,22 @@
+/** Used to escape characters for inclusion in compiled string literals. */
+var stringEscapes = {
+ '\\': '\\',
+ "'": "'",
+ '\n': 'n',
+ '\r': 'r',
+ '\u2028': 'u2028',
+ '\u2029': 'u2029'
+};
+
+/**
+ * Used by `_.template` to escape characters for inclusion in compiled string literals.
+ *
+ * @private
+ * @param {string} chr The matched character to escape.
+ * @returns {string} Returns the escaped character.
+ */
+function escapeStringChar(chr) {
+ return '\\' + stringEscapes[chr];
+}
+
+module.exports = escapeStringChar;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_flatRest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_flatRest.js
new file mode 100644
index 0000000..94ab6cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_flatRest.js
@@ -0,0 +1,16 @@
+var flatten = require('./flatten'),
+ overRest = require('./_overRest'),
+ setToString = require('./_setToString');
+
+/**
+ * A specialized version of `baseRest` which flattens the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+function flatRest(func) {
+ return setToString(overRest(func, undefined, flatten), func + '');
+}
+
+module.exports = flatRest;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_freeGlobal.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_freeGlobal.js
new file mode 100644
index 0000000..bbec998
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_freeGlobal.js
@@ -0,0 +1,4 @@
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+module.exports = freeGlobal;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeys.js
new file mode 100644
index 0000000..a9ce699
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeys.js
@@ -0,0 +1,16 @@
+var baseGetAllKeys = require('./_baseGetAllKeys'),
+ getSymbols = require('./_getSymbols'),
+ keys = require('./keys');
+
+/**
+ * Creates an array of own enumerable property names and symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+function getAllKeys(object) {
+ return baseGetAllKeys(object, keys, getSymbols);
+}
+
+module.exports = getAllKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeysIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeysIn.js
new file mode 100644
index 0000000..1b46678
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getAllKeysIn.js
@@ -0,0 +1,17 @@
+var baseGetAllKeys = require('./_baseGetAllKeys'),
+ getSymbolsIn = require('./_getSymbolsIn'),
+ keysIn = require('./keysIn');
+
+/**
+ * Creates an array of own and inherited enumerable property names and
+ * symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+function getAllKeysIn(object) {
+ return baseGetAllKeys(object, keysIn, getSymbolsIn);
+}
+
+module.exports = getAllKeysIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getData.js
new file mode 100644
index 0000000..a1fe7b7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getData.js
@@ -0,0 +1,15 @@
+var metaMap = require('./_metaMap'),
+ noop = require('./noop');
+
+/**
+ * Gets metadata for `func`.
+ *
+ * @private
+ * @param {Function} func The function to query.
+ * @returns {*} Returns the metadata for `func`.
+ */
+var getData = !metaMap ? noop : function(func) {
+ return metaMap.get(func);
+};
+
+module.exports = getData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getFuncName.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getFuncName.js
new file mode 100644
index 0000000..21e15b3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getFuncName.js
@@ -0,0 +1,31 @@
+var realNames = require('./_realNames');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Gets the name of `func`.
+ *
+ * @private
+ * @param {Function} func The function to query.
+ * @returns {string} Returns the function name.
+ */
+function getFuncName(func) {
+ var result = (func.name + ''),
+ array = realNames[result],
+ length = hasOwnProperty.call(realNames, result) ? array.length : 0;
+
+ while (length--) {
+ var data = array[length],
+ otherFunc = data.func;
+ if (otherFunc == null || otherFunc == func) {
+ return data.name;
+ }
+ }
+ return result;
+}
+
+module.exports = getFuncName;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getHolder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getHolder.js
new file mode 100644
index 0000000..65e94b5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getHolder.js
@@ -0,0 +1,13 @@
+/**
+ * Gets the argument placeholder value for `func`.
+ *
+ * @private
+ * @param {Function} func The function to inspect.
+ * @returns {*} Returns the placeholder value.
+ */
+function getHolder(func) {
+ var object = func;
+ return object.placeholder;
+}
+
+module.exports = getHolder;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMapData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMapData.js
new file mode 100644
index 0000000..17f6303
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMapData.js
@@ -0,0 +1,18 @@
+var isKeyable = require('./_isKeyable');
+
+/**
+ * Gets the data for `map`.
+ *
+ * @private
+ * @param {Object} map The map to query.
+ * @param {string} key The reference key.
+ * @returns {*} Returns the map data.
+ */
+function getMapData(map, key) {
+ var data = map.__data__;
+ return isKeyable(key)
+ ? data[typeof key == 'string' ? 'string' : 'hash']
+ : data.map;
+}
+
+module.exports = getMapData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMatchData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMatchData.js
new file mode 100644
index 0000000..2cc70f9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getMatchData.js
@@ -0,0 +1,24 @@
+var isStrictComparable = require('./_isStrictComparable'),
+ keys = require('./keys');
+
+/**
+ * Gets the property names, values, and compare flags of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the match data of `object`.
+ */
+function getMatchData(object) {
+ var result = keys(object),
+ length = result.length;
+
+ while (length--) {
+ var key = result[length],
+ value = object[key];
+
+ result[length] = [key, value, isStrictComparable(value)];
+ }
+ return result;
+}
+
+module.exports = getMatchData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getNative.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getNative.js
new file mode 100644
index 0000000..97a622b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getNative.js
@@ -0,0 +1,17 @@
+var baseIsNative = require('./_baseIsNative'),
+ getValue = require('./_getValue');
+
+/**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+}
+
+module.exports = getNative;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getPrototype.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getPrototype.js
new file mode 100644
index 0000000..e808612
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getPrototype.js
@@ -0,0 +1,6 @@
+var overArg = require('./_overArg');
+
+/** Built-in value references. */
+var getPrototype = overArg(Object.getPrototypeOf, Object);
+
+module.exports = getPrototype;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getRawTag.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getRawTag.js
new file mode 100644
index 0000000..49a95c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getRawTag.js
@@ -0,0 +1,46 @@
+var Symbol = require('./_Symbol');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+/**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
+ }
+ return result;
+}
+
+module.exports = getRawTag;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbols.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbols.js
new file mode 100644
index 0000000..b53c127
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbols.js
@@ -0,0 +1,16 @@
+var overArg = require('./_overArg'),
+ stubArray = require('./stubArray');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeGetSymbols = Object.getOwnPropertySymbols;
+
+/**
+ * Creates an array of the own enumerable symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of symbols.
+ */
+var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
+
+module.exports = getSymbols;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbolsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbolsIn.js
new file mode 100644
index 0000000..cec0855
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getSymbolsIn.js
@@ -0,0 +1,25 @@
+var arrayPush = require('./_arrayPush'),
+ getPrototype = require('./_getPrototype'),
+ getSymbols = require('./_getSymbols'),
+ stubArray = require('./stubArray');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeGetSymbols = Object.getOwnPropertySymbols;
+
+/**
+ * Creates an array of the own and inherited enumerable symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of symbols.
+ */
+var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
+ var result = [];
+ while (object) {
+ arrayPush(result, getSymbols(object));
+ object = getPrototype(object);
+ }
+ return result;
+};
+
+module.exports = getSymbolsIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getTag.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getTag.js
new file mode 100644
index 0000000..deaf89d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getTag.js
@@ -0,0 +1,58 @@
+var DataView = require('./_DataView'),
+ Map = require('./_Map'),
+ Promise = require('./_Promise'),
+ Set = require('./_Set'),
+ WeakMap = require('./_WeakMap'),
+ baseGetTag = require('./_baseGetTag'),
+ toSource = require('./_toSource');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ objectTag = '[object Object]',
+ promiseTag = '[object Promise]',
+ setTag = '[object Set]',
+ weakMapTag = '[object WeakMap]';
+
+var dataViewTag = '[object DataView]';
+
+/** Used to detect maps, sets, and weakmaps. */
+var dataViewCtorString = toSource(DataView),
+ mapCtorString = toSource(Map),
+ promiseCtorString = toSource(Promise),
+ setCtorString = toSource(Set),
+ weakMapCtorString = toSource(WeakMap);
+
+/**
+ * Gets the `toStringTag` of `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+var getTag = baseGetTag;
+
+// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
+if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
+ (Map && getTag(new Map) != mapTag) ||
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
+ (Set && getTag(new Set) != setTag) ||
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
+ getTag = function(value) {
+ var result = baseGetTag(value),
+ Ctor = result == objectTag ? value.constructor : undefined,
+ ctorString = Ctor ? toSource(Ctor) : '';
+
+ if (ctorString) {
+ switch (ctorString) {
+ case dataViewCtorString: return dataViewTag;
+ case mapCtorString: return mapTag;
+ case promiseCtorString: return promiseTag;
+ case setCtorString: return setTag;
+ case weakMapCtorString: return weakMapTag;
+ }
+ }
+ return result;
+ };
+}
+
+module.exports = getTag;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getValue.js
new file mode 100644
index 0000000..5f7d773
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getValue.js
@@ -0,0 +1,13 @@
+/**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+function getValue(object, key) {
+ return object == null ? undefined : object[key];
+}
+
+module.exports = getValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getView.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getView.js
new file mode 100644
index 0000000..df1e5d4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getView.js
@@ -0,0 +1,33 @@
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+/**
+ * Gets the view, applying any `transforms` to the `start` and `end` positions.
+ *
+ * @private
+ * @param {number} start The start of the view.
+ * @param {number} end The end of the view.
+ * @param {Array} transforms The transformations to apply to the view.
+ * @returns {Object} Returns an object containing the `start` and `end`
+ * positions of the view.
+ */
+function getView(start, end, transforms) {
+ var index = -1,
+ length = transforms.length;
+
+ while (++index < length) {
+ var data = transforms[index],
+ size = data.size;
+
+ switch (data.type) {
+ case 'drop': start += size; break;
+ case 'dropRight': end -= size; break;
+ case 'take': end = nativeMin(end, start + size); break;
+ case 'takeRight': start = nativeMax(start, end - size); break;
+ }
+ }
+ return { 'start': start, 'end': end };
+}
+
+module.exports = getView;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getWrapDetails.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getWrapDetails.js
new file mode 100644
index 0000000..3bcc6e4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_getWrapDetails.js
@@ -0,0 +1,17 @@
+/** Used to match wrap detail comments. */
+var reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
+ reSplitDetails = /,? & /;
+
+/**
+ * Extracts wrapper details from the `source` body comment.
+ *
+ * @private
+ * @param {string} source The source to inspect.
+ * @returns {Array} Returns the wrapper details.
+ */
+function getWrapDetails(source) {
+ var match = source.match(reWrapDetails);
+ return match ? match[1].split(reSplitDetails) : [];
+}
+
+module.exports = getWrapDetails;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasPath.js
new file mode 100644
index 0000000..93dbde1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasPath.js
@@ -0,0 +1,39 @@
+var castPath = require('./_castPath'),
+ isArguments = require('./isArguments'),
+ isArray = require('./isArray'),
+ isIndex = require('./_isIndex'),
+ isLength = require('./isLength'),
+ toKey = require('./_toKey');
+
+/**
+ * Checks if `path` exists on `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @param {Function} hasFunc The function to check properties.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ */
+function hasPath(object, path, hasFunc) {
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length,
+ result = false;
+
+ while (++index < length) {
+ var key = toKey(path[index]);
+ if (!(result = object != null && hasFunc(object, key))) {
+ break;
+ }
+ object = object[key];
+ }
+ if (result || ++index != length) {
+ return result;
+ }
+ length = object == null ? 0 : object.length;
+ return !!length && isLength(length) && isIndex(key, length) &&
+ (isArray(object) || isArguments(object));
+}
+
+module.exports = hasPath;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicode.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicode.js
new file mode 100644
index 0000000..cb6ca15
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicode.js
@@ -0,0 +1,26 @@
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
+ rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsZWJ = '\\u200d';
+
+/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
+var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
+
+/**
+ * Checks if `string` contains Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
+ */
+function hasUnicode(string) {
+ return reHasUnicode.test(string);
+}
+
+module.exports = hasUnicode;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicodeWord.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicodeWord.js
new file mode 100644
index 0000000..a35d6e5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hasUnicodeWord.js
@@ -0,0 +1,15 @@
+/** Used to detect strings that need a more robust regexp to match words. */
+var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
+
+/**
+ * Checks if `string` contains a word composed of Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
+ */
+function hasUnicodeWord(string) {
+ return reHasUnicodeWord.test(string);
+}
+
+module.exports = hasUnicodeWord;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashClear.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashClear.js
new file mode 100644
index 0000000..5d4b70c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashClear.js
@@ -0,0 +1,15 @@
+var nativeCreate = require('./_nativeCreate');
+
+/**
+ * Removes all key-value entries from the hash.
+ *
+ * @private
+ * @name clear
+ * @memberOf Hash
+ */
+function hashClear() {
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
+ this.size = 0;
+}
+
+module.exports = hashClear;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashDelete.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashDelete.js
new file mode 100644
index 0000000..ea9dabf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashDelete.js
@@ -0,0 +1,17 @@
+/**
+ * Removes `key` and its value from the hash.
+ *
+ * @private
+ * @name delete
+ * @memberOf Hash
+ * @param {Object} hash The hash to modify.
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function hashDelete(key) {
+ var result = this.has(key) && delete this.__data__[key];
+ this.size -= result ? 1 : 0;
+ return result;
+}
+
+module.exports = hashDelete;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashGet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashGet.js
new file mode 100644
index 0000000..1fc2f34
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashGet.js
@@ -0,0 +1,30 @@
+var nativeCreate = require('./_nativeCreate');
+
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Gets the hash value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Hash
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function hashGet(key) {
+ var data = this.__data__;
+ if (nativeCreate) {
+ var result = data[key];
+ return result === HASH_UNDEFINED ? undefined : result;
+ }
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
+}
+
+module.exports = hashGet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashHas.js
new file mode 100644
index 0000000..f30aac3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashHas.js
@@ -0,0 +1,23 @@
+var nativeCreate = require('./_nativeCreate');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Checks if a hash value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Hash
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function hashHas(key) {
+ var data = this.__data__;
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
+}
+
+module.exports = hashHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashSet.js
new file mode 100644
index 0000000..e105528
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_hashSet.js
@@ -0,0 +1,23 @@
+var nativeCreate = require('./_nativeCreate');
+
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/**
+ * Sets the hash `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Hash
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the hash instance.
+ */
+function hashSet(key, value) {
+ var data = this.__data__;
+ this.size += this.has(key) ? 0 : 1;
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
+ return this;
+}
+
+module.exports = hashSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneArray.js
new file mode 100644
index 0000000..aef0212
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneArray.js
@@ -0,0 +1,26 @@
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Initializes an array clone.
+ *
+ * @private
+ * @param {Array} array The array to clone.
+ * @returns {Array} Returns the initialized clone.
+ */
+function initCloneArray(array) {
+ var length = array.length,
+ result = array.constructor(length);
+
+ // Add properties assigned by `RegExp#exec`.
+ if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
+ result.index = array.index;
+ result.input = array.input;
+ }
+ return result;
+}
+
+module.exports = initCloneArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneByTag.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneByTag.js
new file mode 100644
index 0000000..e7b77ed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneByTag.js
@@ -0,0 +1,80 @@
+var cloneArrayBuffer = require('./_cloneArrayBuffer'),
+ cloneDataView = require('./_cloneDataView'),
+ cloneMap = require('./_cloneMap'),
+ cloneRegExp = require('./_cloneRegExp'),
+ cloneSet = require('./_cloneSet'),
+ cloneSymbol = require('./_cloneSymbol'),
+ cloneTypedArray = require('./_cloneTypedArray');
+
+/** `Object#toString` result references. */
+var boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ symbolTag = '[object Symbol]';
+
+var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+/**
+ * Initializes an object clone based on its `toStringTag`.
+ *
+ * **Note:** This function only supports cloning values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @param {string} tag The `toStringTag` of the object to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the initialized clone.
+ */
+function initCloneByTag(object, tag, cloneFunc, isDeep) {
+ var Ctor = object.constructor;
+ switch (tag) {
+ case arrayBufferTag:
+ return cloneArrayBuffer(object);
+
+ case boolTag:
+ case dateTag:
+ return new Ctor(+object);
+
+ case dataViewTag:
+ return cloneDataView(object, isDeep);
+
+ case float32Tag: case float64Tag:
+ case int8Tag: case int16Tag: case int32Tag:
+ case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
+ return cloneTypedArray(object, isDeep);
+
+ case mapTag:
+ return cloneMap(object, isDeep, cloneFunc);
+
+ case numberTag:
+ case stringTag:
+ return new Ctor(object);
+
+ case regexpTag:
+ return cloneRegExp(object);
+
+ case setTag:
+ return cloneSet(object, isDeep, cloneFunc);
+
+ case symbolTag:
+ return cloneSymbol(object);
+ }
+}
+
+module.exports = initCloneByTag;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneObject.js
new file mode 100644
index 0000000..5a13e64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_initCloneObject.js
@@ -0,0 +1,18 @@
+var baseCreate = require('./_baseCreate'),
+ getPrototype = require('./_getPrototype'),
+ isPrototype = require('./_isPrototype');
+
+/**
+ * Initializes an object clone.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @returns {Object} Returns the initialized clone.
+ */
+function initCloneObject(object) {
+ return (typeof object.constructor == 'function' && !isPrototype(object))
+ ? baseCreate(getPrototype(object))
+ : {};
+}
+
+module.exports = initCloneObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_insertWrapDetails.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_insertWrapDetails.js
new file mode 100644
index 0000000..e790808
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_insertWrapDetails.js
@@ -0,0 +1,23 @@
+/** Used to match wrap detail comments. */
+var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
+
+/**
+ * Inserts wrapper `details` in a comment at the top of the `source` body.
+ *
+ * @private
+ * @param {string} source The source to modify.
+ * @returns {Array} details The details to insert.
+ * @returns {string} Returns the modified source.
+ */
+function insertWrapDetails(source, details) {
+ var length = details.length;
+ if (!length) {
+ return source;
+ }
+ var lastIndex = length - 1;
+ details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
+ details = details.join(length > 2 ? ', ' : ' ');
+ return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
+}
+
+module.exports = insertWrapDetails;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isFlattenable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isFlattenable.js
new file mode 100644
index 0000000..4cc2c24
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isFlattenable.js
@@ -0,0 +1,20 @@
+var Symbol = require('./_Symbol'),
+ isArguments = require('./isArguments'),
+ isArray = require('./isArray');
+
+/** Built-in value references. */
+var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
+
+/**
+ * Checks if `value` is a flattenable `arguments` object or array.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
+ */
+function isFlattenable(value) {
+ return isArray(value) || isArguments(value) ||
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
+}
+
+module.exports = isFlattenable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIndex.js
new file mode 100644
index 0000000..e123dde
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIndex.js
@@ -0,0 +1,22 @@
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+module.exports = isIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIterateeCall.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIterateeCall.js
new file mode 100644
index 0000000..a0bb5a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isIterateeCall.js
@@ -0,0 +1,30 @@
+var eq = require('./eq'),
+ isArrayLike = require('./isArrayLike'),
+ isIndex = require('./_isIndex'),
+ isObject = require('./isObject');
+
+/**
+ * Checks if the given arguments are from an iteratee call.
+ *
+ * @private
+ * @param {*} value The potential iteratee value argument.
+ * @param {*} index The potential iteratee index or key argument.
+ * @param {*} object The potential iteratee object argument.
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
+ * else `false`.
+ */
+function isIterateeCall(value, index, object) {
+ if (!isObject(object)) {
+ return false;
+ }
+ var type = typeof index;
+ if (type == 'number'
+ ? (isArrayLike(object) && isIndex(index, object.length))
+ : (type == 'string' && index in object)
+ ) {
+ return eq(object[index], value);
+ }
+ return false;
+}
+
+module.exports = isIterateeCall;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKey.js
new file mode 100644
index 0000000..ff08b06
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKey.js
@@ -0,0 +1,29 @@
+var isArray = require('./isArray'),
+ isSymbol = require('./isSymbol');
+
+/** Used to match property names within property paths. */
+var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
+ reIsPlainProp = /^\w*$/;
+
+/**
+ * Checks if `value` is a property name and not a property path.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
+ */
+function isKey(value, object) {
+ if (isArray(value)) {
+ return false;
+ }
+ var type = typeof value;
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
+ value == null || isSymbol(value)) {
+ return true;
+ }
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
+ (object != null && value in Object(object));
+}
+
+module.exports = isKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKeyable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKeyable.js
new file mode 100644
index 0000000..39f1828
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isKeyable.js
@@ -0,0 +1,15 @@
+/**
+ * Checks if `value` is suitable for use as unique object key.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
+ */
+function isKeyable(value) {
+ var type = typeof value;
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
+ ? (value !== '__proto__')
+ : (value === null);
+}
+
+module.exports = isKeyable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isLaziable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isLaziable.js
new file mode 100644
index 0000000..a57c4f2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isLaziable.js
@@ -0,0 +1,28 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ getData = require('./_getData'),
+ getFuncName = require('./_getFuncName'),
+ lodash = require('./wrapperLodash');
+
+/**
+ * Checks if `func` has a lazy counterpart.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
+ * else `false`.
+ */
+function isLaziable(func) {
+ var funcName = getFuncName(func),
+ other = lodash[funcName];
+
+ if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
+ return false;
+ }
+ if (func === other) {
+ return true;
+ }
+ var data = getData(other);
+ return !!data && func === data[0];
+}
+
+module.exports = isLaziable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMaskable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMaskable.js
new file mode 100644
index 0000000..eb98d09
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMaskable.js
@@ -0,0 +1,14 @@
+var coreJsData = require('./_coreJsData'),
+ isFunction = require('./isFunction'),
+ stubFalse = require('./stubFalse');
+
+/**
+ * Checks if `func` is capable of being masked.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
+ */
+var isMaskable = coreJsData ? isFunction : stubFalse;
+
+module.exports = isMaskable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMasked.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMasked.js
new file mode 100644
index 0000000..4b0f21b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isMasked.js
@@ -0,0 +1,20 @@
+var coreJsData = require('./_coreJsData');
+
+/** Used to detect methods masquerading as native. */
+var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+}());
+
+/**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+}
+
+module.exports = isMasked;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isPrototype.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isPrototype.js
new file mode 100644
index 0000000..0f29498
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isPrototype.js
@@ -0,0 +1,18 @@
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
+
+ return value === proto;
+}
+
+module.exports = isPrototype;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isStrictComparable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isStrictComparable.js
new file mode 100644
index 0000000..b59f40b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_isStrictComparable.js
@@ -0,0 +1,15 @@
+var isObject = require('./isObject');
+
+/**
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
+ * equality comparisons, else `false`.
+ */
+function isStrictComparable(value) {
+ return value === value && !isObject(value);
+}
+
+module.exports = isStrictComparable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_iteratorToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_iteratorToArray.js
new file mode 100644
index 0000000..4768566
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_iteratorToArray.js
@@ -0,0 +1,18 @@
+/**
+ * Converts `iterator` to an array.
+ *
+ * @private
+ * @param {Object} iterator The iterator to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function iteratorToArray(iterator) {
+ var data,
+ result = [];
+
+ while (!(data = iterator.next()).done) {
+ result.push(data.value);
+ }
+ return result;
+}
+
+module.exports = iteratorToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyClone.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyClone.js
new file mode 100644
index 0000000..d8a51f8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyClone.js
@@ -0,0 +1,23 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ copyArray = require('./_copyArray');
+
+/**
+ * Creates a clone of the lazy wrapper object.
+ *
+ * @private
+ * @name clone
+ * @memberOf LazyWrapper
+ * @returns {Object} Returns the cloned `LazyWrapper` object.
+ */
+function lazyClone() {
+ var result = new LazyWrapper(this.__wrapped__);
+ result.__actions__ = copyArray(this.__actions__);
+ result.__dir__ = this.__dir__;
+ result.__filtered__ = this.__filtered__;
+ result.__iteratees__ = copyArray(this.__iteratees__);
+ result.__takeCount__ = this.__takeCount__;
+ result.__views__ = copyArray(this.__views__);
+ return result;
+}
+
+module.exports = lazyClone;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyReverse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyReverse.js
new file mode 100644
index 0000000..c5b5219
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyReverse.js
@@ -0,0 +1,23 @@
+var LazyWrapper = require('./_LazyWrapper');
+
+/**
+ * Reverses the direction of lazy iteration.
+ *
+ * @private
+ * @name reverse
+ * @memberOf LazyWrapper
+ * @returns {Object} Returns the new reversed `LazyWrapper` object.
+ */
+function lazyReverse() {
+ if (this.__filtered__) {
+ var result = new LazyWrapper(this);
+ result.__dir__ = -1;
+ result.__filtered__ = true;
+ } else {
+ result = this.clone();
+ result.__dir__ *= -1;
+ }
+ return result;
+}
+
+module.exports = lazyReverse;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyValue.js
new file mode 100644
index 0000000..09bf14b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_lazyValue.js
@@ -0,0 +1,73 @@
+var baseWrapperValue = require('./_baseWrapperValue'),
+ getView = require('./_getView'),
+ isArray = require('./isArray');
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/** Used to indicate the type of lazy iteratees. */
+var LAZY_FILTER_FLAG = 1,
+ LAZY_MAP_FLAG = 2;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Extracts the unwrapped value from its lazy wrapper.
+ *
+ * @private
+ * @name value
+ * @memberOf LazyWrapper
+ * @returns {*} Returns the unwrapped value.
+ */
+function lazyValue() {
+ var array = this.__wrapped__.value(),
+ dir = this.__dir__,
+ isArr = isArray(array),
+ isRight = dir < 0,
+ arrLength = isArr ? array.length : 0,
+ view = getView(0, arrLength, this.__views__),
+ start = view.start,
+ end = view.end,
+ length = end - start,
+ index = isRight ? end : (start - 1),
+ iteratees = this.__iteratees__,
+ iterLength = iteratees.length,
+ resIndex = 0,
+ takeCount = nativeMin(length, this.__takeCount__);
+
+ if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
+ (arrLength == length && takeCount == length)) {
+ return baseWrapperValue(array, this.__actions__);
+ }
+ var result = [];
+
+ outer:
+ while (length-- && resIndex < takeCount) {
+ index += dir;
+
+ var iterIndex = -1,
+ value = array[index];
+
+ while (++iterIndex < iterLength) {
+ var data = iteratees[iterIndex],
+ iteratee = data.iteratee,
+ type = data.type,
+ computed = iteratee(value);
+
+ if (type == LAZY_MAP_FLAG) {
+ value = computed;
+ } else if (!computed) {
+ if (type == LAZY_FILTER_FLAG) {
+ continue outer;
+ } else {
+ break outer;
+ }
+ }
+ }
+ result[resIndex++] = value;
+ }
+ return result;
+}
+
+module.exports = lazyValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheClear.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheClear.js
new file mode 100644
index 0000000..acbe39a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheClear.js
@@ -0,0 +1,13 @@
+/**
+ * Removes all key-value entries from the list cache.
+ *
+ * @private
+ * @name clear
+ * @memberOf ListCache
+ */
+function listCacheClear() {
+ this.__data__ = [];
+ this.size = 0;
+}
+
+module.exports = listCacheClear;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheDelete.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheDelete.js
new file mode 100644
index 0000000..b1384ad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheDelete.js
@@ -0,0 +1,35 @@
+var assocIndexOf = require('./_assocIndexOf');
+
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/** Built-in value references. */
+var splice = arrayProto.splice;
+
+/**
+ * Removes `key` and its value from the list cache.
+ *
+ * @private
+ * @name delete
+ * @memberOf ListCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function listCacheDelete(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ return false;
+ }
+ var lastIndex = data.length - 1;
+ if (index == lastIndex) {
+ data.pop();
+ } else {
+ splice.call(data, index, 1);
+ }
+ --this.size;
+ return true;
+}
+
+module.exports = listCacheDelete;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheGet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheGet.js
new file mode 100644
index 0000000..f8192fc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheGet.js
@@ -0,0 +1,19 @@
+var assocIndexOf = require('./_assocIndexOf');
+
+/**
+ * Gets the list cache value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf ListCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function listCacheGet(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ return index < 0 ? undefined : data[index][1];
+}
+
+module.exports = listCacheGet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheHas.js
new file mode 100644
index 0000000..2adf671
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheHas.js
@@ -0,0 +1,16 @@
+var assocIndexOf = require('./_assocIndexOf');
+
+/**
+ * Checks if a list cache value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf ListCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function listCacheHas(key) {
+ return assocIndexOf(this.__data__, key) > -1;
+}
+
+module.exports = listCacheHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheSet.js
new file mode 100644
index 0000000..5855c95
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_listCacheSet.js
@@ -0,0 +1,26 @@
+var assocIndexOf = require('./_assocIndexOf');
+
+/**
+ * Sets the list cache `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf ListCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the list cache instance.
+ */
+function listCacheSet(key, value) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ ++this.size;
+ data.push([key, value]);
+ } else {
+ data[index][1] = value;
+ }
+ return this;
+}
+
+module.exports = listCacheSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheClear.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheClear.js
new file mode 100644
index 0000000..bc9ca20
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheClear.js
@@ -0,0 +1,21 @@
+var Hash = require('./_Hash'),
+ ListCache = require('./_ListCache'),
+ Map = require('./_Map');
+
+/**
+ * Removes all key-value entries from the map.
+ *
+ * @private
+ * @name clear
+ * @memberOf MapCache
+ */
+function mapCacheClear() {
+ this.size = 0;
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': new (Map || ListCache),
+ 'string': new Hash
+ };
+}
+
+module.exports = mapCacheClear;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheDelete.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheDelete.js
new file mode 100644
index 0000000..946ca3c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheDelete.js
@@ -0,0 +1,18 @@
+var getMapData = require('./_getMapData');
+
+/**
+ * Removes `key` and its value from the map.
+ *
+ * @private
+ * @name delete
+ * @memberOf MapCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function mapCacheDelete(key) {
+ var result = getMapData(this, key)['delete'](key);
+ this.size -= result ? 1 : 0;
+ return result;
+}
+
+module.exports = mapCacheDelete;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheGet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheGet.js
new file mode 100644
index 0000000..f29f55c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheGet.js
@@ -0,0 +1,16 @@
+var getMapData = require('./_getMapData');
+
+/**
+ * Gets the map value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf MapCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function mapCacheGet(key) {
+ return getMapData(this, key).get(key);
+}
+
+module.exports = mapCacheGet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheHas.js
new file mode 100644
index 0000000..a1214c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheHas.js
@@ -0,0 +1,16 @@
+var getMapData = require('./_getMapData');
+
+/**
+ * Checks if a map value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf MapCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function mapCacheHas(key) {
+ return getMapData(this, key).has(key);
+}
+
+module.exports = mapCacheHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheSet.js
new file mode 100644
index 0000000..7346849
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapCacheSet.js
@@ -0,0 +1,22 @@
+var getMapData = require('./_getMapData');
+
+/**
+ * Sets the map `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf MapCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the map cache instance.
+ */
+function mapCacheSet(key, value) {
+ var data = getMapData(this, key),
+ size = data.size;
+
+ data.set(key, value);
+ this.size += data.size == size ? 0 : 1;
+ return this;
+}
+
+module.exports = mapCacheSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapToArray.js
new file mode 100644
index 0000000..fe3dd53
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mapToArray.js
@@ -0,0 +1,18 @@
+/**
+ * Converts `map` to its key-value pairs.
+ *
+ * @private
+ * @param {Object} map The map to convert.
+ * @returns {Array} Returns the key-value pairs.
+ */
+function mapToArray(map) {
+ var index = -1,
+ result = Array(map.size);
+
+ map.forEach(function(value, key) {
+ result[++index] = [key, value];
+ });
+ return result;
+}
+
+module.exports = mapToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_matchesStrictComparable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_matchesStrictComparable.js
new file mode 100644
index 0000000..f608af9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_matchesStrictComparable.js
@@ -0,0 +1,20 @@
+/**
+ * A specialized version of `matchesProperty` for source values suitable
+ * for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+function matchesStrictComparable(key, srcValue) {
+ return function(object) {
+ if (object == null) {
+ return false;
+ }
+ return object[key] === srcValue &&
+ (srcValue !== undefined || (key in Object(object)));
+ };
+}
+
+module.exports = matchesStrictComparable;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_memoizeCapped.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_memoizeCapped.js
new file mode 100644
index 0000000..7f71c8f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_memoizeCapped.js
@@ -0,0 +1,26 @@
+var memoize = require('./memoize');
+
+/** Used as the maximum memoize cache size. */
+var MAX_MEMOIZE_SIZE = 500;
+
+/**
+ * A specialized version of `_.memoize` which clears the memoized function's
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
+ *
+ * @private
+ * @param {Function} func The function to have its output memoized.
+ * @returns {Function} Returns the new memoized function.
+ */
+function memoizeCapped(func) {
+ var result = memoize(func, function(key) {
+ if (cache.size === MAX_MEMOIZE_SIZE) {
+ cache.clear();
+ }
+ return key;
+ });
+
+ var cache = result.cache;
+ return result;
+}
+
+module.exports = memoizeCapped;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeData.js
new file mode 100644
index 0000000..cb570f9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeData.js
@@ -0,0 +1,90 @@
+var composeArgs = require('./_composeArgs'),
+ composeArgsRight = require('./_composeArgsRight'),
+ replaceHolders = require('./_replaceHolders');
+
+/** Used as the internal argument placeholder. */
+var PLACEHOLDER = '__lodash_placeholder__';
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_BOUND_FLAG = 4,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_ARY_FLAG = 128,
+ WRAP_REARG_FLAG = 256;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Merges the function metadata of `source` into `data`.
+ *
+ * Merging metadata reduces the number of wrappers used to invoke a function.
+ * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
+ * may be applied regardless of execution order. Methods like `_.ary` and
+ * `_.rearg` modify function arguments, making the order in which they are
+ * executed important, preventing the merging of metadata. However, we make
+ * an exception for a safe combined case where curried functions have `_.ary`
+ * and or `_.rearg` applied.
+ *
+ * @private
+ * @param {Array} data The destination metadata.
+ * @param {Array} source The source metadata.
+ * @returns {Array} Returns `data`.
+ */
+function mergeData(data, source) {
+ var bitmask = data[1],
+ srcBitmask = source[1],
+ newBitmask = bitmask | srcBitmask,
+ isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
+
+ var isCombo =
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
+ ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
+
+ // Exit early if metadata can't be merged.
+ if (!(isCommon || isCombo)) {
+ return data;
+ }
+ // Use source `thisArg` if available.
+ if (srcBitmask & WRAP_BIND_FLAG) {
+ data[2] = source[2];
+ // Set when currying a bound function.
+ newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
+ }
+ // Compose partial arguments.
+ var value = source[3];
+ if (value) {
+ var partials = data[3];
+ data[3] = partials ? composeArgs(partials, value, source[4]) : value;
+ data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
+ }
+ // Compose partial right arguments.
+ value = source[5];
+ if (value) {
+ partials = data[5];
+ data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
+ data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
+ }
+ // Use source `argPos` if available.
+ value = source[7];
+ if (value) {
+ data[7] = value;
+ }
+ // Use source `ary` if it's smaller.
+ if (srcBitmask & WRAP_ARY_FLAG) {
+ data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
+ }
+ // Use source `arity` if one is not provided.
+ if (data[9] == null) {
+ data[9] = source[9];
+ }
+ // Use source `func` and merge bitmasks.
+ data[0] = source[0];
+ data[1] = newBitmask;
+
+ return data;
+}
+
+module.exports = mergeData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeDefaults.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeDefaults.js
new file mode 100644
index 0000000..9888f0e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_mergeDefaults.js
@@ -0,0 +1,27 @@
+var baseMerge = require('./_baseMerge'),
+ isObject = require('./isObject');
+
+/**
+ * Used by `_.defaultsDeep` to customize its `_.merge` use.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to merge.
+ * @param {Object} object The parent object of `objValue`.
+ * @param {Object} source The parent object of `srcValue`.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ * @returns {*} Returns the value to assign.
+ */
+function mergeDefaults(objValue, srcValue, key, object, source, stack) {
+ if (isObject(objValue) && isObject(srcValue)) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, objValue);
+ baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
+ stack['delete'](srcValue);
+ }
+ return objValue;
+}
+
+module.exports = mergeDefaults;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_metaMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_metaMap.js
new file mode 100644
index 0000000..0157a0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_metaMap.js
@@ -0,0 +1,6 @@
+var WeakMap = require('./_WeakMap');
+
+/** Used to store function metadata. */
+var metaMap = WeakMap && new WeakMap;
+
+module.exports = metaMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeCreate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeCreate.js
new file mode 100644
index 0000000..c7aede8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeCreate.js
@@ -0,0 +1,6 @@
+var getNative = require('./_getNative');
+
+/* Built-in method references that are verified to be native. */
+var nativeCreate = getNative(Object, 'create');
+
+module.exports = nativeCreate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeys.js
new file mode 100644
index 0000000..479a104
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeys.js
@@ -0,0 +1,6 @@
+var overArg = require('./_overArg');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeKeys = overArg(Object.keys, Object);
+
+module.exports = nativeKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeysIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeysIn.js
new file mode 100644
index 0000000..00ee505
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nativeKeysIn.js
@@ -0,0 +1,20 @@
+/**
+ * This function is like
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * except that it includes inherited enumerable properties.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function nativeKeysIn(object) {
+ var result = [];
+ if (object != null) {
+ for (var key in Object(object)) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = nativeKeysIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nodeUtil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nodeUtil.js
new file mode 100644
index 0000000..14e179f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_nodeUtil.js
@@ -0,0 +1,22 @@
+var freeGlobal = require('./_freeGlobal');
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Detect free variable `process` from Node.js. */
+var freeProcess = moduleExports && freeGlobal.process;
+
+/** Used to access faster Node.js helpers. */
+var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+}());
+
+module.exports = nodeUtil;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_objectToString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_objectToString.js
new file mode 100644
index 0000000..c614ec0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_objectToString.js
@@ -0,0 +1,22 @@
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+function objectToString(value) {
+ return nativeObjectToString.call(value);
+}
+
+module.exports = objectToString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overArg.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overArg.js
new file mode 100644
index 0000000..651c5c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overArg.js
@@ -0,0 +1,15 @@
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+module.exports = overArg;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overRest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overRest.js
new file mode 100644
index 0000000..c7cdef3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_overRest.js
@@ -0,0 +1,36 @@
+var apply = require('./_apply');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
+}
+
+module.exports = overRest;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_parent.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_parent.js
new file mode 100644
index 0000000..f174328
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_parent.js
@@ -0,0 +1,16 @@
+var baseGet = require('./_baseGet'),
+ baseSlice = require('./_baseSlice');
+
+/**
+ * Gets the parent value at `path` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} path The path to get the parent value of.
+ * @returns {*} Returns the parent value.
+ */
+function parent(object, path) {
+ return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
+}
+
+module.exports = parent;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEscape.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEscape.js
new file mode 100644
index 0000000..7f47eda
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEscape.js
@@ -0,0 +1,4 @@
+/** Used to match template delimiters. */
+var reEscape = /<%-([\s\S]+?)%>/g;
+
+module.exports = reEscape;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEvaluate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEvaluate.js
new file mode 100644
index 0000000..6adfc31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reEvaluate.js
@@ -0,0 +1,4 @@
+/** Used to match template delimiters. */
+var reEvaluate = /<%([\s\S]+?)%>/g;
+
+module.exports = reEvaluate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reInterpolate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reInterpolate.js
new file mode 100644
index 0000000..d02ff0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reInterpolate.js
@@ -0,0 +1,4 @@
+/** Used to match template delimiters. */
+var reInterpolate = /<%=([\s\S]+?)%>/g;
+
+module.exports = reInterpolate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_realNames.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_realNames.js
new file mode 100644
index 0000000..aa0d529
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_realNames.js
@@ -0,0 +1,4 @@
+/** Used to lookup unminified function names. */
+var realNames = {};
+
+module.exports = realNames;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reorder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reorder.js
new file mode 100644
index 0000000..a3502b0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_reorder.js
@@ -0,0 +1,29 @@
+var copyArray = require('./_copyArray'),
+ isIndex = require('./_isIndex');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Reorder `array` according to the specified indexes where the element at
+ * the first index is assigned as the first element, the element at
+ * the second index is assigned as the second element, and so on.
+ *
+ * @private
+ * @param {Array} array The array to reorder.
+ * @param {Array} indexes The arranged array indexes.
+ * @returns {Array} Returns `array`.
+ */
+function reorder(array, indexes) {
+ var arrLength = array.length,
+ length = nativeMin(indexes.length, arrLength),
+ oldArray = copyArray(array);
+
+ while (length--) {
+ var index = indexes[length];
+ array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
+ }
+ return array;
+}
+
+module.exports = reorder;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_replaceHolders.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_replaceHolders.js
new file mode 100644
index 0000000..74360ec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_replaceHolders.js
@@ -0,0 +1,29 @@
+/** Used as the internal argument placeholder. */
+var PLACEHOLDER = '__lodash_placeholder__';
+
+/**
+ * Replaces all `placeholder` elements in `array` with an internal placeholder
+ * and returns an array of their indexes.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {*} placeholder The placeholder to replace.
+ * @returns {Array} Returns the new array of placeholder indexes.
+ */
+function replaceHolders(array, placeholder) {
+ var index = -1,
+ length = array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (value === placeholder || value === PLACEHOLDER) {
+ array[index] = PLACEHOLDER;
+ result[resIndex++] = index;
+ }
+ }
+ return result;
+}
+
+module.exports = replaceHolders;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_root.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_root.js
new file mode 100644
index 0000000..d2852be
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_root.js
@@ -0,0 +1,9 @@
+var freeGlobal = require('./_freeGlobal');
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+module.exports = root;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheAdd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheAdd.js
new file mode 100644
index 0000000..1081a74
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheAdd.js
@@ -0,0 +1,19 @@
+/** Used to stand-in for `undefined` hash values. */
+var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+/**
+ * Adds `value` to the array cache.
+ *
+ * @private
+ * @name add
+ * @memberOf SetCache
+ * @alias push
+ * @param {*} value The value to cache.
+ * @returns {Object} Returns the cache instance.
+ */
+function setCacheAdd(value) {
+ this.__data__.set(value, HASH_UNDEFINED);
+ return this;
+}
+
+module.exports = setCacheAdd;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheHas.js
new file mode 100644
index 0000000..9a49255
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setCacheHas.js
@@ -0,0 +1,14 @@
+/**
+ * Checks if `value` is in the array cache.
+ *
+ * @private
+ * @name has
+ * @memberOf SetCache
+ * @param {*} value The value to search for.
+ * @returns {number} Returns `true` if `value` is found, else `false`.
+ */
+function setCacheHas(value) {
+ return this.__data__.has(value);
+}
+
+module.exports = setCacheHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setData.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setData.js
new file mode 100644
index 0000000..e5cf3eb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setData.js
@@ -0,0 +1,20 @@
+var baseSetData = require('./_baseSetData'),
+ shortOut = require('./_shortOut');
+
+/**
+ * Sets metadata for `func`.
+ *
+ * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
+ * period of time, it will trip its breaker and transition to an identity
+ * function to avoid garbage collection pauses in V8. See
+ * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
+ * for more details.
+ *
+ * @private
+ * @param {Function} func The function to associate metadata with.
+ * @param {*} data The metadata.
+ * @returns {Function} Returns `func`.
+ */
+var setData = shortOut(baseSetData);
+
+module.exports = setData;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToArray.js
new file mode 100644
index 0000000..b87f074
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToArray.js
@@ -0,0 +1,18 @@
+/**
+ * Converts `set` to an array of its values.
+ *
+ * @private
+ * @param {Object} set The set to convert.
+ * @returns {Array} Returns the values.
+ */
+function setToArray(set) {
+ var index = -1,
+ result = Array(set.size);
+
+ set.forEach(function(value) {
+ result[++index] = value;
+ });
+ return result;
+}
+
+module.exports = setToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToPairs.js
new file mode 100644
index 0000000..36ad37a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToPairs.js
@@ -0,0 +1,18 @@
+/**
+ * Converts `set` to its value-value pairs.
+ *
+ * @private
+ * @param {Object} set The set to convert.
+ * @returns {Array} Returns the value-value pairs.
+ */
+function setToPairs(set) {
+ var index = -1,
+ result = Array(set.size);
+
+ set.forEach(function(value) {
+ result[++index] = [value, value];
+ });
+ return result;
+}
+
+module.exports = setToPairs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToString.js
new file mode 100644
index 0000000..6ca8419
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setToString.js
@@ -0,0 +1,14 @@
+var baseSetToString = require('./_baseSetToString'),
+ shortOut = require('./_shortOut');
+
+/**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+var setToString = shortOut(baseSetToString);
+
+module.exports = setToString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setWrapToString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setWrapToString.js
new file mode 100644
index 0000000..decdc44
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_setWrapToString.js
@@ -0,0 +1,21 @@
+var getWrapDetails = require('./_getWrapDetails'),
+ insertWrapDetails = require('./_insertWrapDetails'),
+ setToString = require('./_setToString'),
+ updateWrapDetails = require('./_updateWrapDetails');
+
+/**
+ * Sets the `toString` method of `wrapper` to mimic the source of `reference`
+ * with wrapper details in a comment at the top of the source body.
+ *
+ * @private
+ * @param {Function} wrapper The function to modify.
+ * @param {Function} reference The reference function.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Function} Returns `wrapper`.
+ */
+function setWrapToString(wrapper, reference, bitmask) {
+ var source = (reference + '');
+ return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
+}
+
+module.exports = setWrapToString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shortOut.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shortOut.js
new file mode 100644
index 0000000..3300a07
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shortOut.js
@@ -0,0 +1,37 @@
+/** Used to detect hot functions by number of calls within a span of milliseconds. */
+var HOT_COUNT = 800,
+ HOT_SPAN = 16;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeNow = Date.now;
+
+/**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+function shortOut(func) {
+ var count = 0,
+ lastCalled = 0;
+
+ return function() {
+ var stamp = nativeNow(),
+ remaining = HOT_SPAN - (stamp - lastCalled);
+
+ lastCalled = stamp;
+ if (remaining > 0) {
+ if (++count >= HOT_COUNT) {
+ return arguments[0];
+ }
+ } else {
+ count = 0;
+ }
+ return func.apply(undefined, arguments);
+ };
+}
+
+module.exports = shortOut;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shuffleSelf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shuffleSelf.js
new file mode 100644
index 0000000..8bcc4f5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_shuffleSelf.js
@@ -0,0 +1,28 @@
+var baseRandom = require('./_baseRandom');
+
+/**
+ * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @param {number} [size=array.length] The size of `array`.
+ * @returns {Array} Returns `array`.
+ */
+function shuffleSelf(array, size) {
+ var index = -1,
+ length = array.length,
+ lastIndex = length - 1;
+
+ size = size === undefined ? length : size;
+ while (++index < size) {
+ var rand = baseRandom(index, lastIndex),
+ value = array[rand];
+
+ array[rand] = array[index];
+ array[index] = value;
+ }
+ array.length = size;
+ return array;
+}
+
+module.exports = shuffleSelf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackClear.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackClear.js
new file mode 100644
index 0000000..ce8e5a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackClear.js
@@ -0,0 +1,15 @@
+var ListCache = require('./_ListCache');
+
+/**
+ * Removes all key-value entries from the stack.
+ *
+ * @private
+ * @name clear
+ * @memberOf Stack
+ */
+function stackClear() {
+ this.__data__ = new ListCache;
+ this.size = 0;
+}
+
+module.exports = stackClear;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackDelete.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackDelete.js
new file mode 100644
index 0000000..ff9887a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackDelete.js
@@ -0,0 +1,18 @@
+/**
+ * Removes `key` and its value from the stack.
+ *
+ * @private
+ * @name delete
+ * @memberOf Stack
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+function stackDelete(key) {
+ var data = this.__data__,
+ result = data['delete'](key);
+
+ this.size = data.size;
+ return result;
+}
+
+module.exports = stackDelete;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackGet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackGet.js
new file mode 100644
index 0000000..1cdf004
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackGet.js
@@ -0,0 +1,14 @@
+/**
+ * Gets the stack value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Stack
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+function stackGet(key) {
+ return this.__data__.get(key);
+}
+
+module.exports = stackGet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackHas.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackHas.js
new file mode 100644
index 0000000..16a3ad1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackHas.js
@@ -0,0 +1,14 @@
+/**
+ * Checks if a stack value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Stack
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+function stackHas(key) {
+ return this.__data__.has(key);
+}
+
+module.exports = stackHas;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackSet.js
new file mode 100644
index 0000000..b790ac5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stackSet.js
@@ -0,0 +1,34 @@
+var ListCache = require('./_ListCache'),
+ Map = require('./_Map'),
+ MapCache = require('./_MapCache');
+
+/** Used as the size to enable large array optimizations. */
+var LARGE_ARRAY_SIZE = 200;
+
+/**
+ * Sets the stack `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Stack
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the stack cache instance.
+ */
+function stackSet(key, value) {
+ var data = this.__data__;
+ if (data instanceof ListCache) {
+ var pairs = data.__data__;
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
+ pairs.push([key, value]);
+ this.size = ++data.size;
+ return this;
+ }
+ data = this.__data__ = new MapCache(pairs);
+ }
+ data.set(key, value);
+ this.size = data.size;
+ return this;
+}
+
+module.exports = stackSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictIndexOf.js
new file mode 100644
index 0000000..0486a49
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictIndexOf.js
@@ -0,0 +1,23 @@
+/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = strictIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictLastIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictLastIndexOf.js
new file mode 100644
index 0000000..d7310dc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_strictLastIndexOf.js
@@ -0,0 +1,21 @@
+/**
+ * A specialized version of `_.lastIndexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictLastIndexOf(array, value, fromIndex) {
+ var index = fromIndex + 1;
+ while (index--) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return index;
+}
+
+module.exports = strictLastIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringSize.js
new file mode 100644
index 0000000..17ef462
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringSize.js
@@ -0,0 +1,18 @@
+var asciiSize = require('./_asciiSize'),
+ hasUnicode = require('./_hasUnicode'),
+ unicodeSize = require('./_unicodeSize');
+
+/**
+ * Gets the number of symbols in `string`.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {number} Returns the string size.
+ */
+function stringSize(string) {
+ return hasUnicode(string)
+ ? unicodeSize(string)
+ : asciiSize(string);
+}
+
+module.exports = stringSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToArray.js
new file mode 100644
index 0000000..d161158
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToArray.js
@@ -0,0 +1,18 @@
+var asciiToArray = require('./_asciiToArray'),
+ hasUnicode = require('./_hasUnicode'),
+ unicodeToArray = require('./_unicodeToArray');
+
+/**
+ * Converts `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function stringToArray(string) {
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
+}
+
+module.exports = stringToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToPath.js
new file mode 100644
index 0000000..db7b0f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_stringToPath.js
@@ -0,0 +1,28 @@
+var memoizeCapped = require('./_memoizeCapped');
+
+/** Used to match property names within property paths. */
+var reLeadingDot = /^\./,
+ rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
+
+/** Used to match backslashes in property paths. */
+var reEscapeChar = /\\(\\)?/g;
+
+/**
+ * Converts `string` to a property path array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the property path array.
+ */
+var stringToPath = memoizeCapped(function(string) {
+ var result = [];
+ if (reLeadingDot.test(string)) {
+ result.push('');
+ }
+ string.replace(rePropName, function(match, number, quote, string) {
+ result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
+ });
+ return result;
+});
+
+module.exports = stringToPath;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toKey.js
new file mode 100644
index 0000000..c6d645c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toKey.js
@@ -0,0 +1,21 @@
+var isSymbol = require('./isSymbol');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * Converts `value` to a string key if it's not a string or symbol.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {string|symbol} Returns the key.
+ */
+function toKey(value) {
+ if (typeof value == 'string' || isSymbol(value)) {
+ return value;
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+module.exports = toKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toSource.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toSource.js
new file mode 100644
index 0000000..a020b38
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_toSource.js
@@ -0,0 +1,26 @@
+/** Used for built-in method references. */
+var funcProto = Function.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to convert.
+ * @returns {string} Returns the source code.
+ */
+function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
+ }
+ return '';
+}
+
+module.exports = toSource;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unescapeHtmlChar.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unescapeHtmlChar.js
new file mode 100644
index 0000000..a71fecb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unescapeHtmlChar.js
@@ -0,0 +1,21 @@
+var basePropertyOf = require('./_basePropertyOf');
+
+/** Used to map HTML entities to characters. */
+var htmlUnescapes = {
+ '&amp;': '&',
+ '&lt;': '<',
+ '&gt;': '>',
+ '&quot;': '"',
+ '&#39;': "'"
+};
+
+/**
+ * Used by `_.unescape` to convert HTML entities to characters.
+ *
+ * @private
+ * @param {string} chr The matched character to unescape.
+ * @returns {string} Returns the unescaped character.
+ */
+var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
+
+module.exports = unescapeHtmlChar;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeSize.js
new file mode 100644
index 0000000..68137ec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeSize.js
@@ -0,0 +1,44 @@
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
+ rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsAstral = '[' + rsAstralRange + ']',
+ rsCombo = '[' + rsComboRange + ']',
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
+ rsNonAstral = '[^' + rsAstralRange + ']',
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
+ rsZWJ = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var reOptMod = rsModifier + '?',
+ rsOptVar = '[' + rsVarRange + ']?',
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
+ rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+/**
+ * Gets the size of a Unicode `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+function unicodeSize(string) {
+ var result = reUnicode.lastIndex = 0;
+ while (reUnicode.test(string)) {
+ ++result;
+ }
+ return result;
+}
+
+module.exports = unicodeSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeToArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeToArray.js
new file mode 100644
index 0000000..2a725c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeToArray.js
@@ -0,0 +1,40 @@
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
+ rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsAstral = '[' + rsAstralRange + ']',
+ rsCombo = '[' + rsComboRange + ']',
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
+ rsNonAstral = '[^' + rsAstralRange + ']',
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
+ rsZWJ = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var reOptMod = rsModifier + '?',
+ rsOptVar = '[' + rsVarRange + ']?',
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
+ rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+/**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+}
+
+module.exports = unicodeToArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeWords.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeWords.js
new file mode 100644
index 0000000..d8b822a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_unicodeWords.js
@@ -0,0 +1,69 @@
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
+ rsDingbatRange = '\\u2700-\\u27bf',
+ rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
+ rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
+ rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
+ rsPunctuationRange = '\\u2000-\\u206f',
+ rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
+ rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
+ rsVarRange = '\\ufe0e\\ufe0f',
+ rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
+
+/** Used to compose unicode capture groups. */
+var rsApos = "['\u2019]",
+ rsBreak = '[' + rsBreakRange + ']',
+ rsCombo = '[' + rsComboRange + ']',
+ rsDigits = '\\d+',
+ rsDingbat = '[' + rsDingbatRange + ']',
+ rsLower = '[' + rsLowerRange + ']',
+ rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
+ rsNonAstral = '[^' + rsAstralRange + ']',
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
+ rsUpper = '[' + rsUpperRange + ']',
+ rsZWJ = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
+ rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
+ rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
+ rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
+ reOptMod = rsModifier + '?',
+ rsOptVar = '[' + rsVarRange + ']?',
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
+ rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
+ rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
+ rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
+
+/** Used to match complex or compound words. */
+var reUnicodeWord = RegExp([
+ rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
+ rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
+ rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
+ rsUpper + '+' + rsOptContrUpper,
+ rsOrdUpper,
+ rsOrdLower,
+ rsDigits,
+ rsEmoji
+].join('|'), 'g');
+
+/**
+ * Splits a Unicode `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+function unicodeWords(string) {
+ return string.match(reUnicodeWord) || [];
+}
+
+module.exports = unicodeWords;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_updateWrapDetails.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_updateWrapDetails.js
new file mode 100644
index 0000000..8759fbd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_updateWrapDetails.js
@@ -0,0 +1,46 @@
+var arrayEach = require('./_arrayEach'),
+ arrayIncludes = require('./_arrayIncludes');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_CURRY_RIGHT_FLAG = 16,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_PARTIAL_RIGHT_FLAG = 64,
+ WRAP_ARY_FLAG = 128,
+ WRAP_REARG_FLAG = 256,
+ WRAP_FLIP_FLAG = 512;
+
+/** Used to associate wrap methods with their bit flags. */
+var wrapFlags = [
+ ['ary', WRAP_ARY_FLAG],
+ ['bind', WRAP_BIND_FLAG],
+ ['bindKey', WRAP_BIND_KEY_FLAG],
+ ['curry', WRAP_CURRY_FLAG],
+ ['curryRight', WRAP_CURRY_RIGHT_FLAG],
+ ['flip', WRAP_FLIP_FLAG],
+ ['partial', WRAP_PARTIAL_FLAG],
+ ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
+ ['rearg', WRAP_REARG_FLAG]
+];
+
+/**
+ * Updates wrapper `details` based on `bitmask` flags.
+ *
+ * @private
+ * @returns {Array} details The details to modify.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Array} Returns `details`.
+ */
+function updateWrapDetails(details, bitmask) {
+ arrayEach(wrapFlags, function(pair) {
+ var value = '_.' + pair[0];
+ if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
+ details.push(value);
+ }
+ });
+ return details.sort();
+}
+
+module.exports = updateWrapDetails;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_wrapperClone.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_wrapperClone.js
new file mode 100644
index 0000000..7bb58a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/_wrapperClone.js
@@ -0,0 +1,23 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ LodashWrapper = require('./_LodashWrapper'),
+ copyArray = require('./_copyArray');
+
+/**
+ * Creates a clone of `wrapper`.
+ *
+ * @private
+ * @param {Object} wrapper The wrapper to clone.
+ * @returns {Object} Returns the cloned wrapper.
+ */
+function wrapperClone(wrapper) {
+ if (wrapper instanceof LazyWrapper) {
+ return wrapper.clone();
+ }
+ var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
+ result.__actions__ = copyArray(wrapper.__actions__);
+ result.__index__ = wrapper.__index__;
+ result.__values__ = wrapper.__values__;
+ return result;
+}
+
+module.exports = wrapperClone;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/add.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/add.js
new file mode 100644
index 0000000..f069515
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/add.js
@@ -0,0 +1,22 @@
+var createMathOperation = require('./_createMathOperation');
+
+/**
+ * Adds two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.4.0
+ * @category Math
+ * @param {number} augend The first number in an addition.
+ * @param {number} addend The second number in an addition.
+ * @returns {number} Returns the total.
+ * @example
+ *
+ * _.add(6, 4);
+ * // => 10
+ */
+var add = createMathOperation(function(augend, addend) {
+ return augend + addend;
+}, 0);
+
+module.exports = add;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/after.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/after.js
new file mode 100644
index 0000000..3900c97
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/after.js
@@ -0,0 +1,42 @@
+var toInteger = require('./toInteger');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * The opposite of `_.before`; this method creates a function that invokes
+ * `func` once it's called `n` or more times.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {number} n The number of calls before `func` is invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var saves = ['profile', 'settings'];
+ *
+ * var done = _.after(saves.length, function() {
+ * console.log('done saving!');
+ * });
+ *
+ * _.forEach(saves, function(type) {
+ * asyncSave({ 'type': type, 'complete': done });
+ * });
+ * // => Logs 'done saving!' after the two async saves have completed.
+ */
+function after(n, func) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n < 1) {
+ return func.apply(this, arguments);
+ }
+ };
+}
+
+module.exports = after;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/array.js
new file mode 100644
index 0000000..af688d3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/array.js
@@ -0,0 +1,67 @@
+module.exports = {
+ 'chunk': require('./chunk'),
+ 'compact': require('./compact'),
+ 'concat': require('./concat'),
+ 'difference': require('./difference'),
+ 'differenceBy': require('./differenceBy'),
+ 'differenceWith': require('./differenceWith'),
+ 'drop': require('./drop'),
+ 'dropRight': require('./dropRight'),
+ 'dropRightWhile': require('./dropRightWhile'),
+ 'dropWhile': require('./dropWhile'),
+ 'fill': require('./fill'),
+ 'findIndex': require('./findIndex'),
+ 'findLastIndex': require('./findLastIndex'),
+ 'first': require('./first'),
+ 'flatten': require('./flatten'),
+ 'flattenDeep': require('./flattenDeep'),
+ 'flattenDepth': require('./flattenDepth'),
+ 'fromPairs': require('./fromPairs'),
+ 'head': require('./head'),
+ 'indexOf': require('./indexOf'),
+ 'initial': require('./initial'),
+ 'intersection': require('./intersection'),
+ 'intersectionBy': require('./intersectionBy'),
+ 'intersectionWith': require('./intersectionWith'),
+ 'join': require('./join'),
+ 'last': require('./last'),
+ 'lastIndexOf': require('./lastIndexOf'),
+ 'nth': require('./nth'),
+ 'pull': require('./pull'),
+ 'pullAll': require('./pullAll'),
+ 'pullAllBy': require('./pullAllBy'),
+ 'pullAllWith': require('./pullAllWith'),
+ 'pullAt': require('./pullAt'),
+ 'remove': require('./remove'),
+ 'reverse': require('./reverse'),
+ 'slice': require('./slice'),
+ 'sortedIndex': require('./sortedIndex'),
+ 'sortedIndexBy': require('./sortedIndexBy'),
+ 'sortedIndexOf': require('./sortedIndexOf'),
+ 'sortedLastIndex': require('./sortedLastIndex'),
+ 'sortedLastIndexBy': require('./sortedLastIndexBy'),
+ 'sortedLastIndexOf': require('./sortedLastIndexOf'),
+ 'sortedUniq': require('./sortedUniq'),
+ 'sortedUniqBy': require('./sortedUniqBy'),
+ 'tail': require('./tail'),
+ 'take': require('./take'),
+ 'takeRight': require('./takeRight'),
+ 'takeRightWhile': require('./takeRightWhile'),
+ 'takeWhile': require('./takeWhile'),
+ 'union': require('./union'),
+ 'unionBy': require('./unionBy'),
+ 'unionWith': require('./unionWith'),
+ 'uniq': require('./uniq'),
+ 'uniqBy': require('./uniqBy'),
+ 'uniqWith': require('./uniqWith'),
+ 'unzip': require('./unzip'),
+ 'unzipWith': require('./unzipWith'),
+ 'without': require('./without'),
+ 'xor': require('./xor'),
+ 'xorBy': require('./xorBy'),
+ 'xorWith': require('./xorWith'),
+ 'zip': require('./zip'),
+ 'zipObject': require('./zipObject'),
+ 'zipObjectDeep': require('./zipObjectDeep'),
+ 'zipWith': require('./zipWith')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ary.js
new file mode 100644
index 0000000..70c87d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ary.js
@@ -0,0 +1,29 @@
+var createWrap = require('./_createWrap');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_ARY_FLAG = 128;
+
+/**
+ * Creates a function that invokes `func`, with up to `n` arguments,
+ * ignoring any additional arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to cap arguments for.
+ * @param {number} [n=func.length] The arity cap.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new capped function.
+ * @example
+ *
+ * _.map(['6', '8', '10'], _.ary(parseInt, 1));
+ * // => [6, 8, 10]
+ */
+function ary(func, n, guard) {
+ n = guard ? undefined : n;
+ n = (func && n == null) ? func.length : n;
+ return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
+}
+
+module.exports = ary;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assign.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assign.js
new file mode 100644
index 0000000..909db26
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assign.js
@@ -0,0 +1,58 @@
+var assignValue = require('./_assignValue'),
+ copyObject = require('./_copyObject'),
+ createAssigner = require('./_createAssigner'),
+ isArrayLike = require('./isArrayLike'),
+ isPrototype = require('./_isPrototype'),
+ keys = require('./keys');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Assigns own enumerable string keyed properties of source objects to the
+ * destination object. Source objects are applied from left to right.
+ * Subsequent sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object` and is loosely based on
+ * [`Object.assign`](https://mdn.io/Object/assign).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assignIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
+ */
+var assign = createAssigner(function(object, source) {
+ if (isPrototype(source) || isArrayLike(source)) {
+ copyObject(source, keys(source), object);
+ return;
+ }
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ assignValue(object, key, source[key]);
+ }
+ }
+});
+
+module.exports = assign;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignIn.js
new file mode 100644
index 0000000..e663473
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignIn.js
@@ -0,0 +1,40 @@
+var copyObject = require('./_copyObject'),
+ createAssigner = require('./_createAssigner'),
+ keysIn = require('./keysIn');
+
+/**
+ * This method is like `_.assign` except that it iterates over own and
+ * inherited source properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extend
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assign
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assignIn({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
+ */
+var assignIn = createAssigner(function(object, source) {
+ copyObject(source, keysIn(source), object);
+});
+
+module.exports = assignIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignInWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignInWith.js
new file mode 100644
index 0000000..68fcc0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignInWith.js
@@ -0,0 +1,38 @@
+var copyObject = require('./_copyObject'),
+ createAssigner = require('./_createAssigner'),
+ keysIn = require('./keysIn');
+
+/**
+ * This method is like `_.assignIn` except that it accepts `customizer`
+ * which is invoked to produce the assigned values. If `customizer` returns
+ * `undefined`, assignment is handled by the method instead. The `customizer`
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extendWith
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @see _.assignWith
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * return _.isUndefined(objValue) ? srcValue : objValue;
+ * }
+ *
+ * var defaults = _.partialRight(_.assignInWith, customizer);
+ *
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
+ copyObject(source, keysIn(source), object, customizer);
+});
+
+module.exports = assignInWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignWith.js
new file mode 100644
index 0000000..7dc6c76
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/assignWith.js
@@ -0,0 +1,37 @@
+var copyObject = require('./_copyObject'),
+ createAssigner = require('./_createAssigner'),
+ keys = require('./keys');
+
+/**
+ * This method is like `_.assign` except that it accepts `customizer`
+ * which is invoked to produce the assigned values. If `customizer` returns
+ * `undefined`, assignment is handled by the method instead. The `customizer`
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @see _.assignInWith
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * return _.isUndefined(objValue) ? srcValue : objValue;
+ * }
+ *
+ * var defaults = _.partialRight(_.assignWith, customizer);
+ *
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
+ copyObject(source, keys(source), object, customizer);
+});
+
+module.exports = assignWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/at.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/at.js
new file mode 100644
index 0000000..781ee9e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/at.js
@@ -0,0 +1,23 @@
+var baseAt = require('./_baseAt'),
+ flatRest = require('./_flatRest');
+
+/**
+ * Creates an array of values corresponding to `paths` of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Array} Returns the picked values.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
+ *
+ * _.at(object, ['a[0].b.c', 'a[1]']);
+ * // => [3, 4]
+ */
+var at = flatRest(baseAt);
+
+module.exports = at;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/attempt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/attempt.js
new file mode 100644
index 0000000..624d015
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/attempt.js
@@ -0,0 +1,35 @@
+var apply = require('./_apply'),
+ baseRest = require('./_baseRest'),
+ isError = require('./isError');
+
+/**
+ * Attempts to invoke `func`, returning either the result or the caught error
+ * object. Any additional arguments are provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Function} func The function to attempt.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {*} Returns the `func` result or error object.
+ * @example
+ *
+ * // Avoid throwing errors for invalid selectors.
+ * var elements = _.attempt(function(selector) {
+ * return document.querySelectorAll(selector);
+ * }, '>_>');
+ *
+ * if (_.isError(elements)) {
+ * elements = [];
+ * }
+ */
+var attempt = baseRest(function(func, args) {
+ try {
+ return apply(func, undefined, args);
+ } catch (e) {
+ return isError(e) ? e : new Error(e);
+ }
+});
+
+module.exports = attempt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/before.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/before.js
new file mode 100644
index 0000000..a3e0a16
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/before.js
@@ -0,0 +1,40 @@
+var toInteger = require('./toInteger');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that invokes `func`, with the `this` binding and arguments
+ * of the created function, while it's called less than `n` times. Subsequent
+ * calls to the created function return the result of the last `func` invocation.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {number} n The number of calls at which `func` is no longer invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * jQuery(element).on('click', _.before(5, addContactToList));
+ * // => Allows adding up to 4 contacts to the list.
+ */
+function before(n, func) {
+ var result;
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n > 0) {
+ result = func.apply(this, arguments);
+ }
+ if (n <= 1) {
+ func = undefined;
+ }
+ return result;
+ };
+}
+
+module.exports = before;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bind.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bind.js
new file mode 100644
index 0000000..b1076e9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bind.js
@@ -0,0 +1,57 @@
+var baseRest = require('./_baseRest'),
+ createWrap = require('./_createWrap'),
+ getHolder = require('./_getHolder'),
+ replaceHolders = require('./_replaceHolders');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_PARTIAL_FLAG = 32;
+
+/**
+ * Creates a function that invokes `func` with the `this` binding of `thisArg`
+ * and `partials` prepended to the arguments it receives.
+ *
+ * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
+ * may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
+ * property of bound functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to bind.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new bound function.
+ * @example
+ *
+ * function greet(greeting, punctuation) {
+ * return greeting + ' ' + this.user + punctuation;
+ * }
+ *
+ * var object = { 'user': 'fred' };
+ *
+ * var bound = _.bind(greet, object, 'hi');
+ * bound('!');
+ * // => 'hi fred!'
+ *
+ * // Bound with placeholders.
+ * var bound = _.bind(greet, object, _, '!');
+ * bound('hi');
+ * // => 'hi fred!'
+ */
+var bind = baseRest(function(func, thisArg, partials) {
+ var bitmask = WRAP_BIND_FLAG;
+ if (partials.length) {
+ var holders = replaceHolders(partials, getHolder(bind));
+ bitmask |= WRAP_PARTIAL_FLAG;
+ }
+ return createWrap(func, bitmask, thisArg, partials, holders);
+});
+
+// Assign default placeholders.
+bind.placeholder = {};
+
+module.exports = bind;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindAll.js
new file mode 100644
index 0000000..a35706d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindAll.js
@@ -0,0 +1,41 @@
+var arrayEach = require('./_arrayEach'),
+ baseAssignValue = require('./_baseAssignValue'),
+ bind = require('./bind'),
+ flatRest = require('./_flatRest'),
+ toKey = require('./_toKey');
+
+/**
+ * Binds methods of an object to the object itself, overwriting the existing
+ * method.
+ *
+ * **Note:** This method doesn't set the "length" property of bound functions.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {Object} object The object to bind and assign the bound methods to.
+ * @param {...(string|string[])} methodNames The object method names to bind.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var view = {
+ * 'label': 'docs',
+ * 'click': function() {
+ * console.log('clicked ' + this.label);
+ * }
+ * };
+ *
+ * _.bindAll(view, ['click']);
+ * jQuery(element).on('click', view.click);
+ * // => Logs 'clicked docs' when clicked.
+ */
+var bindAll = flatRest(function(object, methodNames) {
+ arrayEach(methodNames, function(key) {
+ key = toKey(key);
+ baseAssignValue(object, key, bind(object[key], object));
+ });
+ return object;
+});
+
+module.exports = bindAll;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindKey.js
new file mode 100644
index 0000000..f7fd64c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/bindKey.js
@@ -0,0 +1,68 @@
+var baseRest = require('./_baseRest'),
+ createWrap = require('./_createWrap'),
+ getHolder = require('./_getHolder'),
+ replaceHolders = require('./_replaceHolders');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_PARTIAL_FLAG = 32;
+
+/**
+ * Creates a function that invokes the method at `object[key]` with `partials`
+ * prepended to the arguments it receives.
+ *
+ * This method differs from `_.bind` by allowing bound functions to reference
+ * methods that may be redefined or don't yet exist. See
+ * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
+ * for more details.
+ *
+ * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Function
+ * @param {Object} object The object to invoke the method on.
+ * @param {string} key The key of the method.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new bound function.
+ * @example
+ *
+ * var object = {
+ * 'user': 'fred',
+ * 'greet': function(greeting, punctuation) {
+ * return greeting + ' ' + this.user + punctuation;
+ * }
+ * };
+ *
+ * var bound = _.bindKey(object, 'greet', 'hi');
+ * bound('!');
+ * // => 'hi fred!'
+ *
+ * object.greet = function(greeting, punctuation) {
+ * return greeting + 'ya ' + this.user + punctuation;
+ * };
+ *
+ * bound('!');
+ * // => 'hiya fred!'
+ *
+ * // Bound with placeholders.
+ * var bound = _.bindKey(object, 'greet', _, '!');
+ * bound('hi');
+ * // => 'hiya fred!'
+ */
+var bindKey = baseRest(function(object, key, partials) {
+ var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
+ if (partials.length) {
+ var holders = replaceHolders(partials, getHolder(bindKey));
+ bitmask |= WRAP_PARTIAL_FLAG;
+ }
+ return createWrap(key, bitmask, object, partials, holders);
+});
+
+// Assign default placeholders.
+bindKey.placeholder = {};
+
+module.exports = bindKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/camelCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/camelCase.js
new file mode 100644
index 0000000..d7390de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/camelCase.js
@@ -0,0 +1,29 @@
+var capitalize = require('./capitalize'),
+ createCompounder = require('./_createCompounder');
+
+/**
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the camel cased string.
+ * @example
+ *
+ * _.camelCase('Foo Bar');
+ * // => 'fooBar'
+ *
+ * _.camelCase('--foo-bar--');
+ * // => 'fooBar'
+ *
+ * _.camelCase('__FOO_BAR__');
+ * // => 'fooBar'
+ */
+var camelCase = createCompounder(function(result, word, index) {
+ word = word.toLowerCase();
+ return result + (index ? capitalize(word) : word);
+});
+
+module.exports = camelCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/capitalize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/capitalize.js
new file mode 100644
index 0000000..3e1600e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/capitalize.js
@@ -0,0 +1,23 @@
+var toString = require('./toString'),
+ upperFirst = require('./upperFirst');
+
+/**
+ * Converts the first character of `string` to upper case and the remaining
+ * to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to capitalize.
+ * @returns {string} Returns the capitalized string.
+ * @example
+ *
+ * _.capitalize('FRED');
+ * // => 'Fred'
+ */
+function capitalize(string) {
+ return upperFirst(toString(string).toLowerCase());
+}
+
+module.exports = capitalize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/castArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/castArray.js
new file mode 100644
index 0000000..e470bdb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/castArray.js
@@ -0,0 +1,44 @@
+var isArray = require('./isArray');
+
+/**
+ * Casts `value` as an array if it's not one.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.4.0
+ * @category Lang
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the cast array.
+ * @example
+ *
+ * _.castArray(1);
+ * // => [1]
+ *
+ * _.castArray({ 'a': 1 });
+ * // => [{ 'a': 1 }]
+ *
+ * _.castArray('abc');
+ * // => ['abc']
+ *
+ * _.castArray(null);
+ * // => [null]
+ *
+ * _.castArray(undefined);
+ * // => [undefined]
+ *
+ * _.castArray();
+ * // => []
+ *
+ * var array = [1, 2, 3];
+ * console.log(_.castArray(array) === array);
+ * // => true
+ */
+function castArray() {
+ if (!arguments.length) {
+ return [];
+ }
+ var value = arguments[0];
+ return isArray(value) ? value : [value];
+}
+
+module.exports = castArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ceil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ceil.js
new file mode 100644
index 0000000..56c8722
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/ceil.js
@@ -0,0 +1,26 @@
+var createRound = require('./_createRound');
+
+/**
+ * Computes `number` rounded up to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round up.
+ * @param {number} [precision=0] The precision to round up to.
+ * @returns {number} Returns the rounded up number.
+ * @example
+ *
+ * _.ceil(4.006);
+ * // => 5
+ *
+ * _.ceil(6.004, 2);
+ * // => 6.01
+ *
+ * _.ceil(6040, -2);
+ * // => 6100
+ */
+var ceil = createRound('ceil');
+
+module.exports = ceil;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chain.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chain.js
new file mode 100644
index 0000000..f6cd647
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chain.js
@@ -0,0 +1,38 @@
+var lodash = require('./wrapperLodash');
+
+/**
+ * Creates a `lodash` wrapper instance that wraps `value` with explicit method
+ * chain sequences enabled. The result of such sequences must be unwrapped
+ * with `_#value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Seq
+ * @param {*} value The value to wrap.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'pebbles', 'age': 1 }
+ * ];
+ *
+ * var youngest = _
+ * .chain(users)
+ * .sortBy('age')
+ * .map(function(o) {
+ * return o.user + ' is ' + o.age;
+ * })
+ * .head()
+ * .value();
+ * // => 'pebbles is 1'
+ */
+function chain(value) {
+ var result = lodash(value);
+ result.__chain__ = true;
+ return result;
+}
+
+module.exports = chain;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chunk.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chunk.js
new file mode 100644
index 0000000..5b562fe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/chunk.js
@@ -0,0 +1,50 @@
+var baseSlice = require('./_baseSlice'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toInteger = require('./toInteger');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil,
+ nativeMax = Math.max;
+
+/**
+ * Creates an array of elements split into groups the length of `size`.
+ * If `array` can't be split evenly, the final chunk will be the remaining
+ * elements.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to process.
+ * @param {number} [size=1] The length of each chunk
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the new array of chunks.
+ * @example
+ *
+ * _.chunk(['a', 'b', 'c', 'd'], 2);
+ * // => [['a', 'b'], ['c', 'd']]
+ *
+ * _.chunk(['a', 'b', 'c', 'd'], 3);
+ * // => [['a', 'b', 'c'], ['d']]
+ */
+function chunk(array, size, guard) {
+ if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
+ size = 1;
+ } else {
+ size = nativeMax(toInteger(size), 0);
+ }
+ var length = array == null ? 0 : array.length;
+ if (!length || size < 1) {
+ return [];
+ }
+ var index = 0,
+ resIndex = 0,
+ result = Array(nativeCeil(length / size));
+
+ while (index < length) {
+ result[resIndex++] = baseSlice(array, index, (index += size));
+ }
+ return result;
+}
+
+module.exports = chunk;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clamp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clamp.js
new file mode 100644
index 0000000..91a72c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clamp.js
@@ -0,0 +1,39 @@
+var baseClamp = require('./_baseClamp'),
+ toNumber = require('./toNumber');
+
+/**
+ * Clamps `number` within the inclusive `lower` and `upper` bounds.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Number
+ * @param {number} number The number to clamp.
+ * @param {number} [lower] The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the clamped number.
+ * @example
+ *
+ * _.clamp(-10, -5, 5);
+ * // => -5
+ *
+ * _.clamp(10, -5, 5);
+ * // => 5
+ */
+function clamp(number, lower, upper) {
+ if (upper === undefined) {
+ upper = lower;
+ lower = undefined;
+ }
+ if (upper !== undefined) {
+ upper = toNumber(upper);
+ upper = upper === upper ? upper : 0;
+ }
+ if (lower !== undefined) {
+ lower = toNumber(lower);
+ lower = lower === lower ? lower : 0;
+ }
+ return baseClamp(toNumber(number), lower, upper);
+}
+
+module.exports = clamp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clone.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clone.js
new file mode 100644
index 0000000..dd439d6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/clone.js
@@ -0,0 +1,36 @@
+var baseClone = require('./_baseClone');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_SYMBOLS_FLAG = 4;
+
+/**
+ * Creates a shallow clone of `value`.
+ *
+ * **Note:** This method is loosely based on the
+ * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
+ * and supports cloning arrays, array buffers, booleans, date objects, maps,
+ * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
+ * arrays. The own enumerable properties of `arguments` objects are cloned
+ * as plain objects. An empty object is returned for uncloneable values such
+ * as error objects, functions, DOM nodes, and WeakMaps.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to clone.
+ * @returns {*} Returns the cloned value.
+ * @see _.cloneDeep
+ * @example
+ *
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
+ *
+ * var shallow = _.clone(objects);
+ * console.log(shallow[0] === objects[0]);
+ * // => true
+ */
+function clone(value) {
+ return baseClone(value, CLONE_SYMBOLS_FLAG);
+}
+
+module.exports = clone;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeep.js
new file mode 100644
index 0000000..4425fbe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeep.js
@@ -0,0 +1,29 @@
+var baseClone = require('./_baseClone');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1,
+ CLONE_SYMBOLS_FLAG = 4;
+
+/**
+ * This method is like `_.clone` except that it recursively clones `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Lang
+ * @param {*} value The value to recursively clone.
+ * @returns {*} Returns the deep cloned value.
+ * @see _.clone
+ * @example
+ *
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
+ *
+ * var deep = _.cloneDeep(objects);
+ * console.log(deep[0] === objects[0]);
+ * // => false
+ */
+function cloneDeep(value) {
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
+}
+
+module.exports = cloneDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeepWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeepWith.js
new file mode 100644
index 0000000..fd9c6c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneDeepWith.js
@@ -0,0 +1,40 @@
+var baseClone = require('./_baseClone');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1,
+ CLONE_SYMBOLS_FLAG = 4;
+
+/**
+ * This method is like `_.cloneWith` except that it recursively clones `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to recursively clone.
+ * @param {Function} [customizer] The function to customize cloning.
+ * @returns {*} Returns the deep cloned value.
+ * @see _.cloneWith
+ * @example
+ *
+ * function customizer(value) {
+ * if (_.isElement(value)) {
+ * return value.cloneNode(true);
+ * }
+ * }
+ *
+ * var el = _.cloneDeepWith(document.body, customizer);
+ *
+ * console.log(el === document.body);
+ * // => false
+ * console.log(el.nodeName);
+ * // => 'BODY'
+ * console.log(el.childNodes.length);
+ * // => 20
+ */
+function cloneDeepWith(value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
+}
+
+module.exports = cloneDeepWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneWith.js
new file mode 100644
index 0000000..d2f4e75
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cloneWith.js
@@ -0,0 +1,42 @@
+var baseClone = require('./_baseClone');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_SYMBOLS_FLAG = 4;
+
+/**
+ * This method is like `_.clone` except that it accepts `customizer` which
+ * is invoked to produce the cloned value. If `customizer` returns `undefined`,
+ * cloning is handled by the method instead. The `customizer` is invoked with
+ * up to four arguments; (value [, index|key, object, stack]).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to clone.
+ * @param {Function} [customizer] The function to customize cloning.
+ * @returns {*} Returns the cloned value.
+ * @see _.cloneDeepWith
+ * @example
+ *
+ * function customizer(value) {
+ * if (_.isElement(value)) {
+ * return value.cloneNode(false);
+ * }
+ * }
+ *
+ * var el = _.cloneWith(document.body, customizer);
+ *
+ * console.log(el === document.body);
+ * // => false
+ * console.log(el.nodeName);
+ * // => 'BODY'
+ * console.log(el.childNodes.length);
+ * // => 0
+ */
+function cloneWith(value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
+}
+
+module.exports = cloneWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/collection.js
new file mode 100644
index 0000000..77fe837
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/collection.js
@@ -0,0 +1,30 @@
+module.exports = {
+ 'countBy': require('./countBy'),
+ 'each': require('./each'),
+ 'eachRight': require('./eachRight'),
+ 'every': require('./every'),
+ 'filter': require('./filter'),
+ 'find': require('./find'),
+ 'findLast': require('./findLast'),
+ 'flatMap': require('./flatMap'),
+ 'flatMapDeep': require('./flatMapDeep'),
+ 'flatMapDepth': require('./flatMapDepth'),
+ 'forEach': require('./forEach'),
+ 'forEachRight': require('./forEachRight'),
+ 'groupBy': require('./groupBy'),
+ 'includes': require('./includes'),
+ 'invokeMap': require('./invokeMap'),
+ 'keyBy': require('./keyBy'),
+ 'map': require('./map'),
+ 'orderBy': require('./orderBy'),
+ 'partition': require('./partition'),
+ 'reduce': require('./reduce'),
+ 'reduceRight': require('./reduceRight'),
+ 'reject': require('./reject'),
+ 'sample': require('./sample'),
+ 'sampleSize': require('./sampleSize'),
+ 'shuffle': require('./shuffle'),
+ 'size': require('./size'),
+ 'some': require('./some'),
+ 'sortBy': require('./sortBy')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/commit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/commit.js
new file mode 100644
index 0000000..fe4db71
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/commit.js
@@ -0,0 +1,33 @@
+var LodashWrapper = require('./_LodashWrapper');
+
+/**
+ * Executes the chain sequence and returns the wrapped result.
+ *
+ * @name commit
+ * @memberOf _
+ * @since 3.2.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var array = [1, 2];
+ * var wrapped = _(array).push(3);
+ *
+ * console.log(array);
+ * // => [1, 2]
+ *
+ * wrapped = wrapped.commit();
+ * console.log(array);
+ * // => [1, 2, 3]
+ *
+ * wrapped.last();
+ * // => 3
+ *
+ * console.log(array);
+ * // => [1, 2, 3]
+ */
+function wrapperCommit() {
+ return new LodashWrapper(this.value(), this.__chain__);
+}
+
+module.exports = wrapperCommit;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/compact.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/compact.js
new file mode 100644
index 0000000..031fab4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/compact.js
@@ -0,0 +1,31 @@
+/**
+ * Creates an array with all falsey values removed. The values `false`, `null`,
+ * `0`, `""`, `undefined`, and `NaN` are falsey.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to compact.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.compact([0, 1, false, 2, '', 3]);
+ * // => [1, 2, 3]
+ */
+function compact(array) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (value) {
+ result[resIndex++] = value;
+ }
+ }
+ return result;
+}
+
+module.exports = compact;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/concat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/concat.js
new file mode 100644
index 0000000..1da48a4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/concat.js
@@ -0,0 +1,43 @@
+var arrayPush = require('./_arrayPush'),
+ baseFlatten = require('./_baseFlatten'),
+ copyArray = require('./_copyArray'),
+ isArray = require('./isArray');
+
+/**
+ * Creates a new array concatenating `array` with any additional arrays
+ * and/or values.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to concatenate.
+ * @param {...*} [values] The values to concatenate.
+ * @returns {Array} Returns the new concatenated array.
+ * @example
+ *
+ * var array = [1];
+ * var other = _.concat(array, 2, [3], [[4]]);
+ *
+ * console.log(other);
+ * // => [1, 2, 3, [4]]
+ *
+ * console.log(array);
+ * // => [1]
+ */
+function concat() {
+ var length = arguments.length;
+ if (!length) {
+ return [];
+ }
+ var args = Array(length - 1),
+ array = arguments[0],
+ index = length;
+
+ while (index--) {
+ args[index - 1] = arguments[index];
+ }
+ return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
+}
+
+module.exports = concat;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cond.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cond.js
new file mode 100644
index 0000000..6455598
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/cond.js
@@ -0,0 +1,60 @@
+var apply = require('./_apply'),
+ arrayMap = require('./_arrayMap'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that iterates over `pairs` and invokes the corresponding
+ * function of the first predicate to return truthy. The predicate-function
+ * pairs are invoked with the `this` binding and arguments of the created
+ * function.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {Array} pairs The predicate-function pairs.
+ * @returns {Function} Returns the new composite function.
+ * @example
+ *
+ * var func = _.cond([
+ * [_.matches({ 'a': 1 }), _.constant('matches A')],
+ * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
+ * [_.stubTrue, _.constant('no match')]
+ * ]);
+ *
+ * func({ 'a': 1, 'b': 2 });
+ * // => 'matches A'
+ *
+ * func({ 'a': 0, 'b': 1 });
+ * // => 'matches B'
+ *
+ * func({ 'a': '1', 'b': '2' });
+ * // => 'no match'
+ */
+function cond(pairs) {
+ var length = pairs == null ? 0 : pairs.length,
+ toIteratee = baseIteratee;
+
+ pairs = !length ? [] : arrayMap(pairs, function(pair) {
+ if (typeof pair[1] != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return [toIteratee(pair[0]), pair[1]];
+ });
+
+ return baseRest(function(args) {
+ var index = -1;
+ while (++index < length) {
+ var pair = pairs[index];
+ if (apply(pair[0], this, args)) {
+ return apply(pair[1], this, args);
+ }
+ }
+ });
+}
+
+module.exports = cond;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conforms.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conforms.js
new file mode 100644
index 0000000..5501a94
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conforms.js
@@ -0,0 +1,35 @@
+var baseClone = require('./_baseClone'),
+ baseConforms = require('./_baseConforms');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a function that invokes the predicate properties of `source` with
+ * the corresponding property values of a given object, returning `true` if
+ * all predicates return truthy, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.conformsTo` with
+ * `source` partially applied.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 2, 'b': 1 },
+ * { 'a': 1, 'b': 2 }
+ * ];
+ *
+ * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
+ * // => [{ 'a': 1, 'b': 2 }]
+ */
+function conforms(source) {
+ return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
+}
+
+module.exports = conforms;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conformsTo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conformsTo.js
new file mode 100644
index 0000000..b8a93eb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/conformsTo.js
@@ -0,0 +1,32 @@
+var baseConformsTo = require('./_baseConformsTo'),
+ keys = require('./keys');
+
+/**
+ * Checks if `object` conforms to `source` by invoking the predicate
+ * properties of `source` with the corresponding property values of `object`.
+ *
+ * **Note:** This method is equivalent to `_.conforms` when `source` is
+ * partially applied.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
+ * // => true
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
+ * // => false
+ */
+function conformsTo(object, source) {
+ return source == null || baseConformsTo(object, source, keys(source));
+}
+
+module.exports = conformsTo;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/constant.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/constant.js
new file mode 100644
index 0000000..655ece3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/constant.js
@@ -0,0 +1,26 @@
+/**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+function constant(value) {
+ return function() {
+ return value;
+ };
+}
+
+module.exports = constant;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.js
new file mode 100644
index 0000000..59cdc7b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.js
@@ -0,0 +1,3839 @@
+/**
+ * @license
+ * Lodash (Custom Build) <https://lodash.com/>
+ * Build: `lodash core -o ./dist/lodash.core.js`
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
+ * Released under MIT license <https://lodash.com/license>
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ */
+;(function() {
+
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
+ /** Used as the semantic version number. */
+ var VERSION = '4.17.2';
+
+ /** Error message constants. */
+ var FUNC_ERROR_TEXT = 'Expected a function';
+
+ /** Used to compose bitmasks for value comparisons. */
+ var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+ /** Used to compose bitmasks for function metadata. */
+ var WRAP_BIND_FLAG = 1,
+ WRAP_PARTIAL_FLAG = 32;
+
+ /** Used as references for various `Number` constants. */
+ var INFINITY = 1 / 0,
+ MAX_SAFE_INTEGER = 9007199254740991;
+
+ /** `Object#toString` result references. */
+ var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ asyncTag = '[object AsyncFunction]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ numberTag = '[object Number]',
+ objectTag = '[object Object]',
+ proxyTag = '[object Proxy]',
+ regexpTag = '[object RegExp]',
+ stringTag = '[object String]';
+
+ /** Used to match HTML entities and HTML characters. */
+ var reUnescapedHtml = /[&<>"']/g,
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
+
+ /** Used to map characters to HTML entities. */
+ var htmlEscapes = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#39;'
+ };
+
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+ /** Detect free variable `self`. */
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+ /** Used as a reference to the global object. */
+ var root = freeGlobal || freeSelf || Function('return this')();
+
+ /** Detect free variable `exports`. */
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+ /** Detect free variable `module`. */
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Appends the elements of `values` to `array`.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to append.
+ * @returns {Array} Returns `array`.
+ */
+ function arrayPush(array, values) {
+ array.push.apply(array, values);
+ return array;
+ }
+
+ /**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.propertyOf` without support for deep paths.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function basePropertyOf(object) {
+ return function(key) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.reduce` and `_.reduceRight`, without support
+ * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} accumulator The initial value.
+ * @param {boolean} initAccum Specify using the first or last element of
+ * `collection` as the initial value.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @returns {*} Returns the accumulated value.
+ */
+ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
+ eachFunc(collection, function(value, index, collection) {
+ accumulator = initAccum
+ ? (initAccum = false, value)
+ : iteratee(accumulator, value, index, collection);
+ });
+ return accumulator;
+ }
+
+ /**
+ * The base implementation of `_.values` and `_.valuesIn` which creates an
+ * array of `object` property values corresponding to the property names
+ * of `props`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} props The property names to get values for.
+ * @returns {Object} Returns the array of property values.
+ */
+ function baseValues(object, props) {
+ return baseMap(props, function(key) {
+ return object[key];
+ });
+ }
+
+ /**
+ * Used by `_.escape` to convert characters to HTML entities.
+ *
+ * @private
+ * @param {string} chr The matched character to escape.
+ * @returns {string} Returns the escaped character.
+ */
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
+
+ /**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /** Used for built-in method references. */
+ var arrayProto = Array.prototype,
+ objectProto = Object.prototype;
+
+ /** Used to check objects for own properties. */
+ var hasOwnProperty = objectProto.hasOwnProperty;
+
+ /** Used to generate unique IDs. */
+ var idCounter = 0;
+
+ /**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+ var nativeObjectToString = objectProto.toString;
+
+ /** Used to restore the original `_` reference in `_.noConflict`. */
+ var oldDash = root._;
+
+ /** Built-in value references. */
+ var objectCreate = Object.create,
+ propertyIsEnumerable = objectProto.propertyIsEnumerable;
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeIsFinite = root.isFinite,
+ nativeKeys = overArg(Object.keys, Object),
+ nativeMax = Math.max;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a `lodash` object which wraps `value` to enable implicit method
+ * chain sequences. Methods that operate on and return arrays, collections,
+ * and functions can be chained together. Methods that retrieve a single value
+ * or may return a primitive value will automatically end the chain sequence
+ * and return the unwrapped value. Otherwise, the value must be unwrapped
+ * with `_#value`.
+ *
+ * Explicit chain sequences, which must be unwrapped with `_#value`, may be
+ * enabled using `_.chain`.
+ *
+ * The execution of chained methods is lazy, that is, it's deferred until
+ * `_#value` is implicitly or explicitly called.
+ *
+ * Lazy evaluation allows several methods to support shortcut fusion.
+ * Shortcut fusion is an optimization to merge iteratee calls; this avoids
+ * the creation of intermediate arrays and can greatly reduce the number of
+ * iteratee executions. Sections of a chain sequence qualify for shortcut
+ * fusion if the section is applied to an array of at least `200` elements
+ * and any iteratees accept only one argument. The heuristic for whether a
+ * section qualifies for shortcut fusion is subject to change.
+ *
+ * Chaining is supported in custom builds as long as the `_#value` method is
+ * directly or indirectly included in the build.
+ *
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
+ *
+ * The wrapper methods that support shortcut fusion are:
+ * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
+ * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
+ * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
+ *
+ * The chainable wrapper methods are:
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
+ * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
+ * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
+ * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
+ * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
+ * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
+ * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
+ * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
+ * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
+ * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
+ * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
+ * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
+ * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
+ * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
+ * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
+ * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
+ * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
+ * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
+ * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
+ * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
+ * `zipObject`, `zipObjectDeep`, and `zipWith`
+ *
+ * The wrapper methods that are **not** chainable by default are:
+ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
+ * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
+ * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
+ * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
+ * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
+ * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
+ * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
+ * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
+ * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
+ * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
+ * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
+ * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
+ * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
+ * `upperFirst`, `value`, and `words`
+ *
+ * @name _
+ * @constructor
+ * @category Seq
+ * @param {*} value The value to wrap in a `lodash` instance.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2, 3]);
+ *
+ * // Returns an unwrapped value.
+ * wrapped.reduce(_.add);
+ * // => 6
+ *
+ * // Returns a wrapped value.
+ * var squares = wrapped.map(square);
+ *
+ * _.isArray(squares);
+ * // => false
+ *
+ * _.isArray(squares.value());
+ * // => true
+ */
+ function lodash(value) {
+ return value instanceof LodashWrapper
+ ? value
+ : new LodashWrapper(value);
+ }
+
+ /**
+ * The base implementation of `_.create` without support for assigning
+ * properties to the created object.
+ *
+ * @private
+ * @param {Object} proto The object to inherit from.
+ * @returns {Object} Returns the new object.
+ */
+ var baseCreate = (function() {
+ function object() {}
+ return function(proto) {
+ if (!isObject(proto)) {
+ return {};
+ }
+ if (objectCreate) {
+ return objectCreate(proto);
+ }
+ object.prototype = proto;
+ var result = new object;
+ object.prototype = undefined;
+ return result;
+ };
+ }());
+
+ /**
+ * The base constructor for creating `lodash` wrapper objects.
+ *
+ * @private
+ * @param {*} value The value to wrap.
+ * @param {boolean} [chainAll] Enable explicit method chain sequences.
+ */
+ function LodashWrapper(value, chainAll) {
+ this.__wrapped__ = value;
+ this.__actions__ = [];
+ this.__chain__ = !!chainAll;
+ }
+
+ LodashWrapper.prototype = baseCreate(lodash.prototype);
+ LodashWrapper.prototype.constructor = LodashWrapper;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Used by `_.defaults` to customize its `_.assignIn` use.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to assign.
+ * @param {Object} object The parent object of `objValue`.
+ * @returns {*} Returns the value to assign.
+ */
+ function assignInDefaults(objValue, srcValue, key, object) {
+ if (objValue === undefined ||
+ (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
+ return srcValue;
+ }
+ return objValue;
+ }
+
+ /**
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function assignValue(object, key, value) {
+ var objValue = object[key];
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+ }
+
+ /**
+ * The base implementation of `assignValue` and `assignMergeValue` without
+ * value checks.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function baseAssignValue(object, key, value) {
+ object[key] = value;
+ }
+
+ /**
+ * The base implementation of `_.delay` and `_.defer` which accepts `args`
+ * to provide to `func`.
+ *
+ * @private
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {Array} args The arguments to provide to `func`.
+ * @returns {number|Object} Returns the timer id or timeout object.
+ */
+ function baseDelay(func, wait, args) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return setTimeout(function() { func.apply(undefined, args); }, wait);
+ }
+
+ /**
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ */
+ var baseEach = createBaseEach(baseForOwn);
+
+ /**
+ * The base implementation of `_.every` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`
+ */
+ function baseEvery(collection, predicate) {
+ var result = true;
+ baseEach(collection, function(value, index, collection) {
+ result = !!predicate(value, index, collection);
+ return result;
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of methods like `_.max` and `_.min` which accepts a
+ * `comparator` to determine the extremum value.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The iteratee invoked per iteration.
+ * @param {Function} comparator The comparator used to compare values.
+ * @returns {*} Returns the extremum value.
+ */
+ function baseExtremum(array, iteratee, comparator) {
+ var index = -1,
+ length = array.length;
+
+ while (++index < length) {
+ var value = array[index],
+ current = iteratee(value);
+
+ if (current != null && (computed === undefined
+ ? (current === current && !false)
+ : comparator(current, computed)
+ )) {
+ var computed = current,
+ result = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.filter` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+ function baseFilter(collection, predicate) {
+ var result = [];
+ baseEach(collection, function(value, index, collection) {
+ if (predicate(value, index, collection)) {
+ result.push(value);
+ }
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.flatten` with support for restricting flattening.
+ *
+ * @private
+ * @param {Array} array The array to flatten.
+ * @param {number} depth The maximum recursion depth.
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
+ * @param {Array} [result=[]] The initial result value.
+ * @returns {Array} Returns the new flattened array.
+ */
+ function baseFlatten(array, depth, predicate, isStrict, result) {
+ var index = -1,
+ length = array.length;
+
+ predicate || (predicate = isFlattenable);
+ result || (result = []);
+
+ while (++index < length) {
+ var value = array[index];
+ if (depth > 0 && predicate(value)) {
+ if (depth > 1) {
+ // Recursively flatten arrays (susceptible to call stack limits).
+ baseFlatten(value, depth - 1, predicate, isStrict, result);
+ } else {
+ arrayPush(result, value);
+ }
+ } else if (!isStrict) {
+ result[result.length] = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+ var baseFor = createBaseFor();
+
+ /**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+ function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+ }
+
+ /**
+ * The base implementation of `_.functions` which creates an array of
+ * `object` function property names filtered from `props`.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Array} props The property names to filter.
+ * @returns {Array} Returns the function names.
+ */
+ function baseFunctions(object, props) {
+ return baseFilter(props, function(key) {
+ return isFunction(object[key]);
+ });
+ }
+
+ /**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ function baseGetTag(value) {
+ return objectToString(value);
+ }
+
+ /**
+ * The base implementation of `_.gt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than `other`,
+ * else `false`.
+ */
+ function baseGt(value, other) {
+ return value > other;
+ }
+
+ /**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+ var baseIsArguments = noop;
+
+ /**
+ * The base implementation of `_.isDate` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ */
+ function baseIsDate(value) {
+ return isObjectLike(value) && baseGetTag(value) == dateTag;
+ }
+
+ /**
+ * The base implementation of `_.isEqual` which supports partial comparisons
+ * and tracks traversed objects.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Unordered comparison
+ * 2 - Partial comparison
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ */
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
+ if (value === other) {
+ return true;
+ }
+ if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
+ return value !== value && other !== other;
+ }
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
+ }
+
+ /**
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
+ * deep comparisons and tracks traversed objects enabling objects with circular
+ * references to be compared.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
+ var objIsArr = isArray(object),
+ othIsArr = isArray(other),
+ objTag = arrayTag,
+ othTag = arrayTag;
+
+ if (!objIsArr) {
+ objTag = baseGetTag(object);
+ objTag = objTag == argsTag ? objectTag : objTag;
+ }
+ if (!othIsArr) {
+ othTag = baseGetTag(other);
+ othTag = othTag == argsTag ? objectTag : othTag;
+ }
+ var objIsObj = objTag == objectTag,
+ othIsObj = othTag == objectTag,
+ isSameTag = objTag == othTag;
+
+ stack || (stack = []);
+ var objStack = find(stack, function(entry) {
+ return entry[0] == object;
+ });
+ var othStack = find(stack, function(entry) {
+ return entry[0] == other;
+ });
+ if (objStack && othStack) {
+ return objStack[1] == other;
+ }
+ stack.push([object, other]);
+ stack.push([other, object]);
+ if (isSameTag && !objIsObj) {
+ var result = (objIsArr)
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
+ stack.pop();
+ return result;
+ }
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
+
+ if (objIsWrapped || othIsWrapped) {
+ var objUnwrapped = objIsWrapped ? object.value() : object,
+ othUnwrapped = othIsWrapped ? other.value() : other;
+
+ var result = equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
+ stack.pop();
+ return result;
+ }
+ }
+ if (!isSameTag) {
+ return false;
+ }
+ var result = equalObjects(object, other, bitmask, customizer, equalFunc, stack);
+ stack.pop();
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.isRegExp` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ */
+ function baseIsRegExp(value) {
+ return isObjectLike(value) && baseGetTag(value) == regexpTag;
+ }
+
+ /**
+ * The base implementation of `_.iteratee`.
+ *
+ * @private
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
+ * @returns {Function} Returns the iteratee.
+ */
+ function baseIteratee(func) {
+ if (typeof func == 'function') {
+ return func;
+ }
+ if (func == null) {
+ return identity;
+ }
+ return (typeof func == 'object' ? baseMatches : baseProperty)(func);
+ }
+
+ /**
+ * The base implementation of `_.lt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than `other`,
+ * else `false`.
+ */
+ function baseLt(value, other) {
+ return value < other;
+ }
+
+ /**
+ * The base implementation of `_.map` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+ function baseMap(collection, iteratee) {
+ var index = -1,
+ result = isArrayLike(collection) ? Array(collection.length) : [];
+
+ baseEach(collection, function(value, key, collection) {
+ result[++index] = iteratee(value, key, collection);
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.matches` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ */
+ function baseMatches(source) {
+ var props = nativeKeys(source);
+ return function(object) {
+ var length = props.length;
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (length--) {
+ var key = props[length];
+ if (!(key in object &&
+ baseIsEqual(source[key], object[key], COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG)
+ )) {
+ return false;
+ }
+ }
+ return true;
+ };
+ }
+
+ /**
+ * The base implementation of `_.pick` without support for individual
+ * property identifiers.
+ *
+ * @private
+ * @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
+ * @returns {Object} Returns the new object.
+ */
+ function basePick(object, props) {
+ object = Object(object);
+ return reduce(props, function(result, key) {
+ if (key in object) {
+ result[key] = object[key];
+ }
+ return result;
+ }, {});
+ }
+
+ /**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+ function baseRest(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+ }
+
+ /**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+ function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
+ }
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
+
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
+ }
+ return result;
+ }
+
+ /**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+ function copyArray(source) {
+ return baseSlice(source, 0, source.length);
+ }
+
+ /**
+ * The base implementation of `_.some` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+ function baseSome(collection, predicate) {
+ var result;
+
+ baseEach(collection, function(value, index, collection) {
+ result = predicate(value, index, collection);
+ return !result;
+ });
+ return !!result;
+ }
+
+ /**
+ * The base implementation of `wrapperValue` which returns the result of
+ * performing a sequence of actions on the unwrapped `value`, where each
+ * successive action is supplied the return value of the previous.
+ *
+ * @private
+ * @param {*} value The unwrapped value.
+ * @param {Array} actions Actions to perform to resolve the unwrapped value.
+ * @returns {*} Returns the resolved value.
+ */
+ function baseWrapperValue(value, actions) {
+ var result = value;
+ return reduce(actions, function(result, action) {
+ return action.func.apply(action.thisArg, arrayPush([result], action.args));
+ }, result);
+ }
+
+ /**
+ * Compares values to sort them in ascending order.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {number} Returns the sort order indicator for `value`.
+ */
+ function compareAscending(value, other) {
+ if (value !== other) {
+ var valIsDefined = value !== undefined,
+ valIsNull = value === null,
+ valIsReflexive = value === value,
+ valIsSymbol = false;
+
+ var othIsDefined = other !== undefined,
+ othIsNull = other === null,
+ othIsReflexive = other === other,
+ othIsSymbol = false;
+
+ if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
+ (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
+ (valIsNull && othIsDefined && othIsReflexive) ||
+ (!valIsDefined && othIsReflexive) ||
+ !valIsReflexive) {
+ return 1;
+ }
+ if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
+ (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
+ (othIsNull && valIsDefined && valIsReflexive) ||
+ (!othIsDefined && valIsReflexive) ||
+ !othIsReflexive) {
+ return -1;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Copies properties of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy properties from.
+ * @param {Array} props The property identifiers to copy.
+ * @param {Object} [object={}] The object to copy properties to.
+ * @param {Function} [customizer] The function to customize copied values.
+ * @returns {Object} Returns `object`.
+ */
+ function copyObject(source, props, object, customizer) {
+ var isNew = !object;
+ object || (object = {});
+
+ var index = -1,
+ length = props.length;
+
+ while (++index < length) {
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = source[key];
+ }
+ if (isNew) {
+ baseAssignValue(object, key, newValue);
+ } else {
+ assignValue(object, key, newValue);
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Creates a function like `_.assign`.
+ *
+ * @private
+ * @param {Function} assigner The function to assign values.
+ * @returns {Function} Returns the new assigner function.
+ */
+ function createAssigner(assigner) {
+ return baseRest(function(object, sources) {
+ var index = -1,
+ length = sources.length,
+ customizer = length > 1 ? sources[length - 1] : undefined;
+
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
+ ? (length--, customizer)
+ : undefined;
+
+ object = Object(object);
+ while (++index < length) {
+ var source = sources[index];
+ if (source) {
+ assigner(object, source, index, customizer);
+ }
+ }
+ return object;
+ });
+ }
+
+ /**
+ * Creates a `baseEach` or `baseEachRight` function.
+ *
+ * @private
+ * @param {Function} eachFunc The function to iterate over a collection.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+ function createBaseEach(eachFunc, fromRight) {
+ return function(collection, iteratee) {
+ if (collection == null) {
+ return collection;
+ }
+ if (!isArrayLike(collection)) {
+ return eachFunc(collection, iteratee);
+ }
+ var length = collection.length,
+ index = fromRight ? length : -1,
+ iterable = Object(collection);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (iteratee(iterable[index], index, iterable) === false) {
+ break;
+ }
+ }
+ return collection;
+ };
+ }
+
+ /**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+ function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+ }
+
+ /**
+ * Creates a function that produces an instance of `Ctor` regardless of
+ * whether it was invoked as part of a `new` expression or by `call` or `apply`.
+ *
+ * @private
+ * @param {Function} Ctor The constructor to wrap.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createCtor(Ctor) {
+ return function() {
+ // Use a `switch` statement to work with class constructors. See
+ // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
+ // for more details.
+ var args = arguments;
+ var thisBinding = baseCreate(Ctor.prototype),
+ result = Ctor.apply(thisBinding, args);
+
+ // Mimic the constructor's `return` behavior.
+ // See https://es5.github.io/#x13.2.2 for more details.
+ return isObject(result) ? result : thisBinding;
+ };
+ }
+
+ /**
+ * Creates a `_.find` or `_.findLast` function.
+ *
+ * @private
+ * @param {Function} findIndexFunc The function to find the collection index.
+ * @returns {Function} Returns the new find function.
+ */
+ function createFind(findIndexFunc) {
+ return function(collection, predicate, fromIndex) {
+ var iterable = Object(collection);
+ if (!isArrayLike(collection)) {
+ var iteratee = baseIteratee(predicate, 3);
+ collection = keys(collection);
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
+ }
+ var index = findIndexFunc(collection, predicate, fromIndex);
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke it with the `this` binding
+ * of `thisArg` and `partials` prepended to the arguments it receives.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} partials The arguments to prepend to those provided to
+ * the new function.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createPartial(func, bitmask, thisArg, partials) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
+
+ function wrapper() {
+ var argsIndex = -1,
+ argsLength = arguments.length,
+ leftIndex = -1,
+ leftLength = partials.length,
+ args = Array(leftLength + argsLength),
+ fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+
+ while (++leftIndex < leftLength) {
+ args[leftIndex] = partials[leftIndex];
+ }
+ while (argsLength--) {
+ args[leftIndex++] = arguments[++argsIndex];
+ }
+ return fn.apply(isBind ? thisArg : this, args);
+ }
+ return wrapper;
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Array} array The array to compare.
+ * @param {Array} other The other array to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
+ */
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ arrLength = array.length,
+ othLength = other.length;
+
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
+ return false;
+ }
+ var index = -1,
+ result = true,
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? [] : undefined;
+
+ // Ignore non-index properties.
+ while (++index < arrLength) {
+ var arrValue = array[index],
+ othValue = other[index];
+
+ var compared;
+ if (compared !== undefined) {
+ if (compared) {
+ continue;
+ }
+ result = false;
+ break;
+ }
+ // Recursively compare arrays (susceptible to call stack limits).
+ if (seen) {
+ if (!baseSome(other, function(othValue, othIndex) {
+ if (!indexOf(seen, othIndex) &&
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
+ return seen.push(othIndex);
+ }
+ })) {
+ result = false;
+ break;
+ }
+ } else if (!(
+ arrValue === othValue ||
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
+ )) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
+ * the same `toStringTag`.
+ *
+ * **Note:** This function only supports comparing values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {string} tag The `toStringTag` of the objects to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
+ switch (tag) {
+
+ case boolTag:
+ case dateTag:
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
+
+ case errorTag:
+ return object.name == other.name && object.message == other.message;
+
+ case regexpTag:
+ case stringTag:
+ // Coerce regexes to strings and treat strings, primitives and objects,
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
+ // for more details.
+ return object == (other + '');
+
+ }
+ return false;
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for objects with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ objProps = keys(object),
+ objLength = objProps.length,
+ othProps = keys(other),
+ othLength = othProps.length;
+
+ if (objLength != othLength && !isPartial) {
+ return false;
+ }
+ var index = objLength;
+ while (index--) {
+ var key = objProps[index];
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
+ return false;
+ }
+ }
+ var result = true;
+
+ var skipCtor = isPartial;
+ while (++index < objLength) {
+ key = objProps[index];
+ var objValue = object[key],
+ othValue = other[key];
+
+ var compared;
+ // Recursively compare objects (susceptible to call stack limits).
+ if (!(compared === undefined
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
+ : compared
+ )) {
+ result = false;
+ break;
+ }
+ skipCtor || (skipCtor = key == 'constructor');
+ }
+ if (result && !skipCtor) {
+ var objCtor = object.constructor,
+ othCtor = other.constructor;
+
+ // Non `Object` object instances with different constructors are not equal.
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A specialized version of `baseRest` which flattens the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+ function flatRest(func) {
+ return setToString(overRest(func, undefined, flatten), func + '');
+ }
+
+ /**
+ * Checks if `value` is a flattenable `arguments` object or array.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
+ */
+ function isFlattenable(value) {
+ return isArray(value) || isArguments(value);
+ }
+
+ /**
+ * This function is like
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * except that it includes inherited enumerable properties.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function nativeKeysIn(object) {
+ var result = [];
+ if (object != null) {
+ for (var key in Object(object)) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+ function objectToString(value) {
+ return nativeObjectToString.call(value);
+ }
+
+ /**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return func.apply(this, otherArgs);
+ };
+ }
+
+ /**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var setToString = identity;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an array with all falsey values removed. The values `false`, `null`,
+ * `0`, `""`, `undefined`, and `NaN` are falsey.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to compact.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.compact([0, 1, false, 2, '', 3]);
+ * // => [1, 2, 3]
+ */
+ function compact(array) {
+ return baseFilter(array, Boolean);
+ }
+
+ /**
+ * Creates a new array concatenating `array` with any additional arrays
+ * and/or values.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to concatenate.
+ * @param {...*} [values] The values to concatenate.
+ * @returns {Array} Returns the new concatenated array.
+ * @example
+ *
+ * var array = [1];
+ * var other = _.concat(array, 2, [3], [[4]]);
+ *
+ * console.log(other);
+ * // => [1, 2, 3, [4]]
+ *
+ * console.log(array);
+ * // => [1]
+ */
+ function concat() {
+ var length = arguments.length;
+ if (!length) {
+ return [];
+ }
+ var args = Array(length - 1),
+ array = arguments[0],
+ index = length;
+
+ while (index--) {
+ args[index - 1] = arguments[index];
+ }
+ return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
+ }
+
+ /**
+ * This method is like `_.find` except that it returns the index of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.findIndex(users, function(o) { return o.user == 'barney'; });
+ * // => 0
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findIndex(users, { 'user': 'fred', 'active': false });
+ * // => 1
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findIndex(users, ['active', false]);
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findIndex(users, 'active');
+ * // => 2
+ */
+ function findIndex(array, predicate, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
+ if (index < 0) {
+ index = nativeMax(length + index, 0);
+ }
+ return baseFindIndex(array, baseIteratee(predicate, 3), index);
+ }
+
+ /**
+ * Flattens `array` a single level deep.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
+ */
+ function flatten(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, 1) : [];
+ }
+
+ /**
+ * Recursively flattens `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
+ */
+ function flattenDeep(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, INFINITY) : [];
+ }
+
+ /**
+ * Gets the first element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias first
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the first element of `array`.
+ * @example
+ *
+ * _.head([1, 2, 3]);
+ * // => 1
+ *
+ * _.head([]);
+ * // => undefined
+ */
+ function head(array) {
+ return (array && array.length) ? array[0] : undefined;
+ }
+
+ /**
+ * Gets the index at which the first occurrence of `value` is found in `array`
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. If `fromIndex` is negative, it's used as the
+ * offset from the end of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.indexOf([1, 2, 1, 2], 2);
+ * // => 1
+ *
+ * // Search from the `fromIndex`.
+ * _.indexOf([1, 2, 1, 2], 2, 2);
+ * // => 3
+ */
+ function indexOf(array, value, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (typeof fromIndex == 'number') {
+ fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
+ } else {
+ fromIndex = 0;
+ }
+ var index = (fromIndex || 0) - 1,
+ isReflexive = value === value;
+
+ while (++index < length) {
+ var other = array[index];
+ if ((isReflexive ? other === value : other !== other)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Gets the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the last element of `array`.
+ * @example
+ *
+ * _.last([1, 2, 3]);
+ * // => 3
+ */
+ function last(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? array[length - 1] : undefined;
+ }
+
+ /**
+ * Creates a slice of `array` from `start` up to, but not including, `end`.
+ *
+ * **Note:** This method is used instead of
+ * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
+ * returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+ function slice(array, start, end) {
+ var length = array == null ? 0 : array.length;
+ start = start == null ? 0 : +start;
+ end = end === undefined ? length : +end;
+ return length ? baseSlice(array, start, end) : [];
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a `lodash` wrapper instance that wraps `value` with explicit method
+ * chain sequences enabled. The result of such sequences must be unwrapped
+ * with `_#value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Seq
+ * @param {*} value The value to wrap.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'pebbles', 'age': 1 }
+ * ];
+ *
+ * var youngest = _
+ * .chain(users)
+ * .sortBy('age')
+ * .map(function(o) {
+ * return o.user + ' is ' + o.age;
+ * })
+ * .head()
+ * .value();
+ * // => 'pebbles is 1'
+ */
+ function chain(value) {
+ var result = lodash(value);
+ result.__chain__ = true;
+ return result;
+ }
+
+ /**
+ * This method invokes `interceptor` and returns `value`. The interceptor
+ * is invoked with one argument; (value). The purpose of this method is to
+ * "tap into" a method chain sequence in order to modify intermediate results.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * _([1, 2, 3])
+ * .tap(function(array) {
+ * // Mutate input array.
+ * array.pop();
+ * })
+ * .reverse()
+ * .value();
+ * // => [2, 1]
+ */
+ function tap(value, interceptor) {
+ interceptor(value);
+ return value;
+ }
+
+ /**
+ * This method is like `_.tap` except that it returns the result of `interceptor`.
+ * The purpose of this method is to "pass thru" values replacing intermediate
+ * results in a method chain sequence.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns the result of `interceptor`.
+ * @example
+ *
+ * _(' abc ')
+ * .chain()
+ * .trim()
+ * .thru(function(value) {
+ * return [value];
+ * })
+ * .value();
+ * // => ['abc']
+ */
+ function thru(value, interceptor) {
+ return interceptor(value);
+ }
+
+ /**
+ * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
+ *
+ * @name chain
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 }
+ * ];
+ *
+ * // A sequence without explicit chaining.
+ * _(users).head();
+ * // => { 'user': 'barney', 'age': 36 }
+ *
+ * // A sequence with explicit chaining.
+ * _(users)
+ * .chain()
+ * .head()
+ * .pick('user')
+ * .value();
+ * // => { 'user': 'barney' }
+ */
+ function wrapperChain() {
+ return chain(this);
+ }
+
+ /**
+ * Executes the chain sequence to resolve the unwrapped value.
+ *
+ * @name value
+ * @memberOf _
+ * @since 0.1.0
+ * @alias toJSON, valueOf
+ * @category Seq
+ * @returns {*} Returns the resolved unwrapped value.
+ * @example
+ *
+ * _([1, 2, 3]).value();
+ * // => [1, 2, 3]
+ */
+ function wrapperValue() {
+ return baseWrapperValue(this.__wrapped__, this.__actions__);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Checks if `predicate` returns truthy for **all** elements of `collection`.
+ * Iteration is stopped once `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * **Note:** This method returns `true` for
+ * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
+ * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
+ * elements of empty collections.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.every([true, 1, null, 'yes'], Boolean);
+ * // => false
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.every(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.every(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.every(users, 'active');
+ * // => false
+ */
+ function every(collection, predicate, guard) {
+ predicate = guard ? undefined : predicate;
+ return baseEvery(collection, baseIteratee(predicate));
+ }
+
+ /**
+ * Iterates over elements of `collection`, returning an array of all elements
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.reject
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * _.filter(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, { 'age': 36, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.filter(users, 'active');
+ * // => objects for ['barney']
+ */
+ function filter(collection, predicate) {
+ return baseFilter(collection, baseIteratee(predicate));
+ }
+
+ /**
+ * Iterates over elements of `collection`, returning the first element
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false },
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
+ * ];
+ *
+ * _.find(users, function(o) { return o.age < 40; });
+ * // => object for 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.find(users, { 'age': 1, 'active': true });
+ * // => object for 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.find(users, ['active', false]);
+ * // => object for 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.find(users, 'active');
+ * // => object for 'barney'
+ */
+ var find = createFind(findIndex);
+
+ /**
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
+ * The iteratee is invoked with three arguments: (value, index|key, collection).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * **Note:** As with other "Collections" methods, objects with a "length"
+ * property are iterated like arrays. To avoid this behavior use `_.forIn`
+ * or `_.forOwn` for object iteration.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias each
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEachRight
+ * @example
+ *
+ * _.forEach([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `1` then `2`.
+ *
+ * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */
+ function forEach(collection, iteratee) {
+ return baseEach(collection, baseIteratee(iteratee));
+ }
+
+ /**
+ * Creates an array of values by running each element in `collection` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
+ *
+ * The guarded methods are:
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * _.map([4, 8], square);
+ * // => [16, 64]
+ *
+ * _.map({ 'a': 4, 'b': 8 }, square);
+ * // => [16, 64] (iteration order is not guaranteed)
+ *
+ * var users = [
+ * { 'user': 'barney' },
+ * { 'user': 'fred' }
+ * ];
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, 'user');
+ * // => ['barney', 'fred']
+ */
+ function map(collection, iteratee) {
+ return baseMap(collection, baseIteratee(iteratee));
+ }
+
+ /**
+ * Reduces `collection` to a value which is the accumulated result of running
+ * each element in `collection` thru `iteratee`, where each successive
+ * invocation is supplied the return value of the previous. If `accumulator`
+ * is not given, the first element of `collection` is used as the initial
+ * value. The iteratee is invoked with four arguments:
+ * (accumulator, value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
+ *
+ * The guarded methods are:
+ * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
+ * and `sortBy`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduceRight
+ * @example
+ *
+ * _.reduce([1, 2], function(sum, n) {
+ * return sum + n;
+ * }, 0);
+ * // => 3
+ *
+ * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * return result;
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
+ */
+ function reduce(collection, iteratee, accumulator) {
+ return baseReduce(collection, baseIteratee(iteratee), accumulator, arguments.length < 3, baseEach);
+ }
+
+ /**
+ * Gets the size of `collection` by returning its length for array-like
+ * values or the number of own enumerable string keyed properties for objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @returns {number} Returns the collection size.
+ * @example
+ *
+ * _.size([1, 2, 3]);
+ * // => 3
+ *
+ * _.size({ 'a': 1, 'b': 2 });
+ * // => 2
+ *
+ * _.size('pebbles');
+ * // => 7
+ */
+ function size(collection) {
+ if (collection == null) {
+ return 0;
+ }
+ collection = isArrayLike(collection) ? collection : nativeKeys(collection);
+ return collection.length;
+ }
+
+ /**
+ * Checks if `predicate` returns truthy for **any** element of `collection`.
+ * Iteration is stopped once `predicate` returns truthy. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.some([null, 0, 'yes', false], Boolean);
+ * // => true
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.some(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.some(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.some(users, 'active');
+ * // => true
+ */
+ function some(collection, predicate, guard) {
+ predicate = guard ? undefined : predicate;
+ return baseSome(collection, baseIteratee(predicate));
+ }
+
+ /**
+ * Creates an array of elements, sorted in ascending order by the results of
+ * running each element in a collection thru each iteratee. This method
+ * performs a stable sort, that is, it preserves the original sort order of
+ * equal elements. The iteratees are invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 34 }
+ * ];
+ *
+ * _.sortBy(users, [function(o) { return o.user; }]);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ *
+ * _.sortBy(users, ['user', 'age']);
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
+ */
+ function sortBy(collection, iteratee) {
+ var index = 0;
+ iteratee = baseIteratee(iteratee);
+
+ return baseMap(baseMap(collection, function(value, key, collection) {
+ return { 'value': value, 'index': index++, 'criteria': iteratee(value, key, collection) };
+ }).sort(function(object, other) {
+ return compareAscending(object.criteria, other.criteria) || (object.index - other.index);
+ }), baseProperty('value'));
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a function that invokes `func`, with the `this` binding and arguments
+ * of the created function, while it's called less than `n` times. Subsequent
+ * calls to the created function return the result of the last `func` invocation.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {number} n The number of calls at which `func` is no longer invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * jQuery(element).on('click', _.before(5, addContactToList));
+ * // => Allows adding up to 4 contacts to the list.
+ */
+ function before(n, func) {
+ var result;
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n > 0) {
+ result = func.apply(this, arguments);
+ }
+ if (n <= 1) {
+ func = undefined;
+ }
+ return result;
+ };
+ }
+
+ /**
+ * Creates a function that invokes `func` with the `this` binding of `thisArg`
+ * and `partials` prepended to the arguments it receives.
+ *
+ * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
+ * may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
+ * property of bound functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to bind.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new bound function.
+ * @example
+ *
+ * function greet(greeting, punctuation) {
+ * return greeting + ' ' + this.user + punctuation;
+ * }
+ *
+ * var object = { 'user': 'fred' };
+ *
+ * var bound = _.bind(greet, object, 'hi');
+ * bound('!');
+ * // => 'hi fred!'
+ *
+ * // Bound with placeholders.
+ * var bound = _.bind(greet, object, _, '!');
+ * bound('hi');
+ * // => 'hi fred!'
+ */
+ var bind = baseRest(function(func, thisArg, partials) {
+ return createPartial(func, WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG, thisArg, partials);
+ });
+
+ /**
+ * Defers invoking the `func` until the current call stack has cleared. Any
+ * additional arguments are provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to defer.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.defer(function(text) {
+ * console.log(text);
+ * }, 'deferred');
+ * // => Logs 'deferred' after one millisecond.
+ */
+ var defer = baseRest(function(func, args) {
+ return baseDelay(func, 1, args);
+ });
+
+ /**
+ * Invokes `func` after `wait` milliseconds. Any additional arguments are
+ * provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.delay(function(text) {
+ * console.log(text);
+ * }, 1000, 'later');
+ * // => Logs 'later' after one second.
+ */
+ var delay = baseRest(function(func, wait, args) {
+ return baseDelay(func, toNumber(wait) || 0, args);
+ });
+
+ /**
+ * Creates a function that negates the result of the predicate `func`. The
+ * `func` predicate is invoked with the `this` binding and arguments of the
+ * created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} predicate The predicate to negate.
+ * @returns {Function} Returns the new negated function.
+ * @example
+ *
+ * function isEven(n) {
+ * return n % 2 == 0;
+ * }
+ *
+ * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
+ * // => [1, 3, 5]
+ */
+ function negate(predicate) {
+ if (typeof predicate != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return function() {
+ var args = arguments;
+ return !predicate.apply(this, args);
+ };
+ }
+
+ /**
+ * Creates a function that is restricted to invoking `func` once. Repeat calls
+ * to the function return the value of the first invocation. The `func` is
+ * invoked with the `this` binding and arguments of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var initialize = _.once(createApplication);
+ * initialize();
+ * initialize();
+ * // => `createApplication` is invoked once
+ */
+ function once(func) {
+ return before(2, func);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a shallow clone of `value`.
+ *
+ * **Note:** This method is loosely based on the
+ * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
+ * and supports cloning arrays, array buffers, booleans, date objects, maps,
+ * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
+ * arrays. The own enumerable properties of `arguments` objects are cloned
+ * as plain objects. An empty object is returned for uncloneable values such
+ * as error objects, functions, DOM nodes, and WeakMaps.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to clone.
+ * @returns {*} Returns the cloned value.
+ * @see _.cloneDeep
+ * @example
+ *
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
+ *
+ * var shallow = _.clone(objects);
+ * console.log(shallow[0] === objects[0]);
+ * // => true
+ */
+ function clone(value) {
+ if (!isObject(value)) {
+ return value;
+ }
+ return isArray(value) ? copyArray(value) : copyObject(value, nativeKeys(value));
+ }
+
+ /**
+ * Performs a
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * comparison between two values to determine if they are equivalent.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.eq(object, object);
+ * // => true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+ function eq(value, other) {
+ return value === other || (value !== value && other !== other);
+ }
+
+ /**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+ };
+
+ /**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+ var isArray = Array.isArray;
+
+ /**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+ function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+ }
+
+ /**
+ * Checks if `value` is classified as a boolean primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
+ * @example
+ *
+ * _.isBoolean(false);
+ * // => true
+ *
+ * _.isBoolean(null);
+ * // => false
+ */
+ function isBoolean(value) {
+ return value === true || value === false ||
+ (isObjectLike(value) && baseGetTag(value) == boolTag);
+ }
+
+ /**
+ * Checks if `value` is classified as a `Date` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ * @example
+ *
+ * _.isDate(new Date);
+ * // => true
+ *
+ * _.isDate('Mon April 23 2012');
+ * // => false
+ */
+ var isDate = baseIsDate;
+
+ /**
+ * Checks if `value` is an empty object, collection, map, or set.
+ *
+ * Objects are considered empty if they have no own enumerable string keyed
+ * properties.
+ *
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
+ * @example
+ *
+ * _.isEmpty(null);
+ * // => true
+ *
+ * _.isEmpty(true);
+ * // => true
+ *
+ * _.isEmpty(1);
+ * // => true
+ *
+ * _.isEmpty([1, 2, 3]);
+ * // => false
+ *
+ * _.isEmpty({ 'a': 1 });
+ * // => false
+ */
+ function isEmpty(value) {
+ if (isArrayLike(value) &&
+ (isArray(value) || isString(value) ||
+ isFunction(value.splice) || isArguments(value))) {
+ return !value.length;
+ }
+ return !nativeKeys(value).length;
+ }
+
+ /**
+ * Performs a deep comparison between two values to determine if they are
+ * equivalent.
+ *
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
+ * by their own, not inherited, enumerable properties. Functions and DOM
+ * nodes are **not** supported.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.isEqual(object, other);
+ * // => true
+ *
+ * object === other;
+ * // => false
+ */
+ function isEqual(value, other) {
+ return baseIsEqual(value, other);
+ }
+
+ /**
+ * Checks if `value` is a finite primitive number.
+ *
+ * **Note:** This method is based on
+ * [`Number.isFinite`](https://mdn.io/Number/isFinite).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
+ * @example
+ *
+ * _.isFinite(3);
+ * // => true
+ *
+ * _.isFinite(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isFinite(Infinity);
+ * // => false
+ *
+ * _.isFinite('3');
+ * // => false
+ */
+ function isFinite(value) {
+ return typeof value == 'number' && nativeIsFinite(value);
+ }
+
+ /**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+ function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+ }
+
+ /**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+ function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ }
+
+ /**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+ function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+ }
+
+ /**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+ function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+ }
+
+ /**
+ * Checks if `value` is `NaN`.
+ *
+ * **Note:** This method is based on
+ * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
+ * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
+ * `undefined` and other non-number values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ * @example
+ *
+ * _.isNaN(NaN);
+ * // => true
+ *
+ * _.isNaN(new Number(NaN));
+ * // => true
+ *
+ * isNaN(undefined);
+ * // => true
+ *
+ * _.isNaN(undefined);
+ * // => false
+ */
+ function isNaN(value) {
+ // An `NaN` primitive is the only value that is not equal to itself.
+ // Perform the `toStringTag` check first to avoid errors with some
+ // ActiveX objects in IE.
+ return isNumber(value) && value != +value;
+ }
+
+ /**
+ * Checks if `value` is `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
+ * @example
+ *
+ * _.isNull(null);
+ * // => true
+ *
+ * _.isNull(void 0);
+ * // => false
+ */
+ function isNull(value) {
+ return value === null;
+ }
+
+ /**
+ * Checks if `value` is classified as a `Number` primitive or object.
+ *
+ * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
+ * classified as numbers, use the `_.isFinite` method.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a number, else `false`.
+ * @example
+ *
+ * _.isNumber(3);
+ * // => true
+ *
+ * _.isNumber(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isNumber(Infinity);
+ * // => true
+ *
+ * _.isNumber('3');
+ * // => false
+ */
+ function isNumber(value) {
+ return typeof value == 'number' ||
+ (isObjectLike(value) && baseGetTag(value) == numberTag);
+ }
+
+ /**
+ * Checks if `value` is classified as a `RegExp` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ * @example
+ *
+ * _.isRegExp(/abc/);
+ * // => true
+ *
+ * _.isRegExp('/abc/');
+ * // => false
+ */
+ var isRegExp = baseIsRegExp;
+
+ /**
+ * Checks if `value` is classified as a `String` primitive or object.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
+ * @example
+ *
+ * _.isString('abc');
+ * // => true
+ *
+ * _.isString(1);
+ * // => false
+ */
+ function isString(value) {
+ return typeof value == 'string' ||
+ (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
+ }
+
+ /**
+ * Checks if `value` is `undefined`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
+ * @example
+ *
+ * _.isUndefined(void 0);
+ * // => true
+ *
+ * _.isUndefined(null);
+ * // => false
+ */
+ function isUndefined(value) {
+ return value === undefined;
+ }
+
+ /**
+ * Converts `value` to an array.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Array} Returns the converted array.
+ * @example
+ *
+ * _.toArray({ 'a': 1, 'b': 2 });
+ * // => [1, 2]
+ *
+ * _.toArray('abc');
+ * // => ['a', 'b', 'c']
+ *
+ * _.toArray(1);
+ * // => []
+ *
+ * _.toArray(null);
+ * // => []
+ */
+ function toArray(value) {
+ if (!isArrayLike(value)) {
+ return values(value);
+ }
+ return value.length ? copyArray(value) : [];
+ }
+
+ /**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3.2);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3.2');
+ * // => 3
+ */
+ var toInteger = Number;
+
+ /**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3.2);
+ * // => 3.2
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3.2');
+ * // => 3.2
+ */
+ var toNumber = Number;
+
+ /**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+ function toString(value) {
+ if (typeof value == 'string') {
+ return value;
+ }
+ return value == null ? '' : (value + '');
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Assigns own enumerable string keyed properties of source objects to the
+ * destination object. Source objects are applied from left to right.
+ * Subsequent sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object` and is loosely based on
+ * [`Object.assign`](https://mdn.io/Object/assign).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assignIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ var assign = createAssigner(function(object, source) {
+ copyObject(source, nativeKeys(source), object);
+ });
+
+ /**
+ * This method is like `_.assign` except that it iterates over own and
+ * inherited source properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extend
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assign
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assignIn({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
+ */
+ var assignIn = createAssigner(function(object, source) {
+ copyObject(source, nativeKeysIn(source), object);
+ });
+
+ /**
+ * This method is like `_.assignIn` except that it accepts `customizer`
+ * which is invoked to produce the assigned values. If `customizer` returns
+ * `undefined`, assignment is handled by the method instead. The `customizer`
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extendWith
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @see _.assignWith
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * return _.isUndefined(objValue) ? srcValue : objValue;
+ * }
+ *
+ * var defaults = _.partialRight(_.assignInWith, customizer);
+ *
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+ var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
+ copyObject(source, keysIn(source), object, customizer);
+ });
+
+ /**
+ * Creates an object that inherits from the `prototype` object. If a
+ * `properties` object is given, its own enumerable string keyed properties
+ * are assigned to the created object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Object
+ * @param {Object} prototype The object to inherit from.
+ * @param {Object} [properties] The properties to assign to the object.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * function Shape() {
+ * this.x = 0;
+ * this.y = 0;
+ * }
+ *
+ * function Circle() {
+ * Shape.call(this);
+ * }
+ *
+ * Circle.prototype = _.create(Shape.prototype, {
+ * 'constructor': Circle
+ * });
+ *
+ * var circle = new Circle;
+ * circle instanceof Circle;
+ * // => true
+ *
+ * circle instanceof Shape;
+ * // => true
+ */
+ function create(prototype, properties) {
+ var result = baseCreate(prototype);
+ return properties == null ? result : assign(result, properties);
+ }
+
+ /**
+ * Assigns own and inherited enumerable string keyed properties of source
+ * objects to the destination object for all destination properties that
+ * resolve to `undefined`. Source objects are applied from left to right.
+ * Once a property is set, additional values of the same property are ignored.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.defaultsDeep
+ * @example
+ *
+ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+ var defaults = baseRest(function(args) {
+ args.push(undefined, assignInDefaults);
+ return assignInWith.apply(undefined, args);
+ });
+
+ /**
+ * Checks if `path` is a direct property of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = { 'a': { 'b': 2 } };
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.has(object, 'a');
+ * // => true
+ *
+ * _.has(object, 'a.b');
+ * // => true
+ *
+ * _.has(object, ['a', 'b']);
+ * // => true
+ *
+ * _.has(other, 'a');
+ * // => false
+ */
+ function has(object, path) {
+ return object != null && hasOwnProperty.call(object, path);
+ }
+
+ /**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+ var keys = nativeKeys;
+
+ /**
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */
+ var keysIn = nativeKeysIn;
+
+ /**
+ * Creates an object composed of the picked `object` properties.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pick(object, ['a', 'c']);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ var pick = flatRest(function(object, paths) {
+ return object == null ? {} : basePick(object, paths);
+ });
+
+ /**
+ * This method is like `_.get` except that if the resolved value is a
+ * function it's invoked with the `this` binding of its parent object and
+ * its result is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to resolve.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
+ *
+ * _.result(object, 'a[0].b.c1');
+ * // => 3
+ *
+ * _.result(object, 'a[0].b.c2');
+ * // => 4
+ *
+ * _.result(object, 'a[0].b.c3', 'default');
+ * // => 'default'
+ *
+ * _.result(object, 'a[0].b.c3', _.constant('default'));
+ * // => 'default'
+ */
+ function result(object, path, defaultValue) {
+ var value = object == null ? undefined : object[path];
+ if (value === undefined) {
+ value = defaultValue;
+ }
+ return isFunction(value) ? value.call(object) : value;
+ }
+
+ /**
+ * Creates an array of the own enumerable string keyed property values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.values(new Foo);
+ * // => [1, 2] (iteration order is not guaranteed)
+ *
+ * _.values('hi');
+ * // => ['h', 'i']
+ */
+ function values(object) {
+ return object == null ? [] : baseValues(object, keys(object));
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
+ * corresponding HTML entities.
+ *
+ * **Note:** No other characters are escaped. To escape additional
+ * characters use a third-party library like [_he_](https://mths.be/he).
+ *
+ * Though the ">" character is escaped for symmetry, characters like
+ * ">" and "/" don't need escaping in HTML and have no special meaning
+ * unless they're part of a tag or unquoted attribute value. See
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
+ * (under "semi-related fun fact") for more details.
+ *
+ * When working with HTML you should always
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
+ * XSS vectors.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escape('fred, barney, & pebbles');
+ * // => 'fred, barney, &amp; pebbles'
+ */
+ function escape(string) {
+ string = toString(string);
+ return (string && reHasUnescapedHtml.test(string))
+ ? string.replace(reUnescapedHtml, escapeHtmlChar)
+ : string;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+ function identity(value) {
+ return value;
+ }
+
+ /**
+ * Creates a function that invokes `func` with the arguments of the created
+ * function. If `func` is a property name, the created function returns the
+ * property value for a given element. If `func` is an array or object, the
+ * created function returns `true` for elements that contain the equivalent
+ * source properties, otherwise it returns `false`.
+ *
+ * @static
+ * @since 4.0.0
+ * @memberOf _
+ * @category Util
+ * @param {*} [func=_.identity] The value to convert to a callback.
+ * @returns {Function} Returns the callback.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
+ * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, _.iteratee(['user', 'fred']));
+ * // => [{ 'user': 'fred', 'age': 40 }]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, _.iteratee('user'));
+ * // => ['barney', 'fred']
+ *
+ * // Create custom iteratee shorthands.
+ * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
+ * return !_.isRegExp(func) ? iteratee(func) : function(string) {
+ * return func.test(string);
+ * };
+ * });
+ *
+ * _.filter(['abc', 'def'], /ef/);
+ * // => ['def']
+ */
+ var iteratee = baseIteratee;
+
+ /**
+ * Creates a function that performs a partial deep comparison between a given
+ * object and `source`, returning `true` if the given object has equivalent
+ * property values, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.isMatch` with `source`
+ * partially applied.
+ *
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
+ * ];
+ *
+ * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
+ * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
+ */
+ function matches(source) {
+ return baseMatches(assign({}, source));
+ }
+
+ /**
+ * Adds all own enumerable string keyed function properties of a source
+ * object to the destination object. If `object` is a function, then methods
+ * are added to its prototype as well.
+ *
+ * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
+ * avoid conflicts caused by modifying the original.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {Function|Object} [object=lodash] The destination object.
+ * @param {Object} source The object of functions to add.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
+ * @returns {Function|Object} Returns `object`.
+ * @example
+ *
+ * function vowels(string) {
+ * return _.filter(string, function(v) {
+ * return /[aeiou]/i.test(v);
+ * });
+ * }
+ *
+ * _.mixin({ 'vowels': vowels });
+ * _.vowels('fred');
+ * // => ['e']
+ *
+ * _('fred').vowels().value();
+ * // => ['e']
+ *
+ * _.mixin({ 'vowels': vowels }, { 'chain': false });
+ * _('fred').vowels();
+ * // => ['e']
+ */
+ function mixin(object, source, options) {
+ var props = keys(source),
+ methodNames = baseFunctions(source, props);
+
+ if (options == null &&
+ !(isObject(source) && (methodNames.length || !props.length))) {
+ options = source;
+ source = object;
+ object = this;
+ methodNames = baseFunctions(source, keys(source));
+ }
+ var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
+ isFunc = isFunction(object);
+
+ baseEach(methodNames, function(methodName) {
+ var func = source[methodName];
+ object[methodName] = func;
+ if (isFunc) {
+ object.prototype[methodName] = function() {
+ var chainAll = this.__chain__;
+ if (chain || chainAll) {
+ var result = object(this.__wrapped__),
+ actions = result.__actions__ = copyArray(this.__actions__);
+
+ actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
+ result.__chain__ = chainAll;
+ return result;
+ }
+ return func.apply(object, arrayPush([this.value()], arguments));
+ };
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * Reverts the `_` variable to its previous value and returns a reference to
+ * the `lodash` function.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @returns {Function} Returns the `lodash` function.
+ * @example
+ *
+ * var lodash = _.noConflict();
+ */
+ function noConflict() {
+ if (root._ === this) {
+ root._ = oldDash;
+ }
+ return this;
+ }
+
+ /**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+ function noop() {
+ // No operation performed.
+ }
+
+ /**
+ * Generates a unique ID. If `prefix` is given, the ID is appended to it.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {string} [prefix=''] The value to prefix the ID with.
+ * @returns {string} Returns the unique ID.
+ * @example
+ *
+ * _.uniqueId('contact_');
+ * // => 'contact_104'
+ *
+ * _.uniqueId();
+ * // => '105'
+ */
+ function uniqueId(prefix) {
+ var id = ++idCounter;
+ return toString(prefix) + id;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Computes the maximum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * _.max([4, 2, 8, 6]);
+ * // => 8
+ *
+ * _.max([]);
+ * // => undefined
+ */
+ function max(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseGt)
+ : undefined;
+ }
+
+ /**
+ * Computes the minimum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * _.min([4, 2, 8, 6]);
+ * // => 2
+ *
+ * _.min([]);
+ * // => undefined
+ */
+ function min(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseLt)
+ : undefined;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return wrapped values in chain sequences.
+ lodash.assignIn = assignIn;
+ lodash.before = before;
+ lodash.bind = bind;
+ lodash.chain = chain;
+ lodash.compact = compact;
+ lodash.concat = concat;
+ lodash.create = create;
+ lodash.defaults = defaults;
+ lodash.defer = defer;
+ lodash.delay = delay;
+ lodash.filter = filter;
+ lodash.flatten = flatten;
+ lodash.flattenDeep = flattenDeep;
+ lodash.iteratee = iteratee;
+ lodash.keys = keys;
+ lodash.map = map;
+ lodash.matches = matches;
+ lodash.mixin = mixin;
+ lodash.negate = negate;
+ lodash.once = once;
+ lodash.pick = pick;
+ lodash.slice = slice;
+ lodash.sortBy = sortBy;
+ lodash.tap = tap;
+ lodash.thru = thru;
+ lodash.toArray = toArray;
+ lodash.values = values;
+
+ // Add aliases.
+ lodash.extend = assignIn;
+
+ // Add methods to `lodash.prototype`.
+ mixin(lodash, lodash);
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return unwrapped values in chain sequences.
+ lodash.clone = clone;
+ lodash.escape = escape;
+ lodash.every = every;
+ lodash.find = find;
+ lodash.forEach = forEach;
+ lodash.has = has;
+ lodash.head = head;
+ lodash.identity = identity;
+ lodash.indexOf = indexOf;
+ lodash.isArguments = isArguments;
+ lodash.isArray = isArray;
+ lodash.isBoolean = isBoolean;
+ lodash.isDate = isDate;
+ lodash.isEmpty = isEmpty;
+ lodash.isEqual = isEqual;
+ lodash.isFinite = isFinite;
+ lodash.isFunction = isFunction;
+ lodash.isNaN = isNaN;
+ lodash.isNull = isNull;
+ lodash.isNumber = isNumber;
+ lodash.isObject = isObject;
+ lodash.isRegExp = isRegExp;
+ lodash.isString = isString;
+ lodash.isUndefined = isUndefined;
+ lodash.last = last;
+ lodash.max = max;
+ lodash.min = min;
+ lodash.noConflict = noConflict;
+ lodash.noop = noop;
+ lodash.reduce = reduce;
+ lodash.result = result;
+ lodash.size = size;
+ lodash.some = some;
+ lodash.uniqueId = uniqueId;
+
+ // Add aliases.
+ lodash.each = forEach;
+ lodash.first = head;
+
+ mixin(lodash, (function() {
+ var source = {};
+ baseForOwn(lodash, function(func, methodName) {
+ if (!hasOwnProperty.call(lodash.prototype, methodName)) {
+ source[methodName] = func;
+ }
+ });
+ return source;
+ }()), { 'chain': false });
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * The semantic version number.
+ *
+ * @static
+ * @memberOf _
+ * @type {string}
+ */
+ lodash.VERSION = VERSION;
+
+ // Add `Array` methods to `lodash.prototype`.
+ baseEach(['pop', 'join', 'replace', 'reverse', 'split', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
+ var func = (/^(?:replace|split)$/.test(methodName) ? String.prototype : arrayProto)[methodName],
+ chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
+ retUnwrapped = /^(?:pop|join|replace|shift)$/.test(methodName);
+
+ lodash.prototype[methodName] = function() {
+ var args = arguments;
+ if (retUnwrapped && !this.__chain__) {
+ var value = this.value();
+ return func.apply(isArray(value) ? value : [], args);
+ }
+ return this[chainName](function(value) {
+ return func.apply(isArray(value) ? value : [], args);
+ });
+ };
+ });
+
+ // Add chain sequence methods to the `lodash` wrapper.
+ lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
+
+ /*--------------------------------------------------------------------------*/
+
+ // Some AMD build optimizers, like r.js, check for condition patterns like:
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
+ // Expose Lodash on the global object to prevent errors when Lodash is
+ // loaded by a script tag in the presence of an AMD loader.
+ // See http://requirejs.org/docs/errors.html#mismatch for more details.
+ // Use `_.noConflict` to remove Lodash from the global object.
+ root._ = lodash;
+
+ // Define as an anonymous module so, through path mapping, it can be
+ // referenced as the "underscore" module.
+ define(function() {
+ return lodash;
+ });
+ }
+ // Check for `exports` after `define` in case a build optimizer adds it.
+ else if (freeModule) {
+ // Export for Node.js.
+ (freeModule.exports = lodash)._ = lodash;
+ // Export for CommonJS support.
+ freeExports._ = lodash;
+ }
+ else {
+ // Export to the global object.
+ root._ = lodash;
+ }
+}.call(this));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.min.js
new file mode 100644
index 0000000..ee223b2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/core.min.js
@@ -0,0 +1,29 @@
+/**
+ * @license
+ * Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
+ * Build: `lodash core -o ./dist/lodash.core.js`
+ */
+;(function(){function n(n){return K(n)&&pn.call(n,"callee")&&!bn.call(n,"callee")}function t(n,t){return n.push.apply(n,t),n}function r(n){return function(t){return null==t?nn:t[n]}}function e(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function u(n,t){return d(t,function(t){return n[t]})}function o(n){return n instanceof i?n:new i(n)}function i(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function c(n,t,r,e){return n===nn||M(n,ln[r])&&!pn.call(e,r)?t:n}function f(n,t,r){
+if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(nn,r)},t)}function a(n,t){var r=true;return mn(n,function(n,e,u){return r=!!t(n,e,u)}),r}function l(n,t,r){for(var e=-1,u=n.length;++e<u;){var o=n[e],i=t(o);if(null!=i&&(c===nn?i===i:r(i,c)))var c=i,f=o}return f}function p(n,t){var r=[];return mn(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function s(n,r,e,u,o){var i=-1,c=n.length;for(e||(e=D),o||(o=[]);++i<c;){var f=n[i];0<r&&e(f)?1<r?s(f,r-1,e,u,o):t(o,f):u||(o[o.length]=f);
+}return o}function h(n,t){return n&&On(n,t,In)}function v(n,t){return p(t,function(t){return V(n[t])})}function y(n,t){return n>t}function b(n,t,r,e,u){return n===t||(null==n||null==t||!H(n)&&!K(t)?n!==n&&t!==t:g(n,t,r,e,b,u))}function g(n,t,r,e,u,o){var i=Nn(n),c=Nn(t),f="[object Array]",a="[object Array]";i||(f=hn.call(n),f="[object Arguments]"==f?"[object Object]":f),c||(a=hn.call(t),a="[object Arguments]"==a?"[object Object]":a);var l="[object Object]"==f,c="[object Object]"==a,a=f==a;o||(o=[]);
+var p=An(o,function(t){return t[0]==n}),s=An(o,function(n){return n[0]==t});if(p&&s)return p[1]==t;if(o.push([n,t]),o.push([t,n]),a&&!l){if(i)r=B(n,t,r,e,u,o);else n:{switch(f){case"[object Boolean]":case"[object Date]":case"[object Number]":r=M(+n,+t);break n;case"[object Error]":r=n.name==t.name&&n.message==t.message;break n;case"[object RegExp]":case"[object String]":r=n==t+"";break n}r=false}return o.pop(),r}return 1&r||(i=l&&pn.call(n,"__wrapped__"),f=c&&pn.call(t,"__wrapped__"),!i&&!f)?!!a&&(r=R(n,t,r,e,u,o),
+o.pop(),r):(i=i?n.value():n,f=f?t.value():t,r=u(i,f,r,e,o),o.pop(),r)}function _(n){return typeof n=="function"?n:null==n?Y:(typeof n=="object"?m:r)(n)}function j(n,t){return n<t}function d(n,t){var r=-1,e=U(n)?Array(n.length):[];return mn(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function m(n){var t=_n(n);return function(r){var e=t.length;if(null==r)return!e;for(r=Object(r);e--;){var u=t[e];if(!(u in r&&b(n[u],r[u],3)))return false}return true}}function O(n,t){return n=Object(n),G(t,function(t,r){return r in n&&(t[r]=n[r]),
+t},{})}function x(n){return xn(q(n,void 0,Y),n+"")}function A(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e<u;)r[e]=n[e+t];return r}function E(n){return A(n,0,n.length)}function w(n,t){var r;return mn(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function k(n,r){return G(r,function(n,r){return r.func.apply(r.thisArg,t([n],r.args))},n)}function N(n,t,r,e){var u=!r;r||(r={});for(var o=-1,i=t.length;++o<i;){var c=t[o],f=e?e(r[c],n[c],c,r,n):nn;
+if(f===nn&&(f=n[c]),u)r[c]=f;else{var a=r,l=a[c];pn.call(a,c)&&M(l,f)&&(f!==nn||c in a)||(a[c]=f)}}return r}function F(n){return x(function(t,r){var e=-1,u=r.length,o=1<u?r[u-1]:nn,o=3<n.length&&typeof o=="function"?(u--,o):nn;for(t=Object(t);++e<u;){var i=r[e];i&&n(t,i,e,o)}return t})}function S(n){return function(){var t=arguments,r=dn(n.prototype),t=n.apply(r,t);return H(t)?t:r}}function T(n,t,r){function e(){for(var o=-1,i=arguments.length,c=-1,f=r.length,a=Array(f+i),l=this&&this!==on&&this instanceof e?u:n;++c<f;)a[c]=r[c];
+for(;i--;)a[c++]=arguments[++o];return l.apply(t,a)}if(typeof n!="function")throw new TypeError("Expected a function");var u=S(n);return e}function B(n,t,r,e,u,o){var i=n.length,c=t.length;if(i!=c&&!(1&r&&c>i))return false;for(var c=-1,f=true,a=2&r?[]:nn;++c<i;){var l=n[c],p=t[c];if(void 0!==nn){f=false;break}if(a){if(!w(t,function(n,t){if(!z(a,t)&&(l===n||u(l,n,r,e,o)))return a.push(t)})){f=false;break}}else if(l!==p&&!u(l,p,r,e,o)){f=false;break}}return f}function R(n,t,r,e,u,o){var i=1&r,c=In(n),f=c.length,a=In(t).length;
+if(f!=a&&!i)return false;for(var l=f;l--;){var p=c[l];if(!(i?p in t:pn.call(t,p)))return false}for(a=true;++l<f;){var p=c[l],s=n[p],h=t[p];if(void 0!==nn||s!==h&&!u(s,h,r,e,o)){a=false;break}i||(i="constructor"==p)}return a&&!i&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(a=false)),a}function D(t){return Nn(t)||n(t)}function I(n){var t=[];if(null!=n)for(var r in Object(n))t.push(r);return t}function q(n,t,r){
+return t=jn(t===nn?n.length-1:t,0),function(){for(var e=arguments,u=-1,o=jn(e.length-t,0),i=Array(o);++u<o;)i[u]=e[t+u];for(u=-1,o=Array(t+1);++u<t;)o[u]=e[u];return o[t]=r(i),n.apply(this,o)}}function $(n){return(null==n?0:n.length)?s(n,1):[]}function P(n){return n&&n.length?n[0]:nn}function z(n,t,r){var e=null==n?0:n.length;r=typeof r=="number"?0>r?jn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++r<e;){var o=n[r];if(u?o===t:o!==o)return r}return-1}function C(n,t){return mn(n,_(t))}function G(n,t,r){return e(n,_(t),r,3>arguments.length,mn);
+}function J(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Fn(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=nn),r}}function M(n,t){return n===t||n!==n&&t!==t}function U(n){var t;return(t=null!=n)&&(t=n.length,t=typeof t=="number"&&-1<t&&0==t%1&&9007199254740991>=t),t&&!V(n)}function V(n){return!!H(n)&&(n=hn.call(n),"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n)}function H(n){var t=typeof n;
+return null!=n&&("object"==t||"function"==t)}function K(n){return null!=n&&typeof n=="object"}function L(n){return typeof n=="number"||K(n)&&"[object Number]"==hn.call(n)}function Q(n){return typeof n=="string"||!Nn(n)&&K(n)&&"[object String]"==hn.call(n)}function W(n){return typeof n=="string"?n:null==n?"":n+""}function X(n){return null==n?[]:u(n,In(n))}function Y(n){return n}function Z(n,r,e){var u=In(r),o=v(r,u);null!=e||H(r)&&(o.length||!u.length)||(e=r,r=n,n=this,o=v(r,In(r)));var i=!(H(e)&&"chain"in e&&!e.chain),c=V(n);
+return mn(o,function(e){var u=r[e];n[e]=u,c&&(n.prototype[e]=function(){var r=this.__chain__;if(i||r){var e=n(this.__wrapped__);return(e.__actions__=E(this.__actions__)).push({func:u,args:arguments,thisArg:n}),e.__chain__=r,e}return u.apply(n,t([this.value()],arguments))})}),n}var nn,tn=1/0,rn=/[&<>"']/g,en=RegExp(rn.source),un=typeof self=="object"&&self&&self.Object===Object&&self,on=typeof global=="object"&&global&&global.Object===Object&&global||un||Function("return this")(),cn=(un=typeof exports=="object"&&exports&&!exports.nodeType&&exports)&&typeof module=="object"&&module&&!module.nodeType&&module,fn=function(n){
+return function(t){return null==n?nn:n[t]}}({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}),an=Array.prototype,ln=Object.prototype,pn=ln.hasOwnProperty,sn=0,hn=ln.toString,vn=on._,yn=Object.create,bn=ln.propertyIsEnumerable,gn=on.isFinite,_n=function(n,t){return function(r){return n(t(r))}}(Object.keys,Object),jn=Math.max,dn=function(){function n(){}return function(t){return H(t)?yn?yn(t):(n.prototype=t,t=new n,n.prototype=nn,t):{}}}();i.prototype=dn(o.prototype),i.prototype.constructor=i;
+var mn=function(n,t){return function(r,e){if(null==r)return r;if(!U(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}(h),On=function(n){return function(t,r,e){var u=-1,o=Object(t);e=e(t);for(var i=e.length;i--;){var c=e[n?i:++u];if(false===r(o[c],c,o))break}return t}}(),xn=Y,An=function(n){return function(t,r,e){var u=Object(t);if(!U(t)){var o=_(r);t=In(t),r=function(n){return o(u[n],n,u)}}return r=n(t,r,e),-1<r?u[o?t[r]:r]:nn}}(function(n,t,r){var e=null==n?0:n.length;
+if(!e)return-1;r=null==r?0:Fn(r),0>r&&(r=jn(e+r,0));n:{for(t=_(t),e=n.length,r+=-1;++r<e;)if(t(n[r],r,n)){n=r;break n}n=-1}return n}),En=x(function(n,t,r){return T(n,t,r)}),wn=x(function(n,t){return f(n,1,t)}),kn=x(function(n,t,r){return f(n,Sn(t)||0,r)}),Nn=Array.isArray,Fn=Number,Sn=Number,Tn=F(function(n,t){N(t,_n(t),n)}),Bn=F(function(n,t){N(t,I(t),n)}),Rn=F(function(n,t,r,e){N(t,qn(t),n,e)}),Dn=x(function(n){return n.push(nn,c),Rn.apply(nn,n)}),In=_n,qn=I,$n=function(n){return xn(q(n,nn,$),n+"");
+}(function(n,t){return null==n?{}:O(n,t)});o.assignIn=Bn,o.before=J,o.bind=En,o.chain=function(n){return n=o(n),n.__chain__=true,n},o.compact=function(n){return p(n,Boolean)},o.concat=function(){var n=arguments.length;if(!n)return[];for(var r=Array(n-1),e=arguments[0];n--;)r[n-1]=arguments[n];return t(Nn(e)?E(e):[e],s(r,1))},o.create=function(n,t){var r=dn(n);return null==t?r:Tn(r,t)},o.defaults=Dn,o.defer=wn,o.delay=kn,o.filter=function(n,t){return p(n,_(t))},o.flatten=$,o.flattenDeep=function(n){
+return(null==n?0:n.length)?s(n,tn):[]},o.iteratee=_,o.keys=In,o.map=function(n,t){return d(n,_(t))},o.matches=function(n){return m(Tn({},n))},o.mixin=Z,o.negate=function(n){if(typeof n!="function")throw new TypeError("Expected a function");return function(){return!n.apply(this,arguments)}},o.once=function(n){return J(2,n)},o.pick=$n,o.slice=function(n,t,r){var e=null==n?0:n.length;return r=r===nn?e:+r,e?A(n,null==t?0:+t,r):[]},o.sortBy=function(n,t){var e=0;return t=_(t),d(d(n,function(n,r,u){return{
+value:n,index:e++,criteria:t(n,r,u)}}).sort(function(n,t){var r;n:{r=n.criteria;var e=t.criteria;if(r!==e){var u=r!==nn,o=null===r,i=r===r,c=e!==nn,f=null===e,a=e===e;if(!f&&r>e||o&&c&&a||!u&&a||!i){r=1;break n}if(!o&&r<e||f&&u&&i||!c&&i||!a){r=-1;break n}}r=0}return r||n.index-t.index}),r("value"))},o.tap=function(n,t){return t(n),n},o.thru=function(n,t){return t(n)},o.toArray=function(n){return U(n)?n.length?E(n):[]:X(n)},o.values=X,o.extend=Bn,Z(o,o),o.clone=function(n){return H(n)?Nn(n)?E(n):N(n,_n(n)):n;
+},o.escape=function(n){return(n=W(n))&&en.test(n)?n.replace(rn,fn):n},o.every=function(n,t,r){return t=r?nn:t,a(n,_(t))},o.find=An,o.forEach=C,o.has=function(n,t){return null!=n&&pn.call(n,t)},o.head=P,o.identity=Y,o.indexOf=z,o.isArguments=n,o.isArray=Nn,o.isBoolean=function(n){return true===n||false===n||K(n)&&"[object Boolean]"==hn.call(n)},o.isDate=function(n){return K(n)&&"[object Date]"==hn.call(n)},o.isEmpty=function(t){return U(t)&&(Nn(t)||Q(t)||V(t.splice)||n(t))?!t.length:!_n(t).length},o.isEqual=function(n,t){
+return b(n,t)},o.isFinite=function(n){return typeof n=="number"&&gn(n)},o.isFunction=V,o.isNaN=function(n){return L(n)&&n!=+n},o.isNull=function(n){return null===n},o.isNumber=L,o.isObject=H,o.isRegExp=function(n){return K(n)&&"[object RegExp]"==hn.call(n)},o.isString=Q,o.isUndefined=function(n){return n===nn},o.last=function(n){var t=null==n?0:n.length;return t?n[t-1]:nn},o.max=function(n){return n&&n.length?l(n,Y,y):nn},o.min=function(n){return n&&n.length?l(n,Y,j):nn},o.noConflict=function(){return on._===this&&(on._=vn),
+this},o.noop=function(){},o.reduce=G,o.result=function(n,t,r){return t=null==n?nn:n[t],t===nn&&(t=r),V(t)?t.call(n):t},o.size=function(n){return null==n?0:(n=U(n)?n:_n(n),n.length)},o.some=function(n,t,r){return t=r?nn:t,w(n,_(t))},o.uniqueId=function(n){var t=++sn;return W(n)+t},o.each=C,o.first=P,Z(o,function(){var n={};return h(o,function(t,r){pn.call(o.prototype,r)||(n[r]=t)}),n}(),{chain:false}),o.VERSION="4.17.2",mn("pop join replace reverse split push shift sort splice unshift".split(" "),function(n){
+var t=(/^(?:replace|split)$/.test(n)?String.prototype:an)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|join|replace|shift)$/.test(n);o.prototype[n]=function(){var n=arguments;if(e&&!this.__chain__){var u=this.value();return t.apply(Nn(u)?u:[],n)}return this[r](function(r){return t.apply(Nn(r)?r:[],n)})}}),o.prototype.toJSON=o.prototype.valueOf=o.prototype.value=function(){return k(this.__wrapped__,this.__actions__)},typeof define=="function"&&typeof define.amd=="object"&&define.amd?(on._=o,
+define(function(){return o})):cn?((cn.exports=o)._=o,un._=o):on._=o}).call(this); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/countBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/countBy.js
new file mode 100644
index 0000000..0e88abc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/countBy.js
@@ -0,0 +1,40 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ createAggregator = require('./_createAggregator');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The corresponding value of
+ * each key is the number of times the key was returned by `iteratee`. The
+ * iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * _.countBy([6.1, 4.2, 6.3], Math.floor);
+ * // => { '4': 1, '6': 2 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.countBy(['one', 'two', 'three'], 'length');
+ * // => { '3': 2, '5': 1 }
+ */
+var countBy = createAggregator(function(result, value, key) {
+ if (hasOwnProperty.call(result, key)) {
+ ++result[key];
+ } else {
+ baseAssignValue(result, key, 1);
+ }
+});
+
+module.exports = countBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/create.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/create.js
new file mode 100644
index 0000000..919edb8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/create.js
@@ -0,0 +1,43 @@
+var baseAssign = require('./_baseAssign'),
+ baseCreate = require('./_baseCreate');
+
+/**
+ * Creates an object that inherits from the `prototype` object. If a
+ * `properties` object is given, its own enumerable string keyed properties
+ * are assigned to the created object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Object
+ * @param {Object} prototype The object to inherit from.
+ * @param {Object} [properties] The properties to assign to the object.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * function Shape() {
+ * this.x = 0;
+ * this.y = 0;
+ * }
+ *
+ * function Circle() {
+ * Shape.call(this);
+ * }
+ *
+ * Circle.prototype = _.create(Shape.prototype, {
+ * 'constructor': Circle
+ * });
+ *
+ * var circle = new Circle;
+ * circle instanceof Circle;
+ * // => true
+ *
+ * circle instanceof Shape;
+ * // => true
+ */
+function create(prototype, properties) {
+ var result = baseCreate(prototype);
+ return properties == null ? result : baseAssign(result, properties);
+}
+
+module.exports = create;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curry.js
new file mode 100644
index 0000000..918db1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curry.js
@@ -0,0 +1,57 @@
+var createWrap = require('./_createWrap');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_CURRY_FLAG = 8;
+
+/**
+ * Creates a function that accepts arguments of `func` and either invokes
+ * `func` returning its result, if at least `arity` number of arguments have
+ * been provided, or returns a function that accepts the remaining `func`
+ * arguments, and so on. The arity of `func` may be specified if `func.length`
+ * is not sufficient.
+ *
+ * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
+ * may be used as a placeholder for provided arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of curried functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Function
+ * @param {Function} func The function to curry.
+ * @param {number} [arity=func.length] The arity of `func`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new curried function.
+ * @example
+ *
+ * var abc = function(a, b, c) {
+ * return [a, b, c];
+ * };
+ *
+ * var curried = _.curry(abc);
+ *
+ * curried(1)(2)(3);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2)(3);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2, 3);
+ * // => [1, 2, 3]
+ *
+ * // Curried with placeholders.
+ * curried(1)(_, 3)(2);
+ * // => [1, 2, 3]
+ */
+function curry(func, arity, guard) {
+ arity = guard ? undefined : arity;
+ var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ result.placeholder = curry.placeholder;
+ return result;
+}
+
+// Assign default placeholders.
+curry.placeholder = {};
+
+module.exports = curry;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curryRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curryRight.js
new file mode 100644
index 0000000..c85b6f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/curryRight.js
@@ -0,0 +1,54 @@
+var createWrap = require('./_createWrap');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_CURRY_RIGHT_FLAG = 16;
+
+/**
+ * This method is like `_.curry` except that arguments are applied to `func`
+ * in the manner of `_.partialRight` instead of `_.partial`.
+ *
+ * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for provided arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of curried functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to curry.
+ * @param {number} [arity=func.length] The arity of `func`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new curried function.
+ * @example
+ *
+ * var abc = function(a, b, c) {
+ * return [a, b, c];
+ * };
+ *
+ * var curried = _.curryRight(abc);
+ *
+ * curried(3)(2)(1);
+ * // => [1, 2, 3]
+ *
+ * curried(2, 3)(1);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2, 3);
+ * // => [1, 2, 3]
+ *
+ * // Curried with placeholders.
+ * curried(3)(1, _)(2);
+ * // => [1, 2, 3]
+ */
+function curryRight(func, arity, guard) {
+ arity = guard ? undefined : arity;
+ var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ result.placeholder = curryRight.placeholder;
+ return result;
+}
+
+// Assign default placeholders.
+curryRight.placeholder = {};
+
+module.exports = curryRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/date.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/date.js
new file mode 100644
index 0000000..cbf5b41
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/date.js
@@ -0,0 +1,3 @@
+module.exports = {
+ 'now': require('./now')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/debounce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/debounce.js
new file mode 100644
index 0000000..04d7dfd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/debounce.js
@@ -0,0 +1,188 @@
+var isObject = require('./isObject'),
+ now = require('./now'),
+ toNumber = require('./toNumber');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+/**
+ * Creates a debounced function that delays invoking `func` until after `wait`
+ * milliseconds have elapsed since the last time the debounced function was
+ * invoked. The debounced function comes with a `cancel` method to cancel
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
+ * Provide `options` to indicate whether `func` should be invoked on the
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
+ * with the last arguments provided to the debounced function. Subsequent
+ * calls to the debounced function return the result of the last `func`
+ * invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the debounced function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.debounce` and `_.throttle`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to debounce.
+ * @param {number} [wait=0] The number of milliseconds to delay.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=false]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {number} [options.maxWait]
+ * The maximum time `func` is allowed to be delayed before it's invoked.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new debounced function.
+ * @example
+ *
+ * // Avoid costly calculations while the window size is in flux.
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
+ *
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
+ * 'leading': true,
+ * 'trailing': false
+ * }));
+ *
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
+ * var source = new EventSource('/stream');
+ * jQuery(source).on('message', debounced);
+ *
+ * // Cancel the trailing debounced invocation.
+ * jQuery(window).on('popstate', debounced.cancel);
+ */
+function debounce(func, wait, options) {
+ var lastArgs,
+ lastThis,
+ maxWait,
+ result,
+ timerId,
+ lastCallTime,
+ lastInvokeTime = 0,
+ leading = false,
+ maxing = false,
+ trailing = true;
+
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ wait = toNumber(wait) || 0;
+ if (isObject(options)) {
+ leading = !!options.leading;
+ maxing = 'maxWait' in options;
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
+ }
+
+ function invokeFunc(time) {
+ var args = lastArgs,
+ thisArg = lastThis;
+
+ lastArgs = lastThis = undefined;
+ lastInvokeTime = time;
+ result = func.apply(thisArg, args);
+ return result;
+ }
+
+ function leadingEdge(time) {
+ // Reset any `maxWait` timer.
+ lastInvokeTime = time;
+ // Start the timer for the trailing edge.
+ timerId = setTimeout(timerExpired, wait);
+ // Invoke the leading edge.
+ return leading ? invokeFunc(time) : result;
+ }
+
+ function remainingWait(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime,
+ result = wait - timeSinceLastCall;
+
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
+ }
+
+ function shouldInvoke(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime;
+
+ // Either this is the first call, activity has stopped and we're at the
+ // trailing edge, the system time has gone backwards and we're treating
+ // it as the trailing edge, or we've hit the `maxWait` limit.
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
+ }
+
+ function timerExpired() {
+ var time = now();
+ if (shouldInvoke(time)) {
+ return trailingEdge(time);
+ }
+ // Restart the timer.
+ timerId = setTimeout(timerExpired, remainingWait(time));
+ }
+
+ function trailingEdge(time) {
+ timerId = undefined;
+
+ // Only invoke if we have `lastArgs` which means `func` has been
+ // debounced at least once.
+ if (trailing && lastArgs) {
+ return invokeFunc(time);
+ }
+ lastArgs = lastThis = undefined;
+ return result;
+ }
+
+ function cancel() {
+ if (timerId !== undefined) {
+ clearTimeout(timerId);
+ }
+ lastInvokeTime = 0;
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
+ }
+
+ function flush() {
+ return timerId === undefined ? result : trailingEdge(now());
+ }
+
+ function debounced() {
+ var time = now(),
+ isInvoking = shouldInvoke(time);
+
+ lastArgs = arguments;
+ lastThis = this;
+ lastCallTime = time;
+
+ if (isInvoking) {
+ if (timerId === undefined) {
+ return leadingEdge(lastCallTime);
+ }
+ if (maxing) {
+ // Handle invocations in a tight loop.
+ timerId = setTimeout(timerExpired, wait);
+ return invokeFunc(lastCallTime);
+ }
+ }
+ if (timerId === undefined) {
+ timerId = setTimeout(timerExpired, wait);
+ }
+ return result;
+ }
+ debounced.cancel = cancel;
+ debounced.flush = flush;
+ return debounced;
+}
+
+module.exports = debounce;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/deburr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/deburr.js
new file mode 100644
index 0000000..f85e314
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/deburr.js
@@ -0,0 +1,45 @@
+var deburrLetter = require('./_deburrLetter'),
+ toString = require('./toString');
+
+/** Used to match Latin Unicode letters (excluding mathematical operators). */
+var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
+
+/** Used to compose unicode character classes. */
+var rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
+
+/** Used to compose unicode capture groups. */
+var rsCombo = '[' + rsComboRange + ']';
+
+/**
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
+ */
+var reComboMark = RegExp(rsCombo, 'g');
+
+/**
+ * Deburrs `string` by converting
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
+ * letters to basic Latin letters and removing
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to deburr.
+ * @returns {string} Returns the deburred string.
+ * @example
+ *
+ * _.deburr('déjà vu');
+ * // => 'deja vu'
+ */
+function deburr(string) {
+ string = toString(string);
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
+}
+
+module.exports = deburr;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultTo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultTo.js
new file mode 100644
index 0000000..5b33359
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultTo.js
@@ -0,0 +1,25 @@
+/**
+ * Checks `value` to determine whether a default value should be returned in
+ * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
+ * or `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Util
+ * @param {*} value The value to check.
+ * @param {*} defaultValue The default value.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * _.defaultTo(1, 10);
+ * // => 1
+ *
+ * _.defaultTo(undefined, 10);
+ * // => 10
+ */
+function defaultTo(value, defaultValue) {
+ return (value == null || value !== value) ? defaultValue : value;
+}
+
+module.exports = defaultTo;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaults.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaults.js
new file mode 100644
index 0000000..5333b42
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaults.js
@@ -0,0 +1,32 @@
+var apply = require('./_apply'),
+ assignInDefaults = require('./_assignInDefaults'),
+ assignInWith = require('./assignInWith'),
+ baseRest = require('./_baseRest');
+
+/**
+ * Assigns own and inherited enumerable string keyed properties of source
+ * objects to the destination object for all destination properties that
+ * resolve to `undefined`. Source objects are applied from left to right.
+ * Once a property is set, additional values of the same property are ignored.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.defaultsDeep
+ * @example
+ *
+ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+var defaults = baseRest(function(args) {
+ args.push(undefined, assignInDefaults);
+ return apply(assignInWith, undefined, args);
+});
+
+module.exports = defaults;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultsDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultsDeep.js
new file mode 100644
index 0000000..41680ed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defaultsDeep.js
@@ -0,0 +1,30 @@
+var apply = require('./_apply'),
+ baseRest = require('./_baseRest'),
+ mergeDefaults = require('./_mergeDefaults'),
+ mergeWith = require('./mergeWith');
+
+/**
+ * This method is like `_.defaults` except that it recursively assigns
+ * default properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.defaults
+ * @example
+ *
+ * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
+ * // => { 'a': { 'b': 2, 'c': 3 } }
+ */
+var defaultsDeep = baseRest(function(args) {
+ args.push(undefined, mergeDefaults);
+ return apply(mergeWith, undefined, args);
+});
+
+module.exports = defaultsDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defer.js
new file mode 100644
index 0000000..f6d6c6f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/defer.js
@@ -0,0 +1,26 @@
+var baseDelay = require('./_baseDelay'),
+ baseRest = require('./_baseRest');
+
+/**
+ * Defers invoking the `func` until the current call stack has cleared. Any
+ * additional arguments are provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to defer.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.defer(function(text) {
+ * console.log(text);
+ * }, 'deferred');
+ * // => Logs 'deferred' after one millisecond.
+ */
+var defer = baseRest(function(func, args) {
+ return baseDelay(func, 1, args);
+});
+
+module.exports = defer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/delay.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/delay.js
new file mode 100644
index 0000000..bd55479
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/delay.js
@@ -0,0 +1,28 @@
+var baseDelay = require('./_baseDelay'),
+ baseRest = require('./_baseRest'),
+ toNumber = require('./toNumber');
+
+/**
+ * Invokes `func` after `wait` milliseconds. Any additional arguments are
+ * provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.delay(function(text) {
+ * console.log(text);
+ * }, 1000, 'later');
+ * // => Logs 'later' after one second.
+ */
+var delay = baseRest(function(func, wait, args) {
+ return baseDelay(func, toNumber(wait) || 0, args);
+});
+
+module.exports = delay;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/difference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/difference.js
new file mode 100644
index 0000000..fa28bb3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/difference.js
@@ -0,0 +1,33 @@
+var baseDifference = require('./_baseDifference'),
+ baseFlatten = require('./_baseFlatten'),
+ baseRest = require('./_baseRest'),
+ isArrayLikeObject = require('./isArrayLikeObject');
+
+/**
+ * Creates an array of `array` values not included in the other given arrays
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
+ *
+ * **Note:** Unlike `_.pullAll`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.without, _.xor
+ * @example
+ *
+ * _.difference([2, 1], [2, 3]);
+ * // => [1]
+ */
+var difference = baseRest(function(array, values) {
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
+ : [];
+});
+
+module.exports = difference;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceBy.js
new file mode 100644
index 0000000..2cd63e7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceBy.js
@@ -0,0 +1,44 @@
+var baseDifference = require('./_baseDifference'),
+ baseFlatten = require('./_baseFlatten'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.difference` except that it accepts `iteratee` which
+ * is invoked for each element of `array` and `values` to generate the criterion
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
+ * // => [{ 'x': 2 }]
+ */
+var differenceBy = baseRest(function(array, values) {
+ var iteratee = last(values);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2))
+ : [];
+});
+
+module.exports = differenceBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceWith.js
new file mode 100644
index 0000000..c0233f4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/differenceWith.js
@@ -0,0 +1,40 @@
+var baseDifference = require('./_baseDifference'),
+ baseFlatten = require('./_baseFlatten'),
+ baseRest = require('./_baseRest'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.difference` except that it accepts `comparator`
+ * which is invoked to compare elements of `array` to `values`. The order and
+ * references of result values are determined by the first array. The comparator
+ * is invoked with two arguments: (arrVal, othVal).
+ *
+ * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ *
+ * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
+ * // => [{ 'x': 2, 'y': 1 }]
+ */
+var differenceWith = baseRest(function(array, values) {
+ var comparator = last(values);
+ if (isArrayLikeObject(comparator)) {
+ comparator = undefined;
+ }
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
+ : [];
+});
+
+module.exports = differenceWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/divide.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/divide.js
new file mode 100644
index 0000000..8cae0cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/divide.js
@@ -0,0 +1,22 @@
+var createMathOperation = require('./_createMathOperation');
+
+/**
+ * Divide two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {number} dividend The first number in a division.
+ * @param {number} divisor The second number in a division.
+ * @returns {number} Returns the quotient.
+ * @example
+ *
+ * _.divide(6, 4);
+ * // => 1.5
+ */
+var divide = createMathOperation(function(dividend, divisor) {
+ return dividend / divisor;
+}, 1);
+
+module.exports = divide;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/drop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/drop.js
new file mode 100644
index 0000000..d5c3cba
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/drop.js
@@ -0,0 +1,38 @@
+var baseSlice = require('./_baseSlice'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a slice of `array` with `n` elements dropped from the beginning.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to drop.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.drop([1, 2, 3]);
+ * // => [2, 3]
+ *
+ * _.drop([1, 2, 3], 2);
+ * // => [3]
+ *
+ * _.drop([1, 2, 3], 5);
+ * // => []
+ *
+ * _.drop([1, 2, 3], 0);
+ * // => [1, 2, 3]
+ */
+function drop(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ return baseSlice(array, n < 0 ? 0 : n, length);
+}
+
+module.exports = drop;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRight.js
new file mode 100644
index 0000000..441fe99
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRight.js
@@ -0,0 +1,39 @@
+var baseSlice = require('./_baseSlice'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a slice of `array` with `n` elements dropped from the end.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to drop.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.dropRight([1, 2, 3]);
+ * // => [1, 2]
+ *
+ * _.dropRight([1, 2, 3], 2);
+ * // => [1]
+ *
+ * _.dropRight([1, 2, 3], 5);
+ * // => []
+ *
+ * _.dropRight([1, 2, 3], 0);
+ * // => [1, 2, 3]
+ */
+function dropRight(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ n = length - n;
+ return baseSlice(array, 0, n < 0 ? 0 : n);
+}
+
+module.exports = dropRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRightWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRightWhile.js
new file mode 100644
index 0000000..9ad36a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropRightWhile.js
@@ -0,0 +1,45 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseWhile = require('./_baseWhile');
+
+/**
+ * Creates a slice of `array` excluding elements dropped from the end.
+ * Elements are dropped until `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.dropRightWhile(users, function(o) { return !o.active; });
+ * // => objects for ['barney']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.dropRightWhile(users, ['active', false]);
+ * // => objects for ['barney']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.dropRightWhile(users, 'active');
+ * // => objects for ['barney', 'fred', 'pebbles']
+ */
+function dropRightWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, baseIteratee(predicate, 3), true, true)
+ : [];
+}
+
+module.exports = dropRightWhile;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropWhile.js
new file mode 100644
index 0000000..903ef56
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/dropWhile.js
@@ -0,0 +1,45 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseWhile = require('./_baseWhile');
+
+/**
+ * Creates a slice of `array` excluding elements dropped from the beginning.
+ * Elements are dropped until `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.dropWhile(users, function(o) { return !o.active; });
+ * // => objects for ['pebbles']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.dropWhile(users, { 'user': 'barney', 'active': false });
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.dropWhile(users, ['active', false]);
+ * // => objects for ['pebbles']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.dropWhile(users, 'active');
+ * // => objects for ['barney', 'fred', 'pebbles']
+ */
+function dropWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, baseIteratee(predicate, 3), true)
+ : [];
+}
+
+module.exports = dropWhile;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/each.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/each.js
new file mode 100644
index 0000000..8800f42
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/each.js
@@ -0,0 +1 @@
+module.exports = require('./forEach');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eachRight.js
new file mode 100644
index 0000000..3252b2a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eachRight.js
@@ -0,0 +1 @@
+module.exports = require('./forEachRight');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/endsWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/endsWith.js
new file mode 100644
index 0000000..76fc866
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/endsWith.js
@@ -0,0 +1,43 @@
+var baseClamp = require('./_baseClamp'),
+ baseToString = require('./_baseToString'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/**
+ * Checks if `string` ends with the given target string.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {string} [target] The string to search for.
+ * @param {number} [position=string.length] The position to search up to.
+ * @returns {boolean} Returns `true` if `string` ends with `target`,
+ * else `false`.
+ * @example
+ *
+ * _.endsWith('abc', 'c');
+ * // => true
+ *
+ * _.endsWith('abc', 'b');
+ * // => false
+ *
+ * _.endsWith('abc', 'b', 2);
+ * // => true
+ */
+function endsWith(string, target, position) {
+ string = toString(string);
+ target = baseToString(target);
+
+ var length = string.length;
+ position = position === undefined
+ ? length
+ : baseClamp(toInteger(position), 0, length);
+
+ var end = position;
+ position -= target.length;
+ return position >= 0 && string.slice(position, end) == target;
+}
+
+module.exports = endsWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entries.js
new file mode 100644
index 0000000..7a88df2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entries.js
@@ -0,0 +1 @@
+module.exports = require('./toPairs');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entriesIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entriesIn.js
new file mode 100644
index 0000000..f6c6331
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/entriesIn.js
@@ -0,0 +1 @@
+module.exports = require('./toPairsIn');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eq.js
new file mode 100644
index 0000000..a940688
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/eq.js
@@ -0,0 +1,37 @@
+/**
+ * Performs a
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * comparison between two values to determine if they are equivalent.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.eq(object, object);
+ * // => true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+function eq(value, other) {
+ return value === other || (value !== value && other !== other);
+}
+
+module.exports = eq;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escape.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escape.js
new file mode 100644
index 0000000..9247e00
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escape.js
@@ -0,0 +1,43 @@
+var escapeHtmlChar = require('./_escapeHtmlChar'),
+ toString = require('./toString');
+
+/** Used to match HTML entities and HTML characters. */
+var reUnescapedHtml = /[&<>"']/g,
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
+
+/**
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
+ * corresponding HTML entities.
+ *
+ * **Note:** No other characters are escaped. To escape additional
+ * characters use a third-party library like [_he_](https://mths.be/he).
+ *
+ * Though the ">" character is escaped for symmetry, characters like
+ * ">" and "/" don't need escaping in HTML and have no special meaning
+ * unless they're part of a tag or unquoted attribute value. See
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
+ * (under "semi-related fun fact") for more details.
+ *
+ * When working with HTML you should always
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
+ * XSS vectors.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escape('fred, barney, & pebbles');
+ * // => 'fred, barney, &amp; pebbles'
+ */
+function escape(string) {
+ string = toString(string);
+ return (string && reHasUnescapedHtml.test(string))
+ ? string.replace(reUnescapedHtml, escapeHtmlChar)
+ : string;
+}
+
+module.exports = escape;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escapeRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escapeRegExp.js
new file mode 100644
index 0000000..0a58c69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/escapeRegExp.js
@@ -0,0 +1,32 @@
+var toString = require('./toString');
+
+/**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
+ reHasRegExpChar = RegExp(reRegExpChar.source);
+
+/**
+ * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
+ * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escapeRegExp('[lodash](https://lodash.com/)');
+ * // => '\[lodash\]\(https://lodash\.com/\)'
+ */
+function escapeRegExp(string) {
+ string = toString(string);
+ return (string && reHasRegExpChar.test(string))
+ ? string.replace(reRegExpChar, '\\$&')
+ : string;
+}
+
+module.exports = escapeRegExp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/every.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/every.js
new file mode 100644
index 0000000..25080da
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/every.js
@@ -0,0 +1,56 @@
+var arrayEvery = require('./_arrayEvery'),
+ baseEvery = require('./_baseEvery'),
+ baseIteratee = require('./_baseIteratee'),
+ isArray = require('./isArray'),
+ isIterateeCall = require('./_isIterateeCall');
+
+/**
+ * Checks if `predicate` returns truthy for **all** elements of `collection`.
+ * Iteration is stopped once `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * **Note:** This method returns `true` for
+ * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
+ * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
+ * elements of empty collections.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.every([true, 1, null, 'yes'], Boolean);
+ * // => false
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.every(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.every(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.every(users, 'active');
+ * // => false
+ */
+function every(collection, predicate, guard) {
+ var func = isArray(collection) ? arrayEvery : baseEvery;
+ if (guard && isIterateeCall(collection, predicate, guard)) {
+ predicate = undefined;
+ }
+ return func(collection, baseIteratee(predicate, 3));
+}
+
+module.exports = every;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extend.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extend.js
new file mode 100644
index 0000000..e00166c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extend.js
@@ -0,0 +1 @@
+module.exports = require('./assignIn');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extendWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extendWith.js
new file mode 100644
index 0000000..dbdcb3b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/extendWith.js
@@ -0,0 +1 @@
+module.exports = require('./assignInWith');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fill.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fill.js
new file mode 100644
index 0000000..ae13aa1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fill.js
@@ -0,0 +1,45 @@
+var baseFill = require('./_baseFill'),
+ isIterateeCall = require('./_isIterateeCall');
+
+/**
+ * Fills elements of `array` with `value` from `start` up to, but not
+ * including, `end`.
+ *
+ * **Note:** This method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Array
+ * @param {Array} array The array to fill.
+ * @param {*} value The value to fill `array` with.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _.fill(array, 'a');
+ * console.log(array);
+ * // => ['a', 'a', 'a']
+ *
+ * _.fill(Array(3), 2);
+ * // => [2, 2, 2]
+ *
+ * _.fill([4, 6, 8, 10], '*', 1, 3);
+ * // => [4, '*', '*', 10]
+ */
+function fill(array, value, start, end) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
+ start = 0;
+ end = length;
+ }
+ return baseFill(array, value, start, end);
+}
+
+module.exports = fill;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/filter.js
new file mode 100644
index 0000000..52616be
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/filter.js
@@ -0,0 +1,48 @@
+var arrayFilter = require('./_arrayFilter'),
+ baseFilter = require('./_baseFilter'),
+ baseIteratee = require('./_baseIteratee'),
+ isArray = require('./isArray');
+
+/**
+ * Iterates over elements of `collection`, returning an array of all elements
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.reject
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * _.filter(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, { 'age': 36, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.filter(users, 'active');
+ * // => objects for ['barney']
+ */
+function filter(collection, predicate) {
+ var func = isArray(collection) ? arrayFilter : baseFilter;
+ return func(collection, baseIteratee(predicate, 3));
+}
+
+module.exports = filter;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/find.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/find.js
new file mode 100644
index 0000000..de732cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/find.js
@@ -0,0 +1,42 @@
+var createFind = require('./_createFind'),
+ findIndex = require('./findIndex');
+
+/**
+ * Iterates over elements of `collection`, returning the first element
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false },
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
+ * ];
+ *
+ * _.find(users, function(o) { return o.age < 40; });
+ * // => object for 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.find(users, { 'age': 1, 'active': true });
+ * // => object for 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.find(users, ['active', false]);
+ * // => object for 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.find(users, 'active');
+ * // => object for 'barney'
+ */
+var find = createFind(findIndex);
+
+module.exports = find;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findIndex.js
new file mode 100644
index 0000000..4689069
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findIndex.js
@@ -0,0 +1,55 @@
+var baseFindIndex = require('./_baseFindIndex'),
+ baseIteratee = require('./_baseIteratee'),
+ toInteger = require('./toInteger');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * This method is like `_.find` except that it returns the index of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.findIndex(users, function(o) { return o.user == 'barney'; });
+ * // => 0
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findIndex(users, { 'user': 'fred', 'active': false });
+ * // => 1
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findIndex(users, ['active', false]);
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findIndex(users, 'active');
+ * // => 2
+ */
+function findIndex(array, predicate, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
+ if (index < 0) {
+ index = nativeMax(length + index, 0);
+ }
+ return baseFindIndex(array, baseIteratee(predicate, 3), index);
+}
+
+module.exports = findIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findKey.js
new file mode 100644
index 0000000..cac0248
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findKey.js
@@ -0,0 +1,44 @@
+var baseFindKey = require('./_baseFindKey'),
+ baseForOwn = require('./_baseForOwn'),
+ baseIteratee = require('./_baseIteratee');
+
+/**
+ * This method is like `_.find` except that it returns the key of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {string|undefined} Returns the key of the matched element,
+ * else `undefined`.
+ * @example
+ *
+ * var users = {
+ * 'barney': { 'age': 36, 'active': true },
+ * 'fred': { 'age': 40, 'active': false },
+ * 'pebbles': { 'age': 1, 'active': true }
+ * };
+ *
+ * _.findKey(users, function(o) { return o.age < 40; });
+ * // => 'barney' (iteration order is not guaranteed)
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findKey(users, { 'age': 1, 'active': true });
+ * // => 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findKey(users, ['active', false]);
+ * // => 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findKey(users, 'active');
+ * // => 'barney'
+ */
+function findKey(object, predicate) {
+ return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn);
+}
+
+module.exports = findKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLast.js
new file mode 100644
index 0000000..70b4271
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLast.js
@@ -0,0 +1,25 @@
+var createFind = require('./_createFind'),
+ findLastIndex = require('./findLastIndex');
+
+/**
+ * This method is like `_.find` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=collection.length-1] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * _.findLast([1, 2, 3, 4], function(n) {
+ * return n % 2 == 1;
+ * });
+ * // => 3
+ */
+var findLast = createFind(findLastIndex);
+
+module.exports = findLast;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastIndex.js
new file mode 100644
index 0000000..7da3431
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastIndex.js
@@ -0,0 +1,59 @@
+var baseFindIndex = require('./_baseFindIndex'),
+ baseIteratee = require('./_baseIteratee'),
+ toInteger = require('./toInteger');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+/**
+ * This method is like `_.findIndex` except that it iterates over elements
+ * of `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=array.length-1] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
+ * // => 2
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findLastIndex(users, { 'user': 'barney', 'active': true });
+ * // => 0
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findLastIndex(users, ['active', false]);
+ * // => 2
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findLastIndex(users, 'active');
+ * // => 0
+ */
+function findLastIndex(array, predicate, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = length - 1;
+ if (fromIndex !== undefined) {
+ index = toInteger(fromIndex);
+ index = fromIndex < 0
+ ? nativeMax(length + index, 0)
+ : nativeMin(index, length - 1);
+ }
+ return baseFindIndex(array, baseIteratee(predicate, 3), index, true);
+}
+
+module.exports = findLastIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastKey.js
new file mode 100644
index 0000000..66fb9fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/findLastKey.js
@@ -0,0 +1,44 @@
+var baseFindKey = require('./_baseFindKey'),
+ baseForOwnRight = require('./_baseForOwnRight'),
+ baseIteratee = require('./_baseIteratee');
+
+/**
+ * This method is like `_.findKey` except that it iterates over elements of
+ * a collection in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {string|undefined} Returns the key of the matched element,
+ * else `undefined`.
+ * @example
+ *
+ * var users = {
+ * 'barney': { 'age': 36, 'active': true },
+ * 'fred': { 'age': 40, 'active': false },
+ * 'pebbles': { 'age': 1, 'active': true }
+ * };
+ *
+ * _.findLastKey(users, function(o) { return o.age < 40; });
+ * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findLastKey(users, { 'age': 36, 'active': true });
+ * // => 'barney'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findLastKey(users, ['active', false]);
+ * // => 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findLastKey(users, 'active');
+ * // => 'pebbles'
+ */
+function findLastKey(object, predicate) {
+ return baseFindKey(object, baseIteratee(predicate, 3), baseForOwnRight);
+}
+
+module.exports = findLastKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/first.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/first.js
new file mode 100644
index 0000000..53f4ad1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/first.js
@@ -0,0 +1 @@
+module.exports = require('./head');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMap.js
new file mode 100644
index 0000000..e668506
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMap.js
@@ -0,0 +1,29 @@
+var baseFlatten = require('./_baseFlatten'),
+ map = require('./map');
+
+/**
+ * Creates a flattened array of values by running each element in `collection`
+ * thru `iteratee` and flattening the mapped results. The iteratee is invoked
+ * with three arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [n, n];
+ * }
+ *
+ * _.flatMap([1, 2], duplicate);
+ * // => [1, 1, 2, 2]
+ */
+function flatMap(collection, iteratee) {
+ return baseFlatten(map(collection, iteratee), 1);
+}
+
+module.exports = flatMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDeep.js
new file mode 100644
index 0000000..4653d60
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDeep.js
@@ -0,0 +1,31 @@
+var baseFlatten = require('./_baseFlatten'),
+ map = require('./map');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * This method is like `_.flatMap` except that it recursively flattens the
+ * mapped results.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [[[n, n]]];
+ * }
+ *
+ * _.flatMapDeep([1, 2], duplicate);
+ * // => [1, 1, 2, 2]
+ */
+function flatMapDeep(collection, iteratee) {
+ return baseFlatten(map(collection, iteratee), INFINITY);
+}
+
+module.exports = flatMapDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDepth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDepth.js
new file mode 100644
index 0000000..6d72005
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatMapDepth.js
@@ -0,0 +1,31 @@
+var baseFlatten = require('./_baseFlatten'),
+ map = require('./map'),
+ toInteger = require('./toInteger');
+
+/**
+ * This method is like `_.flatMap` except that it recursively flattens the
+ * mapped results up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [[[n, n]]];
+ * }
+ *
+ * _.flatMapDepth([1, 2], duplicate, 2);
+ * // => [[1, 1], [2, 2]]
+ */
+function flatMapDepth(collection, iteratee, depth) {
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(map(collection, iteratee), depth);
+}
+
+module.exports = flatMapDepth;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatten.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatten.js
new file mode 100644
index 0000000..3f09f7f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flatten.js
@@ -0,0 +1,22 @@
+var baseFlatten = require('./_baseFlatten');
+
+/**
+ * Flattens `array` a single level deep.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
+ */
+function flatten(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, 1) : [];
+}
+
+module.exports = flatten;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDeep.js
new file mode 100644
index 0000000..8ad585c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDeep.js
@@ -0,0 +1,25 @@
+var baseFlatten = require('./_baseFlatten');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/**
+ * Recursively flattens `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
+ */
+function flattenDeep(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, INFINITY) : [];
+}
+
+module.exports = flattenDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDepth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDepth.js
new file mode 100644
index 0000000..441fdcc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flattenDepth.js
@@ -0,0 +1,33 @@
+var baseFlatten = require('./_baseFlatten'),
+ toInteger = require('./toInteger');
+
+/**
+ * Recursively flatten `array` up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.4.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * var array = [1, [2, [3, [4]], 5]];
+ *
+ * _.flattenDepth(array, 1);
+ * // => [1, 2, [3, [4]], 5]
+ *
+ * _.flattenDepth(array, 2);
+ * // => [1, 2, 3, [4], 5]
+ */
+function flattenDepth(array, depth) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(array, depth);
+}
+
+module.exports = flattenDepth;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flip.js
new file mode 100644
index 0000000..c28dd78
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flip.js
@@ -0,0 +1,28 @@
+var createWrap = require('./_createWrap');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_FLIP_FLAG = 512;
+
+/**
+ * Creates a function that invokes `func` with arguments reversed.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to flip arguments for.
+ * @returns {Function} Returns the new flipped function.
+ * @example
+ *
+ * var flipped = _.flip(function() {
+ * return _.toArray(arguments);
+ * });
+ *
+ * flipped('a', 'b', 'c', 'd');
+ * // => ['d', 'c', 'b', 'a']
+ */
+function flip(func) {
+ return createWrap(func, WRAP_FLIP_FLAG);
+}
+
+module.exports = flip;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/floor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/floor.js
new file mode 100644
index 0000000..ab6dfa2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/floor.js
@@ -0,0 +1,26 @@
+var createRound = require('./_createRound');
+
+/**
+ * Computes `number` rounded down to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round down.
+ * @param {number} [precision=0] The precision to round down to.
+ * @returns {number} Returns the rounded down number.
+ * @example
+ *
+ * _.floor(4.006);
+ * // => 4
+ *
+ * _.floor(0.046, 2);
+ * // => 0.04
+ *
+ * _.floor(4060, -2);
+ * // => 4000
+ */
+var floor = createRound('floor');
+
+module.exports = floor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flow.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flow.js
new file mode 100644
index 0000000..74b6b62
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flow.js
@@ -0,0 +1,27 @@
+var createFlow = require('./_createFlow');
+
+/**
+ * Creates a function that returns the result of invoking the given functions
+ * with the `this` binding of the created function, where each successive
+ * invocation is supplied the return value of the previous.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
+ * @returns {Function} Returns the new composite function.
+ * @see _.flowRight
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var addSquare = _.flow([_.add, square]);
+ * addSquare(1, 2);
+ * // => 9
+ */
+var flow = createFlow();
+
+module.exports = flow;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flowRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flowRight.js
new file mode 100644
index 0000000..1146141
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/flowRight.js
@@ -0,0 +1,26 @@
+var createFlow = require('./_createFlow');
+
+/**
+ * This method is like `_.flow` except that it creates a function that
+ * invokes the given functions from right to left.
+ *
+ * @static
+ * @since 3.0.0
+ * @memberOf _
+ * @category Util
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
+ * @returns {Function} Returns the new composite function.
+ * @see _.flow
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var addSquare = _.flowRight([square, _.add]);
+ * addSquare(1, 2);
+ * // => 9
+ */
+var flowRight = createFlow(true);
+
+module.exports = flowRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEach.js
new file mode 100644
index 0000000..c64eaa7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEach.js
@@ -0,0 +1,41 @@
+var arrayEach = require('./_arrayEach'),
+ baseEach = require('./_baseEach'),
+ castFunction = require('./_castFunction'),
+ isArray = require('./isArray');
+
+/**
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
+ * The iteratee is invoked with three arguments: (value, index|key, collection).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * **Note:** As with other "Collections" methods, objects with a "length"
+ * property are iterated like arrays. To avoid this behavior use `_.forIn`
+ * or `_.forOwn` for object iteration.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias each
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEachRight
+ * @example
+ *
+ * _.forEach([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `1` then `2`.
+ *
+ * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */
+function forEach(collection, iteratee) {
+ var func = isArray(collection) ? arrayEach : baseEach;
+ return func(collection, castFunction(iteratee));
+}
+
+module.exports = forEach;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEachRight.js
new file mode 100644
index 0000000..7390eba
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forEachRight.js
@@ -0,0 +1,31 @@
+var arrayEachRight = require('./_arrayEachRight'),
+ baseEachRight = require('./_baseEachRight'),
+ castFunction = require('./_castFunction'),
+ isArray = require('./isArray');
+
+/**
+ * This method is like `_.forEach` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @alias eachRight
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEach
+ * @example
+ *
+ * _.forEachRight([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `2` then `1`.
+ */
+function forEachRight(collection, iteratee) {
+ var func = isArray(collection) ? arrayEachRight : baseEachRight;
+ return func(collection, castFunction(iteratee));
+}
+
+module.exports = forEachRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forIn.js
new file mode 100644
index 0000000..583a596
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forIn.js
@@ -0,0 +1,39 @@
+var baseFor = require('./_baseFor'),
+ castFunction = require('./_castFunction'),
+ keysIn = require('./keysIn');
+
+/**
+ * Iterates over own and inherited enumerable string keyed properties of an
+ * object and invokes `iteratee` for each property. The iteratee is invoked
+ * with three arguments: (value, key, object). Iteratee functions may exit
+ * iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forInRight
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forIn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
+ */
+function forIn(object, iteratee) {
+ return object == null
+ ? object
+ : baseFor(object, castFunction(iteratee), keysIn);
+}
+
+module.exports = forIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forInRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forInRight.js
new file mode 100644
index 0000000..4aedf58
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forInRight.js
@@ -0,0 +1,37 @@
+var baseForRight = require('./_baseForRight'),
+ castFunction = require('./_castFunction'),
+ keysIn = require('./keysIn');
+
+/**
+ * This method is like `_.forIn` except that it iterates over properties of
+ * `object` in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forInRight(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
+ */
+function forInRight(object, iteratee) {
+ return object == null
+ ? object
+ : baseForRight(object, castFunction(iteratee), keysIn);
+}
+
+module.exports = forInRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwn.js
new file mode 100644
index 0000000..94eed84
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwn.js
@@ -0,0 +1,36 @@
+var baseForOwn = require('./_baseForOwn'),
+ castFunction = require('./_castFunction');
+
+/**
+ * Iterates over own enumerable string keyed properties of an object and
+ * invokes `iteratee` for each property. The iteratee is invoked with three
+ * arguments: (value, key, object). Iteratee functions may exit iteration
+ * early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forOwnRight
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forOwn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */
+function forOwn(object, iteratee) {
+ return object && baseForOwn(object, castFunction(iteratee));
+}
+
+module.exports = forOwn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwnRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwnRight.js
new file mode 100644
index 0000000..86f338f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/forOwnRight.js
@@ -0,0 +1,34 @@
+var baseForOwnRight = require('./_baseForOwnRight'),
+ castFunction = require('./_castFunction');
+
+/**
+ * This method is like `_.forOwn` except that it iterates over properties of
+ * `object` in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forOwn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forOwnRight(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
+ */
+function forOwnRight(object, iteratee) {
+ return object && baseForOwnRight(object, castFunction(iteratee));
+}
+
+module.exports = forOwnRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp.js
new file mode 100644
index 0000000..e372dbb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp.js
@@ -0,0 +1,2 @@
+var _ = require('./lodash.min').runInContext();
+module.exports = require('./fp/_baseConvert')(_, _);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/F.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/F.js
new file mode 100644
index 0000000..a05a63a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/F.js
@@ -0,0 +1 @@
+module.exports = require('./stubFalse');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/T.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/T.js
new file mode 100644
index 0000000..e2ba8ea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/T.js
@@ -0,0 +1 @@
+module.exports = require('./stubTrue');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/__.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/__.js
new file mode 100644
index 0000000..4af98de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/__.js
@@ -0,0 +1 @@
+module.exports = require('./placeholder');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_baseConvert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_baseConvert.js
new file mode 100644
index 0000000..c9d3247
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_baseConvert.js
@@ -0,0 +1,567 @@
+var mapping = require('./_mapping'),
+ fallbackHolder = require('./placeholder');
+
+/** Built-in value reference. */
+var push = Array.prototype.push;
+
+/**
+ * Creates a function, with an arity of `n`, that invokes `func` with the
+ * arguments it receives.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} n The arity of the new function.
+ * @returns {Function} Returns the new function.
+ */
+function baseArity(func, n) {
+ return n == 2
+ ? function(a, b) { return func.apply(undefined, arguments); }
+ : function(a) { return func.apply(undefined, arguments); };
+}
+
+/**
+ * Creates a function that invokes `func`, with up to `n` arguments, ignoring
+ * any additional arguments.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @param {number} n The arity cap.
+ * @returns {Function} Returns the new function.
+ */
+function baseAry(func, n) {
+ return n == 2
+ ? function(a, b) { return func(a, b); }
+ : function(a) { return func(a); };
+}
+
+/**
+ * Creates a clone of `array`.
+ *
+ * @private
+ * @param {Array} array The array to clone.
+ * @returns {Array} Returns the cloned array.
+ */
+function cloneArray(array) {
+ var length = array ? array.length : 0,
+ result = Array(length);
+
+ while (length--) {
+ result[length] = array[length];
+ }
+ return result;
+}
+
+/**
+ * Creates a function that clones a given object using the assignment `func`.
+ *
+ * @private
+ * @param {Function} func The assignment function.
+ * @returns {Function} Returns the new cloner function.
+ */
+function createCloner(func) {
+ return function(object) {
+ return func({}, object);
+ };
+}
+
+/**
+ * This function is like `_.spread` except that it includes arguments after those spread.
+ *
+ * @private
+ * @param {Function} func The function to spread arguments over.
+ * @param {number} start The start position of the spread.
+ * @returns {Function} Returns the new function.
+ */
+function spread(func, start) {
+ return function() {
+ var length = arguments.length,
+ args = Array(length);
+
+ while (length--) {
+ args[length] = arguments[length];
+ }
+ var array = args[start],
+ lastIndex = args.length - 1,
+ otherArgs = args.slice(0, start);
+
+ if (array) {
+ push.apply(otherArgs, array);
+ }
+ if (start != lastIndex) {
+ push.apply(otherArgs, args.slice(start + 1));
+ }
+ return func.apply(this, otherArgs);
+ };
+}
+
+/**
+ * Creates a function that wraps `func` and uses `cloner` to clone the first
+ * argument it receives.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} cloner The function to clone arguments.
+ * @returns {Function} Returns the new immutable function.
+ */
+function wrapImmutable(func, cloner) {
+ return function() {
+ var length = arguments.length;
+ if (!length) {
+ return;
+ }
+ var args = Array(length);
+ while (length--) {
+ args[length] = arguments[length];
+ }
+ var result = args[0] = cloner.apply(undefined, args);
+ func.apply(undefined, args);
+ return result;
+ };
+}
+
+/**
+ * The base implementation of `convert` which accepts a `util` object of methods
+ * required to perform conversions.
+ *
+ * @param {Object} util The util object.
+ * @param {string} name The name of the function to convert.
+ * @param {Function} func The function to convert.
+ * @param {Object} [options] The options object.
+ * @param {boolean} [options.cap=true] Specify capping iteratee arguments.
+ * @param {boolean} [options.curry=true] Specify currying.
+ * @param {boolean} [options.fixed=true] Specify fixed arity.
+ * @param {boolean} [options.immutable=true] Specify immutable operations.
+ * @param {boolean} [options.rearg=true] Specify rearranging arguments.
+ * @returns {Function|Object} Returns the converted function or object.
+ */
+function baseConvert(util, name, func, options) {
+ var setPlaceholder,
+ isLib = typeof name == 'function',
+ isObj = name === Object(name);
+
+ if (isObj) {
+ options = func;
+ func = name;
+ name = undefined;
+ }
+ if (func == null) {
+ throw new TypeError;
+ }
+ options || (options = {});
+
+ var config = {
+ 'cap': 'cap' in options ? options.cap : true,
+ 'curry': 'curry' in options ? options.curry : true,
+ 'fixed': 'fixed' in options ? options.fixed : true,
+ 'immutable': 'immutable' in options ? options.immutable : true,
+ 'rearg': 'rearg' in options ? options.rearg : true
+ };
+
+ var forceCurry = ('curry' in options) && options.curry,
+ forceFixed = ('fixed' in options) && options.fixed,
+ forceRearg = ('rearg' in options) && options.rearg,
+ placeholder = isLib ? func : fallbackHolder,
+ pristine = isLib ? func.runInContext() : undefined;
+
+ var helpers = isLib ? func : {
+ 'ary': util.ary,
+ 'assign': util.assign,
+ 'clone': util.clone,
+ 'curry': util.curry,
+ 'forEach': util.forEach,
+ 'isArray': util.isArray,
+ 'isFunction': util.isFunction,
+ 'iteratee': util.iteratee,
+ 'keys': util.keys,
+ 'rearg': util.rearg,
+ 'toInteger': util.toInteger,
+ 'toPath': util.toPath
+ };
+
+ var ary = helpers.ary,
+ assign = helpers.assign,
+ clone = helpers.clone,
+ curry = helpers.curry,
+ each = helpers.forEach,
+ isArray = helpers.isArray,
+ isFunction = helpers.isFunction,
+ keys = helpers.keys,
+ rearg = helpers.rearg,
+ toInteger = helpers.toInteger,
+ toPath = helpers.toPath;
+
+ var aryMethodKeys = keys(mapping.aryMethod);
+
+ var wrappers = {
+ 'castArray': function(castArray) {
+ return function() {
+ var value = arguments[0];
+ return isArray(value)
+ ? castArray(cloneArray(value))
+ : castArray.apply(undefined, arguments);
+ };
+ },
+ 'iteratee': function(iteratee) {
+ return function() {
+ var func = arguments[0],
+ arity = arguments[1],
+ result = iteratee(func, arity),
+ length = result.length;
+
+ if (config.cap && typeof arity == 'number') {
+ arity = arity > 2 ? (arity - 2) : 1;
+ return (length && length <= arity) ? result : baseAry(result, arity);
+ }
+ return result;
+ };
+ },
+ 'mixin': function(mixin) {
+ return function(source) {
+ var func = this;
+ if (!isFunction(func)) {
+ return mixin(func, Object(source));
+ }
+ var pairs = [];
+ each(keys(source), function(key) {
+ if (isFunction(source[key])) {
+ pairs.push([key, func.prototype[key]]);
+ }
+ });
+
+ mixin(func, Object(source));
+
+ each(pairs, function(pair) {
+ var value = pair[1];
+ if (isFunction(value)) {
+ func.prototype[pair[0]] = value;
+ } else {
+ delete func.prototype[pair[0]];
+ }
+ });
+ return func;
+ };
+ },
+ 'nthArg': function(nthArg) {
+ return function(n) {
+ var arity = n < 0 ? 1 : (toInteger(n) + 1);
+ return curry(nthArg(n), arity);
+ };
+ },
+ 'rearg': function(rearg) {
+ return function(func, indexes) {
+ var arity = indexes ? indexes.length : 0;
+ return curry(rearg(func, indexes), arity);
+ };
+ },
+ 'runInContext': function(runInContext) {
+ return function(context) {
+ return baseConvert(util, runInContext(context), options);
+ };
+ }
+ };
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Casts `func` to a function with an arity capped iteratee if needed.
+ *
+ * @private
+ * @param {string} name The name of the function to inspect.
+ * @param {Function} func The function to inspect.
+ * @returns {Function} Returns the cast function.
+ */
+ function castCap(name, func) {
+ if (config.cap) {
+ var indexes = mapping.iterateeRearg[name];
+ if (indexes) {
+ return iterateeRearg(func, indexes);
+ }
+ var n = !isLib && mapping.iterateeAry[name];
+ if (n) {
+ return iterateeAry(func, n);
+ }
+ }
+ return func;
+ }
+
+ /**
+ * Casts `func` to a curried function if needed.
+ *
+ * @private
+ * @param {string} name The name of the function to inspect.
+ * @param {Function} func The function to inspect.
+ * @param {number} n The arity of `func`.
+ * @returns {Function} Returns the cast function.
+ */
+ function castCurry(name, func, n) {
+ return (forceCurry || (config.curry && n > 1))
+ ? curry(func, n)
+ : func;
+ }
+
+ /**
+ * Casts `func` to a fixed arity function if needed.
+ *
+ * @private
+ * @param {string} name The name of the function to inspect.
+ * @param {Function} func The function to inspect.
+ * @param {number} n The arity cap.
+ * @returns {Function} Returns the cast function.
+ */
+ function castFixed(name, func, n) {
+ if (config.fixed && (forceFixed || !mapping.skipFixed[name])) {
+ var data = mapping.methodSpread[name],
+ start = data && data.start;
+
+ return start === undefined ? ary(func, n) : spread(func, start);
+ }
+ return func;
+ }
+
+ /**
+ * Casts `func` to an rearged function if needed.
+ *
+ * @private
+ * @param {string} name The name of the function to inspect.
+ * @param {Function} func The function to inspect.
+ * @param {number} n The arity of `func`.
+ * @returns {Function} Returns the cast function.
+ */
+ function castRearg(name, func, n) {
+ return (config.rearg && n > 1 && (forceRearg || !mapping.skipRearg[name]))
+ ? rearg(func, mapping.methodRearg[name] || mapping.aryRearg[n])
+ : func;
+ }
+
+ /**
+ * Creates a clone of `object` by `path`.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @param {Array|string} path The path to clone by.
+ * @returns {Object} Returns the cloned object.
+ */
+ function cloneByPath(object, path) {
+ path = toPath(path);
+
+ var index = -1,
+ length = path.length,
+ lastIndex = length - 1,
+ result = clone(Object(object)),
+ nested = result;
+
+ while (nested != null && ++index < length) {
+ var key = path[index],
+ value = nested[key];
+
+ if (value != null) {
+ nested[path[index]] = clone(index == lastIndex ? value : Object(value));
+ }
+ nested = nested[key];
+ }
+ return result;
+ }
+
+ /**
+ * Converts `lodash` to an immutable auto-curried iteratee-first data-last
+ * version with conversion `options` applied.
+ *
+ * @param {Object} [options] The options object. See `baseConvert` for more details.
+ * @returns {Function} Returns the converted `lodash`.
+ */
+ function convertLib(options) {
+ return _.runInContext.convert(options)(undefined);
+ }
+
+ /**
+ * Create a converter function for `func` of `name`.
+ *
+ * @param {string} name The name of the function to convert.
+ * @param {Function} func The function to convert.
+ * @returns {Function} Returns the new converter function.
+ */
+ function createConverter(name, func) {
+ var realName = mapping.aliasToReal[name] || name,
+ methodName = mapping.remap[realName] || realName,
+ oldOptions = options;
+
+ return function(options) {
+ var newUtil = isLib ? pristine : helpers,
+ newFunc = isLib ? pristine[methodName] : func,
+ newOptions = assign(assign({}, oldOptions), options);
+
+ return baseConvert(newUtil, realName, newFunc, newOptions);
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke its iteratee, with up to `n`
+ * arguments, ignoring any additional arguments.
+ *
+ * @private
+ * @param {Function} func The function to cap iteratee arguments for.
+ * @param {number} n The arity cap.
+ * @returns {Function} Returns the new function.
+ */
+ function iterateeAry(func, n) {
+ return overArg(func, function(func) {
+ return typeof func == 'function' ? baseAry(func, n) : func;
+ });
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke its iteratee with arguments
+ * arranged according to the specified `indexes` where the argument value at
+ * the first index is provided as the first argument, the argument value at
+ * the second index is provided as the second argument, and so on.
+ *
+ * @private
+ * @param {Function} func The function to rearrange iteratee arguments for.
+ * @param {number[]} indexes The arranged argument indexes.
+ * @returns {Function} Returns the new function.
+ */
+ function iterateeRearg(func, indexes) {
+ return overArg(func, function(func) {
+ var n = indexes.length;
+ return baseArity(rearg(baseAry(func, n), indexes), n);
+ });
+ }
+
+ /**
+ * Creates a function that invokes `func` with its first argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function() {
+ var length = arguments.length;
+ if (!length) {
+ return func();
+ }
+ var args = Array(length);
+ while (length--) {
+ args[length] = arguments[length];
+ }
+ var index = config.rearg ? 0 : (length - 1);
+ args[index] = transform(args[index]);
+ return func.apply(undefined, args);
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` and applys the conversions
+ * rules by `name`.
+ *
+ * @private
+ * @param {string} name The name of the function to wrap.
+ * @param {Function} func The function to wrap.
+ * @returns {Function} Returns the converted function.
+ */
+ function wrap(name, func) {
+ var result,
+ realName = mapping.aliasToReal[name] || name,
+ wrapped = func,
+ wrapper = wrappers[realName];
+
+ if (wrapper) {
+ wrapped = wrapper(func);
+ }
+ else if (config.immutable) {
+ if (mapping.mutate.array[realName]) {
+ wrapped = wrapImmutable(func, cloneArray);
+ }
+ else if (mapping.mutate.object[realName]) {
+ wrapped = wrapImmutable(func, createCloner(func));
+ }
+ else if (mapping.mutate.set[realName]) {
+ wrapped = wrapImmutable(func, cloneByPath);
+ }
+ }
+ each(aryMethodKeys, function(aryKey) {
+ each(mapping.aryMethod[aryKey], function(otherName) {
+ if (realName == otherName) {
+ var spreadData = mapping.methodSpread[realName],
+ afterRearg = spreadData && spreadData.afterRearg;
+
+ result = afterRearg
+ ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey)
+ : castRearg(realName, castFixed(realName, wrapped, aryKey), aryKey);
+
+ result = castCap(realName, result);
+ result = castCurry(realName, result, aryKey);
+ return false;
+ }
+ });
+ return !result;
+ });
+
+ result || (result = wrapped);
+ if (result == func) {
+ result = forceCurry ? curry(result, 1) : function() {
+ return func.apply(this, arguments);
+ };
+ }
+ result.convert = createConverter(realName, func);
+ if (mapping.placeholder[realName]) {
+ setPlaceholder = true;
+ result.placeholder = func.placeholder = placeholder;
+ }
+ return result;
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ if (!isObj) {
+ return wrap(name, func);
+ }
+ var _ = func;
+
+ // Convert methods by ary cap.
+ var pairs = [];
+ each(aryMethodKeys, function(aryKey) {
+ each(mapping.aryMethod[aryKey], function(key) {
+ var func = _[mapping.remap[key] || key];
+ if (func) {
+ pairs.push([key, wrap(key, func)]);
+ }
+ });
+ });
+
+ // Convert remaining methods.
+ each(keys(_), function(key) {
+ var func = _[key];
+ if (typeof func == 'function') {
+ var length = pairs.length;
+ while (length--) {
+ if (pairs[length][0] == key) {
+ return;
+ }
+ }
+ func.convert = createConverter(key, func);
+ pairs.push([key, func]);
+ }
+ });
+
+ // Assign to `_` leaving `_.prototype` unchanged to allow chaining.
+ each(pairs, function(pair) {
+ _[pair[0]] = pair[1];
+ });
+
+ _.convert = convertLib;
+ if (setPlaceholder) {
+ _.placeholder = placeholder;
+ }
+ // Assign aliases.
+ each(keys(_), function(key) {
+ each(mapping.realToAlias[key] || [], function(alias) {
+ _[alias] = _[key];
+ });
+ });
+
+ return _;
+}
+
+module.exports = baseConvert;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_convertBrowser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_convertBrowser.js
new file mode 100644
index 0000000..bde030d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_convertBrowser.js
@@ -0,0 +1,18 @@
+var baseConvert = require('./_baseConvert');
+
+/**
+ * Converts `lodash` to an immutable auto-curried iteratee-first data-last
+ * version with conversion `options` applied.
+ *
+ * @param {Function} lodash The lodash function to convert.
+ * @param {Object} [options] The options object. See `baseConvert` for more details.
+ * @returns {Function} Returns the converted `lodash`.
+ */
+function browserConvert(lodash, options) {
+ return baseConvert(lodash, lodash, options);
+}
+
+if (typeof _ == 'function' && typeof _.runInContext == 'function') {
+ _ = browserConvert(_.runInContext());
+}
+module.exports = browserConvert;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_falseOptions.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_falseOptions.js
new file mode 100644
index 0000000..773235e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_falseOptions.js
@@ -0,0 +1,7 @@
+module.exports = {
+ 'cap': false,
+ 'curry': false,
+ 'fixed': false,
+ 'immutable': false,
+ 'rearg': false
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_mapping.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_mapping.js
new file mode 100644
index 0000000..cbbcd99
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_mapping.js
@@ -0,0 +1,367 @@
+/** Used to map aliases to their real names. */
+exports.aliasToReal = {
+
+ // Lodash aliases.
+ 'each': 'forEach',
+ 'eachRight': 'forEachRight',
+ 'entries': 'toPairs',
+ 'entriesIn': 'toPairsIn',
+ 'extend': 'assignIn',
+ 'extendAll': 'assignInAll',
+ 'extendAllWith': 'assignInAllWith',
+ 'extendWith': 'assignInWith',
+ 'first': 'head',
+
+ // Methods that are curried variants of others.
+ 'conforms': 'conformsTo',
+ 'matches': 'isMatch',
+ 'property': 'get',
+
+ // Ramda aliases.
+ '__': 'placeholder',
+ 'F': 'stubFalse',
+ 'T': 'stubTrue',
+ 'all': 'every',
+ 'allPass': 'overEvery',
+ 'always': 'constant',
+ 'any': 'some',
+ 'anyPass': 'overSome',
+ 'apply': 'spread',
+ 'assoc': 'set',
+ 'assocPath': 'set',
+ 'complement': 'negate',
+ 'compose': 'flowRight',
+ 'contains': 'includes',
+ 'dissoc': 'unset',
+ 'dissocPath': 'unset',
+ 'dropLast': 'dropRight',
+ 'dropLastWhile': 'dropRightWhile',
+ 'equals': 'isEqual',
+ 'identical': 'eq',
+ 'indexBy': 'keyBy',
+ 'init': 'initial',
+ 'invertObj': 'invert',
+ 'juxt': 'over',
+ 'omitAll': 'omit',
+ 'nAry': 'ary',
+ 'path': 'get',
+ 'pathEq': 'matchesProperty',
+ 'pathOr': 'getOr',
+ 'paths': 'at',
+ 'pickAll': 'pick',
+ 'pipe': 'flow',
+ 'pluck': 'map',
+ 'prop': 'get',
+ 'propEq': 'matchesProperty',
+ 'propOr': 'getOr',
+ 'props': 'at',
+ 'symmetricDifference': 'xor',
+ 'symmetricDifferenceBy': 'xorBy',
+ 'symmetricDifferenceWith': 'xorWith',
+ 'takeLast': 'takeRight',
+ 'takeLastWhile': 'takeRightWhile',
+ 'unapply': 'rest',
+ 'unnest': 'flatten',
+ 'useWith': 'overArgs',
+ 'where': 'conformsTo',
+ 'whereEq': 'isMatch',
+ 'zipObj': 'zipObject'
+};
+
+/** Used to map ary to method names. */
+exports.aryMethod = {
+ '1': [
+ 'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create',
+ 'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow',
+ 'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll',
+ 'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse',
+ 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart',
+ 'uniqueId', 'words', 'zipAll'
+ ],
+ '2': [
+ 'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith',
+ 'at', 'before', 'bind', 'bindAll', 'bindKey', 'chunk', 'cloneDeepWith',
+ 'cloneWith', 'concat', 'conformsTo', 'countBy', 'curryN', 'curryRightN',
+ 'debounce', 'defaults', 'defaultsDeep', 'defaultTo', 'delay', 'difference',
+ 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',
+ 'every', 'filter', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
+ 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', 'forEach',
+ 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',
+ 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',
+ 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy',
+ 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty',
+ 'maxBy', 'meanBy', 'merge', 'mergeAllWith', 'minBy', 'multiply', 'nth', 'omit',
+ 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial',
+ 'partialRight', 'partition', 'pick', 'pickBy', 'propertyOf', 'pull', 'pullAll',
+ 'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
+ 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
+ 'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
+ 'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight',
+ 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars',
+ 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith',
+ 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject',
+ 'zipObjectDeep'
+ ],
+ '3': [
+ 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
+ 'findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom', 'getOr',
+ 'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith',
+ 'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth',
+ 'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd',
+ 'padCharsStart', 'pullAllBy', 'pullAllWith', 'rangeStep', 'rangeStepRight',
+ 'reduce', 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy',
+ 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', 'update', 'xorBy',
+ 'xorWith', 'zipWith'
+ ],
+ '4': [
+ 'fill', 'setWith', 'updateWith'
+ ]
+};
+
+/** Used to map ary to rearg configs. */
+exports.aryRearg = {
+ '2': [1, 0],
+ '3': [2, 0, 1],
+ '4': [3, 2, 0, 1]
+};
+
+/** Used to map method names to their iteratee ary. */
+exports.iterateeAry = {
+ 'dropRightWhile': 1,
+ 'dropWhile': 1,
+ 'every': 1,
+ 'filter': 1,
+ 'find': 1,
+ 'findFrom': 1,
+ 'findIndex': 1,
+ 'findIndexFrom': 1,
+ 'findKey': 1,
+ 'findLast': 1,
+ 'findLastFrom': 1,
+ 'findLastIndex': 1,
+ 'findLastIndexFrom': 1,
+ 'findLastKey': 1,
+ 'flatMap': 1,
+ 'flatMapDeep': 1,
+ 'flatMapDepth': 1,
+ 'forEach': 1,
+ 'forEachRight': 1,
+ 'forIn': 1,
+ 'forInRight': 1,
+ 'forOwn': 1,
+ 'forOwnRight': 1,
+ 'map': 1,
+ 'mapKeys': 1,
+ 'mapValues': 1,
+ 'partition': 1,
+ 'reduce': 2,
+ 'reduceRight': 2,
+ 'reject': 1,
+ 'remove': 1,
+ 'some': 1,
+ 'takeRightWhile': 1,
+ 'takeWhile': 1,
+ 'times': 1,
+ 'transform': 2
+};
+
+/** Used to map method names to iteratee rearg configs. */
+exports.iterateeRearg = {
+ 'mapKeys': [1]
+};
+
+/** Used to map method names to rearg configs. */
+exports.methodRearg = {
+ 'assignInAllWith': [1, 0],
+ 'assignInWith': [1, 2, 0],
+ 'assignAllWith': [1, 0],
+ 'assignWith': [1, 2, 0],
+ 'differenceBy': [1, 2, 0],
+ 'differenceWith': [1, 2, 0],
+ 'getOr': [2, 1, 0],
+ 'intersectionBy': [1, 2, 0],
+ 'intersectionWith': [1, 2, 0],
+ 'isEqualWith': [1, 2, 0],
+ 'isMatchWith': [2, 1, 0],
+ 'mergeAllWith': [1, 0],
+ 'mergeWith': [1, 2, 0],
+ 'padChars': [2, 1, 0],
+ 'padCharsEnd': [2, 1, 0],
+ 'padCharsStart': [2, 1, 0],
+ 'pullAllBy': [2, 1, 0],
+ 'pullAllWith': [2, 1, 0],
+ 'rangeStep': [1, 2, 0],
+ 'rangeStepRight': [1, 2, 0],
+ 'setWith': [3, 1, 2, 0],
+ 'sortedIndexBy': [2, 1, 0],
+ 'sortedLastIndexBy': [2, 1, 0],
+ 'unionBy': [1, 2, 0],
+ 'unionWith': [1, 2, 0],
+ 'updateWith': [3, 1, 2, 0],
+ 'xorBy': [1, 2, 0],
+ 'xorWith': [1, 2, 0],
+ 'zipWith': [1, 2, 0]
+};
+
+/** Used to map method names to spread configs. */
+exports.methodSpread = {
+ 'assignAll': { 'start': 0 },
+ 'assignAllWith': { 'start': 0 },
+ 'assignInAll': { 'start': 0 },
+ 'assignInAllWith': { 'start': 0 },
+ 'defaultsAll': { 'start': 0 },
+ 'defaultsDeepAll': { 'start': 0 },
+ 'invokeArgs': { 'start': 2 },
+ 'invokeArgsMap': { 'start': 2 },
+ 'mergeAll': { 'start': 0 },
+ 'mergeAllWith': { 'start': 0 },
+ 'partial': { 'start': 1 },
+ 'partialRight': { 'start': 1 },
+ 'without': { 'start': 1 },
+ 'zipAll': { 'start': 0 }
+};
+
+/** Used to identify methods which mutate arrays or objects. */
+exports.mutate = {
+ 'array': {
+ 'fill': true,
+ 'pull': true,
+ 'pullAll': true,
+ 'pullAllBy': true,
+ 'pullAllWith': true,
+ 'pullAt': true,
+ 'remove': true,
+ 'reverse': true
+ },
+ 'object': {
+ 'assign': true,
+ 'assignAll': true,
+ 'assignAllWith': true,
+ 'assignIn': true,
+ 'assignInAll': true,
+ 'assignInAllWith': true,
+ 'assignInWith': true,
+ 'assignWith': true,
+ 'defaults': true,
+ 'defaultsAll': true,
+ 'defaultsDeep': true,
+ 'defaultsDeepAll': true,
+ 'merge': true,
+ 'mergeAll': true,
+ 'mergeAllWith': true,
+ 'mergeWith': true,
+ },
+ 'set': {
+ 'set': true,
+ 'setWith': true,
+ 'unset': true,
+ 'update': true,
+ 'updateWith': true
+ }
+};
+
+/** Used to track methods with placeholder support */
+exports.placeholder = {
+ 'bind': true,
+ 'bindKey': true,
+ 'curry': true,
+ 'curryRight': true,
+ 'partial': true,
+ 'partialRight': true
+};
+
+/** Used to map real names to their aliases. */
+exports.realToAlias = (function() {
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
+ object = exports.aliasToReal,
+ result = {};
+
+ for (var key in object) {
+ var value = object[key];
+ if (hasOwnProperty.call(result, value)) {
+ result[value].push(key);
+ } else {
+ result[value] = [key];
+ }
+ }
+ return result;
+}());
+
+/** Used to map method names to other names. */
+exports.remap = {
+ 'assignAll': 'assign',
+ 'assignAllWith': 'assignWith',
+ 'assignInAll': 'assignIn',
+ 'assignInAllWith': 'assignInWith',
+ 'curryN': 'curry',
+ 'curryRightN': 'curryRight',
+ 'defaultsAll': 'defaults',
+ 'defaultsDeepAll': 'defaultsDeep',
+ 'findFrom': 'find',
+ 'findIndexFrom': 'findIndex',
+ 'findLastFrom': 'findLast',
+ 'findLastIndexFrom': 'findLastIndex',
+ 'getOr': 'get',
+ 'includesFrom': 'includes',
+ 'indexOfFrom': 'indexOf',
+ 'invokeArgs': 'invoke',
+ 'invokeArgsMap': 'invokeMap',
+ 'lastIndexOfFrom': 'lastIndexOf',
+ 'mergeAll': 'merge',
+ 'mergeAllWith': 'mergeWith',
+ 'padChars': 'pad',
+ 'padCharsEnd': 'padEnd',
+ 'padCharsStart': 'padStart',
+ 'propertyOf': 'get',
+ 'rangeStep': 'range',
+ 'rangeStepRight': 'rangeRight',
+ 'restFrom': 'rest',
+ 'spreadFrom': 'spread',
+ 'trimChars': 'trim',
+ 'trimCharsEnd': 'trimEnd',
+ 'trimCharsStart': 'trimStart',
+ 'zipAll': 'zip'
+};
+
+/** Used to track methods that skip fixing their arity. */
+exports.skipFixed = {
+ 'castArray': true,
+ 'flow': true,
+ 'flowRight': true,
+ 'iteratee': true,
+ 'mixin': true,
+ 'rearg': true,
+ 'runInContext': true
+};
+
+/** Used to track methods that skip rearranging arguments. */
+exports.skipRearg = {
+ 'add': true,
+ 'assign': true,
+ 'assignIn': true,
+ 'bind': true,
+ 'bindKey': true,
+ 'concat': true,
+ 'difference': true,
+ 'divide': true,
+ 'eq': true,
+ 'gt': true,
+ 'gte': true,
+ 'isEqual': true,
+ 'lt': true,
+ 'lte': true,
+ 'matchesProperty': true,
+ 'merge': true,
+ 'multiply': true,
+ 'overArgs': true,
+ 'partial': true,
+ 'partialRight': true,
+ 'propertyOf': true,
+ 'random': true,
+ 'range': true,
+ 'rangeRight': true,
+ 'subtract': true,
+ 'zip': true,
+ 'zipObject': true,
+ 'zipObjectDeep': true
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_util.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_util.js
new file mode 100644
index 0000000..7084463
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/_util.js
@@ -0,0 +1,14 @@
+module.exports = {
+ 'ary': require('../ary'),
+ 'assign': require('../_baseAssign'),
+ 'clone': require('../clone'),
+ 'curry': require('../curry'),
+ 'forEach': require('../_arrayEach'),
+ 'isArray': require('../isArray'),
+ 'isFunction': require('../isFunction'),
+ 'iteratee': require('../iteratee'),
+ 'keys': require('../_baseKeys'),
+ 'rearg': require('../rearg'),
+ 'toInteger': require('../toInteger'),
+ 'toPath': require('../toPath')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/add.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/add.js
new file mode 100644
index 0000000..816eeec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/add.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('add', require('../add'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/after.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/after.js
new file mode 100644
index 0000000..21a0167
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/after.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('after', require('../after'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/all.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/all.js
new file mode 100644
index 0000000..d0839f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/all.js
@@ -0,0 +1 @@
+module.exports = require('./every');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/allPass.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/allPass.js
new file mode 100644
index 0000000..79b73ef
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/allPass.js
@@ -0,0 +1 @@
+module.exports = require('./overEvery');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/always.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/always.js
new file mode 100644
index 0000000..9887703
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/always.js
@@ -0,0 +1 @@
+module.exports = require('./constant');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/any.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/any.js
new file mode 100644
index 0000000..900ac25
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/any.js
@@ -0,0 +1 @@
+module.exports = require('./some');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/anyPass.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/anyPass.js
new file mode 100644
index 0000000..2774ab3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/anyPass.js
@@ -0,0 +1 @@
+module.exports = require('./overSome');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/apply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/apply.js
new file mode 100644
index 0000000..2b75712
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/apply.js
@@ -0,0 +1 @@
+module.exports = require('./spread');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/array.js
new file mode 100644
index 0000000..fe939c2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/array.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../array'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ary.js
new file mode 100644
index 0000000..8edf187
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ary.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('ary', require('../ary'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assign.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assign.js
new file mode 100644
index 0000000..23f47af
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assign.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assign', require('../assign'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAll.js
new file mode 100644
index 0000000..b1d36c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignAll', require('../assign'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAllWith.js
new file mode 100644
index 0000000..21e836e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignAllWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignAllWith', require('../assignWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignIn.js
new file mode 100644
index 0000000..6e7c65f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignIn', require('../assignIn'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAll.js
new file mode 100644
index 0000000..7ba75db
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignInAll', require('../assignIn'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAllWith.js
new file mode 100644
index 0000000..e766903
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInAllWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignInAllWith', require('../assignInWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInWith.js
new file mode 100644
index 0000000..acb5923
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignInWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignInWith', require('../assignInWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignWith.js
new file mode 100644
index 0000000..eb92521
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assignWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('assignWith', require('../assignWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assoc.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assoc.js
new file mode 100644
index 0000000..7648820
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assoc.js
@@ -0,0 +1 @@
+module.exports = require('./set');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assocPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assocPath.js
new file mode 100644
index 0000000..7648820
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/assocPath.js
@@ -0,0 +1 @@
+module.exports = require('./set');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/at.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/at.js
new file mode 100644
index 0000000..cc39d25
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/at.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('at', require('../at'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/attempt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/attempt.js
new file mode 100644
index 0000000..26ca42e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/attempt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('attempt', require('../attempt'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/before.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/before.js
new file mode 100644
index 0000000..7a2de65
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/before.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('before', require('../before'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bind.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bind.js
new file mode 100644
index 0000000..5cbe4f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bind.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('bind', require('../bind'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindAll.js
new file mode 100644
index 0000000..6b4a4a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('bindAll', require('../bindAll'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindKey.js
new file mode 100644
index 0000000..6a46c6b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/bindKey.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('bindKey', require('../bindKey'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/camelCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/camelCase.js
new file mode 100644
index 0000000..87b77b4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/camelCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('camelCase', require('../camelCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/capitalize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/capitalize.js
new file mode 100644
index 0000000..cac74e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/capitalize.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('capitalize', require('../capitalize'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/castArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/castArray.js
new file mode 100644
index 0000000..8681c09
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/castArray.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('castArray', require('../castArray'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ceil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ceil.js
new file mode 100644
index 0000000..f416b72
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/ceil.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('ceil', require('../ceil'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chain.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chain.js
new file mode 100644
index 0000000..604fe39
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chain.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('chain', require('../chain'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chunk.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chunk.js
new file mode 100644
index 0000000..871ab08
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/chunk.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('chunk', require('../chunk'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clamp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clamp.js
new file mode 100644
index 0000000..3b06c01
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clamp.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('clamp', require('../clamp'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clone.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clone.js
new file mode 100644
index 0000000..cadb59c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/clone.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('clone', require('../clone'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeep.js
new file mode 100644
index 0000000..a6107aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('cloneDeep', require('../cloneDeep'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeepWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeepWith.js
new file mode 100644
index 0000000..6f01e44
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneDeepWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('cloneDeepWith', require('../cloneDeepWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneWith.js
new file mode 100644
index 0000000..aa88578
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cloneWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('cloneWith', require('../cloneWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/collection.js
new file mode 100644
index 0000000..fc8b328
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/collection.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../collection'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/commit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/commit.js
new file mode 100644
index 0000000..130a894
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/commit.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('commit', require('../commit'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compact.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compact.js
new file mode 100644
index 0000000..ce8f7a1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compact.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('compact', require('../compact'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/complement.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/complement.js
new file mode 100644
index 0000000..93eb462
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/complement.js
@@ -0,0 +1 @@
+module.exports = require('./negate');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compose.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compose.js
new file mode 100644
index 0000000..1954e94
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/compose.js
@@ -0,0 +1 @@
+module.exports = require('./flowRight');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/concat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/concat.js
new file mode 100644
index 0000000..e59346a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/concat.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('concat', require('../concat'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cond.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cond.js
new file mode 100644
index 0000000..6a0120e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/cond.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('cond', require('../cond'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conforms.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conforms.js
new file mode 100644
index 0000000..3247f64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conforms.js
@@ -0,0 +1 @@
+module.exports = require('./conformsTo');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conformsTo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conformsTo.js
new file mode 100644
index 0000000..aa7f41e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/conformsTo.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('conformsTo', require('../conformsTo'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/constant.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/constant.js
new file mode 100644
index 0000000..9e406fc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/constant.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('constant', require('../constant'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/contains.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/contains.js
new file mode 100644
index 0000000..594722a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/contains.js
@@ -0,0 +1 @@
+module.exports = require('./includes');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/convert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/convert.js
new file mode 100644
index 0000000..4795dc4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/convert.js
@@ -0,0 +1,18 @@
+var baseConvert = require('./_baseConvert'),
+ util = require('./_util');
+
+/**
+ * Converts `func` of `name` to an immutable auto-curried iteratee-first data-last
+ * version with conversion `options` applied. If `name` is an object its methods
+ * will be converted.
+ *
+ * @param {string} name The name of the function to wrap.
+ * @param {Function} [func] The function to wrap.
+ * @param {Object} [options] The options object. See `baseConvert` for more details.
+ * @returns {Function|Object} Returns the converted function or object.
+ */
+function convert(name, func, options) {
+ return baseConvert(util, name, func, options);
+}
+
+module.exports = convert;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/countBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/countBy.js
new file mode 100644
index 0000000..dfa4643
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/countBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('countBy', require('../countBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/create.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/create.js
new file mode 100644
index 0000000..752025f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/create.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('create', require('../create'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curry.js
new file mode 100644
index 0000000..b0b4168
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curry.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('curry', require('../curry'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryN.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryN.js
new file mode 100644
index 0000000..2ae7d00
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryN.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('curryN', require('../curry'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRight.js
new file mode 100644
index 0000000..cb619eb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('curryRight', require('../curryRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRightN.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRightN.js
new file mode 100644
index 0000000..2495afc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/curryRightN.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('curryRightN', require('../curryRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/date.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/date.js
new file mode 100644
index 0000000..82cb952
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/date.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../date'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/debounce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/debounce.js
new file mode 100644
index 0000000..2612229
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/debounce.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('debounce', require('../debounce'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/deburr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/deburr.js
new file mode 100644
index 0000000..96463ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/deburr.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('deburr', require('../deburr'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultTo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultTo.js
new file mode 100644
index 0000000..d6b52a4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultTo.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defaultTo', require('../defaultTo'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaults.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaults.js
new file mode 100644
index 0000000..e1a8e6e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaults.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defaults', require('../defaults'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsAll.js
new file mode 100644
index 0000000..238fcc3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defaultsAll', require('../defaults'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeep.js
new file mode 100644
index 0000000..1f172ff
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defaultsDeep', require('../defaultsDeep'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeepAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeepAll.js
new file mode 100644
index 0000000..6835f2f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defaultsDeepAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defaultsDeepAll', require('../defaultsDeep'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defer.js
new file mode 100644
index 0000000..ec7990f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/defer.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('defer', require('../defer'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/delay.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/delay.js
new file mode 100644
index 0000000..556dbd5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/delay.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('delay', require('../delay'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/difference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/difference.js
new file mode 100644
index 0000000..2d03765
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/difference.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('difference', require('../difference'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceBy.js
new file mode 100644
index 0000000..2f91491
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('differenceBy', require('../differenceBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceWith.js
new file mode 100644
index 0000000..bcf5ad2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/differenceWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('differenceWith', require('../differenceWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissoc.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissoc.js
new file mode 100644
index 0000000..7ec7be1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissoc.js
@@ -0,0 +1 @@
+module.exports = require('./unset');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissocPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissocPath.js
new file mode 100644
index 0000000..7ec7be1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dissocPath.js
@@ -0,0 +1 @@
+module.exports = require('./unset');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/divide.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/divide.js
new file mode 100644
index 0000000..82048c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/divide.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('divide', require('../divide'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/drop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/drop.js
new file mode 100644
index 0000000..2fa9b4f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/drop.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('drop', require('../drop'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLast.js
new file mode 100644
index 0000000..174e525
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLast.js
@@ -0,0 +1 @@
+module.exports = require('./dropRight');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLastWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLastWhile.js
new file mode 100644
index 0000000..be2a9d2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropLastWhile.js
@@ -0,0 +1 @@
+module.exports = require('./dropRightWhile');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRight.js
new file mode 100644
index 0000000..e98881f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('dropRight', require('../dropRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRightWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRightWhile.js
new file mode 100644
index 0000000..cacaa70
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropRightWhile.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('dropRightWhile', require('../dropRightWhile'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropWhile.js
new file mode 100644
index 0000000..285f864
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/dropWhile.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('dropWhile', require('../dropWhile'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/each.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/each.js
new file mode 100644
index 0000000..8800f42
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/each.js
@@ -0,0 +1 @@
+module.exports = require('./forEach');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eachRight.js
new file mode 100644
index 0000000..3252b2a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eachRight.js
@@ -0,0 +1 @@
+module.exports = require('./forEachRight');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/endsWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/endsWith.js
new file mode 100644
index 0000000..17dc2a4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/endsWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('endsWith', require('../endsWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entries.js
new file mode 100644
index 0000000..7a88df2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entries.js
@@ -0,0 +1 @@
+module.exports = require('./toPairs');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entriesIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entriesIn.js
new file mode 100644
index 0000000..f6c6331
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/entriesIn.js
@@ -0,0 +1 @@
+module.exports = require('./toPairsIn');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eq.js
new file mode 100644
index 0000000..9a3d21b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/eq.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('eq', require('../eq'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/equals.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/equals.js
new file mode 100644
index 0000000..e6a5ce0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/equals.js
@@ -0,0 +1 @@
+module.exports = require('./isEqual');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escape.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escape.js
new file mode 100644
index 0000000..52c1fbb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escape.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('escape', require('../escape'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escapeRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escapeRegExp.js
new file mode 100644
index 0000000..369b2ef
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/escapeRegExp.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('escapeRegExp', require('../escapeRegExp'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/every.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/every.js
new file mode 100644
index 0000000..95c2776
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/every.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('every', require('../every'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extend.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extend.js
new file mode 100644
index 0000000..e00166c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extend.js
@@ -0,0 +1 @@
+module.exports = require('./assignIn');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAll.js
new file mode 100644
index 0000000..cc55b64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAll.js
@@ -0,0 +1 @@
+module.exports = require('./assignInAll');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAllWith.js
new file mode 100644
index 0000000..6679d20
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendAllWith.js
@@ -0,0 +1 @@
+module.exports = require('./assignInAllWith');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendWith.js
new file mode 100644
index 0000000..dbdcb3b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/extendWith.js
@@ -0,0 +1 @@
+module.exports = require('./assignInWith');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fill.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fill.js
new file mode 100644
index 0000000..b2d47e8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fill.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('fill', require('../fill'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/filter.js
new file mode 100644
index 0000000..796d501
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/filter.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('filter', require('../filter'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/find.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/find.js
new file mode 100644
index 0000000..f805d33
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/find.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('find', require('../find'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findFrom.js
new file mode 100644
index 0000000..da8275e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findFrom', require('../find'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndex.js
new file mode 100644
index 0000000..8c15fd1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndex.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findIndex', require('../findIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndexFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndexFrom.js
new file mode 100644
index 0000000..32e98cb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findIndexFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findIndexFrom', require('../findIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findKey.js
new file mode 100644
index 0000000..475bcfa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findKey.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findKey', require('../findKey'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLast.js
new file mode 100644
index 0000000..093fe94
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLast.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findLast', require('../findLast'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastFrom.js
new file mode 100644
index 0000000..76c38fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findLastFrom', require('../findLast'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndex.js
new file mode 100644
index 0000000..36986df
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndex.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findLastIndex', require('../findLastIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndexFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndexFrom.js
new file mode 100644
index 0000000..34c8176
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastIndexFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findLastIndexFrom', require('../findLastIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastKey.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastKey.js
new file mode 100644
index 0000000..5f81b60
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/findLastKey.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('findLastKey', require('../findLastKey'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/first.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/first.js
new file mode 100644
index 0000000..53f4ad1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/first.js
@@ -0,0 +1 @@
+module.exports = require('./head');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMap.js
new file mode 100644
index 0000000..d01dc4d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flatMap', require('../flatMap'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDeep.js
new file mode 100644
index 0000000..569c42e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDeep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flatMapDeep', require('../flatMapDeep'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDepth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDepth.js
new file mode 100644
index 0000000..6eb68fd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatMapDepth.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flatMapDepth', require('../flatMapDepth'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatten.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatten.js
new file mode 100644
index 0000000..30425d8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flatten.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flatten', require('../flatten'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDeep.js
new file mode 100644
index 0000000..aed5db2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDeep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flattenDeep', require('../flattenDeep'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDepth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDepth.js
new file mode 100644
index 0000000..ad65e37
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flattenDepth.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flattenDepth', require('../flattenDepth'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flip.js
new file mode 100644
index 0000000..0547e7b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flip.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flip', require('../flip'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/floor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/floor.js
new file mode 100644
index 0000000..a6cf335
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/floor.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('floor', require('../floor'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flow.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flow.js
new file mode 100644
index 0000000..cd83677
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flow.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flow', require('../flow'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flowRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flowRight.js
new file mode 100644
index 0000000..972a5b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/flowRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('flowRight', require('../flowRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEach.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEach.js
new file mode 100644
index 0000000..2f49452
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEach.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forEach', require('../forEach'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEachRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEachRight.js
new file mode 100644
index 0000000..3ff9733
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forEachRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forEachRight', require('../forEachRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forIn.js
new file mode 100644
index 0000000..9341749
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forIn', require('../forIn'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forInRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forInRight.js
new file mode 100644
index 0000000..cecf8bb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forInRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forInRight', require('../forInRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwn.js
new file mode 100644
index 0000000..246449e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forOwn', require('../forOwn'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwnRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwnRight.js
new file mode 100644
index 0000000..c5e826e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/forOwnRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('forOwnRight', require('../forOwnRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fromPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fromPairs.js
new file mode 100644
index 0000000..f8cc596
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/fromPairs.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('fromPairs', require('../fromPairs'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/function.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/function.js
new file mode 100644
index 0000000..dfe69b1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/function.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../function'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functions.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functions.js
new file mode 100644
index 0000000..09d1bb1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functions.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('functions', require('../functions'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functionsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functionsIn.js
new file mode 100644
index 0000000..2cfeb83
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/functionsIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('functionsIn', require('../functionsIn'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/get.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/get.js
new file mode 100644
index 0000000..6d3a328
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/get.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('get', require('../get'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/getOr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/getOr.js
new file mode 100644
index 0000000..7dbf771
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/getOr.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('getOr', require('../get'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/groupBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/groupBy.js
new file mode 100644
index 0000000..fc0bc78
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/groupBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('groupBy', require('../groupBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gt.js
new file mode 100644
index 0000000..9e57c80
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('gt', require('../gt'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gte.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gte.js
new file mode 100644
index 0000000..4584786
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/gte.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('gte', require('../gte'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/has.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/has.js
new file mode 100644
index 0000000..b901298
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/has.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('has', require('../has'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/hasIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/hasIn.js
new file mode 100644
index 0000000..b3c3d1a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/hasIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('hasIn', require('../hasIn'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/head.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/head.js
new file mode 100644
index 0000000..2694f0a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/head.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('head', require('../head'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identical.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identical.js
new file mode 100644
index 0000000..85563f4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identical.js
@@ -0,0 +1 @@
+module.exports = require('./eq');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identity.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identity.js
new file mode 100644
index 0000000..096415a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/identity.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('identity', require('../identity'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/inRange.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/inRange.js
new file mode 100644
index 0000000..202d940
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/inRange.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('inRange', require('../inRange'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includes.js
new file mode 100644
index 0000000..1146780
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includes.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('includes', require('../includes'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includesFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includesFrom.js
new file mode 100644
index 0000000..683afdb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/includesFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('includesFrom', require('../includes'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexBy.js
new file mode 100644
index 0000000..7e64bc0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexBy.js
@@ -0,0 +1 @@
+module.exports = require('./keyBy');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOf.js
new file mode 100644
index 0000000..524658e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('indexOf', require('../indexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOfFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOfFrom.js
new file mode 100644
index 0000000..d99c822
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/indexOfFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('indexOfFrom', require('../indexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/init.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/init.js
new file mode 100644
index 0000000..2f88d8b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/init.js
@@ -0,0 +1 @@
+module.exports = require('./initial');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/initial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/initial.js
new file mode 100644
index 0000000..b732ba0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/initial.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('initial', require('../initial'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersection.js
new file mode 100644
index 0000000..52936d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersection.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('intersection', require('../intersection'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionBy.js
new file mode 100644
index 0000000..72629f2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('intersectionBy', require('../intersectionBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionWith.js
new file mode 100644
index 0000000..e064f40
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/intersectionWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('intersectionWith', require('../intersectionWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invert.js
new file mode 100644
index 0000000..2d5d1f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invert.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invert', require('../invert'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertBy.js
new file mode 100644
index 0000000..63ca97e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invertBy', require('../invertBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertObj.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertObj.js
new file mode 100644
index 0000000..f1d842e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invertObj.js
@@ -0,0 +1 @@
+module.exports = require('./invert');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invoke.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invoke.js
new file mode 100644
index 0000000..fcf17f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invoke.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invoke', require('../invoke'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgs.js
new file mode 100644
index 0000000..d3f2953
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgs.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invokeArgs', require('../invoke'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgsMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgsMap.js
new file mode 100644
index 0000000..eaa9f84
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeArgsMap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invokeArgsMap', require('../invokeMap'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeMap.js
new file mode 100644
index 0000000..6515fd7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/invokeMap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('invokeMap', require('../invokeMap'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArguments.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArguments.js
new file mode 100644
index 0000000..1d93c9e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArguments.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isArguments', require('../isArguments'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArray.js
new file mode 100644
index 0000000..ba7ade8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArray.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isArray', require('../isArray'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayBuffer.js
new file mode 100644
index 0000000..5088513
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayBuffer.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isArrayBuffer', require('../isArrayBuffer'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLike.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLike.js
new file mode 100644
index 0000000..8f1856b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLike.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isArrayLike', require('../isArrayLike'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLikeObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLikeObject.js
new file mode 100644
index 0000000..2108498
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isArrayLikeObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isArrayLikeObject', require('../isArrayLikeObject'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBoolean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBoolean.js
new file mode 100644
index 0000000..9339f75
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBoolean.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isBoolean', require('../isBoolean'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBuffer.js
new file mode 100644
index 0000000..e60b123
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isBuffer.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isBuffer', require('../isBuffer'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isDate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isDate.js
new file mode 100644
index 0000000..dc41d08
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isDate.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isDate', require('../isDate'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isElement.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isElement.js
new file mode 100644
index 0000000..18ee039
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isElement.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isElement', require('../isElement'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEmpty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEmpty.js
new file mode 100644
index 0000000..0f4ae84
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEmpty.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isEmpty', require('../isEmpty'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqual.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqual.js
new file mode 100644
index 0000000..4138386
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqual.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isEqual', require('../isEqual'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqualWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqualWith.js
new file mode 100644
index 0000000..029ff5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isEqualWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isEqualWith', require('../isEqualWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isError.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isError.js
new file mode 100644
index 0000000..3dfd81c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isError.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isError', require('../isError'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFinite.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFinite.js
new file mode 100644
index 0000000..0b647b8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFinite.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isFinite', require('../isFinite'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFunction.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFunction.js
new file mode 100644
index 0000000..ff8e5c4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isFunction.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isFunction', require('../isFunction'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isInteger.js
new file mode 100644
index 0000000..67af4ff
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isInteger.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isInteger', require('../isInteger'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isLength.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isLength.js
new file mode 100644
index 0000000..fc101c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isLength.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isLength', require('../isLength'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMap.js
new file mode 100644
index 0000000..a209aa6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isMap', require('../isMap'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatch.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatch.js
new file mode 100644
index 0000000..6264ca1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatch.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isMatch', require('../isMatch'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatchWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatchWith.js
new file mode 100644
index 0000000..d95f319
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isMatchWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isMatchWith', require('../isMatchWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNaN.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNaN.js
new file mode 100644
index 0000000..66a978f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNaN.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isNaN', require('../isNaN'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNative.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNative.js
new file mode 100644
index 0000000..3d775ba
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNative.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isNative', require('../isNative'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNil.js
new file mode 100644
index 0000000..5952c02
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNil.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isNil', require('../isNil'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNull.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNull.js
new file mode 100644
index 0000000..f201a35
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNull.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isNull', require('../isNull'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNumber.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNumber.js
new file mode 100644
index 0000000..a2b5fa0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isNumber.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isNumber', require('../isNumber'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObject.js
new file mode 100644
index 0000000..231ace0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isObject', require('../isObject'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObjectLike.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObjectLike.js
new file mode 100644
index 0000000..f16082e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isObjectLike.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isObjectLike', require('../isObjectLike'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isPlainObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isPlainObject.js
new file mode 100644
index 0000000..b5bea90
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isPlainObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isPlainObject', require('../isPlainObject'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isRegExp.js
new file mode 100644
index 0000000..12a1a3d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isRegExp.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isRegExp', require('../isRegExp'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSafeInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSafeInteger.js
new file mode 100644
index 0000000..7230f55
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSafeInteger.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isSafeInteger', require('../isSafeInteger'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSet.js
new file mode 100644
index 0000000..35c01f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSet.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isSet', require('../isSet'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isString.js
new file mode 100644
index 0000000..1fd0679
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isString.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isString', require('../isString'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSymbol.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSymbol.js
new file mode 100644
index 0000000..3867695
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isSymbol.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isSymbol', require('../isSymbol'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isTypedArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isTypedArray.js
new file mode 100644
index 0000000..8567953
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isTypedArray.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isTypedArray', require('../isTypedArray'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isUndefined.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isUndefined.js
new file mode 100644
index 0000000..ddbca31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isUndefined.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isUndefined', require('../isUndefined'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakMap.js
new file mode 100644
index 0000000..ef60c61
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakMap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isWeakMap', require('../isWeakMap'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakSet.js
new file mode 100644
index 0000000..c99bfaa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/isWeakSet.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('isWeakSet', require('../isWeakSet'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/iteratee.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/iteratee.js
new file mode 100644
index 0000000..9f0f717
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/iteratee.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('iteratee', require('../iteratee'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/join.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/join.js
new file mode 100644
index 0000000..a220e00
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/join.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('join', require('../join'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/juxt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/juxt.js
new file mode 100644
index 0000000..f71e04e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/juxt.js
@@ -0,0 +1 @@
+module.exports = require('./over');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/kebabCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/kebabCase.js
new file mode 100644
index 0000000..60737f1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/kebabCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('kebabCase', require('../kebabCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keyBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keyBy.js
new file mode 100644
index 0000000..9a6a85d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keyBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('keyBy', require('../keyBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keys.js
new file mode 100644
index 0000000..e12bb07
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keys.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('keys', require('../keys'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keysIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keysIn.js
new file mode 100644
index 0000000..f3eb36a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/keysIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('keysIn', require('../keysIn'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lang.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lang.js
new file mode 100644
index 0000000..08cc9c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lang.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../lang'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/last.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/last.js
new file mode 100644
index 0000000..0f71699
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/last.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('last', require('../last'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOf.js
new file mode 100644
index 0000000..ddf39c3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lastIndexOf', require('../lastIndexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOfFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOfFrom.js
new file mode 100644
index 0000000..1ff6a0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lastIndexOfFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lastIndexOfFrom', require('../lastIndexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerCase.js
new file mode 100644
index 0000000..ea64bc1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lowerCase', require('../lowerCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerFirst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerFirst.js
new file mode 100644
index 0000000..539720a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lowerFirst.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lowerFirst', require('../lowerFirst'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lt.js
new file mode 100644
index 0000000..a31d21e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lt', require('../lt'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lte.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lte.js
new file mode 100644
index 0000000..d795d10
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/lte.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('lte', require('../lte'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/map.js
new file mode 100644
index 0000000..cf98794
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/map.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('map', require('../map'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapKeys.js
new file mode 100644
index 0000000..1684587
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapKeys.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mapKeys', require('../mapKeys'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapValues.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapValues.js
new file mode 100644
index 0000000..4004972
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mapValues.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mapValues', require('../mapValues'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matches.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matches.js
new file mode 100644
index 0000000..29d1e1e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matches.js
@@ -0,0 +1 @@
+module.exports = require('./isMatch');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matchesProperty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matchesProperty.js
new file mode 100644
index 0000000..4575bd2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/matchesProperty.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('matchesProperty', require('../matchesProperty'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/math.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/math.js
new file mode 100644
index 0000000..e8f50f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/math.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../math'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/max.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/max.js
new file mode 100644
index 0000000..a66acac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/max.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('max', require('../max'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/maxBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/maxBy.js
new file mode 100644
index 0000000..d083fd6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/maxBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('maxBy', require('../maxBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mean.js
new file mode 100644
index 0000000..3117246
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mean.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mean', require('../mean'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/meanBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/meanBy.js
new file mode 100644
index 0000000..556f25e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/meanBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('meanBy', require('../meanBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/memoize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/memoize.js
new file mode 100644
index 0000000..638eec6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/memoize.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('memoize', require('../memoize'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/merge.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/merge.js
new file mode 100644
index 0000000..ac66add
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/merge.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('merge', require('../merge'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAll.js
new file mode 100644
index 0000000..a3674d6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mergeAll', require('../merge'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAllWith.js
new file mode 100644
index 0000000..4bd4206
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeAllWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mergeAllWith', require('../mergeWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeWith.js
new file mode 100644
index 0000000..00d44d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mergeWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mergeWith', require('../mergeWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/method.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/method.js
new file mode 100644
index 0000000..f4060c6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/method.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('method', require('../method'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/methodOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/methodOf.js
new file mode 100644
index 0000000..6139905
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/methodOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('methodOf', require('../methodOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/min.js
new file mode 100644
index 0000000..d12c6b4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/min.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('min', require('../min'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/minBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/minBy.js
new file mode 100644
index 0000000..fdb9e24
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/minBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('minBy', require('../minBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mixin.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mixin.js
new file mode 100644
index 0000000..332e6fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/mixin.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('mixin', require('../mixin'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/multiply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/multiply.js
new file mode 100644
index 0000000..4dcf0b0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/multiply.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('multiply', require('../multiply'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nAry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nAry.js
new file mode 100644
index 0000000..f262a76
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nAry.js
@@ -0,0 +1 @@
+module.exports = require('./ary');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/negate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/negate.js
new file mode 100644
index 0000000..8b6dc7c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/negate.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('negate', require('../negate'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/next.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/next.js
new file mode 100644
index 0000000..140155e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/next.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('next', require('../next'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/noop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/noop.js
new file mode 100644
index 0000000..b9e32cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/noop.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('noop', require('../noop'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/now.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/now.js
new file mode 100644
index 0000000..6de2068
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/now.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('now', require('../now'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nth.js
new file mode 100644
index 0000000..da4fda7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nth.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('nth', require('../nth'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nthArg.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nthArg.js
new file mode 100644
index 0000000..fce3165
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/nthArg.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('nthArg', require('../nthArg'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/number.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/number.js
new file mode 100644
index 0000000..5c10b88
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/number.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../number'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/object.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/object.js
new file mode 100644
index 0000000..ae39a13
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/object.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../object'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omit.js
new file mode 100644
index 0000000..fd68529
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omit.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('omit', require('../omit'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitAll.js
new file mode 100644
index 0000000..144cf4b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitAll.js
@@ -0,0 +1 @@
+module.exports = require('./omit');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitBy.js
new file mode 100644
index 0000000..90df738
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/omitBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('omitBy', require('../omitBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/once.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/once.js
new file mode 100644
index 0000000..f8f0a5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/once.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('once', require('../once'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/orderBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/orderBy.js
new file mode 100644
index 0000000..848e210
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/orderBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('orderBy', require('../orderBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/over.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/over.js
new file mode 100644
index 0000000..01eba7b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/over.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('over', require('../over'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overArgs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overArgs.js
new file mode 100644
index 0000000..738556f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overArgs.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('overArgs', require('../overArgs'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overEvery.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overEvery.js
new file mode 100644
index 0000000..9f5a032
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overEvery.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('overEvery', require('../overEvery'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overSome.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overSome.js
new file mode 100644
index 0000000..15939d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/overSome.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('overSome', require('../overSome'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pad.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pad.js
new file mode 100644
index 0000000..f1dea4a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pad.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pad', require('../pad'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padChars.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padChars.js
new file mode 100644
index 0000000..d6e0804
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padChars.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('padChars', require('../pad'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsEnd.js
new file mode 100644
index 0000000..d4ab79a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsEnd.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('padCharsEnd', require('../padEnd'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsStart.js
new file mode 100644
index 0000000..a08a300
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padCharsStart.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('padCharsStart', require('../padStart'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padEnd.js
new file mode 100644
index 0000000..a8522ec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padEnd.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('padEnd', require('../padEnd'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padStart.js
new file mode 100644
index 0000000..f4ca79d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/padStart.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('padStart', require('../padStart'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/parseInt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/parseInt.js
new file mode 100644
index 0000000..27314cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/parseInt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('parseInt', require('../parseInt'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partial.js
new file mode 100644
index 0000000..5d46015
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partial.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('partial', require('../partial'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partialRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partialRight.js
new file mode 100644
index 0000000..7f05fed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partialRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('partialRight', require('../partialRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partition.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partition.js
new file mode 100644
index 0000000..2ebcacc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/partition.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('partition', require('../partition'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/path.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/path.js
new file mode 100644
index 0000000..b29cfb2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/path.js
@@ -0,0 +1 @@
+module.exports = require('./get');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathEq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathEq.js
new file mode 100644
index 0000000..36c027a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathEq.js
@@ -0,0 +1 @@
+module.exports = require('./matchesProperty');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathOr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathOr.js
new file mode 100644
index 0000000..4ab5820
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pathOr.js
@@ -0,0 +1 @@
+module.exports = require('./getOr');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/paths.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/paths.js
new file mode 100644
index 0000000..1eb7950
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/paths.js
@@ -0,0 +1 @@
+module.exports = require('./at');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pick.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pick.js
new file mode 100644
index 0000000..197393d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pick.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pick', require('../pick'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickAll.js
new file mode 100644
index 0000000..a8ecd46
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickAll.js
@@ -0,0 +1 @@
+module.exports = require('./pick');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickBy.js
new file mode 100644
index 0000000..d832d16
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pickBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pickBy', require('../pickBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pipe.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pipe.js
new file mode 100644
index 0000000..b2e1e2c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pipe.js
@@ -0,0 +1 @@
+module.exports = require('./flow');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/placeholder.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/placeholder.js
new file mode 100644
index 0000000..1ce1739
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/placeholder.js
@@ -0,0 +1,6 @@
+/**
+ * The default argument placeholder value for methods.
+ *
+ * @type {Object}
+ */
+module.exports = {};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/plant.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/plant.js
new file mode 100644
index 0000000..eca8f32
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/plant.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('plant', require('../plant'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pluck.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pluck.js
new file mode 100644
index 0000000..0d1e1ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pluck.js
@@ -0,0 +1 @@
+module.exports = require('./map');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/prop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/prop.js
new file mode 100644
index 0000000..b29cfb2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/prop.js
@@ -0,0 +1 @@
+module.exports = require('./get');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propEq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propEq.js
new file mode 100644
index 0000000..36c027a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propEq.js
@@ -0,0 +1 @@
+module.exports = require('./matchesProperty');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propOr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propOr.js
new file mode 100644
index 0000000..4ab5820
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propOr.js
@@ -0,0 +1 @@
+module.exports = require('./getOr');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/property.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/property.js
new file mode 100644
index 0000000..b29cfb2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/property.js
@@ -0,0 +1 @@
+module.exports = require('./get');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propertyOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propertyOf.js
new file mode 100644
index 0000000..f6273ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/propertyOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('propertyOf', require('../get'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/props.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/props.js
new file mode 100644
index 0000000..1eb7950
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/props.js
@@ -0,0 +1 @@
+module.exports = require('./at');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pull.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pull.js
new file mode 100644
index 0000000..8d7084f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pull.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pull', require('../pull'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAll.js
new file mode 100644
index 0000000..98d5c9a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pullAll', require('../pullAll'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllBy.js
new file mode 100644
index 0000000..876bc3b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pullAllBy', require('../pullAllBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllWith.js
new file mode 100644
index 0000000..f71ba4d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAllWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pullAllWith', require('../pullAllWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAt.js
new file mode 100644
index 0000000..e8b3bb6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/pullAt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('pullAt', require('../pullAt'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/random.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/random.js
new file mode 100644
index 0000000..99d852e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/random.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('random', require('../random'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/range.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/range.js
new file mode 100644
index 0000000..a6bb591
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/range.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('range', require('../range'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeRight.js
new file mode 100644
index 0000000..fdb712f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('rangeRight', require('../rangeRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStep.js
new file mode 100644
index 0000000..d72dfc2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('rangeStep', require('../range'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStepRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStepRight.js
new file mode 100644
index 0000000..8b2a67b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rangeStepRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('rangeStepRight', require('../rangeRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rearg.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rearg.js
new file mode 100644
index 0000000..678e02a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rearg.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('rearg', require('../rearg'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduce.js
new file mode 100644
index 0000000..4cef0a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduce.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('reduce', require('../reduce'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduceRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduceRight.js
new file mode 100644
index 0000000..caf5bb5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reduceRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('reduceRight', require('../reduceRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reject.js
new file mode 100644
index 0000000..c163273
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('reject', require('../reject'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/remove.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/remove.js
new file mode 100644
index 0000000..e9d1327
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/remove.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('remove', require('../remove'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/repeat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/repeat.js
new file mode 100644
index 0000000..08470f2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/repeat.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('repeat', require('../repeat'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/replace.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/replace.js
new file mode 100644
index 0000000..2227db6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/replace.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('replace', require('../replace'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rest.js
new file mode 100644
index 0000000..c1f3d64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/rest.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('rest', require('../rest'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/restFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/restFrom.js
new file mode 100644
index 0000000..714e42b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/restFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('restFrom', require('../rest'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/result.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/result.js
new file mode 100644
index 0000000..f86ce07
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/result.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('result', require('../result'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reverse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reverse.js
new file mode 100644
index 0000000..07c9f5e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/reverse.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('reverse', require('../reverse'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/round.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/round.js
new file mode 100644
index 0000000..4c0e5c8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/round.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('round', require('../round'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sample.js
new file mode 100644
index 0000000..6bea125
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sample.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sample', require('../sample'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sampleSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sampleSize.js
new file mode 100644
index 0000000..359ed6f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sampleSize.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sampleSize', require('../sampleSize'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/seq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/seq.js
new file mode 100644
index 0000000..d8f42b0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/seq.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../seq'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/set.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/set.js
new file mode 100644
index 0000000..0b56a56
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/set.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('set', require('../set'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/setWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/setWith.js
new file mode 100644
index 0000000..0b58495
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/setWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('setWith', require('../setWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/shuffle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/shuffle.js
new file mode 100644
index 0000000..aa3a1ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/shuffle.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('shuffle', require('../shuffle'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/size.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/size.js
new file mode 100644
index 0000000..7490136
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/size.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('size', require('../size'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/slice.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/slice.js
new file mode 100644
index 0000000..15945d3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/slice.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('slice', require('../slice'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/snakeCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/snakeCase.js
new file mode 100644
index 0000000..a0ff780
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/snakeCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('snakeCase', require('../snakeCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/some.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/some.js
new file mode 100644
index 0000000..a4fa2d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/some.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('some', require('../some'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortBy.js
new file mode 100644
index 0000000..e0790ad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortBy', require('../sortBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndex.js
new file mode 100644
index 0000000..364a054
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndex.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedIndex', require('../sortedIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexBy.js
new file mode 100644
index 0000000..9593dbd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedIndexBy', require('../sortedIndexBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexOf.js
new file mode 100644
index 0000000..c9084ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedIndexOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedIndexOf', require('../sortedIndexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndex.js
new file mode 100644
index 0000000..47fe241
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndex.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedLastIndex', require('../sortedLastIndex'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexBy.js
new file mode 100644
index 0000000..0f9a347
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedLastIndexBy', require('../sortedLastIndexBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexOf.js
new file mode 100644
index 0000000..0d4d932
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedLastIndexOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedLastIndexOf', require('../sortedLastIndexOf'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniq.js
new file mode 100644
index 0000000..882d283
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniq.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedUniq', require('../sortedUniq'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniqBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniqBy.js
new file mode 100644
index 0000000..033db91
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sortedUniqBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sortedUniqBy', require('../sortedUniqBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/split.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/split.js
new file mode 100644
index 0000000..14de1a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/split.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('split', require('../split'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spread.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spread.js
new file mode 100644
index 0000000..2d11b70
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spread.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('spread', require('../spread'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spreadFrom.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spreadFrom.js
new file mode 100644
index 0000000..0b630df
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/spreadFrom.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('spreadFrom', require('../spread'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startCase.js
new file mode 100644
index 0000000..ada98c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('startCase', require('../startCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startsWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startsWith.js
new file mode 100644
index 0000000..985e2f2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/startsWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('startsWith', require('../startsWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/string.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/string.js
new file mode 100644
index 0000000..773b037
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/string.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../string'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubArray.js
new file mode 100644
index 0000000..cd604cb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubArray.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('stubArray', require('../stubArray'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubFalse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubFalse.js
new file mode 100644
index 0000000..3296664
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubFalse.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('stubFalse', require('../stubFalse'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubObject.js
new file mode 100644
index 0000000..c6c8ec4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('stubObject', require('../stubObject'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubString.js
new file mode 100644
index 0000000..701051e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubString.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('stubString', require('../stubString'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubTrue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubTrue.js
new file mode 100644
index 0000000..9249082
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/stubTrue.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('stubTrue', require('../stubTrue'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/subtract.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/subtract.js
new file mode 100644
index 0000000..d32b16d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/subtract.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('subtract', require('../subtract'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sum.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sum.js
new file mode 100644
index 0000000..5cce12b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sum.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sum', require('../sum'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sumBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sumBy.js
new file mode 100644
index 0000000..c882656
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/sumBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('sumBy', require('../sumBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifference.js
new file mode 100644
index 0000000..78c16ad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifference.js
@@ -0,0 +1 @@
+module.exports = require('./xor');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceBy.js
new file mode 100644
index 0000000..298fc7f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceBy.js
@@ -0,0 +1 @@
+module.exports = require('./xorBy');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceWith.js
new file mode 100644
index 0000000..70bc6fa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/symmetricDifferenceWith.js
@@ -0,0 +1 @@
+module.exports = require('./xorWith');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tail.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tail.js
new file mode 100644
index 0000000..f122f0a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tail.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('tail', require('../tail'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/take.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/take.js
new file mode 100644
index 0000000..9af98a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/take.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('take', require('../take'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLast.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLast.js
new file mode 100644
index 0000000..e98c84a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLast.js
@@ -0,0 +1 @@
+module.exports = require('./takeRight');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLastWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLastWhile.js
new file mode 100644
index 0000000..5367968
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeLastWhile.js
@@ -0,0 +1 @@
+module.exports = require('./takeRightWhile');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRight.js
new file mode 100644
index 0000000..b82950a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRight.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('takeRight', require('../takeRight'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRightWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRightWhile.js
new file mode 100644
index 0000000..8ffb0a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeRightWhile.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('takeRightWhile', require('../takeRightWhile'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeWhile.js
new file mode 100644
index 0000000..2813664
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/takeWhile.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('takeWhile', require('../takeWhile'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tap.js
new file mode 100644
index 0000000..d33ad6e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/tap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('tap', require('../tap'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/template.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/template.js
new file mode 100644
index 0000000..74857e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/template.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('template', require('../template'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/templateSettings.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/templateSettings.js
new file mode 100644
index 0000000..7bcc0a8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/templateSettings.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('templateSettings', require('../templateSettings'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/throttle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/throttle.js
new file mode 100644
index 0000000..77fff14
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/throttle.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('throttle', require('../throttle'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/thru.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/thru.js
new file mode 100644
index 0000000..d42b3b1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/thru.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('thru', require('../thru'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/times.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/times.js
new file mode 100644
index 0000000..0dab06d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/times.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('times', require('../times'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toArray.js
new file mode 100644
index 0000000..f0c360a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toArray.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toArray', require('../toArray'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toFinite.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toFinite.js
new file mode 100644
index 0000000..3a47687
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toFinite.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toFinite', require('../toFinite'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toInteger.js
new file mode 100644
index 0000000..e0af6a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toInteger.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toInteger', require('../toInteger'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toIterator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toIterator.js
new file mode 100644
index 0000000..65e6baa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toIterator.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toIterator', require('../toIterator'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toJSON.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toJSON.js
new file mode 100644
index 0000000..2d718d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toJSON.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toJSON', require('../toJSON'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLength.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLength.js
new file mode 100644
index 0000000..b97cdd9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLength.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toLength', require('../toLength'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLower.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLower.js
new file mode 100644
index 0000000..616ef36
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toLower.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toLower', require('../toLower'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toNumber.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toNumber.js
new file mode 100644
index 0000000..d0c6f4d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toNumber.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toNumber', require('../toNumber'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairs.js
new file mode 100644
index 0000000..af78378
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairs.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toPairs', require('../toPairs'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairsIn.js
new file mode 100644
index 0000000..66504ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPairsIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toPairsIn', require('../toPairsIn'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPath.js
new file mode 100644
index 0000000..b4d5e50
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPath.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toPath', require('../toPath'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPlainObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPlainObject.js
new file mode 100644
index 0000000..278bb86
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toPlainObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toPlainObject', require('../toPlainObject'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toSafeInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toSafeInteger.js
new file mode 100644
index 0000000..367a26f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toSafeInteger.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toSafeInteger', require('../toSafeInteger'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toString.js
new file mode 100644
index 0000000..cec4f8e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toString.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toString', require('../toString'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toUpper.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toUpper.js
new file mode 100644
index 0000000..54f9a56
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/toUpper.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('toUpper', require('../toUpper'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/transform.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/transform.js
new file mode 100644
index 0000000..759d088
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/transform.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('transform', require('../transform'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trim.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trim.js
new file mode 100644
index 0000000..e6319a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trim.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trim', require('../trim'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimChars.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimChars.js
new file mode 100644
index 0000000..c9294de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimChars.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trimChars', require('../trim'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsEnd.js
new file mode 100644
index 0000000..284bc2f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsEnd.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trimCharsEnd', require('../trimEnd'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsStart.js
new file mode 100644
index 0000000..ff0ee65
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimCharsStart.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trimCharsStart', require('../trimStart'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimEnd.js
new file mode 100644
index 0000000..7190880
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimEnd.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trimEnd', require('../trimEnd'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimStart.js
new file mode 100644
index 0000000..fda902c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/trimStart.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('trimStart', require('../trimStart'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/truncate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/truncate.js
new file mode 100644
index 0000000..d265c1d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/truncate.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('truncate', require('../truncate'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unapply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unapply.js
new file mode 100644
index 0000000..c5dfe77
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unapply.js
@@ -0,0 +1 @@
+module.exports = require('./rest');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unary.js
new file mode 100644
index 0000000..286c945
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unary.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unary', require('../unary'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unescape.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unescape.js
new file mode 100644
index 0000000..fddcb46
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unescape.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unescape', require('../unescape'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/union.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/union.js
new file mode 100644
index 0000000..ef8228d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/union.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('union', require('../union'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionBy.js
new file mode 100644
index 0000000..603687a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unionBy', require('../unionBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionWith.js
new file mode 100644
index 0000000..65bb3a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unionWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unionWith', require('../unionWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniq.js
new file mode 100644
index 0000000..bc18524
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniq.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('uniq', require('../uniq'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqBy.js
new file mode 100644
index 0000000..634c6a8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('uniqBy', require('../uniqBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqWith.js
new file mode 100644
index 0000000..0ec601a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('uniqWith', require('../uniqWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqueId.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqueId.js
new file mode 100644
index 0000000..aa8fc2f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/uniqueId.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('uniqueId', require('../uniqueId'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unnest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unnest.js
new file mode 100644
index 0000000..5d34060
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unnest.js
@@ -0,0 +1 @@
+module.exports = require('./flatten');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unset.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unset.js
new file mode 100644
index 0000000..ea203a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unset.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unset', require('../unset'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzip.js
new file mode 100644
index 0000000..cc364b3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzip.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unzip', require('../unzip'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzipWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzipWith.js
new file mode 100644
index 0000000..182eaa1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/unzipWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('unzipWith', require('../unzipWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/update.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/update.js
new file mode 100644
index 0000000..b8ce2cc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/update.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('update', require('../update'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/updateWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/updateWith.js
new file mode 100644
index 0000000..d5e8282
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/updateWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('updateWith', require('../updateWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperCase.js
new file mode 100644
index 0000000..c886f20
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperCase.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('upperCase', require('../upperCase'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperFirst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperFirst.js
new file mode 100644
index 0000000..d8c04df
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/upperFirst.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('upperFirst', require('../upperFirst'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/useWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/useWith.js
new file mode 100644
index 0000000..d8b3df5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/useWith.js
@@ -0,0 +1 @@
+module.exports = require('./overArgs');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/util.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/util.js
new file mode 100644
index 0000000..18c00ba
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/util.js
@@ -0,0 +1,2 @@
+var convert = require('./convert');
+module.exports = convert(require('../util'));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/value.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/value.js
new file mode 100644
index 0000000..555eec7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/value.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('value', require('../value'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valueOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valueOf.js
new file mode 100644
index 0000000..f968807
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valueOf.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('valueOf', require('../valueOf'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/values.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/values.js
new file mode 100644
index 0000000..2dfc561
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/values.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('values', require('../values'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valuesIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valuesIn.js
new file mode 100644
index 0000000..a1b2bb8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/valuesIn.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('valuesIn', require('../valuesIn'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/where.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/where.js
new file mode 100644
index 0000000..3247f64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/where.js
@@ -0,0 +1 @@
+module.exports = require('./conformsTo');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/whereEq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/whereEq.js
new file mode 100644
index 0000000..29d1e1e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/whereEq.js
@@ -0,0 +1 @@
+module.exports = require('./isMatch');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/without.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/without.js
new file mode 100644
index 0000000..bad9e12
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/without.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('without', require('../without'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/words.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/words.js
new file mode 100644
index 0000000..4a90141
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/words.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('words', require('../words'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrap.js
new file mode 100644
index 0000000..e93bd8a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrap.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrap', require('../wrap'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperAt.js
new file mode 100644
index 0000000..8f0a310
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperAt.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrapperAt', require('../wrapperAt'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperChain.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperChain.js
new file mode 100644
index 0000000..2a48ea2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperChain.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrapperChain', require('../wrapperChain'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperLodash.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperLodash.js
new file mode 100644
index 0000000..a7162d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperLodash.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrapperLodash', require('../wrapperLodash'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperReverse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperReverse.js
new file mode 100644
index 0000000..e1481aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperReverse.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrapperReverse', require('../wrapperReverse'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperValue.js
new file mode 100644
index 0000000..8eb9112
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/wrapperValue.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('wrapperValue', require('../wrapperValue'), require('./_falseOptions'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xor.js
new file mode 100644
index 0000000..29e2819
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xor.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('xor', require('../xor'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorBy.js
new file mode 100644
index 0000000..b355686
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorBy.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('xorBy', require('../xorBy'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorWith.js
new file mode 100644
index 0000000..8e05739
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/xorWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('xorWith', require('../xorWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zip.js
new file mode 100644
index 0000000..69e147a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zip.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('zip', require('../zip'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipAll.js
new file mode 100644
index 0000000..efa8ccb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipAll.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('zipAll', require('../zip'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObj.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObj.js
new file mode 100644
index 0000000..f4a3453
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObj.js
@@ -0,0 +1 @@
+module.exports = require('./zipObject');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObject.js
new file mode 100644
index 0000000..462dbb6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObject.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('zipObject', require('../zipObject'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObjectDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObjectDeep.js
new file mode 100644
index 0000000..53a5d33
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipObjectDeep.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('zipObjectDeep', require('../zipObjectDeep'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipWith.js
new file mode 100644
index 0000000..c5cf9e2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fp/zipWith.js
@@ -0,0 +1,5 @@
+var convert = require('./convert'),
+ func = convert('zipWith', require('../zipWith'));
+
+func.placeholder = require('./placeholder');
+module.exports = func;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fromPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fromPairs.js
new file mode 100644
index 0000000..ee7940d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/fromPairs.js
@@ -0,0 +1,28 @@
+/**
+ * The inverse of `_.toPairs`; this method returns an object composed
+ * from key-value `pairs`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} pairs The key-value pairs.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.fromPairs([['a', 1], ['b', 2]]);
+ * // => { 'a': 1, 'b': 2 }
+ */
+function fromPairs(pairs) {
+ var index = -1,
+ length = pairs == null ? 0 : pairs.length,
+ result = {};
+
+ while (++index < length) {
+ var pair = pairs[index];
+ result[pair[0]] = pair[1];
+ }
+ return result;
+}
+
+module.exports = fromPairs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/function.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/function.js
new file mode 100644
index 0000000..b0fc6d9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/function.js
@@ -0,0 +1,25 @@
+module.exports = {
+ 'after': require('./after'),
+ 'ary': require('./ary'),
+ 'before': require('./before'),
+ 'bind': require('./bind'),
+ 'bindKey': require('./bindKey'),
+ 'curry': require('./curry'),
+ 'curryRight': require('./curryRight'),
+ 'debounce': require('./debounce'),
+ 'defer': require('./defer'),
+ 'delay': require('./delay'),
+ 'flip': require('./flip'),
+ 'memoize': require('./memoize'),
+ 'negate': require('./negate'),
+ 'once': require('./once'),
+ 'overArgs': require('./overArgs'),
+ 'partial': require('./partial'),
+ 'partialRight': require('./partialRight'),
+ 'rearg': require('./rearg'),
+ 'rest': require('./rest'),
+ 'spread': require('./spread'),
+ 'throttle': require('./throttle'),
+ 'unary': require('./unary'),
+ 'wrap': require('./wrap')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functions.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functions.js
new file mode 100644
index 0000000..9722928
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functions.js
@@ -0,0 +1,31 @@
+var baseFunctions = require('./_baseFunctions'),
+ keys = require('./keys');
+
+/**
+ * Creates an array of function property names from own enumerable properties
+ * of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @returns {Array} Returns the function names.
+ * @see _.functionsIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = _.constant('a');
+ * this.b = _.constant('b');
+ * }
+ *
+ * Foo.prototype.c = _.constant('c');
+ *
+ * _.functions(new Foo);
+ * // => ['a', 'b']
+ */
+function functions(object) {
+ return object == null ? [] : baseFunctions(object, keys(object));
+}
+
+module.exports = functions;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functionsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functionsIn.js
new file mode 100644
index 0000000..f00345d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/functionsIn.js
@@ -0,0 +1,31 @@
+var baseFunctions = require('./_baseFunctions'),
+ keysIn = require('./keysIn');
+
+/**
+ * Creates an array of function property names from own and inherited
+ * enumerable properties of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @returns {Array} Returns the function names.
+ * @see _.functions
+ * @example
+ *
+ * function Foo() {
+ * this.a = _.constant('a');
+ * this.b = _.constant('b');
+ * }
+ *
+ * Foo.prototype.c = _.constant('c');
+ *
+ * _.functionsIn(new Foo);
+ * // => ['a', 'b', 'c']
+ */
+function functionsIn(object) {
+ return object == null ? [] : baseFunctions(object, keysIn(object));
+}
+
+module.exports = functionsIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/get.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/get.js
new file mode 100644
index 0000000..8805ff9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/get.js
@@ -0,0 +1,33 @@
+var baseGet = require('./_baseGet');
+
+/**
+ * Gets the value at `path` of `object`. If the resolved value is
+ * `undefined`, the `defaultValue` is returned in its place.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.get(object, 'a[0].b.c');
+ * // => 3
+ *
+ * _.get(object, ['a', '0', 'b', 'c']);
+ * // => 3
+ *
+ * _.get(object, 'a.b.c', 'default');
+ * // => 'default'
+ */
+function get(object, path, defaultValue) {
+ var result = object == null ? undefined : baseGet(object, path);
+ return result === undefined ? defaultValue : result;
+}
+
+module.exports = get;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/groupBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/groupBy.js
new file mode 100644
index 0000000..babf4f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/groupBy.js
@@ -0,0 +1,41 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ createAggregator = require('./_createAggregator');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The order of grouped values
+ * is determined by the order they occur in `collection`. The corresponding
+ * value of each key is an array of elements responsible for generating the
+ * key. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * _.groupBy([6.1, 4.2, 6.3], Math.floor);
+ * // => { '4': [4.2], '6': [6.1, 6.3] }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.groupBy(['one', 'two', 'three'], 'length');
+ * // => { '3': ['one', 'two'], '5': ['three'] }
+ */
+var groupBy = createAggregator(function(result, value, key) {
+ if (hasOwnProperty.call(result, key)) {
+ result[key].push(value);
+ } else {
+ baseAssignValue(result, key, [value]);
+ }
+});
+
+module.exports = groupBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gt.js
new file mode 100644
index 0000000..3a66282
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gt.js
@@ -0,0 +1,29 @@
+var baseGt = require('./_baseGt'),
+ createRelationalOperation = require('./_createRelationalOperation');
+
+/**
+ * Checks if `value` is greater than `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than `other`,
+ * else `false`.
+ * @see _.lt
+ * @example
+ *
+ * _.gt(3, 1);
+ * // => true
+ *
+ * _.gt(3, 3);
+ * // => false
+ *
+ * _.gt(1, 3);
+ * // => false
+ */
+var gt = createRelationalOperation(baseGt);
+
+module.exports = gt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gte.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gte.js
new file mode 100644
index 0000000..4180a68
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/gte.js
@@ -0,0 +1,30 @@
+var createRelationalOperation = require('./_createRelationalOperation');
+
+/**
+ * Checks if `value` is greater than or equal to `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than or equal to
+ * `other`, else `false`.
+ * @see _.lte
+ * @example
+ *
+ * _.gte(3, 1);
+ * // => true
+ *
+ * _.gte(3, 3);
+ * // => true
+ *
+ * _.gte(1, 3);
+ * // => false
+ */
+var gte = createRelationalOperation(function(value, other) {
+ return value >= other;
+});
+
+module.exports = gte;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/has.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/has.js
new file mode 100644
index 0000000..34df55e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/has.js
@@ -0,0 +1,35 @@
+var baseHas = require('./_baseHas'),
+ hasPath = require('./_hasPath');
+
+/**
+ * Checks if `path` is a direct property of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = { 'a': { 'b': 2 } };
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.has(object, 'a');
+ * // => true
+ *
+ * _.has(object, 'a.b');
+ * // => true
+ *
+ * _.has(object, ['a', 'b']);
+ * // => true
+ *
+ * _.has(other, 'a');
+ * // => false
+ */
+function has(object, path) {
+ return object != null && hasPath(object, path, baseHas);
+}
+
+module.exports = has;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/hasIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/hasIn.js
new file mode 100644
index 0000000..06a3686
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/hasIn.js
@@ -0,0 +1,34 @@
+var baseHasIn = require('./_baseHasIn'),
+ hasPath = require('./_hasPath');
+
+/**
+ * Checks if `path` is a direct or inherited property of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.hasIn(object, 'a');
+ * // => true
+ *
+ * _.hasIn(object, 'a.b');
+ * // => true
+ *
+ * _.hasIn(object, ['a', 'b']);
+ * // => true
+ *
+ * _.hasIn(object, 'b');
+ * // => false
+ */
+function hasIn(object, path) {
+ return object != null && hasPath(object, path, baseHasIn);
+}
+
+module.exports = hasIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/head.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/head.js
new file mode 100644
index 0000000..dee9d1f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/head.js
@@ -0,0 +1,23 @@
+/**
+ * Gets the first element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias first
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the first element of `array`.
+ * @example
+ *
+ * _.head([1, 2, 3]);
+ * // => 1
+ *
+ * _.head([]);
+ * // => undefined
+ */
+function head(array) {
+ return (array && array.length) ? array[0] : undefined;
+}
+
+module.exports = head;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/identity.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/identity.js
new file mode 100644
index 0000000..2d5d963
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/identity.js
@@ -0,0 +1,21 @@
+/**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+function identity(value) {
+ return value;
+}
+
+module.exports = identity;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/inRange.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/inRange.js
new file mode 100644
index 0000000..f20728d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/inRange.js
@@ -0,0 +1,55 @@
+var baseInRange = require('./_baseInRange'),
+ toFinite = require('./toFinite'),
+ toNumber = require('./toNumber');
+
+/**
+ * Checks if `n` is between `start` and up to, but not including, `end`. If
+ * `end` is not specified, it's set to `start` with `start` then set to `0`.
+ * If `start` is greater than `end` the params are swapped to support
+ * negative ranges.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.3.0
+ * @category Number
+ * @param {number} number The number to check.
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
+ * @see _.range, _.rangeRight
+ * @example
+ *
+ * _.inRange(3, 2, 4);
+ * // => true
+ *
+ * _.inRange(4, 8);
+ * // => true
+ *
+ * _.inRange(4, 2);
+ * // => false
+ *
+ * _.inRange(2, 2);
+ * // => false
+ *
+ * _.inRange(1.2, 2);
+ * // => true
+ *
+ * _.inRange(5.2, 4);
+ * // => false
+ *
+ * _.inRange(-3, -2, -6);
+ * // => true
+ */
+function inRange(number, start, end) {
+ start = toFinite(start);
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ } else {
+ end = toFinite(end);
+ }
+ number = toNumber(number);
+ return baseInRange(number, start, end);
+}
+
+module.exports = inRange;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/includes.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/includes.js
new file mode 100644
index 0000000..ae0deed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/includes.js
@@ -0,0 +1,53 @@
+var baseIndexOf = require('./_baseIndexOf'),
+ isArrayLike = require('./isArrayLike'),
+ isString = require('./isString'),
+ toInteger = require('./toInteger'),
+ values = require('./values');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * Checks if `value` is in `collection`. If `collection` is a string, it's
+ * checked for a substring of `value`, otherwise
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * is used for equality comparisons. If `fromIndex` is negative, it's used as
+ * the offset from the end of `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
+ * @returns {boolean} Returns `true` if `value` is found, else `false`.
+ * @example
+ *
+ * _.includes([1, 2, 3], 1);
+ * // => true
+ *
+ * _.includes([1, 2, 3], 1, 2);
+ * // => false
+ *
+ * _.includes({ 'a': 1, 'b': 2 }, 1);
+ * // => true
+ *
+ * _.includes('abcd', 'bc');
+ * // => true
+ */
+function includes(collection, value, fromIndex, guard) {
+ collection = isArrayLike(collection) ? collection : values(collection);
+ fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
+
+ var length = collection.length;
+ if (fromIndex < 0) {
+ fromIndex = nativeMax(length + fromIndex, 0);
+ }
+ return isString(collection)
+ ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
+ : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
+}
+
+module.exports = includes;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/index.js
new file mode 100644
index 0000000..5d063e2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/index.js
@@ -0,0 +1 @@
+module.exports = require('./lodash'); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/indexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/indexOf.js
new file mode 100644
index 0000000..3c644af
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/indexOf.js
@@ -0,0 +1,42 @@
+var baseIndexOf = require('./_baseIndexOf'),
+ toInteger = require('./toInteger');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * Gets the index at which the first occurrence of `value` is found in `array`
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. If `fromIndex` is negative, it's used as the
+ * offset from the end of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.indexOf([1, 2, 1, 2], 2);
+ * // => 1
+ *
+ * // Search from the `fromIndex`.
+ * _.indexOf([1, 2, 1, 2], 2, 2);
+ * // => 3
+ */
+function indexOf(array, value, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
+ if (index < 0) {
+ index = nativeMax(length + index, 0);
+ }
+ return baseIndexOf(array, value, index);
+}
+
+module.exports = indexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/initial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/initial.js
new file mode 100644
index 0000000..f47fc50
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/initial.js
@@ -0,0 +1,22 @@
+var baseSlice = require('./_baseSlice');
+
+/**
+ * Gets all but the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.initial([1, 2, 3]);
+ * // => [1, 2]
+ */
+function initial(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 0, -1) : [];
+}
+
+module.exports = initial;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersection.js
new file mode 100644
index 0000000..a94c135
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersection.js
@@ -0,0 +1,30 @@
+var arrayMap = require('./_arrayMap'),
+ baseIntersection = require('./_baseIntersection'),
+ baseRest = require('./_baseRest'),
+ castArrayLikeObject = require('./_castArrayLikeObject');
+
+/**
+ * Creates an array of unique values that are included in all given arrays
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * _.intersection([2, 1], [2, 3]);
+ * // => [2]
+ */
+var intersection = baseRest(function(arrays) {
+ var mapped = arrayMap(arrays, castArrayLikeObject);
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped)
+ : [];
+});
+
+module.exports = intersection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionBy.js
new file mode 100644
index 0000000..31461aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionBy.js
@@ -0,0 +1,45 @@
+var arrayMap = require('./_arrayMap'),
+ baseIntersection = require('./_baseIntersection'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ castArrayLikeObject = require('./_castArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.intersection` except that it accepts `iteratee`
+ * which is invoked for each element of each `arrays` to generate the criterion
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [2.1]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }]
+ */
+var intersectionBy = baseRest(function(arrays) {
+ var iteratee = last(arrays),
+ mapped = arrayMap(arrays, castArrayLikeObject);
+
+ if (iteratee === last(mapped)) {
+ iteratee = undefined;
+ } else {
+ mapped.pop();
+ }
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped, baseIteratee(iteratee, 2))
+ : [];
+});
+
+module.exports = intersectionBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionWith.js
new file mode 100644
index 0000000..63cabfa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/intersectionWith.js
@@ -0,0 +1,41 @@
+var arrayMap = require('./_arrayMap'),
+ baseIntersection = require('./_baseIntersection'),
+ baseRest = require('./_baseRest'),
+ castArrayLikeObject = require('./_castArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.intersection` except that it accepts `comparator`
+ * which is invoked to compare elements of `arrays`. The order and references
+ * of result values are determined by the first array. The comparator is
+ * invoked with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.intersectionWith(objects, others, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }]
+ */
+var intersectionWith = baseRest(function(arrays) {
+ var comparator = last(arrays),
+ mapped = arrayMap(arrays, castArrayLikeObject);
+
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ if (comparator) {
+ mapped.pop();
+ }
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped, undefined, comparator)
+ : [];
+});
+
+module.exports = intersectionWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invert.js
new file mode 100644
index 0000000..21d10ab
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invert.js
@@ -0,0 +1,27 @@
+var constant = require('./constant'),
+ createInverter = require('./_createInverter'),
+ identity = require('./identity');
+
+/**
+ * Creates an object composed of the inverted keys and values of `object`.
+ * If `object` contains duplicate values, subsequent values overwrite
+ * property assignments of previous values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.7.0
+ * @category Object
+ * @param {Object} object The object to invert.
+ * @returns {Object} Returns the new inverted object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2, 'c': 1 };
+ *
+ * _.invert(object);
+ * // => { '1': 'c', '2': 'b' }
+ */
+var invert = createInverter(function(result, value, key) {
+ result[value] = key;
+}, constant(identity));
+
+module.exports = invert;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invertBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invertBy.js
new file mode 100644
index 0000000..e5ba0f7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invertBy.js
@@ -0,0 +1,44 @@
+var baseIteratee = require('./_baseIteratee'),
+ createInverter = require('./_createInverter');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * This method is like `_.invert` except that the inverted object is generated
+ * from the results of running each element of `object` thru `iteratee`. The
+ * corresponding inverted value of each inverted key is an array of keys
+ * responsible for generating the inverted value. The iteratee is invoked
+ * with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.1.0
+ * @category Object
+ * @param {Object} object The object to invert.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Object} Returns the new inverted object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2, 'c': 1 };
+ *
+ * _.invertBy(object);
+ * // => { '1': ['a', 'c'], '2': ['b'] }
+ *
+ * _.invertBy(object, function(value) {
+ * return 'group' + value;
+ * });
+ * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
+ */
+var invertBy = createInverter(function(result, value, key) {
+ if (hasOwnProperty.call(result, value)) {
+ result[value].push(key);
+ } else {
+ result[value] = [key];
+ }
+}, baseIteratee);
+
+module.exports = invertBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invoke.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invoke.js
new file mode 100644
index 0000000..97d51eb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invoke.js
@@ -0,0 +1,24 @@
+var baseInvoke = require('./_baseInvoke'),
+ baseRest = require('./_baseRest');
+
+/**
+ * Invokes the method at `path` of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {*} Returns the result of the invoked method.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
+ *
+ * _.invoke(object, 'a[0].b.c.slice', 1, 3);
+ * // => [2, 3]
+ */
+var invoke = baseRest(baseInvoke);
+
+module.exports = invoke;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invokeMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invokeMap.js
new file mode 100644
index 0000000..8da5126
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/invokeMap.js
@@ -0,0 +1,41 @@
+var apply = require('./_apply'),
+ baseEach = require('./_baseEach'),
+ baseInvoke = require('./_baseInvoke'),
+ baseRest = require('./_baseRest'),
+ isArrayLike = require('./isArrayLike');
+
+/**
+ * Invokes the method at `path` of each element in `collection`, returning
+ * an array of the results of each invoked method. Any additional arguments
+ * are provided to each invoked method. If `path` is a function, it's invoked
+ * for, and `this` bound to, each element in `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Array|Function|string} path The path of the method to invoke or
+ * the function invoked per iteration.
+ * @param {...*} [args] The arguments to invoke each method with.
+ * @returns {Array} Returns the array of results.
+ * @example
+ *
+ * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
+ * // => [[1, 5, 7], [1, 2, 3]]
+ *
+ * _.invokeMap([123, 456], String.prototype.split, '');
+ * // => [['1', '2', '3'], ['4', '5', '6']]
+ */
+var invokeMap = baseRest(function(collection, path, args) {
+ var index = -1,
+ isFunc = typeof path == 'function',
+ result = isArrayLike(collection) ? Array(collection.length) : [];
+
+ baseEach(collection, function(value) {
+ result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
+ });
+ return result;
+});
+
+module.exports = invokeMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArguments.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArguments.js
new file mode 100644
index 0000000..8b9ed66
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArguments.js
@@ -0,0 +1,36 @@
+var baseIsArguments = require('./_baseIsArguments'),
+ isObjectLike = require('./isObjectLike');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto.propertyIsEnumerable;
+
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+};
+
+module.exports = isArguments;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArray.js
new file mode 100644
index 0000000..88ab55f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArray.js
@@ -0,0 +1,26 @@
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray = Array.isArray;
+
+module.exports = isArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayBuffer.js
new file mode 100644
index 0000000..12904a6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayBuffer.js
@@ -0,0 +1,27 @@
+var baseIsArrayBuffer = require('./_baseIsArrayBuffer'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer;
+
+/**
+ * Checks if `value` is classified as an `ArrayBuffer` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
+ * @example
+ *
+ * _.isArrayBuffer(new ArrayBuffer(2));
+ * // => true
+ *
+ * _.isArrayBuffer(new Array(2));
+ * // => false
+ */
+var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
+
+module.exports = isArrayBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLike.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLike.js
new file mode 100644
index 0000000..0f96680
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLike.js
@@ -0,0 +1,33 @@
+var isFunction = require('./isFunction'),
+ isLength = require('./isLength');
+
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+}
+
+module.exports = isArrayLike;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLikeObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLikeObject.js
new file mode 100644
index 0000000..6c4812a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isArrayLikeObject.js
@@ -0,0 +1,33 @@
+var isArrayLike = require('./isArrayLike'),
+ isObjectLike = require('./isObjectLike');
+
+/**
+ * This method is like `_.isArrayLike` except that it also checks if `value`
+ * is an object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
+ * else `false`.
+ * @example
+ *
+ * _.isArrayLikeObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLikeObject(document.body.children);
+ * // => true
+ *
+ * _.isArrayLikeObject('abc');
+ * // => false
+ *
+ * _.isArrayLikeObject(_.noop);
+ * // => false
+ */
+function isArrayLikeObject(value) {
+ return isObjectLike(value) && isArrayLike(value);
+}
+
+module.exports = isArrayLikeObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBoolean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBoolean.js
new file mode 100644
index 0000000..a43ed4b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBoolean.js
@@ -0,0 +1,29 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var boolTag = '[object Boolean]';
+
+/**
+ * Checks if `value` is classified as a boolean primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
+ * @example
+ *
+ * _.isBoolean(false);
+ * // => true
+ *
+ * _.isBoolean(null);
+ * // => false
+ */
+function isBoolean(value) {
+ return value === true || value === false ||
+ (isObjectLike(value) && baseGetTag(value) == boolTag);
+}
+
+module.exports = isBoolean;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBuffer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBuffer.js
new file mode 100644
index 0000000..c103cc7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isBuffer.js
@@ -0,0 +1,38 @@
+var root = require('./_root'),
+ stubFalse = require('./stubFalse');
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
+
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+var isBuffer = nativeIsBuffer || stubFalse;
+
+module.exports = isBuffer;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isDate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isDate.js
new file mode 100644
index 0000000..7f0209f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isDate.js
@@ -0,0 +1,27 @@
+var baseIsDate = require('./_baseIsDate'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsDate = nodeUtil && nodeUtil.isDate;
+
+/**
+ * Checks if `value` is classified as a `Date` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ * @example
+ *
+ * _.isDate(new Date);
+ * // => true
+ *
+ * _.isDate('Mon April 23 2012');
+ * // => false
+ */
+var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
+
+module.exports = isDate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isElement.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isElement.js
new file mode 100644
index 0000000..76ae29c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isElement.js
@@ -0,0 +1,25 @@
+var isObjectLike = require('./isObjectLike'),
+ isPlainObject = require('./isPlainObject');
+
+/**
+ * Checks if `value` is likely a DOM element.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
+ * @example
+ *
+ * _.isElement(document.body);
+ * // => true
+ *
+ * _.isElement('<body>');
+ * // => false
+ */
+function isElement(value) {
+ return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
+}
+
+module.exports = isElement;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEmpty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEmpty.js
new file mode 100644
index 0000000..3597294
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEmpty.js
@@ -0,0 +1,77 @@
+var baseKeys = require('./_baseKeys'),
+ getTag = require('./_getTag'),
+ isArguments = require('./isArguments'),
+ isArray = require('./isArray'),
+ isArrayLike = require('./isArrayLike'),
+ isBuffer = require('./isBuffer'),
+ isPrototype = require('./_isPrototype'),
+ isTypedArray = require('./isTypedArray');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ setTag = '[object Set]';
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Checks if `value` is an empty object, collection, map, or set.
+ *
+ * Objects are considered empty if they have no own enumerable string keyed
+ * properties.
+ *
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
+ * @example
+ *
+ * _.isEmpty(null);
+ * // => true
+ *
+ * _.isEmpty(true);
+ * // => true
+ *
+ * _.isEmpty(1);
+ * // => true
+ *
+ * _.isEmpty([1, 2, 3]);
+ * // => false
+ *
+ * _.isEmpty({ 'a': 1 });
+ * // => false
+ */
+function isEmpty(value) {
+ if (value == null) {
+ return true;
+ }
+ if (isArrayLike(value) &&
+ (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
+ isBuffer(value) || isTypedArray(value) || isArguments(value))) {
+ return !value.length;
+ }
+ var tag = getTag(value);
+ if (tag == mapTag || tag == setTag) {
+ return !value.size;
+ }
+ if (isPrototype(value)) {
+ return !baseKeys(value).length;
+ }
+ for (var key in value) {
+ if (hasOwnProperty.call(value, key)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+module.exports = isEmpty;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqual.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqual.js
new file mode 100644
index 0000000..8a54126
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqual.js
@@ -0,0 +1,35 @@
+var baseIsEqual = require('./_baseIsEqual');
+
+/**
+ * Performs a deep comparison between two values to determine if they are
+ * equivalent.
+ *
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
+ * by their own, not inherited, enumerable properties. Functions and DOM
+ * nodes are **not** supported.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.isEqual(object, other);
+ * // => true
+ *
+ * object === other;
+ * // => false
+ */
+function isEqual(value, other) {
+ return baseIsEqual(value, other);
+}
+
+module.exports = isEqual;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqualWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqualWith.js
new file mode 100644
index 0000000..21bdc7f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isEqualWith.js
@@ -0,0 +1,41 @@
+var baseIsEqual = require('./_baseIsEqual');
+
+/**
+ * This method is like `_.isEqual` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined`, comparisons
+ * are handled by the method instead. The `customizer` is invoked with up to
+ * six arguments: (objValue, othValue [, index|key, object, other, stack]).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * function isGreeting(value) {
+ * return /^h(?:i|ello)$/.test(value);
+ * }
+ *
+ * function customizer(objValue, othValue) {
+ * if (isGreeting(objValue) && isGreeting(othValue)) {
+ * return true;
+ * }
+ * }
+ *
+ * var array = ['hello', 'goodbye'];
+ * var other = ['hi', 'goodbye'];
+ *
+ * _.isEqualWith(array, other, customizer);
+ * // => true
+ */
+function isEqualWith(value, other, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ var result = customizer ? customizer(value, other) : undefined;
+ return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
+}
+
+module.exports = isEqualWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isError.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isError.js
new file mode 100644
index 0000000..b4f41e0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isError.js
@@ -0,0 +1,36 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike'),
+ isPlainObject = require('./isPlainObject');
+
+/** `Object#toString` result references. */
+var domExcTag = '[object DOMException]',
+ errorTag = '[object Error]';
+
+/**
+ * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
+ * `SyntaxError`, `TypeError`, or `URIError` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
+ * @example
+ *
+ * _.isError(new Error);
+ * // => true
+ *
+ * _.isError(Error);
+ * // => false
+ */
+function isError(value) {
+ if (!isObjectLike(value)) {
+ return false;
+ }
+ var tag = baseGetTag(value);
+ return tag == errorTag || tag == domExcTag ||
+ (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
+}
+
+module.exports = isError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFinite.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFinite.js
new file mode 100644
index 0000000..601842b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFinite.js
@@ -0,0 +1,36 @@
+var root = require('./_root');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsFinite = root.isFinite;
+
+/**
+ * Checks if `value` is a finite primitive number.
+ *
+ * **Note:** This method is based on
+ * [`Number.isFinite`](https://mdn.io/Number/isFinite).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
+ * @example
+ *
+ * _.isFinite(3);
+ * // => true
+ *
+ * _.isFinite(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isFinite(Infinity);
+ * // => false
+ *
+ * _.isFinite('3');
+ * // => false
+ */
+function isFinite(value) {
+ return typeof value == 'number' && nativeIsFinite(value);
+}
+
+module.exports = isFinite;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFunction.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFunction.js
new file mode 100644
index 0000000..907a8cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isFunction.js
@@ -0,0 +1,37 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObject = require('./isObject');
+
+/** `Object#toString` result references. */
+var asyncTag = '[object AsyncFunction]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ proxyTag = '[object Proxy]';
+
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+}
+
+module.exports = isFunction;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isInteger.js
new file mode 100644
index 0000000..66aa87d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isInteger.js
@@ -0,0 +1,33 @@
+var toInteger = require('./toInteger');
+
+/**
+ * Checks if `value` is an integer.
+ *
+ * **Note:** This method is based on
+ * [`Number.isInteger`](https://mdn.io/Number/isInteger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
+ * @example
+ *
+ * _.isInteger(3);
+ * // => true
+ *
+ * _.isInteger(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isInteger(Infinity);
+ * // => false
+ *
+ * _.isInteger('3');
+ * // => false
+ */
+function isInteger(value) {
+ return typeof value == 'number' && value == toInteger(value);
+}
+
+module.exports = isInteger;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isLength.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isLength.js
new file mode 100644
index 0000000..3a95caa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isLength.js
@@ -0,0 +1,35 @@
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+module.exports = isLength;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMap.js
new file mode 100644
index 0000000..44f8517
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMap.js
@@ -0,0 +1,27 @@
+var baseIsMap = require('./_baseIsMap'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsMap = nodeUtil && nodeUtil.isMap;
+
+/**
+ * Checks if `value` is classified as a `Map` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ * @example
+ *
+ * _.isMap(new Map);
+ * // => true
+ *
+ * _.isMap(new WeakMap);
+ * // => false
+ */
+var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
+
+module.exports = isMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatch.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatch.js
new file mode 100644
index 0000000..9773a18
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatch.js
@@ -0,0 +1,36 @@
+var baseIsMatch = require('./_baseIsMatch'),
+ getMatchData = require('./_getMatchData');
+
+/**
+ * Performs a partial deep comparison between `object` and `source` to
+ * determine if `object` contains equivalent property values.
+ *
+ * **Note:** This method is equivalent to `_.matches` when `source` is
+ * partially applied.
+ *
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ *
+ * _.isMatch(object, { 'b': 2 });
+ * // => true
+ *
+ * _.isMatch(object, { 'b': 1 });
+ * // => false
+ */
+function isMatch(object, source) {
+ return object === source || baseIsMatch(object, source, getMatchData(source));
+}
+
+module.exports = isMatch;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatchWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatchWith.js
new file mode 100644
index 0000000..187b6a6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isMatchWith.js
@@ -0,0 +1,41 @@
+var baseIsMatch = require('./_baseIsMatch'),
+ getMatchData = require('./_getMatchData');
+
+/**
+ * This method is like `_.isMatch` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined`, comparisons
+ * are handled by the method instead. The `customizer` is invoked with five
+ * arguments: (objValue, srcValue, index|key, object, source).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ * @example
+ *
+ * function isGreeting(value) {
+ * return /^h(?:i|ello)$/.test(value);
+ * }
+ *
+ * function customizer(objValue, srcValue) {
+ * if (isGreeting(objValue) && isGreeting(srcValue)) {
+ * return true;
+ * }
+ * }
+ *
+ * var object = { 'greeting': 'hello' };
+ * var source = { 'greeting': 'hi' };
+ *
+ * _.isMatchWith(object, source, customizer);
+ * // => true
+ */
+function isMatchWith(object, source, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseIsMatch(object, source, getMatchData(source), customizer);
+}
+
+module.exports = isMatchWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNaN.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNaN.js
new file mode 100644
index 0000000..7d0d783
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNaN.js
@@ -0,0 +1,38 @@
+var isNumber = require('./isNumber');
+
+/**
+ * Checks if `value` is `NaN`.
+ *
+ * **Note:** This method is based on
+ * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
+ * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
+ * `undefined` and other non-number values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ * @example
+ *
+ * _.isNaN(NaN);
+ * // => true
+ *
+ * _.isNaN(new Number(NaN));
+ * // => true
+ *
+ * isNaN(undefined);
+ * // => true
+ *
+ * _.isNaN(undefined);
+ * // => false
+ */
+function isNaN(value) {
+ // An `NaN` primitive is the only value that is not equal to itself.
+ // Perform the `toStringTag` check first to avoid errors with some
+ // ActiveX objects in IE.
+ return isNumber(value) && value != +value;
+}
+
+module.exports = isNaN;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNative.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNative.js
new file mode 100644
index 0000000..f0cb8d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNative.js
@@ -0,0 +1,40 @@
+var baseIsNative = require('./_baseIsNative'),
+ isMaskable = require('./_isMaskable');
+
+/** Error message constants. */
+var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.';
+
+/**
+ * Checks if `value` is a pristine native function.
+ *
+ * **Note:** This method can't reliably detect native functions in the presence
+ * of the core-js package because core-js circumvents this kind of detection.
+ * Despite multiple requests, the core-js maintainer has made it clear: any
+ * attempt to fix the detection will be obstructed. As a result, we're left
+ * with little choice but to throw an error. Unfortunately, this also affects
+ * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
+ * which rely on core-js.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ * @example
+ *
+ * _.isNative(Array.prototype.push);
+ * // => true
+ *
+ * _.isNative(_);
+ * // => false
+ */
+function isNative(value) {
+ if (isMaskable(value)) {
+ throw new Error(CORE_ERROR_TEXT);
+ }
+ return baseIsNative(value);
+}
+
+module.exports = isNative;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNil.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNil.js
new file mode 100644
index 0000000..79f0505
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNil.js
@@ -0,0 +1,25 @@
+/**
+ * Checks if `value` is `null` or `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
+ * @example
+ *
+ * _.isNil(null);
+ * // => true
+ *
+ * _.isNil(void 0);
+ * // => true
+ *
+ * _.isNil(NaN);
+ * // => false
+ */
+function isNil(value) {
+ return value == null;
+}
+
+module.exports = isNil;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNull.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNull.js
new file mode 100644
index 0000000..c0a374d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNull.js
@@ -0,0 +1,22 @@
+/**
+ * Checks if `value` is `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
+ * @example
+ *
+ * _.isNull(null);
+ * // => true
+ *
+ * _.isNull(void 0);
+ * // => false
+ */
+function isNull(value) {
+ return value === null;
+}
+
+module.exports = isNull;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNumber.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNumber.js
new file mode 100644
index 0000000..cd34ee4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isNumber.js
@@ -0,0 +1,38 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var numberTag = '[object Number]';
+
+/**
+ * Checks if `value` is classified as a `Number` primitive or object.
+ *
+ * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
+ * classified as numbers, use the `_.isFinite` method.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a number, else `false`.
+ * @example
+ *
+ * _.isNumber(3);
+ * // => true
+ *
+ * _.isNumber(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isNumber(Infinity);
+ * // => true
+ *
+ * _.isNumber('3');
+ * // => false
+ */
+function isNumber(value) {
+ return typeof value == 'number' ||
+ (isObjectLike(value) && baseGetTag(value) == numberTag);
+}
+
+module.exports = isNumber;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObject.js
new file mode 100644
index 0000000..1dc8939
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObject.js
@@ -0,0 +1,31 @@
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+}
+
+module.exports = isObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObjectLike.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObjectLike.js
new file mode 100644
index 0000000..301716b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isObjectLike.js
@@ -0,0 +1,29 @@
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+}
+
+module.exports = isObjectLike;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isPlainObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isPlainObject.js
new file mode 100644
index 0000000..2387373
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isPlainObject.js
@@ -0,0 +1,62 @@
+var baseGetTag = require('./_baseGetTag'),
+ getPrototype = require('./_getPrototype'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var objectTag = '[object Object]';
+
+/** Used for built-in method references. */
+var funcProto = Function.prototype,
+ objectProto = Object.prototype;
+
+/** Used to resolve the decompiled source of functions. */
+var funcToString = funcProto.toString;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/** Used to infer the `Object` constructor. */
+var objectCtorString = funcToString.call(Object);
+
+/**
+ * Checks if `value` is a plain object, that is, an object created by the
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.8.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * _.isPlainObject(new Foo);
+ * // => false
+ *
+ * _.isPlainObject([1, 2, 3]);
+ * // => false
+ *
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
+ * // => true
+ *
+ * _.isPlainObject(Object.create(null));
+ * // => true
+ */
+function isPlainObject(value) {
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
+ return false;
+ }
+ var proto = getPrototype(value);
+ if (proto === null) {
+ return true;
+ }
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
+ funcToString.call(Ctor) == objectCtorString;
+}
+
+module.exports = isPlainObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isRegExp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isRegExp.js
new file mode 100644
index 0000000..76c9b6e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isRegExp.js
@@ -0,0 +1,27 @@
+var baseIsRegExp = require('./_baseIsRegExp'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp;
+
+/**
+ * Checks if `value` is classified as a `RegExp` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ * @example
+ *
+ * _.isRegExp(/abc/);
+ * // => true
+ *
+ * _.isRegExp('/abc/');
+ * // => false
+ */
+var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
+
+module.exports = isRegExp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSafeInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSafeInteger.js
new file mode 100644
index 0000000..2a48526
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSafeInteger.js
@@ -0,0 +1,37 @@
+var isInteger = require('./isInteger');
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
+ * double precision number which isn't the result of a rounded unsafe integer.
+ *
+ * **Note:** This method is based on
+ * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
+ * @example
+ *
+ * _.isSafeInteger(3);
+ * // => true
+ *
+ * _.isSafeInteger(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isSafeInteger(Infinity);
+ * // => false
+ *
+ * _.isSafeInteger('3');
+ * // => false
+ */
+function isSafeInteger(value) {
+ return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
+}
+
+module.exports = isSafeInteger;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSet.js
new file mode 100644
index 0000000..ab88bdf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSet.js
@@ -0,0 +1,27 @@
+var baseIsSet = require('./_baseIsSet'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsSet = nodeUtil && nodeUtil.isSet;
+
+/**
+ * Checks if `value` is classified as a `Set` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ * @example
+ *
+ * _.isSet(new Set);
+ * // => true
+ *
+ * _.isSet(new WeakSet);
+ * // => false
+ */
+var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
+
+module.exports = isSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isString.js
new file mode 100644
index 0000000..627eb9c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isString.js
@@ -0,0 +1,30 @@
+var baseGetTag = require('./_baseGetTag'),
+ isArray = require('./isArray'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var stringTag = '[object String]';
+
+/**
+ * Checks if `value` is classified as a `String` primitive or object.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
+ * @example
+ *
+ * _.isString('abc');
+ * // => true
+ *
+ * _.isString(1);
+ * // => false
+ */
+function isString(value) {
+ return typeof value == 'string' ||
+ (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
+}
+
+module.exports = isString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSymbol.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSymbol.js
new file mode 100644
index 0000000..dfb60b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isSymbol.js
@@ -0,0 +1,29 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var symbolTag = '[object Symbol]';
+
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
+}
+
+module.exports = isSymbol;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isTypedArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isTypedArray.js
new file mode 100644
index 0000000..da3f8dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isTypedArray.js
@@ -0,0 +1,27 @@
+var baseIsTypedArray = require('./_baseIsTypedArray'),
+ baseUnary = require('./_baseUnary'),
+ nodeUtil = require('./_nodeUtil');
+
+/* Node.js helper references. */
+var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+module.exports = isTypedArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isUndefined.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isUndefined.js
new file mode 100644
index 0000000..377d121
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isUndefined.js
@@ -0,0 +1,22 @@
+/**
+ * Checks if `value` is `undefined`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
+ * @example
+ *
+ * _.isUndefined(void 0);
+ * // => true
+ *
+ * _.isUndefined(null);
+ * // => false
+ */
+function isUndefined(value) {
+ return value === undefined;
+}
+
+module.exports = isUndefined;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakMap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakMap.js
new file mode 100644
index 0000000..8d36f66
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakMap.js
@@ -0,0 +1,28 @@
+var getTag = require('./_getTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var weakMapTag = '[object WeakMap]';
+
+/**
+ * Checks if `value` is classified as a `WeakMap` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
+ * @example
+ *
+ * _.isWeakMap(new WeakMap);
+ * // => true
+ *
+ * _.isWeakMap(new Map);
+ * // => false
+ */
+function isWeakMap(value) {
+ return isObjectLike(value) && getTag(value) == weakMapTag;
+}
+
+module.exports = isWeakMap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakSet.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakSet.js
new file mode 100644
index 0000000..e628b26
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/isWeakSet.js
@@ -0,0 +1,28 @@
+var baseGetTag = require('./_baseGetTag'),
+ isObjectLike = require('./isObjectLike');
+
+/** `Object#toString` result references. */
+var weakSetTag = '[object WeakSet]';
+
+/**
+ * Checks if `value` is classified as a `WeakSet` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
+ * @example
+ *
+ * _.isWeakSet(new WeakSet);
+ * // => true
+ *
+ * _.isWeakSet(new Set);
+ * // => false
+ */
+function isWeakSet(value) {
+ return isObjectLike(value) && baseGetTag(value) == weakSetTag;
+}
+
+module.exports = isWeakSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/iteratee.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/iteratee.js
new file mode 100644
index 0000000..61b73a8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/iteratee.js
@@ -0,0 +1,53 @@
+var baseClone = require('./_baseClone'),
+ baseIteratee = require('./_baseIteratee');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a function that invokes `func` with the arguments of the created
+ * function. If `func` is a property name, the created function returns the
+ * property value for a given element. If `func` is an array or object, the
+ * created function returns `true` for elements that contain the equivalent
+ * source properties, otherwise it returns `false`.
+ *
+ * @static
+ * @since 4.0.0
+ * @memberOf _
+ * @category Util
+ * @param {*} [func=_.identity] The value to convert to a callback.
+ * @returns {Function} Returns the callback.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
+ * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, _.iteratee(['user', 'fred']));
+ * // => [{ 'user': 'fred', 'age': 40 }]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, _.iteratee('user'));
+ * // => ['barney', 'fred']
+ *
+ * // Create custom iteratee shorthands.
+ * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
+ * return !_.isRegExp(func) ? iteratee(func) : function(string) {
+ * return func.test(string);
+ * };
+ * });
+ *
+ * _.filter(['abc', 'def'], /ef/);
+ * // => ['def']
+ */
+function iteratee(func) {
+ return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
+}
+
+module.exports = iteratee;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/join.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/join.js
new file mode 100644
index 0000000..45de079
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/join.js
@@ -0,0 +1,26 @@
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeJoin = arrayProto.join;
+
+/**
+ * Converts all elements in `array` into a string separated by `separator`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to convert.
+ * @param {string} [separator=','] The element separator.
+ * @returns {string} Returns the joined string.
+ * @example
+ *
+ * _.join(['a', 'b', 'c'], '~');
+ * // => 'a~b~c'
+ */
+function join(array, separator) {
+ return array == null ? '' : nativeJoin.call(array, separator);
+}
+
+module.exports = join;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/kebabCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/kebabCase.js
new file mode 100644
index 0000000..8a52be6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/kebabCase.js
@@ -0,0 +1,28 @@
+var createCompounder = require('./_createCompounder');
+
+/**
+ * Converts `string` to
+ * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the kebab cased string.
+ * @example
+ *
+ * _.kebabCase('Foo Bar');
+ * // => 'foo-bar'
+ *
+ * _.kebabCase('fooBar');
+ * // => 'foo-bar'
+ *
+ * _.kebabCase('__FOO_BAR__');
+ * // => 'foo-bar'
+ */
+var kebabCase = createCompounder(function(result, word, index) {
+ return result + (index ? '-' : '') + word.toLowerCase();
+});
+
+module.exports = kebabCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keyBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keyBy.js
new file mode 100644
index 0000000..acc007a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keyBy.js
@@ -0,0 +1,36 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ createAggregator = require('./_createAggregator');
+
+/**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The corresponding value of
+ * each key is the last element responsible for generating the key. The
+ * iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * var array = [
+ * { 'dir': 'left', 'code': 97 },
+ * { 'dir': 'right', 'code': 100 }
+ * ];
+ *
+ * _.keyBy(array, function(o) {
+ * return String.fromCharCode(o.code);
+ * });
+ * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
+ *
+ * _.keyBy(array, 'dir');
+ * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
+ */
+var keyBy = createAggregator(function(result, value, key) {
+ baseAssignValue(result, key, value);
+});
+
+module.exports = keyBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keys.js
new file mode 100644
index 0000000..d143c71
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keys.js
@@ -0,0 +1,37 @@
+var arrayLikeKeys = require('./_arrayLikeKeys'),
+ baseKeys = require('./_baseKeys'),
+ isArrayLike = require('./isArrayLike');
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+}
+
+module.exports = keys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keysIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keysIn.js
new file mode 100644
index 0000000..a62308f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/keysIn.js
@@ -0,0 +1,32 @@
+var arrayLikeKeys = require('./_arrayLikeKeys'),
+ baseKeysIn = require('./_baseKeysIn'),
+ isArrayLike = require('./isArrayLike');
+
+/**
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */
+function keysIn(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
+}
+
+module.exports = keysIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lang.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lang.js
new file mode 100644
index 0000000..a396216
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lang.js
@@ -0,0 +1,58 @@
+module.exports = {
+ 'castArray': require('./castArray'),
+ 'clone': require('./clone'),
+ 'cloneDeep': require('./cloneDeep'),
+ 'cloneDeepWith': require('./cloneDeepWith'),
+ 'cloneWith': require('./cloneWith'),
+ 'conformsTo': require('./conformsTo'),
+ 'eq': require('./eq'),
+ 'gt': require('./gt'),
+ 'gte': require('./gte'),
+ 'isArguments': require('./isArguments'),
+ 'isArray': require('./isArray'),
+ 'isArrayBuffer': require('./isArrayBuffer'),
+ 'isArrayLike': require('./isArrayLike'),
+ 'isArrayLikeObject': require('./isArrayLikeObject'),
+ 'isBoolean': require('./isBoolean'),
+ 'isBuffer': require('./isBuffer'),
+ 'isDate': require('./isDate'),
+ 'isElement': require('./isElement'),
+ 'isEmpty': require('./isEmpty'),
+ 'isEqual': require('./isEqual'),
+ 'isEqualWith': require('./isEqualWith'),
+ 'isError': require('./isError'),
+ 'isFinite': require('./isFinite'),
+ 'isFunction': require('./isFunction'),
+ 'isInteger': require('./isInteger'),
+ 'isLength': require('./isLength'),
+ 'isMap': require('./isMap'),
+ 'isMatch': require('./isMatch'),
+ 'isMatchWith': require('./isMatchWith'),
+ 'isNaN': require('./isNaN'),
+ 'isNative': require('./isNative'),
+ 'isNil': require('./isNil'),
+ 'isNull': require('./isNull'),
+ 'isNumber': require('./isNumber'),
+ 'isObject': require('./isObject'),
+ 'isObjectLike': require('./isObjectLike'),
+ 'isPlainObject': require('./isPlainObject'),
+ 'isRegExp': require('./isRegExp'),
+ 'isSafeInteger': require('./isSafeInteger'),
+ 'isSet': require('./isSet'),
+ 'isString': require('./isString'),
+ 'isSymbol': require('./isSymbol'),
+ 'isTypedArray': require('./isTypedArray'),
+ 'isUndefined': require('./isUndefined'),
+ 'isWeakMap': require('./isWeakMap'),
+ 'isWeakSet': require('./isWeakSet'),
+ 'lt': require('./lt'),
+ 'lte': require('./lte'),
+ 'toArray': require('./toArray'),
+ 'toFinite': require('./toFinite'),
+ 'toInteger': require('./toInteger'),
+ 'toLength': require('./toLength'),
+ 'toNumber': require('./toNumber'),
+ 'toPlainObject': require('./toPlainObject'),
+ 'toSafeInteger': require('./toSafeInteger'),
+ 'toString': require('./toString')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/last.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/last.js
new file mode 100644
index 0000000..cad1eaf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/last.js
@@ -0,0 +1,20 @@
+/**
+ * Gets the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the last element of `array`.
+ * @example
+ *
+ * _.last([1, 2, 3]);
+ * // => 3
+ */
+function last(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? array[length - 1] : undefined;
+}
+
+module.exports = last;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lastIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lastIndexOf.js
new file mode 100644
index 0000000..dabfb61
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lastIndexOf.js
@@ -0,0 +1,46 @@
+var baseFindIndex = require('./_baseFindIndex'),
+ baseIsNaN = require('./_baseIsNaN'),
+ strictLastIndexOf = require('./_strictLastIndexOf'),
+ toInteger = require('./toInteger');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max,
+ nativeMin = Math.min;
+
+/**
+ * This method is like `_.indexOf` except that it iterates over elements of
+ * `array` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=array.length-1] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.lastIndexOf([1, 2, 1, 2], 2);
+ * // => 3
+ *
+ * // Search from the `fromIndex`.
+ * _.lastIndexOf([1, 2, 1, 2], 2, 2);
+ * // => 1
+ */
+function lastIndexOf(array, value, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = length;
+ if (fromIndex !== undefined) {
+ index = toInteger(fromIndex);
+ index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
+ }
+ return value === value
+ ? strictLastIndexOf(array, value, index)
+ : baseFindIndex(array, baseIsNaN, index, true);
+}
+
+module.exports = lastIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.js
new file mode 100644
index 0000000..ebd9671
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.js
@@ -0,0 +1,17065 @@
+/**
+ * @license
+ * Lodash <https://lodash.com/>
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
+ * Released under MIT license <https://lodash.com/license>
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ */
+;(function() {
+
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
+ /** Used as the semantic version number. */
+ var VERSION = '4.17.2';
+
+ /** Used as the size to enable large array optimizations. */
+ var LARGE_ARRAY_SIZE = 200;
+
+ /** Error message constants. */
+ var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
+ FUNC_ERROR_TEXT = 'Expected a function';
+
+ /** Used to stand-in for `undefined` hash values. */
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+ /** Used as the maximum memoize cache size. */
+ var MAX_MEMOIZE_SIZE = 500;
+
+ /** Used as the internal argument placeholder. */
+ var PLACEHOLDER = '__lodash_placeholder__';
+
+ /** Used to compose bitmasks for cloning. */
+ var CLONE_DEEP_FLAG = 1,
+ CLONE_FLAT_FLAG = 2,
+ CLONE_SYMBOLS_FLAG = 4;
+
+ /** Used to compose bitmasks for value comparisons. */
+ var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+ /** Used to compose bitmasks for function metadata. */
+ var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_BOUND_FLAG = 4,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_CURRY_RIGHT_FLAG = 16,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_PARTIAL_RIGHT_FLAG = 64,
+ WRAP_ARY_FLAG = 128,
+ WRAP_REARG_FLAG = 256,
+ WRAP_FLIP_FLAG = 512;
+
+ /** Used as default options for `_.truncate`. */
+ var DEFAULT_TRUNC_LENGTH = 30,
+ DEFAULT_TRUNC_OMISSION = '...';
+
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
+ var HOT_COUNT = 800,
+ HOT_SPAN = 16;
+
+ /** Used to indicate the type of lazy iteratees. */
+ var LAZY_FILTER_FLAG = 1,
+ LAZY_MAP_FLAG = 2,
+ LAZY_WHILE_FLAG = 3;
+
+ /** Used as references for various `Number` constants. */
+ var INFINITY = 1 / 0,
+ MAX_SAFE_INTEGER = 9007199254740991,
+ MAX_INTEGER = 1.7976931348623157e+308,
+ NAN = 0 / 0;
+
+ /** Used as references for the maximum length and index of an array. */
+ var MAX_ARRAY_LENGTH = 4294967295,
+ MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
+ HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
+
+ /** Used to associate wrap methods with their bit flags. */
+ var wrapFlags = [
+ ['ary', WRAP_ARY_FLAG],
+ ['bind', WRAP_BIND_FLAG],
+ ['bindKey', WRAP_BIND_KEY_FLAG],
+ ['curry', WRAP_CURRY_FLAG],
+ ['curryRight', WRAP_CURRY_RIGHT_FLAG],
+ ['flip', WRAP_FLIP_FLAG],
+ ['partial', WRAP_PARTIAL_FLAG],
+ ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
+ ['rearg', WRAP_REARG_FLAG]
+ ];
+
+ /** `Object#toString` result references. */
+ var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ asyncTag = '[object AsyncFunction]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ domExcTag = '[object DOMException]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ nullTag = '[object Null]',
+ objectTag = '[object Object]',
+ promiseTag = '[object Promise]',
+ proxyTag = '[object Proxy]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ symbolTag = '[object Symbol]',
+ undefinedTag = '[object Undefined]',
+ weakMapTag = '[object WeakMap]',
+ weakSetTag = '[object WeakSet]';
+
+ var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+ /** Used to match empty string literals in compiled template source. */
+ var reEmptyStringLeading = /\b__p \+= '';/g,
+ reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
+ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
+
+ /** Used to match HTML entities and HTML characters. */
+ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
+ reUnescapedHtml = /[&<>"']/g,
+ reHasEscapedHtml = RegExp(reEscapedHtml.source),
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
+
+ /** Used to match template delimiters. */
+ var reEscape = /<%-([\s\S]+?)%>/g,
+ reEvaluate = /<%([\s\S]+?)%>/g,
+ reInterpolate = /<%=([\s\S]+?)%>/g;
+
+ /** Used to match property names within property paths. */
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
+ reIsPlainProp = /^\w*$/,
+ reLeadingDot = /^\./,
+ rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
+
+ /**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
+ reHasRegExpChar = RegExp(reRegExpChar.source);
+
+ /** Used to match leading and trailing whitespace. */
+ var reTrim = /^\s+|\s+$/g,
+ reTrimStart = /^\s+/,
+ reTrimEnd = /\s+$/;
+
+ /** Used to match wrap detail comments. */
+ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
+ reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
+ reSplitDetails = /,? & /;
+
+ /** Used to match words composed of alphanumeric characters. */
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
+
+ /** Used to match backslashes in property paths. */
+ var reEscapeChar = /\\(\\)?/g;
+
+ /**
+ * Used to match
+ * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
+ */
+ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
+
+ /** Used to match `RegExp` flags from their coerced string values. */
+ var reFlags = /\w*$/;
+
+ /** Used to detect bad signed hexadecimal string values. */
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
+
+ /** Used to detect binary string values. */
+ var reIsBinary = /^0b[01]+$/i;
+
+ /** Used to detect host constructors (Safari). */
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+ /** Used to detect octal string values. */
+ var reIsOctal = /^0o[0-7]+$/i;
+
+ /** Used to detect unsigned integer values. */
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
+
+ /** Used to ensure capturing order of template delimiters. */
+ var reNoMatch = /($^)/;
+
+ /** Used to match unescaped characters in compiled string literals. */
+ var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
+
+ /** Used to compose unicode character classes. */
+ var rsAstralRange = '\\ud800-\\udfff',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
+ rsDingbatRange = '\\u2700-\\u27bf',
+ rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
+ rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
+ rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
+ rsPunctuationRange = '\\u2000-\\u206f',
+ rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
+ rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
+ rsVarRange = '\\ufe0e\\ufe0f',
+ rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
+
+ /** Used to compose unicode capture groups. */
+ var rsApos = "['\u2019]",
+ rsAstral = '[' + rsAstralRange + ']',
+ rsBreak = '[' + rsBreakRange + ']',
+ rsCombo = '[' + rsComboRange + ']',
+ rsDigits = '\\d+',
+ rsDingbat = '[' + rsDingbatRange + ']',
+ rsLower = '[' + rsLowerRange + ']',
+ rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
+ rsNonAstral = '[^' + rsAstralRange + ']',
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
+ rsUpper = '[' + rsUpperRange + ']',
+ rsZWJ = '\\u200d';
+
+ /** Used to compose unicode regexes. */
+ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
+ rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
+ rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
+ rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
+ reOptMod = rsModifier + '?',
+ rsOptVar = '[' + rsVarRange + ']?',
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
+ rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
+ rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
+ rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
+ rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+ /** Used to match apostrophes. */
+ var reApos = RegExp(rsApos, 'g');
+
+ /**
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
+ */
+ var reComboMark = RegExp(rsCombo, 'g');
+
+ /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+ /** Used to match complex or compound words. */
+ var reUnicodeWord = RegExp([
+ rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
+ rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
+ rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
+ rsUpper + '+' + rsOptContrUpper,
+ rsOrdUpper,
+ rsOrdLower,
+ rsDigits,
+ rsEmoji
+ ].join('|'), 'g');
+
+ /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
+ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
+
+ /** Used to detect strings that need a more robust regexp to match words. */
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
+
+ /** Used to assign default `context` object properties. */
+ var contextProps = [
+ 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
+ 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
+ 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
+ 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
+ '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
+ ];
+
+ /** Used to make template sourceURLs easier to identify. */
+ var templateCounter = -1;
+
+ /** Used to identify `toStringTag` values of typed arrays. */
+ var typedArrayTags = {};
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+ typedArrayTags[uint32Tag] = true;
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
+ typedArrayTags[weakMapTag] = false;
+
+ /** Used to identify `toStringTag` values supported by `_.clone`. */
+ var cloneableTags = {};
+ cloneableTags[argsTag] = cloneableTags[arrayTag] =
+ cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
+ cloneableTags[boolTag] = cloneableTags[dateTag] =
+ cloneableTags[float32Tag] = cloneableTags[float64Tag] =
+ cloneableTags[int8Tag] = cloneableTags[int16Tag] =
+ cloneableTags[int32Tag] = cloneableTags[mapTag] =
+ cloneableTags[numberTag] = cloneableTags[objectTag] =
+ cloneableTags[regexpTag] = cloneableTags[setTag] =
+ cloneableTags[stringTag] = cloneableTags[symbolTag] =
+ cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
+ cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
+ cloneableTags[errorTag] = cloneableTags[funcTag] =
+ cloneableTags[weakMapTag] = false;
+
+ /** Used to map Latin Unicode letters to basic Latin letters. */
+ var deburredLetters = {
+ // Latin-1 Supplement block.
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
+ '\xc7': 'C', '\xe7': 'c',
+ '\xd0': 'D', '\xf0': 'd',
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
+ '\xd1': 'N', '\xf1': 'n',
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
+ '\xc6': 'Ae', '\xe6': 'ae',
+ '\xde': 'Th', '\xfe': 'th',
+ '\xdf': 'ss',
+ // Latin Extended-A block.
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
+ '\u0134': 'J', '\u0135': 'j',
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
+ '\u0174': 'W', '\u0175': 'w',
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
+ '\u0132': 'IJ', '\u0133': 'ij',
+ '\u0152': 'Oe', '\u0153': 'oe',
+ '\u0149': "'n", '\u017f': 's'
+ };
+
+ /** Used to map characters to HTML entities. */
+ var htmlEscapes = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#39;'
+ };
+
+ /** Used to map HTML entities to characters. */
+ var htmlUnescapes = {
+ '&amp;': '&',
+ '&lt;': '<',
+ '&gt;': '>',
+ '&quot;': '"',
+ '&#39;': "'"
+ };
+
+ /** Used to escape characters for inclusion in compiled string literals. */
+ var stringEscapes = {
+ '\\': '\\',
+ "'": "'",
+ '\n': 'n',
+ '\r': 'r',
+ '\u2028': 'u2028',
+ '\u2029': 'u2029'
+ };
+
+ /** Built-in method references without a dependency on `root`. */
+ var freeParseFloat = parseFloat,
+ freeParseInt = parseInt;
+
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+ /** Detect free variable `self`. */
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+ /** Used as a reference to the global object. */
+ var root = freeGlobal || freeSelf || Function('return this')();
+
+ /** Detect free variable `exports`. */
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+ /** Detect free variable `module`. */
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+ /** Detect the popular CommonJS extension `module.exports`. */
+ var moduleExports = freeModule && freeModule.exports === freeExports;
+
+ /** Detect free variable `process` from Node.js. */
+ var freeProcess = moduleExports && freeGlobal.process;
+
+ /** Used to access faster Node.js helpers. */
+ var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+ }());
+
+ /* Node.js helper references. */
+ var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
+ nodeIsDate = nodeUtil && nodeUtil.isDate,
+ nodeIsMap = nodeUtil && nodeUtil.isMap,
+ nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
+ nodeIsSet = nodeUtil && nodeUtil.isSet,
+ nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Adds the key-value `pair` to `map`.
+ *
+ * @private
+ * @param {Object} map The map to modify.
+ * @param {Array} pair The key-value pair to add.
+ * @returns {Object} Returns `map`.
+ */
+ function addMapEntry(map, pair) {
+ // Don't return `map.set` because it's not chainable in IE 11.
+ map.set(pair[0], pair[1]);
+ return map;
+ }
+
+ /**
+ * Adds `value` to `set`.
+ *
+ * @private
+ * @param {Object} set The set to modify.
+ * @param {*} value The value to add.
+ * @returns {Object} Returns `set`.
+ */
+ function addSetEntry(set, value) {
+ // Don't return `set.add` because it's not chainable in IE 11.
+ set.add(value);
+ return set;
+ }
+
+ /**
+ * A faster alternative to `Function#apply`, this function invokes `func`
+ * with the `this` binding of `thisArg` and the arguments of `args`.
+ *
+ * @private
+ * @param {Function} func The function to invoke.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} args The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+ function apply(func, thisArg, args) {
+ switch (args.length) {
+ case 0: return func.call(thisArg);
+ case 1: return func.call(thisArg, args[0]);
+ case 2: return func.call(thisArg, args[0], args[1]);
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
+ }
+ return func.apply(thisArg, args);
+ }
+
+ /**
+ * A specialized version of `baseAggregator` for arrays.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform keys.
+ * @param {Object} accumulator The initial aggregated object.
+ * @returns {Function} Returns `accumulator`.
+ */
+ function arrayAggregator(array, setter, iteratee, accumulator) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ var value = array[index];
+ setter(accumulator, value, iteratee(value), array);
+ }
+ return accumulator;
+ }
+
+ /**
+ * A specialized version of `_.forEach` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+ function arrayEach(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
+ }
+ }
+ return array;
+ }
+
+ /**
+ * A specialized version of `_.forEachRight` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+ function arrayEachRight(array, iteratee) {
+ var length = array == null ? 0 : array.length;
+
+ while (length--) {
+ if (iteratee(array[length], length, array) === false) {
+ break;
+ }
+ }
+ return array;
+ }
+
+ /**
+ * A specialized version of `_.every` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`.
+ */
+ function arrayEvery(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (!predicate(array[index], index, array)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * A specialized version of `_.filter` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+ function arrayFilter(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value, index, array)) {
+ result[resIndex++] = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A specialized version of `_.includes` for arrays without support for
+ * specifying an index to search from.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+ function arrayIncludes(array, value) {
+ var length = array == null ? 0 : array.length;
+ return !!length && baseIndexOf(array, value, 0) > -1;
+ }
+
+ /**
+ * This function is like `arrayIncludes` except that it accepts a comparator.
+ *
+ * @private
+ * @param {Array} [array] The array to inspect.
+ * @param {*} target The value to search for.
+ * @param {Function} comparator The comparator invoked per element.
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
+ */
+ function arrayIncludesWith(array, value, comparator) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (comparator(value, array[index])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+ function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+ }
+
+ /**
+ * Appends the elements of `values` to `array`.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to append.
+ * @returns {Array} Returns `array`.
+ */
+ function arrayPush(array, values) {
+ var index = -1,
+ length = values.length,
+ offset = array.length;
+
+ while (++index < length) {
+ array[offset + index] = values[index];
+ }
+ return array;
+ }
+
+ /**
+ * A specialized version of `_.reduce` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
+ * the initial value.
+ * @returns {*} Returns the accumulated value.
+ */
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ if (initAccum && length) {
+ accumulator = array[++index];
+ }
+ while (++index < length) {
+ accumulator = iteratee(accumulator, array[index], index, array);
+ }
+ return accumulator;
+ }
+
+ /**
+ * A specialized version of `_.reduceRight` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @param {boolean} [initAccum] Specify using the last element of `array` as
+ * the initial value.
+ * @returns {*} Returns the accumulated value.
+ */
+ function arrayReduceRight(array, iteratee, accumulator, initAccum) {
+ var length = array == null ? 0 : array.length;
+ if (initAccum && length) {
+ accumulator = array[--length];
+ }
+ while (length--) {
+ accumulator = iteratee(accumulator, array[length], length, array);
+ }
+ return accumulator;
+ }
+
+ /**
+ * A specialized version of `_.some` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+ function arraySome(array, predicate) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (predicate(array[index], index, array)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Gets the size of an ASCII `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+ var asciiSize = baseProperty('length');
+
+ /**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function asciiToArray(string) {
+ return string.split('');
+ }
+
+ /**
+ * Splits an ASCII `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+ function asciiWords(string) {
+ return string.match(reAsciiWord) || [];
+ }
+
+ /**
+ * The base implementation of methods like `_.findKey` and `_.findLastKey`,
+ * without support for iteratee shorthands, which iterates over `collection`
+ * using `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @returns {*} Returns the found element or its key, else `undefined`.
+ */
+ function baseFindKey(collection, predicate, eachFunc) {
+ var result;
+ eachFunc(collection, function(value, key, collection) {
+ if (predicate(value, key, collection)) {
+ result = key;
+ return false;
+ }
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+ }
+
+ /**
+ * This function is like `baseIndexOf` except that it accepts a comparator.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @param {Function} comparator The comparator invoked per element.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function baseIndexOfWith(array, value, fromIndex, comparator) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (comparator(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+ function baseIsNaN(value) {
+ return value !== value;
+ }
+
+ /**
+ * The base implementation of `_.mean` and `_.meanBy` without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {number} Returns the mean.
+ */
+ function baseMean(array, iteratee) {
+ var length = array == null ? 0 : array.length;
+ return length ? (baseSum(array, iteratee) / length) : NAN;
+ }
+
+ /**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.propertyOf` without support for deep paths.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function basePropertyOf(object) {
+ return function(key) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.reduce` and `_.reduceRight`, without support
+ * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {*} accumulator The initial value.
+ * @param {boolean} initAccum Specify using the first or last element of
+ * `collection` as the initial value.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @returns {*} Returns the accumulated value.
+ */
+ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
+ eachFunc(collection, function(value, index, collection) {
+ accumulator = initAccum
+ ? (initAccum = false, value)
+ : iteratee(accumulator, value, index, collection);
+ });
+ return accumulator;
+ }
+
+ /**
+ * The base implementation of `_.sortBy` which uses `comparer` to define the
+ * sort order of `array` and replaces criteria objects with their corresponding
+ * values.
+ *
+ * @private
+ * @param {Array} array The array to sort.
+ * @param {Function} comparer The function to define sort order.
+ * @returns {Array} Returns `array`.
+ */
+ function baseSortBy(array, comparer) {
+ var length = array.length;
+
+ array.sort(comparer);
+ while (length--) {
+ array[length] = array[length].value;
+ }
+ return array;
+ }
+
+ /**
+ * The base implementation of `_.sum` and `_.sumBy` without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {number} Returns the sum.
+ */
+ function baseSum(array, iteratee) {
+ var result,
+ index = -1,
+ length = array.length;
+
+ while (++index < length) {
+ var current = iteratee(array[index]);
+ if (current !== undefined) {
+ result = result === undefined ? current : (result + current);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+ function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
+ * of key-value pairs for `object` corresponding to the property names of `props`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} props The property names to get values for.
+ * @returns {Object} Returns the key-value pairs.
+ */
+ function baseToPairs(object, props) {
+ return arrayMap(props, function(key) {
+ return [key, object[key]];
+ });
+ }
+
+ /**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+ function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+ }
+
+ /**
+ * The base implementation of `_.values` and `_.valuesIn` which creates an
+ * array of `object` property values corresponding to the property names
+ * of `props`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} props The property names to get values for.
+ * @returns {Object} Returns the array of property values.
+ */
+ function baseValues(object, props) {
+ return arrayMap(props, function(key) {
+ return object[key];
+ });
+ }
+
+ /**
+ * Checks if a `cache` value for `key` exists.
+ *
+ * @private
+ * @param {Object} cache The cache to query.
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function cacheHas(cache, key) {
+ return cache.has(key);
+ }
+
+ /**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the first unmatched string symbol.
+ */
+ function charsStartIndex(strSymbols, chrSymbols) {
+ var index = -1,
+ length = strSymbols.length;
+
+ while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+ }
+
+ /**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the last unmatched string symbol.
+ */
+ function charsEndIndex(strSymbols, chrSymbols) {
+ var index = strSymbols.length;
+
+ while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+ }
+
+ /**
+ * Gets the number of `placeholder` occurrences in `array`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} placeholder The placeholder to search for.
+ * @returns {number} Returns the placeholder count.
+ */
+ function countHolders(array, placeholder) {
+ var length = array.length,
+ result = 0;
+
+ while (length--) {
+ if (array[length] === placeholder) {
+ ++result;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
+ * letters to basic Latin letters.
+ *
+ * @private
+ * @param {string} letter The matched letter to deburr.
+ * @returns {string} Returns the deburred letter.
+ */
+ var deburrLetter = basePropertyOf(deburredLetters);
+
+ /**
+ * Used by `_.escape` to convert characters to HTML entities.
+ *
+ * @private
+ * @param {string} chr The matched character to escape.
+ * @returns {string} Returns the escaped character.
+ */
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
+
+ /**
+ * Used by `_.template` to escape characters for inclusion in compiled string literals.
+ *
+ * @private
+ * @param {string} chr The matched character to escape.
+ * @returns {string} Returns the escaped character.
+ */
+ function escapeStringChar(chr) {
+ return '\\' + stringEscapes[chr];
+ }
+
+ /**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+ function getValue(object, key) {
+ return object == null ? undefined : object[key];
+ }
+
+ /**
+ * Checks if `string` contains Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
+ */
+ function hasUnicode(string) {
+ return reHasUnicode.test(string);
+ }
+
+ /**
+ * Checks if `string` contains a word composed of Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
+ */
+ function hasUnicodeWord(string) {
+ return reHasUnicodeWord.test(string);
+ }
+
+ /**
+ * Converts `iterator` to an array.
+ *
+ * @private
+ * @param {Object} iterator The iterator to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function iteratorToArray(iterator) {
+ var data,
+ result = [];
+
+ while (!(data = iterator.next()).done) {
+ result.push(data.value);
+ }
+ return result;
+ }
+
+ /**
+ * Converts `map` to its key-value pairs.
+ *
+ * @private
+ * @param {Object} map The map to convert.
+ * @returns {Array} Returns the key-value pairs.
+ */
+ function mapToArray(map) {
+ var index = -1,
+ result = Array(map.size);
+
+ map.forEach(function(value, key) {
+ result[++index] = [key, value];
+ });
+ return result;
+ }
+
+ /**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+ }
+
+ /**
+ * Replaces all `placeholder` elements in `array` with an internal placeholder
+ * and returns an array of their indexes.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {*} placeholder The placeholder to replace.
+ * @returns {Array} Returns the new array of placeholder indexes.
+ */
+ function replaceHolders(array, placeholder) {
+ var index = -1,
+ length = array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (value === placeholder || value === PLACEHOLDER) {
+ array[index] = PLACEHOLDER;
+ result[resIndex++] = index;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Converts `set` to an array of its values.
+ *
+ * @private
+ * @param {Object} set The set to convert.
+ * @returns {Array} Returns the values.
+ */
+ function setToArray(set) {
+ var index = -1,
+ result = Array(set.size);
+
+ set.forEach(function(value) {
+ result[++index] = value;
+ });
+ return result;
+ }
+
+ /**
+ * Converts `set` to its value-value pairs.
+ *
+ * @private
+ * @param {Object} set The set to convert.
+ * @returns {Array} Returns the value-value pairs.
+ */
+ function setToPairs(set) {
+ var index = -1,
+ result = Array(set.size);
+
+ set.forEach(function(value) {
+ result[++index] = [value, value];
+ });
+ return result;
+ }
+
+ /**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * A specialized version of `_.lastIndexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function strictLastIndexOf(array, value, fromIndex) {
+ var index = fromIndex + 1;
+ while (index--) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return index;
+ }
+
+ /**
+ * Gets the number of symbols in `string`.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {number} Returns the string size.
+ */
+ function stringSize(string) {
+ return hasUnicode(string)
+ ? unicodeSize(string)
+ : asciiSize(string);
+ }
+
+ /**
+ * Converts `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function stringToArray(string) {
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
+ }
+
+ /**
+ * Used by `_.unescape` to convert HTML entities to characters.
+ *
+ * @private
+ * @param {string} chr The matched character to unescape.
+ * @returns {string} Returns the unescaped character.
+ */
+ var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
+
+ /**
+ * Gets the size of a Unicode `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+ function unicodeSize(string) {
+ var result = reUnicode.lastIndex = 0;
+ while (reUnicode.test(string)) {
+ ++result;
+ }
+ return result;
+ }
+
+ /**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+ }
+
+ /**
+ * Splits a Unicode `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+ function unicodeWords(string) {
+ return string.match(reUnicodeWord) || [];
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * Create a new pristine `lodash` function using the `context` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Util
+ * @param {Object} [context=root] The context object.
+ * @returns {Function} Returns a new `lodash` function.
+ * @example
+ *
+ * _.mixin({ 'foo': _.constant('foo') });
+ *
+ * var lodash = _.runInContext();
+ * lodash.mixin({ 'bar': lodash.constant('bar') });
+ *
+ * _.isFunction(_.foo);
+ * // => true
+ * _.isFunction(_.bar);
+ * // => false
+ *
+ * lodash.isFunction(lodash.foo);
+ * // => false
+ * lodash.isFunction(lodash.bar);
+ * // => true
+ *
+ * // Create a suped-up `defer` in Node.js.
+ * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
+ */
+ var runInContext = (function runInContext(context) {
+ context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
+
+ /** Built-in constructor references. */
+ var Array = context.Array,
+ Date = context.Date,
+ Error = context.Error,
+ Function = context.Function,
+ Math = context.Math,
+ Object = context.Object,
+ RegExp = context.RegExp,
+ String = context.String,
+ TypeError = context.TypeError;
+
+ /** Used for built-in method references. */
+ var arrayProto = Array.prototype,
+ funcProto = Function.prototype,
+ objectProto = Object.prototype;
+
+ /** Used to detect overreaching core-js shims. */
+ var coreJsData = context['__core-js_shared__'];
+
+ /** Used to resolve the decompiled source of functions. */
+ var funcToString = funcProto.toString;
+
+ /** Used to check objects for own properties. */
+ var hasOwnProperty = objectProto.hasOwnProperty;
+
+ /** Used to generate unique IDs. */
+ var idCounter = 0;
+
+ /** Used to detect methods masquerading as native. */
+ var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+ }());
+
+ /**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+ var nativeObjectToString = objectProto.toString;
+
+ /** Used to infer the `Object` constructor. */
+ var objectCtorString = funcToString.call(Object);
+
+ /** Used to restore the original `_` reference in `_.noConflict`. */
+ var oldDash = root._;
+
+ /** Used to detect if a method is native. */
+ var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+ );
+
+ /** Built-in value references. */
+ var Buffer = moduleExports ? context.Buffer : undefined,
+ Symbol = context.Symbol,
+ Uint8Array = context.Uint8Array,
+ allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
+ getPrototype = overArg(Object.getPrototypeOf, Object),
+ objectCreate = Object.create,
+ propertyIsEnumerable = objectProto.propertyIsEnumerable,
+ splice = arrayProto.splice,
+ spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
+ symIterator = Symbol ? Symbol.iterator : undefined,
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+ var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+ }());
+
+ /** Mocked built-ins. */
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
+ ctxNow = Date && Date.now !== root.Date.now && Date.now,
+ ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeCeil = Math.ceil,
+ nativeFloor = Math.floor,
+ nativeGetSymbols = Object.getOwnPropertySymbols,
+ nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
+ nativeIsFinite = context.isFinite,
+ nativeJoin = arrayProto.join,
+ nativeKeys = overArg(Object.keys, Object),
+ nativeMax = Math.max,
+ nativeMin = Math.min,
+ nativeNow = Date.now,
+ nativeParseInt = context.parseInt,
+ nativeRandom = Math.random,
+ nativeReverse = arrayProto.reverse;
+
+ /* Built-in method references that are verified to be native. */
+ var DataView = getNative(context, 'DataView'),
+ Map = getNative(context, 'Map'),
+ Promise = getNative(context, 'Promise'),
+ Set = getNative(context, 'Set'),
+ WeakMap = getNative(context, 'WeakMap'),
+ nativeCreate = getNative(Object, 'create');
+
+ /** Used to store function metadata. */
+ var metaMap = WeakMap && new WeakMap;
+
+ /** Used to lookup unminified function names. */
+ var realNames = {};
+
+ /** Used to detect maps, sets, and weakmaps. */
+ var dataViewCtorString = toSource(DataView),
+ mapCtorString = toSource(Map),
+ promiseCtorString = toSource(Promise),
+ setCtorString = toSource(Set),
+ weakMapCtorString = toSource(WeakMap);
+
+ /** Used to convert symbols to primitives and strings. */
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a `lodash` object which wraps `value` to enable implicit method
+ * chain sequences. Methods that operate on and return arrays, collections,
+ * and functions can be chained together. Methods that retrieve a single value
+ * or may return a primitive value will automatically end the chain sequence
+ * and return the unwrapped value. Otherwise, the value must be unwrapped
+ * with `_#value`.
+ *
+ * Explicit chain sequences, which must be unwrapped with `_#value`, may be
+ * enabled using `_.chain`.
+ *
+ * The execution of chained methods is lazy, that is, it's deferred until
+ * `_#value` is implicitly or explicitly called.
+ *
+ * Lazy evaluation allows several methods to support shortcut fusion.
+ * Shortcut fusion is an optimization to merge iteratee calls; this avoids
+ * the creation of intermediate arrays and can greatly reduce the number of
+ * iteratee executions. Sections of a chain sequence qualify for shortcut
+ * fusion if the section is applied to an array of at least `200` elements
+ * and any iteratees accept only one argument. The heuristic for whether a
+ * section qualifies for shortcut fusion is subject to change.
+ *
+ * Chaining is supported in custom builds as long as the `_#value` method is
+ * directly or indirectly included in the build.
+ *
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
+ *
+ * The wrapper methods that support shortcut fusion are:
+ * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
+ * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
+ * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
+ *
+ * The chainable wrapper methods are:
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
+ * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
+ * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
+ * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
+ * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
+ * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
+ * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
+ * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
+ * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
+ * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
+ * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
+ * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
+ * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
+ * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
+ * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
+ * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
+ * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
+ * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
+ * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
+ * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
+ * `zipObject`, `zipObjectDeep`, and `zipWith`
+ *
+ * The wrapper methods that are **not** chainable by default are:
+ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
+ * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
+ * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
+ * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
+ * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
+ * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
+ * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
+ * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
+ * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
+ * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
+ * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
+ * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
+ * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
+ * `upperFirst`, `value`, and `words`
+ *
+ * @name _
+ * @constructor
+ * @category Seq
+ * @param {*} value The value to wrap in a `lodash` instance.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2, 3]);
+ *
+ * // Returns an unwrapped value.
+ * wrapped.reduce(_.add);
+ * // => 6
+ *
+ * // Returns a wrapped value.
+ * var squares = wrapped.map(square);
+ *
+ * _.isArray(squares);
+ * // => false
+ *
+ * _.isArray(squares.value());
+ * // => true
+ */
+ function lodash(value) {
+ if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
+ if (value instanceof LodashWrapper) {
+ return value;
+ }
+ if (hasOwnProperty.call(value, '__wrapped__')) {
+ return wrapperClone(value);
+ }
+ }
+ return new LodashWrapper(value);
+ }
+
+ /**
+ * The base implementation of `_.create` without support for assigning
+ * properties to the created object.
+ *
+ * @private
+ * @param {Object} proto The object to inherit from.
+ * @returns {Object} Returns the new object.
+ */
+ var baseCreate = (function() {
+ function object() {}
+ return function(proto) {
+ if (!isObject(proto)) {
+ return {};
+ }
+ if (objectCreate) {
+ return objectCreate(proto);
+ }
+ object.prototype = proto;
+ var result = new object;
+ object.prototype = undefined;
+ return result;
+ };
+ }());
+
+ /**
+ * The function whose prototype chain sequence wrappers inherit from.
+ *
+ * @private
+ */
+ function baseLodash() {
+ // No operation performed.
+ }
+
+ /**
+ * The base constructor for creating `lodash` wrapper objects.
+ *
+ * @private
+ * @param {*} value The value to wrap.
+ * @param {boolean} [chainAll] Enable explicit method chain sequences.
+ */
+ function LodashWrapper(value, chainAll) {
+ this.__wrapped__ = value;
+ this.__actions__ = [];
+ this.__chain__ = !!chainAll;
+ this.__index__ = 0;
+ this.__values__ = undefined;
+ }
+
+ /**
+ * By default, the template delimiters used by lodash are like those in
+ * embedded Ruby (ERB). Change the following template settings to use
+ * alternative delimiters.
+ *
+ * @static
+ * @memberOf _
+ * @type {Object}
+ */
+ lodash.templateSettings = {
+
+ /**
+ * Used to detect `data` property values to be HTML-escaped.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'escape': reEscape,
+
+ /**
+ * Used to detect code to be evaluated.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'evaluate': reEvaluate,
+
+ /**
+ * Used to detect `data` property values to inject.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'interpolate': reInterpolate,
+
+ /**
+ * Used to reference the data object in the template text.
+ *
+ * @memberOf _.templateSettings
+ * @type {string}
+ */
+ 'variable': '',
+
+ /**
+ * Used to import variables into the compiled template.
+ *
+ * @memberOf _.templateSettings
+ * @type {Object}
+ */
+ 'imports': {
+
+ /**
+ * A reference to the `lodash` function.
+ *
+ * @memberOf _.templateSettings.imports
+ * @type {Function}
+ */
+ '_': lodash
+ }
+ };
+
+ // Ensure wrappers are instances of `baseLodash`.
+ lodash.prototype = baseLodash.prototype;
+ lodash.prototype.constructor = lodash;
+
+ LodashWrapper.prototype = baseCreate(baseLodash.prototype);
+ LodashWrapper.prototype.constructor = LodashWrapper;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
+ *
+ * @private
+ * @constructor
+ * @param {*} value The value to wrap.
+ */
+ function LazyWrapper(value) {
+ this.__wrapped__ = value;
+ this.__actions__ = [];
+ this.__dir__ = 1;
+ this.__filtered__ = false;
+ this.__iteratees__ = [];
+ this.__takeCount__ = MAX_ARRAY_LENGTH;
+ this.__views__ = [];
+ }
+
+ /**
+ * Creates a clone of the lazy wrapper object.
+ *
+ * @private
+ * @name clone
+ * @memberOf LazyWrapper
+ * @returns {Object} Returns the cloned `LazyWrapper` object.
+ */
+ function lazyClone() {
+ var result = new LazyWrapper(this.__wrapped__);
+ result.__actions__ = copyArray(this.__actions__);
+ result.__dir__ = this.__dir__;
+ result.__filtered__ = this.__filtered__;
+ result.__iteratees__ = copyArray(this.__iteratees__);
+ result.__takeCount__ = this.__takeCount__;
+ result.__views__ = copyArray(this.__views__);
+ return result;
+ }
+
+ /**
+ * Reverses the direction of lazy iteration.
+ *
+ * @private
+ * @name reverse
+ * @memberOf LazyWrapper
+ * @returns {Object} Returns the new reversed `LazyWrapper` object.
+ */
+ function lazyReverse() {
+ if (this.__filtered__) {
+ var result = new LazyWrapper(this);
+ result.__dir__ = -1;
+ result.__filtered__ = true;
+ } else {
+ result = this.clone();
+ result.__dir__ *= -1;
+ }
+ return result;
+ }
+
+ /**
+ * Extracts the unwrapped value from its lazy wrapper.
+ *
+ * @private
+ * @name value
+ * @memberOf LazyWrapper
+ * @returns {*} Returns the unwrapped value.
+ */
+ function lazyValue() {
+ var array = this.__wrapped__.value(),
+ dir = this.__dir__,
+ isArr = isArray(array),
+ isRight = dir < 0,
+ arrLength = isArr ? array.length : 0,
+ view = getView(0, arrLength, this.__views__),
+ start = view.start,
+ end = view.end,
+ length = end - start,
+ index = isRight ? end : (start - 1),
+ iteratees = this.__iteratees__,
+ iterLength = iteratees.length,
+ resIndex = 0,
+ takeCount = nativeMin(length, this.__takeCount__);
+
+ if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
+ (arrLength == length && takeCount == length)) {
+ return baseWrapperValue(array, this.__actions__);
+ }
+ var result = [];
+
+ outer:
+ while (length-- && resIndex < takeCount) {
+ index += dir;
+
+ var iterIndex = -1,
+ value = array[index];
+
+ while (++iterIndex < iterLength) {
+ var data = iteratees[iterIndex],
+ iteratee = data.iteratee,
+ type = data.type,
+ computed = iteratee(value);
+
+ if (type == LAZY_MAP_FLAG) {
+ value = computed;
+ } else if (!computed) {
+ if (type == LAZY_FILTER_FLAG) {
+ continue outer;
+ } else {
+ break outer;
+ }
+ }
+ }
+ result[resIndex++] = value;
+ }
+ return result;
+ }
+
+ // Ensure `LazyWrapper` is an instance of `baseLodash`.
+ LazyWrapper.prototype = baseCreate(baseLodash.prototype);
+ LazyWrapper.prototype.constructor = LazyWrapper;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a hash object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function Hash(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the hash.
+ *
+ * @private
+ * @name clear
+ * @memberOf Hash
+ */
+ function hashClear() {
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the hash.
+ *
+ * @private
+ * @name delete
+ * @memberOf Hash
+ * @param {Object} hash The hash to modify.
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function hashDelete(key) {
+ var result = this.has(key) && delete this.__data__[key];
+ this.size -= result ? 1 : 0;
+ return result;
+ }
+
+ /**
+ * Gets the hash value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Hash
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function hashGet(key) {
+ var data = this.__data__;
+ if (nativeCreate) {
+ var result = data[key];
+ return result === HASH_UNDEFINED ? undefined : result;
+ }
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
+ }
+
+ /**
+ * Checks if a hash value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Hash
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function hashHas(key) {
+ var data = this.__data__;
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
+ }
+
+ /**
+ * Sets the hash `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Hash
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the hash instance.
+ */
+ function hashSet(key, value) {
+ var data = this.__data__;
+ this.size += this.has(key) ? 0 : 1;
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
+ return this;
+ }
+
+ // Add methods to `Hash`.
+ Hash.prototype.clear = hashClear;
+ Hash.prototype['delete'] = hashDelete;
+ Hash.prototype.get = hashGet;
+ Hash.prototype.has = hashHas;
+ Hash.prototype.set = hashSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an list cache object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function ListCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the list cache.
+ *
+ * @private
+ * @name clear
+ * @memberOf ListCache
+ */
+ function listCacheClear() {
+ this.__data__ = [];
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the list cache.
+ *
+ * @private
+ * @name delete
+ * @memberOf ListCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function listCacheDelete(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ return false;
+ }
+ var lastIndex = data.length - 1;
+ if (index == lastIndex) {
+ data.pop();
+ } else {
+ splice.call(data, index, 1);
+ }
+ --this.size;
+ return true;
+ }
+
+ /**
+ * Gets the list cache value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf ListCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function listCacheGet(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ return index < 0 ? undefined : data[index][1];
+ }
+
+ /**
+ * Checks if a list cache value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf ListCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function listCacheHas(key) {
+ return assocIndexOf(this.__data__, key) > -1;
+ }
+
+ /**
+ * Sets the list cache `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf ListCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the list cache instance.
+ */
+ function listCacheSet(key, value) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ ++this.size;
+ data.push([key, value]);
+ } else {
+ data[index][1] = value;
+ }
+ return this;
+ }
+
+ // Add methods to `ListCache`.
+ ListCache.prototype.clear = listCacheClear;
+ ListCache.prototype['delete'] = listCacheDelete;
+ ListCache.prototype.get = listCacheGet;
+ ListCache.prototype.has = listCacheHas;
+ ListCache.prototype.set = listCacheSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a map cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function MapCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the map.
+ *
+ * @private
+ * @name clear
+ * @memberOf MapCache
+ */
+ function mapCacheClear() {
+ this.size = 0;
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': new (Map || ListCache),
+ 'string': new Hash
+ };
+ }
+
+ /**
+ * Removes `key` and its value from the map.
+ *
+ * @private
+ * @name delete
+ * @memberOf MapCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function mapCacheDelete(key) {
+ var result = getMapData(this, key)['delete'](key);
+ this.size -= result ? 1 : 0;
+ return result;
+ }
+
+ /**
+ * Gets the map value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf MapCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function mapCacheGet(key) {
+ return getMapData(this, key).get(key);
+ }
+
+ /**
+ * Checks if a map value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf MapCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function mapCacheHas(key) {
+ return getMapData(this, key).has(key);
+ }
+
+ /**
+ * Sets the map `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf MapCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the map cache instance.
+ */
+ function mapCacheSet(key, value) {
+ var data = getMapData(this, key),
+ size = data.size;
+
+ data.set(key, value);
+ this.size += data.size == size ? 0 : 1;
+ return this;
+ }
+
+ // Add methods to `MapCache`.
+ MapCache.prototype.clear = mapCacheClear;
+ MapCache.prototype['delete'] = mapCacheDelete;
+ MapCache.prototype.get = mapCacheGet;
+ MapCache.prototype.has = mapCacheHas;
+ MapCache.prototype.set = mapCacheSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ *
+ * Creates an array cache object to store unique values.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [values] The values to cache.
+ */
+ function SetCache(values) {
+ var index = -1,
+ length = values == null ? 0 : values.length;
+
+ this.__data__ = new MapCache;
+ while (++index < length) {
+ this.add(values[index]);
+ }
+ }
+
+ /**
+ * Adds `value` to the array cache.
+ *
+ * @private
+ * @name add
+ * @memberOf SetCache
+ * @alias push
+ * @param {*} value The value to cache.
+ * @returns {Object} Returns the cache instance.
+ */
+ function setCacheAdd(value) {
+ this.__data__.set(value, HASH_UNDEFINED);
+ return this;
+ }
+
+ /**
+ * Checks if `value` is in the array cache.
+ *
+ * @private
+ * @name has
+ * @memberOf SetCache
+ * @param {*} value The value to search for.
+ * @returns {number} Returns `true` if `value` is found, else `false`.
+ */
+ function setCacheHas(value) {
+ return this.__data__.has(value);
+ }
+
+ // Add methods to `SetCache`.
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
+ SetCache.prototype.has = setCacheHas;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a stack cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function Stack(entries) {
+ var data = this.__data__ = new ListCache(entries);
+ this.size = data.size;
+ }
+
+ /**
+ * Removes all key-value entries from the stack.
+ *
+ * @private
+ * @name clear
+ * @memberOf Stack
+ */
+ function stackClear() {
+ this.__data__ = new ListCache;
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the stack.
+ *
+ * @private
+ * @name delete
+ * @memberOf Stack
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function stackDelete(key) {
+ var data = this.__data__,
+ result = data['delete'](key);
+
+ this.size = data.size;
+ return result;
+ }
+
+ /**
+ * Gets the stack value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Stack
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function stackGet(key) {
+ return this.__data__.get(key);
+ }
+
+ /**
+ * Checks if a stack value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Stack
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function stackHas(key) {
+ return this.__data__.has(key);
+ }
+
+ /**
+ * Sets the stack `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Stack
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the stack cache instance.
+ */
+ function stackSet(key, value) {
+ var data = this.__data__;
+ if (data instanceof ListCache) {
+ var pairs = data.__data__;
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
+ pairs.push([key, value]);
+ this.size = ++data.size;
+ return this;
+ }
+ data = this.__data__ = new MapCache(pairs);
+ }
+ data.set(key, value);
+ this.size = data.size;
+ return this;
+ }
+
+ // Add methods to `Stack`.
+ Stack.prototype.clear = stackClear;
+ Stack.prototype['delete'] = stackDelete;
+ Stack.prototype.get = stackGet;
+ Stack.prototype.has = stackHas;
+ Stack.prototype.set = stackSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+ function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A specialized version of `_.sample` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @returns {*} Returns the random element.
+ */
+ function arraySample(array) {
+ var length = array.length;
+ return length ? array[baseRandom(0, length - 1)] : undefined;
+ }
+
+ /**
+ * A specialized version of `_.sampleSize` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+ function arraySampleSize(array, n) {
+ return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
+ }
+
+ /**
+ * A specialized version of `_.shuffle` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+ function arrayShuffle(array) {
+ return shuffleSelf(copyArray(array));
+ }
+
+ /**
+ * Used by `_.defaults` to customize its `_.assignIn` use.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to assign.
+ * @param {Object} object The parent object of `objValue`.
+ * @returns {*} Returns the value to assign.
+ */
+ function assignInDefaults(objValue, srcValue, key, object) {
+ if (objValue === undefined ||
+ (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
+ return srcValue;
+ }
+ return objValue;
+ }
+
+ /**
+ * This function is like `assignValue` except that it doesn't assign
+ * `undefined` values.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function assignMergeValue(object, key, value) {
+ if ((value !== undefined && !eq(object[key], value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+ }
+
+ /**
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function assignValue(object, key, value) {
+ var objValue = object[key];
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+ }
+
+ /**
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} key The key to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function assocIndexOf(array, key) {
+ var length = array.length;
+ while (length--) {
+ if (eq(array[length][0], key)) {
+ return length;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Aggregates elements of `collection` on `accumulator` with keys transformed
+ * by `iteratee` and values set by `setter`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform keys.
+ * @param {Object} accumulator The initial aggregated object.
+ * @returns {Function} Returns `accumulator`.
+ */
+ function baseAggregator(collection, setter, iteratee, accumulator) {
+ baseEach(collection, function(value, key, collection) {
+ setter(accumulator, value, iteratee(value), collection);
+ });
+ return accumulator;
+ }
+
+ /**
+ * The base implementation of `_.assign` without support for multiple sources
+ * or `customizer` functions.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @returns {Object} Returns `object`.
+ */
+ function baseAssign(object, source) {
+ return object && copyObject(source, keys(source), object);
+ }
+
+ /**
+ * The base implementation of `_.assignIn` without support for multiple sources
+ * or `customizer` functions.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @returns {Object} Returns `object`.
+ */
+ function baseAssignIn(object, source) {
+ return object && copyObject(source, keysIn(source), object);
+ }
+
+ /**
+ * The base implementation of `assignValue` and `assignMergeValue` without
+ * value checks.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function baseAssignValue(object, key, value) {
+ if (key == '__proto__' && defineProperty) {
+ defineProperty(object, key, {
+ 'configurable': true,
+ 'enumerable': true,
+ 'value': value,
+ 'writable': true
+ });
+ } else {
+ object[key] = value;
+ }
+ }
+
+ /**
+ * The base implementation of `_.at` without support for individual paths.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {string[]} paths The property paths to pick.
+ * @returns {Array} Returns the picked elements.
+ */
+ function baseAt(object, paths) {
+ var index = -1,
+ length = paths.length,
+ result = Array(length),
+ skip = object == null;
+
+ while (++index < length) {
+ result[index] = skip ? undefined : get(object, paths[index]);
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.clamp` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {number} number The number to clamp.
+ * @param {number} [lower] The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the clamped number.
+ */
+ function baseClamp(number, lower, upper) {
+ if (number === number) {
+ if (upper !== undefined) {
+ number = number <= upper ? number : upper;
+ }
+ if (lower !== undefined) {
+ number = number >= lower ? number : lower;
+ }
+ }
+ return number;
+ }
+
+ /**
+ * The base implementation of `_.clone` and `_.cloneDeep` which tracks
+ * traversed objects.
+ *
+ * @private
+ * @param {*} value The value to clone.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Deep clone
+ * 2 - Flatten inherited properties
+ * 4 - Clone symbols
+ * @param {Function} [customizer] The function to customize cloning.
+ * @param {string} [key] The key of `value`.
+ * @param {Object} [object] The parent object of `value`.
+ * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
+ * @returns {*} Returns the cloned value.
+ */
+ function baseClone(value, bitmask, customizer, key, object, stack) {
+ var result,
+ isDeep = bitmask & CLONE_DEEP_FLAG,
+ isFlat = bitmask & CLONE_FLAT_FLAG,
+ isFull = bitmask & CLONE_SYMBOLS_FLAG;
+
+ if (customizer) {
+ result = object ? customizer(value, key, object, stack) : customizer(value);
+ }
+ if (result !== undefined) {
+ return result;
+ }
+ if (!isObject(value)) {
+ return value;
+ }
+ var isArr = isArray(value);
+ if (isArr) {
+ result = initCloneArray(value);
+ if (!isDeep) {
+ return copyArray(value, result);
+ }
+ } else {
+ var tag = getTag(value),
+ isFunc = tag == funcTag || tag == genTag;
+
+ if (isBuffer(value)) {
+ return cloneBuffer(value, isDeep);
+ }
+ if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
+ result = (isFlat || isFunc) ? {} : initCloneObject(value);
+ if (!isDeep) {
+ return isFlat
+ ? copySymbolsIn(value, baseAssignIn(result, value))
+ : copySymbols(value, baseAssign(result, value));
+ }
+ } else {
+ if (!cloneableTags[tag]) {
+ return object ? value : {};
+ }
+ result = initCloneByTag(value, tag, baseClone, isDeep);
+ }
+ }
+ // Check for circular references and return its corresponding clone.
+ stack || (stack = new Stack);
+ var stacked = stack.get(value);
+ if (stacked) {
+ return stacked;
+ }
+ stack.set(value, result);
+
+ var keysFunc = isFull
+ ? (isFlat ? getAllKeysIn : getAllKeys)
+ : (isFlat ? keysIn : keys);
+
+ var props = isArr ? undefined : keysFunc(value);
+ arrayEach(props || value, function(subValue, key) {
+ if (props) {
+ key = subValue;
+ subValue = value[key];
+ }
+ // Recursively populate clone (susceptible to call stack limits).
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.conforms` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {Function} Returns the new spec function.
+ */
+ function baseConforms(source) {
+ var props = keys(source);
+ return function(object) {
+ return baseConformsTo(object, source, props);
+ };
+ }
+
+ /**
+ * The base implementation of `_.conformsTo` which accepts `props` to check.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
+ */
+ function baseConformsTo(object, source, props) {
+ var length = props.length;
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (length--) {
+ var key = props[length],
+ predicate = source[key],
+ value = object[key];
+
+ if ((value === undefined && !(key in object)) || !predicate(value)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * The base implementation of `_.delay` and `_.defer` which accepts `args`
+ * to provide to `func`.
+ *
+ * @private
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {Array} args The arguments to provide to `func`.
+ * @returns {number|Object} Returns the timer id or timeout object.
+ */
+ function baseDelay(func, wait, args) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return setTimeout(function() { func.apply(undefined, args); }, wait);
+ }
+
+ /**
+ * The base implementation of methods like `_.difference` without support
+ * for excluding multiple arrays or iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Array} values The values to exclude.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ */
+ function baseDifference(array, values, iteratee, comparator) {
+ var index = -1,
+ includes = arrayIncludes,
+ isCommon = true,
+ length = array.length,
+ result = [],
+ valuesLength = values.length;
+
+ if (!length) {
+ return result;
+ }
+ if (iteratee) {
+ values = arrayMap(values, baseUnary(iteratee));
+ }
+ if (comparator) {
+ includes = arrayIncludesWith;
+ isCommon = false;
+ }
+ else if (values.length >= LARGE_ARRAY_SIZE) {
+ includes = cacheHas;
+ isCommon = false;
+ values = new SetCache(values);
+ }
+ outer:
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee == null ? value : iteratee(value);
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (isCommon && computed === computed) {
+ var valuesIndex = valuesLength;
+ while (valuesIndex--) {
+ if (values[valuesIndex] === computed) {
+ continue outer;
+ }
+ }
+ result.push(value);
+ }
+ else if (!includes(values, computed, comparator)) {
+ result.push(value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ */
+ var baseEach = createBaseEach(baseForOwn);
+
+ /**
+ * The base implementation of `_.forEachRight` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ */
+ var baseEachRight = createBaseEach(baseForOwnRight, true);
+
+ /**
+ * The base implementation of `_.every` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`
+ */
+ function baseEvery(collection, predicate) {
+ var result = true;
+ baseEach(collection, function(value, index, collection) {
+ result = !!predicate(value, index, collection);
+ return result;
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of methods like `_.max` and `_.min` which accepts a
+ * `comparator` to determine the extremum value.
+ *
+ * @private
+ * @param {Array} array The array to iterate over.
+ * @param {Function} iteratee The iteratee invoked per iteration.
+ * @param {Function} comparator The comparator used to compare values.
+ * @returns {*} Returns the extremum value.
+ */
+ function baseExtremum(array, iteratee, comparator) {
+ var index = -1,
+ length = array.length;
+
+ while (++index < length) {
+ var value = array[index],
+ current = iteratee(value);
+
+ if (current != null && (computed === undefined
+ ? (current === current && !isSymbol(current))
+ : comparator(current, computed)
+ )) {
+ var computed = current,
+ result = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.fill` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to fill.
+ * @param {*} value The value to fill `array` with.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns `array`.
+ */
+ function baseFill(array, value, start, end) {
+ var length = array.length;
+
+ start = toInteger(start);
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = (end === undefined || end > length) ? length : toInteger(end);
+ if (end < 0) {
+ end += length;
+ }
+ end = start > end ? 0 : toLength(end);
+ while (start < end) {
+ array[start++] = value;
+ }
+ return array;
+ }
+
+ /**
+ * The base implementation of `_.filter` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ */
+ function baseFilter(collection, predicate) {
+ var result = [];
+ baseEach(collection, function(value, index, collection) {
+ if (predicate(value, index, collection)) {
+ result.push(value);
+ }
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.flatten` with support for restricting flattening.
+ *
+ * @private
+ * @param {Array} array The array to flatten.
+ * @param {number} depth The maximum recursion depth.
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
+ * @param {Array} [result=[]] The initial result value.
+ * @returns {Array} Returns the new flattened array.
+ */
+ function baseFlatten(array, depth, predicate, isStrict, result) {
+ var index = -1,
+ length = array.length;
+
+ predicate || (predicate = isFlattenable);
+ result || (result = []);
+
+ while (++index < length) {
+ var value = array[index];
+ if (depth > 0 && predicate(value)) {
+ if (depth > 1) {
+ // Recursively flatten arrays (susceptible to call stack limits).
+ baseFlatten(value, depth - 1, predicate, isStrict, result);
+ } else {
+ arrayPush(result, value);
+ }
+ } else if (!isStrict) {
+ result[result.length] = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+ var baseFor = createBaseFor();
+
+ /**
+ * This function is like `baseFor` except that it iterates over properties
+ * in the opposite order.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+ var baseForRight = createBaseFor(true);
+
+ /**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+ function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+ }
+
+ /**
+ * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+ function baseForOwnRight(object, iteratee) {
+ return object && baseForRight(object, iteratee, keys);
+ }
+
+ /**
+ * The base implementation of `_.functions` which creates an array of
+ * `object` function property names filtered from `props`.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Array} props The property names to filter.
+ * @returns {Array} Returns the function names.
+ */
+ function baseFunctions(object, props) {
+ return arrayFilter(props, function(key) {
+ return isFunction(object[key]);
+ });
+ }
+
+ /**
+ * The base implementation of `_.get` without support for default values.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @returns {*} Returns the resolved value.
+ */
+ function baseGet(object, path) {
+ path = castPath(path, object);
+
+ var index = 0,
+ length = path.length;
+
+ while (object != null && index < length) {
+ object = object[toKey(path[index++])];
+ }
+ return (index && index == length) ? object : undefined;
+ }
+
+ /**
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
+ * symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
+ var result = keysFunc(object);
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
+ }
+
+ /**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ value = Object(value);
+ return (symToStringTag && symToStringTag in value)
+ ? getRawTag(value)
+ : objectToString(value);
+ }
+
+ /**
+ * The base implementation of `_.gt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than `other`,
+ * else `false`.
+ */
+ function baseGt(value, other) {
+ return value > other;
+ }
+
+ /**
+ * The base implementation of `_.has` without support for deep paths.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {Array|string} key The key to check.
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
+ */
+ function baseHas(object, key) {
+ return object != null && hasOwnProperty.call(object, key);
+ }
+
+ /**
+ * The base implementation of `_.hasIn` without support for deep paths.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {Array|string} key The key to check.
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
+ */
+ function baseHasIn(object, key) {
+ return object != null && key in Object(object);
+ }
+
+ /**
+ * The base implementation of `_.inRange` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {number} number The number to check.
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
+ */
+ function baseInRange(number, start, end) {
+ return number >= nativeMin(start, end) && number < nativeMax(start, end);
+ }
+
+ /**
+ * The base implementation of methods like `_.intersection`, without support
+ * for iteratee shorthands, that accepts an array of arrays to inspect.
+ *
+ * @private
+ * @param {Array} arrays The arrays to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of shared values.
+ */
+ function baseIntersection(arrays, iteratee, comparator) {
+ var includes = comparator ? arrayIncludesWith : arrayIncludes,
+ length = arrays[0].length,
+ othLength = arrays.length,
+ othIndex = othLength,
+ caches = Array(othLength),
+ maxLength = Infinity,
+ result = [];
+
+ while (othIndex--) {
+ var array = arrays[othIndex];
+ if (othIndex && iteratee) {
+ array = arrayMap(array, baseUnary(iteratee));
+ }
+ maxLength = nativeMin(array.length, maxLength);
+ caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
+ ? new SetCache(othIndex && array)
+ : undefined;
+ }
+ array = arrays[0];
+
+ var index = -1,
+ seen = caches[0];
+
+ outer:
+ while (++index < length && result.length < maxLength) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (!(seen
+ ? cacheHas(seen, computed)
+ : includes(result, computed, comparator)
+ )) {
+ othIndex = othLength;
+ while (--othIndex) {
+ var cache = caches[othIndex];
+ if (!(cache
+ ? cacheHas(cache, computed)
+ : includes(arrays[othIndex], computed, comparator))
+ ) {
+ continue outer;
+ }
+ }
+ if (seen) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.invert` and `_.invertBy` which inverts
+ * `object` with values transformed by `iteratee` and set by `setter`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} setter The function to set `accumulator` values.
+ * @param {Function} iteratee The iteratee to transform values.
+ * @param {Object} accumulator The initial inverted object.
+ * @returns {Function} Returns `accumulator`.
+ */
+ function baseInverter(object, setter, iteratee, accumulator) {
+ baseForOwn(object, function(value, key, object) {
+ setter(accumulator, iteratee(value), key, object);
+ });
+ return accumulator;
+ }
+
+ /**
+ * The base implementation of `_.invoke` without support for individual
+ * method arguments.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {Array} args The arguments to invoke the method with.
+ * @returns {*} Returns the result of the invoked method.
+ */
+ function baseInvoke(object, path, args) {
+ path = castPath(path, object);
+ object = parent(object, path);
+ var func = object == null ? object : object[toKey(last(path))];
+ return func == null ? undefined : apply(func, object, args);
+ }
+
+ /**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+ function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+ }
+
+ /**
+ * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
+ */
+ function baseIsArrayBuffer(value) {
+ return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
+ }
+
+ /**
+ * The base implementation of `_.isDate` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ */
+ function baseIsDate(value) {
+ return isObjectLike(value) && baseGetTag(value) == dateTag;
+ }
+
+ /**
+ * The base implementation of `_.isEqual` which supports partial comparisons
+ * and tracks traversed objects.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Unordered comparison
+ * 2 - Partial comparison
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ */
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
+ if (value === other) {
+ return true;
+ }
+ if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
+ return value !== value && other !== other;
+ }
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
+ }
+
+ /**
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
+ * deep comparisons and tracks traversed objects enabling objects with circular
+ * references to be compared.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
+ var objIsArr = isArray(object),
+ othIsArr = isArray(other),
+ objTag = arrayTag,
+ othTag = arrayTag;
+
+ if (!objIsArr) {
+ objTag = getTag(object);
+ objTag = objTag == argsTag ? objectTag : objTag;
+ }
+ if (!othIsArr) {
+ othTag = getTag(other);
+ othTag = othTag == argsTag ? objectTag : othTag;
+ }
+ var objIsObj = objTag == objectTag,
+ othIsObj = othTag == objectTag,
+ isSameTag = objTag == othTag;
+
+ if (isSameTag && isBuffer(object)) {
+ if (!isBuffer(other)) {
+ return false;
+ }
+ objIsArr = true;
+ objIsObj = false;
+ }
+ if (isSameTag && !objIsObj) {
+ stack || (stack = new Stack);
+ return (objIsArr || isTypedArray(object))
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
+ }
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
+
+ if (objIsWrapped || othIsWrapped) {
+ var objUnwrapped = objIsWrapped ? object.value() : object,
+ othUnwrapped = othIsWrapped ? other.value() : other;
+
+ stack || (stack = new Stack);
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
+ }
+ }
+ if (!isSameTag) {
+ return false;
+ }
+ stack || (stack = new Stack);
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
+ }
+
+ /**
+ * The base implementation of `_.isMap` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ */
+ function baseIsMap(value) {
+ return isObjectLike(value) && getTag(value) == mapTag;
+ }
+
+ /**
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @param {Array} matchData The property names, values, and compare flags to match.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ */
+ function baseIsMatch(object, source, matchData, customizer) {
+ var index = matchData.length,
+ length = index,
+ noCustomizer = !customizer;
+
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (index--) {
+ var data = matchData[index];
+ if ((noCustomizer && data[2])
+ ? data[1] !== object[data[0]]
+ : !(data[0] in object)
+ ) {
+ return false;
+ }
+ }
+ while (++index < length) {
+ data = matchData[index];
+ var key = data[0],
+ objValue = object[key],
+ srcValue = data[1];
+
+ if (noCustomizer && data[2]) {
+ if (objValue === undefined && !(key in object)) {
+ return false;
+ }
+ } else {
+ var stack = new Stack;
+ if (customizer) {
+ var result = customizer(objValue, srcValue, key, object, source, stack);
+ }
+ if (!(result === undefined
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
+ : result
+ )) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+ function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
+ }
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+ }
+
+ /**
+ * The base implementation of `_.isRegExp` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ */
+ function baseIsRegExp(value) {
+ return isObjectLike(value) && baseGetTag(value) == regexpTag;
+ }
+
+ /**
+ * The base implementation of `_.isSet` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ */
+ function baseIsSet(value) {
+ return isObjectLike(value) && getTag(value) == setTag;
+ }
+
+ /**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+ function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+ }
+
+ /**
+ * The base implementation of `_.iteratee`.
+ *
+ * @private
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
+ * @returns {Function} Returns the iteratee.
+ */
+ function baseIteratee(value) {
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
+ if (typeof value == 'function') {
+ return value;
+ }
+ if (value == null) {
+ return identity;
+ }
+ if (typeof value == 'object') {
+ return isArray(value)
+ ? baseMatchesProperty(value[0], value[1])
+ : baseMatches(value);
+ }
+ return property(value);
+ }
+
+ /**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function baseKeysIn(object) {
+ if (!isObject(object)) {
+ return nativeKeysIn(object);
+ }
+ var isProto = isPrototype(object),
+ result = [];
+
+ for (var key in object) {
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.lt` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than `other`,
+ * else `false`.
+ */
+ function baseLt(value, other) {
+ return value < other;
+ }
+
+ /**
+ * The base implementation of `_.map` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+ function baseMap(collection, iteratee) {
+ var index = -1,
+ result = isArrayLike(collection) ? Array(collection.length) : [];
+
+ baseEach(collection, function(value, key, collection) {
+ result[++index] = iteratee(value, key, collection);
+ });
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.matches` which doesn't clone `source`.
+ *
+ * @private
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ */
+ function baseMatches(source) {
+ var matchData = getMatchData(source);
+ if (matchData.length == 1 && matchData[0][2]) {
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
+ }
+ return function(object) {
+ return object === source || baseIsMatch(object, source, matchData);
+ };
+ }
+
+ /**
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
+ *
+ * @private
+ * @param {string} path The path of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+ function baseMatchesProperty(path, srcValue) {
+ if (isKey(path) && isStrictComparable(srcValue)) {
+ return matchesStrictComparable(toKey(path), srcValue);
+ }
+ return function(object) {
+ var objValue = get(object, path);
+ return (objValue === undefined && objValue === srcValue)
+ ? hasIn(object, path)
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
+ };
+ }
+
+ /**
+ * The base implementation of `_.merge` without support for multiple sources.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} [customizer] The function to customize merged values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+ function baseMerge(object, source, srcIndex, customizer, stack) {
+ if (object === source) {
+ return;
+ }
+ baseFor(source, function(srcValue, key) {
+ if (isObject(srcValue)) {
+ stack || (stack = new Stack);
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
+ }
+ else {
+ var newValue = customizer
+ ? customizer(object[key], srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = srcValue;
+ }
+ assignMergeValue(object, key, newValue);
+ }
+ }, keysIn);
+ }
+
+ /**
+ * A specialized version of `baseMerge` for arrays and objects which performs
+ * deep merges and tracks traversed objects enabling objects with circular
+ * references to be merged.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {string} key The key of the value to merge.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} mergeFunc The function to merge values.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
+ var objValue = object[key],
+ srcValue = source[key],
+ stacked = stack.get(srcValue);
+
+ if (stacked) {
+ assignMergeValue(object, key, stacked);
+ return;
+ }
+ var newValue = customizer
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ var isCommon = newValue === undefined;
+
+ if (isCommon) {
+ var isArr = isArray(srcValue),
+ isBuff = !isArr && isBuffer(srcValue),
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
+
+ newValue = srcValue;
+ if (isArr || isBuff || isTyped) {
+ if (isArray(objValue)) {
+ newValue = objValue;
+ }
+ else if (isArrayLikeObject(objValue)) {
+ newValue = copyArray(objValue);
+ }
+ else if (isBuff) {
+ isCommon = false;
+ newValue = cloneBuffer(srcValue, true);
+ }
+ else if (isTyped) {
+ isCommon = false;
+ newValue = cloneTypedArray(srcValue, true);
+ }
+ else {
+ newValue = [];
+ }
+ }
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
+ newValue = objValue;
+ if (isArguments(objValue)) {
+ newValue = toPlainObject(objValue);
+ }
+ else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
+ newValue = initCloneObject(srcValue);
+ }
+ }
+ else {
+ isCommon = false;
+ }
+ }
+ if (isCommon) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, newValue);
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
+ stack['delete'](srcValue);
+ }
+ assignMergeValue(object, key, newValue);
+ }
+
+ /**
+ * The base implementation of `_.nth` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {Array} array The array to query.
+ * @param {number} n The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ */
+ function baseNth(array, n) {
+ var length = array.length;
+ if (!length) {
+ return;
+ }
+ n += n < 0 ? length : 0;
+ return isIndex(n, length) ? array[n] : undefined;
+ }
+
+ /**
+ * The base implementation of `_.orderBy` without param guards.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
+ * @param {string[]} orders The sort orders of `iteratees`.
+ * @returns {Array} Returns the new sorted array.
+ */
+ function baseOrderBy(collection, iteratees, orders) {
+ var index = -1;
+ iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
+
+ var result = baseMap(collection, function(value, key, collection) {
+ var criteria = arrayMap(iteratees, function(iteratee) {
+ return iteratee(value);
+ });
+ return { 'criteria': criteria, 'index': ++index, 'value': value };
+ });
+
+ return baseSortBy(result, function(object, other) {
+ return compareMultiple(object, other, orders);
+ });
+ }
+
+ /**
+ * The base implementation of `_.pick` without support for individual
+ * property identifiers.
+ *
+ * @private
+ * @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
+ * @returns {Object} Returns the new object.
+ */
+ function basePick(object, paths) {
+ object = Object(object);
+ return basePickBy(object, paths, function(value, path) {
+ return hasIn(object, path);
+ });
+ }
+
+ /**
+ * The base implementation of `_.pickBy` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
+ * @param {Function} predicate The function invoked per property.
+ * @returns {Object} Returns the new object.
+ */
+ function basePickBy(object, paths, predicate) {
+ var index = -1,
+ length = paths.length,
+ result = {};
+
+ while (++index < length) {
+ var path = paths[index],
+ value = baseGet(object, path);
+
+ if (predicate(value, path)) {
+ baseSet(result, castPath(path, object), value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * A specialized version of `baseProperty` which supports deep paths.
+ *
+ * @private
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function basePropertyDeep(path) {
+ return function(object) {
+ return baseGet(object, path);
+ };
+ }
+
+ /**
+ * The base implementation of `_.pullAllBy` without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns `array`.
+ */
+ function basePullAll(array, values, iteratee, comparator) {
+ var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
+ index = -1,
+ length = values.length,
+ seen = array;
+
+ if (array === values) {
+ values = copyArray(values);
+ }
+ if (iteratee) {
+ seen = arrayMap(array, baseUnary(iteratee));
+ }
+ while (++index < length) {
+ var fromIndex = 0,
+ value = values[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
+ if (seen !== array) {
+ splice.call(seen, fromIndex, 1);
+ }
+ splice.call(array, fromIndex, 1);
+ }
+ }
+ return array;
+ }
+
+ /**
+ * The base implementation of `_.pullAt` without support for individual
+ * indexes or capturing the removed elements.
+ *
+ * @private
+ * @param {Array} array The array to modify.
+ * @param {number[]} indexes The indexes of elements to remove.
+ * @returns {Array} Returns `array`.
+ */
+ function basePullAt(array, indexes) {
+ var length = array ? indexes.length : 0,
+ lastIndex = length - 1;
+
+ while (length--) {
+ var index = indexes[length];
+ if (length == lastIndex || index !== previous) {
+ var previous = index;
+ if (isIndex(index)) {
+ splice.call(array, index, 1);
+ } else {
+ baseUnset(array, index);
+ }
+ }
+ }
+ return array;
+ }
+
+ /**
+ * The base implementation of `_.random` without support for returning
+ * floating-point numbers.
+ *
+ * @private
+ * @param {number} lower The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the random number.
+ */
+ function baseRandom(lower, upper) {
+ return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
+ }
+
+ /**
+ * The base implementation of `_.range` and `_.rangeRight` which doesn't
+ * coerce arguments.
+ *
+ * @private
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} step The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the range of numbers.
+ */
+ function baseRange(start, end, step, fromRight) {
+ var index = -1,
+ length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
+
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.repeat` which doesn't coerce arguments.
+ *
+ * @private
+ * @param {string} string The string to repeat.
+ * @param {number} n The number of times to repeat the string.
+ * @returns {string} Returns the repeated string.
+ */
+ function baseRepeat(string, n) {
+ var result = '';
+ if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
+ return result;
+ }
+ // Leverage the exponentiation by squaring algorithm for a faster repeat.
+ // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
+ do {
+ if (n % 2) {
+ result += string;
+ }
+ n = nativeFloor(n / 2);
+ if (n) {
+ string += string;
+ }
+ } while (n);
+
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+ function baseRest(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+ }
+
+ /**
+ * The base implementation of `_.sample`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @returns {*} Returns the random element.
+ */
+ function baseSample(collection) {
+ return arraySample(values(collection));
+ }
+
+ /**
+ * The base implementation of `_.sampleSize` without param guards.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+ function baseSampleSize(collection, n) {
+ var array = values(collection);
+ return shuffleSelf(array, baseClamp(n, 0, array.length));
+ }
+
+ /**
+ * The base implementation of `_.set`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @param {Function} [customizer] The function to customize path creation.
+ * @returns {Object} Returns `object`.
+ */
+ function baseSet(object, path, value, customizer) {
+ if (!isObject(object)) {
+ return object;
+ }
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length,
+ lastIndex = length - 1,
+ nested = object;
+
+ while (nested != null && ++index < length) {
+ var key = toKey(path[index]),
+ newValue = value;
+
+ if (index != lastIndex) {
+ var objValue = nested[key];
+ newValue = customizer ? customizer(objValue, key, nested) : undefined;
+ if (newValue === undefined) {
+ newValue = isObject(objValue)
+ ? objValue
+ : (isIndex(path[index + 1]) ? [] : {});
+ }
+ }
+ assignValue(nested, key, newValue);
+ nested = nested[key];
+ }
+ return object;
+ }
+
+ /**
+ * The base implementation of `setData` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to associate metadata with.
+ * @param {*} data The metadata.
+ * @returns {Function} Returns `func`.
+ */
+ var baseSetData = !metaMap ? identity : function(func, data) {
+ metaMap.set(func, data);
+ return func;
+ };
+
+ /**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
+ });
+ };
+
+ /**
+ * The base implementation of `_.shuffle`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+ function baseShuffle(collection) {
+ return shuffleSelf(values(collection));
+ }
+
+ /**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+ function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
+ }
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
+
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.some` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} predicate The function invoked per iteration.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ */
+ function baseSome(collection, predicate) {
+ var result;
+
+ baseEach(collection, function(value, index, collection) {
+ result = predicate(value, index, collection);
+ return !result;
+ });
+ return !!result;
+ }
+
+ /**
+ * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
+ * performs a binary search of `array` to determine the index at which `value`
+ * should be inserted into `array` in order to maintain its sort order.
+ *
+ * @private
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ */
+ function baseSortedIndex(array, value, retHighest) {
+ var low = 0,
+ high = array == null ? low : array.length;
+
+ if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
+ while (low < high) {
+ var mid = (low + high) >>> 1,
+ computed = array[mid];
+
+ if (computed !== null && !isSymbol(computed) &&
+ (retHighest ? (computed <= value) : (computed < value))) {
+ low = mid + 1;
+ } else {
+ high = mid;
+ }
+ }
+ return high;
+ }
+ return baseSortedIndexBy(array, value, identity, retHighest);
+ }
+
+ /**
+ * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
+ * which invokes `iteratee` for `value` and each element of `array` to compute
+ * their sort ranking. The iteratee is invoked with one argument; (value).
+ *
+ * @private
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} iteratee The iteratee invoked per element.
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ */
+ function baseSortedIndexBy(array, value, iteratee, retHighest) {
+ value = iteratee(value);
+
+ var low = 0,
+ high = array == null ? 0 : array.length,
+ valIsNaN = value !== value,
+ valIsNull = value === null,
+ valIsSymbol = isSymbol(value),
+ valIsUndefined = value === undefined;
+
+ while (low < high) {
+ var mid = nativeFloor((low + high) / 2),
+ computed = iteratee(array[mid]),
+ othIsDefined = computed !== undefined,
+ othIsNull = computed === null,
+ othIsReflexive = computed === computed,
+ othIsSymbol = isSymbol(computed);
+
+ if (valIsNaN) {
+ var setLow = retHighest || othIsReflexive;
+ } else if (valIsUndefined) {
+ setLow = othIsReflexive && (retHighest || othIsDefined);
+ } else if (valIsNull) {
+ setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
+ } else if (valIsSymbol) {
+ setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
+ } else if (othIsNull || othIsSymbol) {
+ setLow = false;
+ } else {
+ setLow = retHighest ? (computed <= value) : (computed < value);
+ }
+ if (setLow) {
+ low = mid + 1;
+ } else {
+ high = mid;
+ }
+ }
+ return nativeMin(high, MAX_ARRAY_INDEX);
+ }
+
+ /**
+ * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ */
+ function baseSortedUniq(array, iteratee) {
+ var index = -1,
+ length = array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ if (!index || !eq(computed, seen)) {
+ var seen = computed;
+ result[resIndex++] = value === 0 ? 0 : value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.toNumber` which doesn't ensure correct
+ * conversions of binary, hexadecimal, or octal string values.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ */
+ function baseToNumber(value) {
+ if (typeof value == 'number') {
+ return value;
+ }
+ if (isSymbol(value)) {
+ return NAN;
+ }
+ return +value;
+ }
+
+ /**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+ function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+ }
+
+ /**
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ */
+ function baseUniq(array, iteratee, comparator) {
+ var index = -1,
+ includes = arrayIncludes,
+ length = array.length,
+ isCommon = true,
+ result = [],
+ seen = result;
+
+ if (comparator) {
+ isCommon = false;
+ includes = arrayIncludesWith;
+ }
+ else if (length >= LARGE_ARRAY_SIZE) {
+ var set = iteratee ? null : createSet(array);
+ if (set) {
+ return setToArray(set);
+ }
+ isCommon = false;
+ includes = cacheHas;
+ seen = new SetCache;
+ }
+ else {
+ seen = iteratee ? [] : result;
+ }
+ outer:
+ while (++index < length) {
+ var value = array[index],
+ computed = iteratee ? iteratee(value) : value;
+
+ value = (comparator || value !== 0) ? value : 0;
+ if (isCommon && computed === computed) {
+ var seenIndex = seen.length;
+ while (seenIndex--) {
+ if (seen[seenIndex] === computed) {
+ continue outer;
+ }
+ }
+ if (iteratee) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ else if (!includes(seen, computed, comparator)) {
+ if (seen !== result) {
+ seen.push(computed);
+ }
+ result.push(value);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.unset`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The property path to unset.
+ * @returns {boolean} Returns `true` if the property is deleted, else `false`.
+ */
+ function baseUnset(object, path) {
+ path = castPath(path, object);
+ object = parent(object, path);
+ return object == null || delete object[toKey(last(path))];
+ }
+
+ /**
+ * The base implementation of `_.update`.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to update.
+ * @param {Function} updater The function to produce the updated value.
+ * @param {Function} [customizer] The function to customize path creation.
+ * @returns {Object} Returns `object`.
+ */
+ function baseUpdate(object, path, updater, customizer) {
+ return baseSet(object, path, updater(baseGet(object, path)), customizer);
+ }
+
+ /**
+ * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
+ * without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to query.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the slice of `array`.
+ */
+ function baseWhile(array, predicate, isDrop, fromRight) {
+ var length = array.length,
+ index = fromRight ? length : -1;
+
+ while ((fromRight ? index-- : ++index < length) &&
+ predicate(array[index], index, array)) {}
+
+ return isDrop
+ ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
+ : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
+ }
+
+ /**
+ * The base implementation of `wrapperValue` which returns the result of
+ * performing a sequence of actions on the unwrapped `value`, where each
+ * successive action is supplied the return value of the previous.
+ *
+ * @private
+ * @param {*} value The unwrapped value.
+ * @param {Array} actions Actions to perform to resolve the unwrapped value.
+ * @returns {*} Returns the resolved value.
+ */
+ function baseWrapperValue(value, actions) {
+ var result = value;
+ if (result instanceof LazyWrapper) {
+ result = result.value();
+ }
+ return arrayReduce(actions, function(result, action) {
+ return action.func.apply(action.thisArg, arrayPush([result], action.args));
+ }, result);
+ }
+
+ /**
+ * The base implementation of methods like `_.xor`, without support for
+ * iteratee shorthands, that accepts an array of arrays to inspect.
+ *
+ * @private
+ * @param {Array} arrays The arrays to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of values.
+ */
+ function baseXor(arrays, iteratee, comparator) {
+ var length = arrays.length;
+ if (length < 2) {
+ return length ? baseUniq(arrays[0]) : [];
+ }
+ var index = -1,
+ result = Array(length);
+
+ while (++index < length) {
+ var array = arrays[index],
+ othIndex = -1;
+
+ while (++othIndex < length) {
+ if (othIndex != index) {
+ result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
+ }
+ }
+ }
+ return baseUniq(baseFlatten(result, 1), iteratee, comparator);
+ }
+
+ /**
+ * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
+ *
+ * @private
+ * @param {Array} props The property identifiers.
+ * @param {Array} values The property values.
+ * @param {Function} assignFunc The function to assign values.
+ * @returns {Object} Returns the new object.
+ */
+ function baseZipObject(props, values, assignFunc) {
+ var index = -1,
+ length = props.length,
+ valsLength = values.length,
+ result = {};
+
+ while (++index < length) {
+ var value = index < valsLength ? values[index] : undefined;
+ assignFunc(result, props[index], value);
+ }
+ return result;
+ }
+
+ /**
+ * Casts `value` to an empty array if it's not an array like object.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array|Object} Returns the cast array-like object.
+ */
+ function castArrayLikeObject(value) {
+ return isArrayLikeObject(value) ? value : [];
+ }
+
+ /**
+ * Casts `value` to `identity` if it's not a function.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Function} Returns cast function.
+ */
+ function castFunction(value) {
+ return typeof value == 'function' ? value : identity;
+ }
+
+ /**
+ * Casts `value` to a path array if it's not one.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {Array} Returns the cast property path array.
+ */
+ function castPath(value, object) {
+ if (isArray(value)) {
+ return value;
+ }
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
+ }
+
+ /**
+ * A `baseRest` alias which can be replaced with `identity` by module
+ * replacement plugins.
+ *
+ * @private
+ * @type {Function}
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+ var castRest = baseRest;
+
+ /**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+ function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+ }
+
+ /**
+ * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
+ *
+ * @private
+ * @param {number|Object} id The timer id or timeout object of the timer to clear.
+ */
+ var clearTimeout = ctxClearTimeout || function(id) {
+ return root.clearTimeout(id);
+ };
+
+ /**
+ * Creates a clone of `buffer`.
+ *
+ * @private
+ * @param {Buffer} buffer The buffer to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Buffer} Returns the cloned buffer.
+ */
+ function cloneBuffer(buffer, isDeep) {
+ if (isDeep) {
+ return buffer.slice();
+ }
+ var length = buffer.length,
+ result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
+
+ buffer.copy(result);
+ return result;
+ }
+
+ /**
+ * Creates a clone of `arrayBuffer`.
+ *
+ * @private
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
+ */
+ function cloneArrayBuffer(arrayBuffer) {
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
+ return result;
+ }
+
+ /**
+ * Creates a clone of `dataView`.
+ *
+ * @private
+ * @param {Object} dataView The data view to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned data view.
+ */
+ function cloneDataView(dataView, isDeep) {
+ var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
+ }
+
+ /**
+ * Creates a clone of `map`.
+ *
+ * @private
+ * @param {Object} map The map to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned map.
+ */
+ function cloneMap(map, isDeep, cloneFunc) {
+ var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
+ return arrayReduce(array, addMapEntry, new map.constructor);
+ }
+
+ /**
+ * Creates a clone of `regexp`.
+ *
+ * @private
+ * @param {Object} regexp The regexp to clone.
+ * @returns {Object} Returns the cloned regexp.
+ */
+ function cloneRegExp(regexp) {
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
+ result.lastIndex = regexp.lastIndex;
+ return result;
+ }
+
+ /**
+ * Creates a clone of `set`.
+ *
+ * @private
+ * @param {Object} set The set to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned set.
+ */
+ function cloneSet(set, isDeep, cloneFunc) {
+ var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
+ return arrayReduce(array, addSetEntry, new set.constructor);
+ }
+
+ /**
+ * Creates a clone of the `symbol` object.
+ *
+ * @private
+ * @param {Object} symbol The symbol object to clone.
+ * @returns {Object} Returns the cloned symbol object.
+ */
+ function cloneSymbol(symbol) {
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
+ }
+
+ /**
+ * Creates a clone of `typedArray`.
+ *
+ * @private
+ * @param {Object} typedArray The typed array to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned typed array.
+ */
+ function cloneTypedArray(typedArray, isDeep) {
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
+ }
+
+ /**
+ * Compares values to sort them in ascending order.
+ *
+ * @private
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {number} Returns the sort order indicator for `value`.
+ */
+ function compareAscending(value, other) {
+ if (value !== other) {
+ var valIsDefined = value !== undefined,
+ valIsNull = value === null,
+ valIsReflexive = value === value,
+ valIsSymbol = isSymbol(value);
+
+ var othIsDefined = other !== undefined,
+ othIsNull = other === null,
+ othIsReflexive = other === other,
+ othIsSymbol = isSymbol(other);
+
+ if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
+ (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
+ (valIsNull && othIsDefined && othIsReflexive) ||
+ (!valIsDefined && othIsReflexive) ||
+ !valIsReflexive) {
+ return 1;
+ }
+ if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
+ (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
+ (othIsNull && valIsDefined && valIsReflexive) ||
+ (!othIsDefined && valIsReflexive) ||
+ !othIsReflexive) {
+ return -1;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Used by `_.orderBy` to compare multiple properties of a value to another
+ * and stable sort them.
+ *
+ * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
+ * specify an order of "desc" for descending or "asc" for ascending sort order
+ * of corresponding values.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {boolean[]|string[]} orders The order to sort by for each property.
+ * @returns {number} Returns the sort order indicator for `object`.
+ */
+ function compareMultiple(object, other, orders) {
+ var index = -1,
+ objCriteria = object.criteria,
+ othCriteria = other.criteria,
+ length = objCriteria.length,
+ ordersLength = orders.length;
+
+ while (++index < length) {
+ var result = compareAscending(objCriteria[index], othCriteria[index]);
+ if (result) {
+ if (index >= ordersLength) {
+ return result;
+ }
+ var order = orders[index];
+ return result * (order == 'desc' ? -1 : 1);
+ }
+ }
+ // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
+ // that causes it, under certain circumstances, to provide the same value for
+ // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
+ // for more details.
+ //
+ // This also ensures a stable sort in V8 and other engines.
+ // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
+ return object.index - other.index;
+ }
+
+ /**
+ * Creates an array that is the composition of partially applied arguments,
+ * placeholders, and provided arguments into a single array of arguments.
+ *
+ * @private
+ * @param {Array} args The provided arguments.
+ * @param {Array} partials The arguments to prepend to those provided.
+ * @param {Array} holders The `partials` placeholder indexes.
+ * @params {boolean} [isCurried] Specify composing for a curried function.
+ * @returns {Array} Returns the new array of composed arguments.
+ */
+ function composeArgs(args, partials, holders, isCurried) {
+ var argsIndex = -1,
+ argsLength = args.length,
+ holdersLength = holders.length,
+ leftIndex = -1,
+ leftLength = partials.length,
+ rangeLength = nativeMax(argsLength - holdersLength, 0),
+ result = Array(leftLength + rangeLength),
+ isUncurried = !isCurried;
+
+ while (++leftIndex < leftLength) {
+ result[leftIndex] = partials[leftIndex];
+ }
+ while (++argsIndex < holdersLength) {
+ if (isUncurried || argsIndex < argsLength) {
+ result[holders[argsIndex]] = args[argsIndex];
+ }
+ }
+ while (rangeLength--) {
+ result[leftIndex++] = args[argsIndex++];
+ }
+ return result;
+ }
+
+ /**
+ * This function is like `composeArgs` except that the arguments composition
+ * is tailored for `_.partialRight`.
+ *
+ * @private
+ * @param {Array} args The provided arguments.
+ * @param {Array} partials The arguments to append to those provided.
+ * @param {Array} holders The `partials` placeholder indexes.
+ * @params {boolean} [isCurried] Specify composing for a curried function.
+ * @returns {Array} Returns the new array of composed arguments.
+ */
+ function composeArgsRight(args, partials, holders, isCurried) {
+ var argsIndex = -1,
+ argsLength = args.length,
+ holdersIndex = -1,
+ holdersLength = holders.length,
+ rightIndex = -1,
+ rightLength = partials.length,
+ rangeLength = nativeMax(argsLength - holdersLength, 0),
+ result = Array(rangeLength + rightLength),
+ isUncurried = !isCurried;
+
+ while (++argsIndex < rangeLength) {
+ result[argsIndex] = args[argsIndex];
+ }
+ var offset = argsIndex;
+ while (++rightIndex < rightLength) {
+ result[offset + rightIndex] = partials[rightIndex];
+ }
+ while (++holdersIndex < holdersLength) {
+ if (isUncurried || argsIndex < argsLength) {
+ result[offset + holders[holdersIndex]] = args[argsIndex++];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+ function copyArray(source, array) {
+ var index = -1,
+ length = source.length;
+
+ array || (array = Array(length));
+ while (++index < length) {
+ array[index] = source[index];
+ }
+ return array;
+ }
+
+ /**
+ * Copies properties of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy properties from.
+ * @param {Array} props The property identifiers to copy.
+ * @param {Object} [object={}] The object to copy properties to.
+ * @param {Function} [customizer] The function to customize copied values.
+ * @returns {Object} Returns `object`.
+ */
+ function copyObject(source, props, object, customizer) {
+ var isNew = !object;
+ object || (object = {});
+
+ var index = -1,
+ length = props.length;
+
+ while (++index < length) {
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = source[key];
+ }
+ if (isNew) {
+ baseAssignValue(object, key, newValue);
+ } else {
+ assignValue(object, key, newValue);
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Copies own symbols of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy symbols from.
+ * @param {Object} [object={}] The object to copy symbols to.
+ * @returns {Object} Returns `object`.
+ */
+ function copySymbols(source, object) {
+ return copyObject(source, getSymbols(source), object);
+ }
+
+ /**
+ * Copies own and inherited symbols of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy symbols from.
+ * @param {Object} [object={}] The object to copy symbols to.
+ * @returns {Object} Returns `object`.
+ */
+ function copySymbolsIn(source, object) {
+ return copyObject(source, getSymbolsIn(source), object);
+ }
+
+ /**
+ * Creates a function like `_.groupBy`.
+ *
+ * @private
+ * @param {Function} setter The function to set accumulator values.
+ * @param {Function} [initializer] The accumulator object initializer.
+ * @returns {Function} Returns the new aggregator function.
+ */
+ function createAggregator(setter, initializer) {
+ return function(collection, iteratee) {
+ var func = isArray(collection) ? arrayAggregator : baseAggregator,
+ accumulator = initializer ? initializer() : {};
+
+ return func(collection, setter, getIteratee(iteratee, 2), accumulator);
+ };
+ }
+
+ /**
+ * Creates a function like `_.assign`.
+ *
+ * @private
+ * @param {Function} assigner The function to assign values.
+ * @returns {Function} Returns the new assigner function.
+ */
+ function createAssigner(assigner) {
+ return baseRest(function(object, sources) {
+ var index = -1,
+ length = sources.length,
+ customizer = length > 1 ? sources[length - 1] : undefined,
+ guard = length > 2 ? sources[2] : undefined;
+
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
+ ? (length--, customizer)
+ : undefined;
+
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
+ customizer = length < 3 ? undefined : customizer;
+ length = 1;
+ }
+ object = Object(object);
+ while (++index < length) {
+ var source = sources[index];
+ if (source) {
+ assigner(object, source, index, customizer);
+ }
+ }
+ return object;
+ });
+ }
+
+ /**
+ * Creates a `baseEach` or `baseEachRight` function.
+ *
+ * @private
+ * @param {Function} eachFunc The function to iterate over a collection.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+ function createBaseEach(eachFunc, fromRight) {
+ return function(collection, iteratee) {
+ if (collection == null) {
+ return collection;
+ }
+ if (!isArrayLike(collection)) {
+ return eachFunc(collection, iteratee);
+ }
+ var length = collection.length,
+ index = fromRight ? length : -1,
+ iterable = Object(collection);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (iteratee(iterable[index], index, iterable) === false) {
+ break;
+ }
+ }
+ return collection;
+ };
+ }
+
+ /**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+ function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke it with the optional `this`
+ * binding of `thisArg`.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createBind(func, bitmask, thisArg) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
+
+ function wrapper() {
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(isBind ? thisArg : this, arguments);
+ }
+ return wrapper;
+ }
+
+ /**
+ * Creates a function like `_.lowerFirst`.
+ *
+ * @private
+ * @param {string} methodName The name of the `String` case method to use.
+ * @returns {Function} Returns the new case function.
+ */
+ function createCaseFirst(methodName) {
+ return function(string) {
+ string = toString(string);
+
+ var strSymbols = hasUnicode(string)
+ ? stringToArray(string)
+ : undefined;
+
+ var chr = strSymbols
+ ? strSymbols[0]
+ : string.charAt(0);
+
+ var trailing = strSymbols
+ ? castSlice(strSymbols, 1).join('')
+ : string.slice(1);
+
+ return chr[methodName]() + trailing;
+ };
+ }
+
+ /**
+ * Creates a function like `_.camelCase`.
+ *
+ * @private
+ * @param {Function} callback The function to combine each word.
+ * @returns {Function} Returns the new compounder function.
+ */
+ function createCompounder(callback) {
+ return function(string) {
+ return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
+ };
+ }
+
+ /**
+ * Creates a function that produces an instance of `Ctor` regardless of
+ * whether it was invoked as part of a `new` expression or by `call` or `apply`.
+ *
+ * @private
+ * @param {Function} Ctor The constructor to wrap.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createCtor(Ctor) {
+ return function() {
+ // Use a `switch` statement to work with class constructors. See
+ // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
+ // for more details.
+ var args = arguments;
+ switch (args.length) {
+ case 0: return new Ctor;
+ case 1: return new Ctor(args[0]);
+ case 2: return new Ctor(args[0], args[1]);
+ case 3: return new Ctor(args[0], args[1], args[2]);
+ case 4: return new Ctor(args[0], args[1], args[2], args[3]);
+ case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
+ case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
+ case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+ }
+ var thisBinding = baseCreate(Ctor.prototype),
+ result = Ctor.apply(thisBinding, args);
+
+ // Mimic the constructor's `return` behavior.
+ // See https://es5.github.io/#x13.2.2 for more details.
+ return isObject(result) ? result : thisBinding;
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` to enable currying.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {number} arity The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createCurry(func, bitmask, arity) {
+ var Ctor = createCtor(func);
+
+ function wrapper() {
+ var length = arguments.length,
+ args = Array(length),
+ index = length,
+ placeholder = getHolder(wrapper);
+
+ while (index--) {
+ args[index] = arguments[index];
+ }
+ var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
+ ? []
+ : replaceHolders(args, placeholder);
+
+ length -= holders.length;
+ if (length < arity) {
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, undefined,
+ args, holders, undefined, undefined, arity - length);
+ }
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return apply(fn, this, args);
+ }
+ return wrapper;
+ }
+
+ /**
+ * Creates a `_.find` or `_.findLast` function.
+ *
+ * @private
+ * @param {Function} findIndexFunc The function to find the collection index.
+ * @returns {Function} Returns the new find function.
+ */
+ function createFind(findIndexFunc) {
+ return function(collection, predicate, fromIndex) {
+ var iterable = Object(collection);
+ if (!isArrayLike(collection)) {
+ var iteratee = getIteratee(predicate, 3);
+ collection = keys(collection);
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
+ }
+ var index = findIndexFunc(collection, predicate, fromIndex);
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
+ };
+ }
+
+ /**
+ * Creates a `_.flow` or `_.flowRight` function.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new flow function.
+ */
+ function createFlow(fromRight) {
+ return flatRest(function(funcs) {
+ var length = funcs.length,
+ index = length,
+ prereq = LodashWrapper.prototype.thru;
+
+ if (fromRight) {
+ funcs.reverse();
+ }
+ while (index--) {
+ var func = funcs[index];
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
+ var wrapper = new LodashWrapper([], true);
+ }
+ }
+ index = wrapper ? index : length;
+ while (++index < length) {
+ func = funcs[index];
+
+ var funcName = getFuncName(func),
+ data = funcName == 'wrapper' ? getData(func) : undefined;
+
+ if (data && isLaziable(data[0]) &&
+ data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
+ !data[4].length && data[9] == 1
+ ) {
+ wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
+ } else {
+ wrapper = (func.length == 1 && isLaziable(func))
+ ? wrapper[funcName]()
+ : wrapper.thru(func);
+ }
+ }
+ return function() {
+ var args = arguments,
+ value = args[0];
+
+ if (wrapper && args.length == 1 &&
+ isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
+ return wrapper.plant(value).value();
+ }
+ var index = 0,
+ result = length ? funcs[index].apply(this, args) : value;
+
+ while (++index < length) {
+ result = funcs[index].call(this, result);
+ }
+ return result;
+ };
+ });
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke it with optional `this`
+ * binding of `thisArg`, partial application, and currying.
+ *
+ * @private
+ * @param {Function|string} func The function or method name to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to prepend to those provided to
+ * the new function.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [partialsRight] The arguments to append to those provided
+ * to the new function.
+ * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
+ var isAry = bitmask & WRAP_ARY_FLAG,
+ isBind = bitmask & WRAP_BIND_FLAG,
+ isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
+ isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
+ isFlip = bitmask & WRAP_FLIP_FLAG,
+ Ctor = isBindKey ? undefined : createCtor(func);
+
+ function wrapper() {
+ var length = arguments.length,
+ args = Array(length),
+ index = length;
+
+ while (index--) {
+ args[index] = arguments[index];
+ }
+ if (isCurried) {
+ var placeholder = getHolder(wrapper),
+ holdersCount = countHolders(args, placeholder);
+ }
+ if (partials) {
+ args = composeArgs(args, partials, holders, isCurried);
+ }
+ if (partialsRight) {
+ args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
+ }
+ length -= holdersCount;
+ if (isCurried && length < arity) {
+ var newHolders = replaceHolders(args, placeholder);
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, thisArg,
+ args, newHolders, argPos, ary, arity - length
+ );
+ }
+ var thisBinding = isBind ? thisArg : this,
+ fn = isBindKey ? thisBinding[func] : func;
+
+ length = args.length;
+ if (argPos) {
+ args = reorder(args, argPos);
+ } else if (isFlip && length > 1) {
+ args.reverse();
+ }
+ if (isAry && ary < length) {
+ args.length = ary;
+ }
+ if (this && this !== root && this instanceof wrapper) {
+ fn = Ctor || createCtor(fn);
+ }
+ return fn.apply(thisBinding, args);
+ }
+ return wrapper;
+ }
+
+ /**
+ * Creates a function like `_.invertBy`.
+ *
+ * @private
+ * @param {Function} setter The function to set accumulator values.
+ * @param {Function} toIteratee The function to resolve iteratees.
+ * @returns {Function} Returns the new inverter function.
+ */
+ function createInverter(setter, toIteratee) {
+ return function(object, iteratee) {
+ return baseInverter(object, setter, toIteratee(iteratee), {});
+ };
+ }
+
+ /**
+ * Creates a function that performs a mathematical operation on two values.
+ *
+ * @private
+ * @param {Function} operator The function to perform the operation.
+ * @param {number} [defaultValue] The value used for `undefined` arguments.
+ * @returns {Function} Returns the new mathematical operation function.
+ */
+ function createMathOperation(operator, defaultValue) {
+ return function(value, other) {
+ var result;
+ if (value === undefined && other === undefined) {
+ return defaultValue;
+ }
+ if (value !== undefined) {
+ result = value;
+ }
+ if (other !== undefined) {
+ if (result === undefined) {
+ return other;
+ }
+ if (typeof value == 'string' || typeof other == 'string') {
+ value = baseToString(value);
+ other = baseToString(other);
+ } else {
+ value = baseToNumber(value);
+ other = baseToNumber(other);
+ }
+ result = operator(value, other);
+ }
+ return result;
+ };
+ }
+
+ /**
+ * Creates a function like `_.over`.
+ *
+ * @private
+ * @param {Function} arrayFunc The function to iterate over iteratees.
+ * @returns {Function} Returns the new over function.
+ */
+ function createOver(arrayFunc) {
+ return flatRest(function(iteratees) {
+ iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
+ return baseRest(function(args) {
+ var thisArg = this;
+ return arrayFunc(iteratees, function(iteratee) {
+ return apply(iteratee, thisArg, args);
+ });
+ });
+ });
+ }
+
+ /**
+ * Creates the padding for `string` based on `length`. The `chars` string
+ * is truncated if the number of characters exceeds `length`.
+ *
+ * @private
+ * @param {number} length The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padding for `string`.
+ */
+ function createPadding(length, chars) {
+ chars = chars === undefined ? ' ' : baseToString(chars);
+
+ var charsLength = chars.length;
+ if (charsLength < 2) {
+ return charsLength ? baseRepeat(chars, length) : chars;
+ }
+ var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
+ return hasUnicode(chars)
+ ? castSlice(stringToArray(result), 0, length).join('')
+ : result.slice(0, length);
+ }
+
+ /**
+ * Creates a function that wraps `func` to invoke it with the `this` binding
+ * of `thisArg` and `partials` prepended to the arguments it receives.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} partials The arguments to prepend to those provided to
+ * the new function.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createPartial(func, bitmask, thisArg, partials) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
+
+ function wrapper() {
+ var argsIndex = -1,
+ argsLength = arguments.length,
+ leftIndex = -1,
+ leftLength = partials.length,
+ args = Array(leftLength + argsLength),
+ fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+
+ while (++leftIndex < leftLength) {
+ args[leftIndex] = partials[leftIndex];
+ }
+ while (argsLength--) {
+ args[leftIndex++] = arguments[++argsIndex];
+ }
+ return apply(fn, isBind ? thisArg : this, args);
+ }
+ return wrapper;
+ }
+
+ /**
+ * Creates a `_.range` or `_.rangeRight` function.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new range function.
+ */
+ function createRange(fromRight) {
+ return function(start, end, step) {
+ if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
+ end = step = undefined;
+ }
+ // Ensure the sign of `-0` is preserved.
+ start = toFinite(start);
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ } else {
+ end = toFinite(end);
+ }
+ step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
+ return baseRange(start, end, step, fromRight);
+ };
+ }
+
+ /**
+ * Creates a function that performs a relational operation on two values.
+ *
+ * @private
+ * @param {Function} operator The function to perform the operation.
+ * @returns {Function} Returns the new relational operation function.
+ */
+ function createRelationalOperation(operator) {
+ return function(value, other) {
+ if (!(typeof value == 'string' && typeof other == 'string')) {
+ value = toNumber(value);
+ other = toNumber(other);
+ }
+ return operator(value, other);
+ };
+ }
+
+ /**
+ * Creates a function that wraps `func` to continue currying.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @param {Function} wrapFunc The function to create the `func` wrapper.
+ * @param {*} placeholder The placeholder value.
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to prepend to those provided to
+ * the new function.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
+ var isCurry = bitmask & WRAP_CURRY_FLAG,
+ newHolders = isCurry ? holders : undefined,
+ newHoldersRight = isCurry ? undefined : holders,
+ newPartials = isCurry ? partials : undefined,
+ newPartialsRight = isCurry ? undefined : partials;
+
+ bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
+ bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
+
+ if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
+ bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
+ }
+ var newData = [
+ func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
+ newHoldersRight, argPos, ary, arity
+ ];
+
+ var result = wrapFunc.apply(undefined, newData);
+ if (isLaziable(func)) {
+ setData(result, newData);
+ }
+ result.placeholder = placeholder;
+ return setWrapToString(result, func, bitmask);
+ }
+
+ /**
+ * Creates a function like `_.round`.
+ *
+ * @private
+ * @param {string} methodName The name of the `Math` method to use when rounding.
+ * @returns {Function} Returns the new round function.
+ */
+ function createRound(methodName) {
+ var func = Math[methodName];
+ return function(number, precision) {
+ number = toNumber(number);
+ precision = nativeMin(toInteger(precision), 292);
+ if (precision) {
+ // Shift with exponential notation to avoid floating-point issues.
+ // See [MDN](https://mdn.io/round#Examples) for more details.
+ var pair = (toString(number) + 'e').split('e'),
+ value = func(pair[0] + 'e' + (+pair[1] + precision));
+
+ pair = (toString(value) + 'e').split('e');
+ return +(pair[0] + 'e' + (+pair[1] - precision));
+ }
+ return func(number);
+ };
+ }
+
+ /**
+ * Creates a set object of `values`.
+ *
+ * @private
+ * @param {Array} values The values to add to the set.
+ * @returns {Object} Returns the new set.
+ */
+ var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
+ return new Set(values);
+ };
+
+ /**
+ * Creates a `_.toPairs` or `_.toPairsIn` function.
+ *
+ * @private
+ * @param {Function} keysFunc The function to get the keys of a given object.
+ * @returns {Function} Returns the new pairs function.
+ */
+ function createToPairs(keysFunc) {
+ return function(object) {
+ var tag = getTag(object);
+ if (tag == mapTag) {
+ return mapToArray(object);
+ }
+ if (tag == setTag) {
+ return setToPairs(object);
+ }
+ return baseToPairs(object, keysFunc(object));
+ };
+ }
+
+ /**
+ * Creates a function that either curries or invokes `func` with optional
+ * `this` binding and partially applied arguments.
+ *
+ * @private
+ * @param {Function|string} func The function or method name to wrap.
+ * @param {number} bitmask The bitmask flags.
+ * 1 - `_.bind`
+ * 2 - `_.bindKey`
+ * 4 - `_.curry` or `_.curryRight` of a bound function
+ * 8 - `_.curry`
+ * 16 - `_.curryRight`
+ * 32 - `_.partial`
+ * 64 - `_.partialRight`
+ * 128 - `_.rearg`
+ * 256 - `_.ary`
+ * 512 - `_.flip`
+ * @param {*} [thisArg] The `this` binding of `func`.
+ * @param {Array} [partials] The arguments to be partially applied.
+ * @param {Array} [holders] The `partials` placeholder indexes.
+ * @param {Array} [argPos] The argument positions of the new function.
+ * @param {number} [ary] The arity cap of `func`.
+ * @param {number} [arity] The arity of `func`.
+ * @returns {Function} Returns the new wrapped function.
+ */
+ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
+ var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
+ if (!isBindKey && typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var length = partials ? partials.length : 0;
+ if (!length) {
+ bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
+ partials = holders = undefined;
+ }
+ ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
+ arity = arity === undefined ? arity : toInteger(arity);
+ length -= holders ? holders.length : 0;
+
+ if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
+ var partialsRight = partials,
+ holdersRight = holders;
+
+ partials = holders = undefined;
+ }
+ var data = isBindKey ? undefined : getData(func);
+
+ var newData = [
+ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
+ argPos, ary, arity
+ ];
+
+ if (data) {
+ mergeData(newData, data);
+ }
+ func = newData[0];
+ bitmask = newData[1];
+ thisArg = newData[2];
+ partials = newData[3];
+ holders = newData[4];
+ arity = newData[9] = newData[9] == null
+ ? (isBindKey ? 0 : func.length)
+ : nativeMax(newData[9] - length, 0);
+
+ if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
+ bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
+ }
+ if (!bitmask || bitmask == WRAP_BIND_FLAG) {
+ var result = createBind(func, bitmask, thisArg);
+ } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
+ result = createCurry(func, bitmask, arity);
+ } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
+ result = createPartial(func, bitmask, thisArg, partials);
+ } else {
+ result = createHybrid.apply(undefined, newData);
+ }
+ var setter = data ? baseSetData : setData;
+ return setWrapToString(setter(result, newData), func, bitmask);
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Array} array The array to compare.
+ * @param {Array} other The other array to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
+ */
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ arrLength = array.length,
+ othLength = other.length;
+
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(array);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var index = -1,
+ result = true,
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
+
+ stack.set(array, other);
+ stack.set(other, array);
+
+ // Ignore non-index properties.
+ while (++index < arrLength) {
+ var arrValue = array[index],
+ othValue = other[index];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, arrValue, index, other, array, stack)
+ : customizer(arrValue, othValue, index, array, other, stack);
+ }
+ if (compared !== undefined) {
+ if (compared) {
+ continue;
+ }
+ result = false;
+ break;
+ }
+ // Recursively compare arrays (susceptible to call stack limits).
+ if (seen) {
+ if (!arraySome(other, function(othValue, othIndex) {
+ if (!cacheHas(seen, othIndex) &&
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
+ return seen.push(othIndex);
+ }
+ })) {
+ result = false;
+ break;
+ }
+ } else if (!(
+ arrValue === othValue ||
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
+ )) {
+ result = false;
+ break;
+ }
+ }
+ stack['delete'](array);
+ stack['delete'](other);
+ return result;
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
+ * the same `toStringTag`.
+ *
+ * **Note:** This function only supports comparing values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {string} tag The `toStringTag` of the objects to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
+ switch (tag) {
+ case dataViewTag:
+ if ((object.byteLength != other.byteLength) ||
+ (object.byteOffset != other.byteOffset)) {
+ return false;
+ }
+ object = object.buffer;
+ other = other.buffer;
+
+ case arrayBufferTag:
+ if ((object.byteLength != other.byteLength) ||
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
+ return false;
+ }
+ return true;
+
+ case boolTag:
+ case dateTag:
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
+
+ case errorTag:
+ return object.name == other.name && object.message == other.message;
+
+ case regexpTag:
+ case stringTag:
+ // Coerce regexes to strings and treat strings, primitives and objects,
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
+ // for more details.
+ return object == (other + '');
+
+ case mapTag:
+ var convert = mapToArray;
+
+ case setTag:
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
+ convert || (convert = setToArray);
+
+ if (object.size != other.size && !isPartial) {
+ return false;
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked) {
+ return stacked == other;
+ }
+ bitmask |= COMPARE_UNORDERED_FLAG;
+
+ // Recursively compare objects (susceptible to call stack limits).
+ stack.set(object, other);
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
+ stack['delete'](object);
+ return result;
+
+ case symbolTag:
+ if (symbolValueOf) {
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * A specialized version of `baseIsEqualDeep` for objects with support for
+ * partial deep comparisons.
+ *
+ * @private
+ * @param {Object} object The object to compare.
+ * @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
+ * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
+ */
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ objProps = keys(object),
+ objLength = objProps.length,
+ othProps = keys(other),
+ othLength = othProps.length;
+
+ if (objLength != othLength && !isPartial) {
+ return false;
+ }
+ var index = objLength;
+ while (index--) {
+ var key = objProps[index];
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
+ return false;
+ }
+ }
+ // Assume cyclic values are equal.
+ var stacked = stack.get(object);
+ if (stacked && stack.get(other)) {
+ return stacked == other;
+ }
+ var result = true;
+ stack.set(object, other);
+ stack.set(other, object);
+
+ var skipCtor = isPartial;
+ while (++index < objLength) {
+ key = objProps[index];
+ var objValue = object[key],
+ othValue = other[key];
+
+ if (customizer) {
+ var compared = isPartial
+ ? customizer(othValue, objValue, key, other, object, stack)
+ : customizer(objValue, othValue, key, object, other, stack);
+ }
+ // Recursively compare objects (susceptible to call stack limits).
+ if (!(compared === undefined
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
+ : compared
+ )) {
+ result = false;
+ break;
+ }
+ skipCtor || (skipCtor = key == 'constructor');
+ }
+ if (result && !skipCtor) {
+ var objCtor = object.constructor,
+ othCtor = other.constructor;
+
+ // Non `Object` object instances with different constructors are not equal.
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ result = false;
+ }
+ }
+ stack['delete'](object);
+ stack['delete'](other);
+ return result;
+ }
+
+ /**
+ * A specialized version of `baseRest` which flattens the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+ function flatRest(func) {
+ return setToString(overRest(func, undefined, flatten), func + '');
+ }
+
+ /**
+ * Creates an array of own enumerable property names and symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+ function getAllKeys(object) {
+ return baseGetAllKeys(object, keys, getSymbols);
+ }
+
+ /**
+ * Creates an array of own and inherited enumerable property names and
+ * symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names and symbols.
+ */
+ function getAllKeysIn(object) {
+ return baseGetAllKeys(object, keysIn, getSymbolsIn);
+ }
+
+ /**
+ * Gets metadata for `func`.
+ *
+ * @private
+ * @param {Function} func The function to query.
+ * @returns {*} Returns the metadata for `func`.
+ */
+ var getData = !metaMap ? noop : function(func) {
+ return metaMap.get(func);
+ };
+
+ /**
+ * Gets the name of `func`.
+ *
+ * @private
+ * @param {Function} func The function to query.
+ * @returns {string} Returns the function name.
+ */
+ function getFuncName(func) {
+ var result = (func.name + ''),
+ array = realNames[result],
+ length = hasOwnProperty.call(realNames, result) ? array.length : 0;
+
+ while (length--) {
+ var data = array[length],
+ otherFunc = data.func;
+ if (otherFunc == null || otherFunc == func) {
+ return data.name;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Gets the argument placeholder value for `func`.
+ *
+ * @private
+ * @param {Function} func The function to inspect.
+ * @returns {*} Returns the placeholder value.
+ */
+ function getHolder(func) {
+ var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
+ return object.placeholder;
+ }
+
+ /**
+ * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
+ * this function returns the custom method, otherwise it returns `baseIteratee`.
+ * If arguments are provided, the chosen function is invoked with them and
+ * its result is returned.
+ *
+ * @private
+ * @param {*} [value] The value to convert to an iteratee.
+ * @param {number} [arity] The arity of the created iteratee.
+ * @returns {Function} Returns the chosen function or its result.
+ */
+ function getIteratee() {
+ var result = lodash.iteratee || iteratee;
+ result = result === iteratee ? baseIteratee : result;
+ return arguments.length ? result(arguments[0], arguments[1]) : result;
+ }
+
+ /**
+ * Gets the data for `map`.
+ *
+ * @private
+ * @param {Object} map The map to query.
+ * @param {string} key The reference key.
+ * @returns {*} Returns the map data.
+ */
+ function getMapData(map, key) {
+ var data = map.__data__;
+ return isKeyable(key)
+ ? data[typeof key == 'string' ? 'string' : 'hash']
+ : data.map;
+ }
+
+ /**
+ * Gets the property names, values, and compare flags of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the match data of `object`.
+ */
+ function getMatchData(object) {
+ var result = keys(object),
+ length = result.length;
+
+ while (length--) {
+ var key = result[length],
+ value = object[key];
+
+ result[length] = [key, value, isStrictComparable(value)];
+ }
+ return result;
+ }
+
+ /**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+ function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+ }
+
+ /**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+ function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Creates an array of the own enumerable symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of symbols.
+ */
+ var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
+
+ /**
+ * Creates an array of the own and inherited enumerable symbols of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of symbols.
+ */
+ var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
+ var result = [];
+ while (object) {
+ arrayPush(result, getSymbols(object));
+ object = getPrototype(object);
+ }
+ return result;
+ };
+
+ /**
+ * Gets the `toStringTag` of `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ var getTag = baseGetTag;
+
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
+ (Map && getTag(new Map) != mapTag) ||
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
+ (Set && getTag(new Set) != setTag) ||
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
+ getTag = function(value) {
+ var result = baseGetTag(value),
+ Ctor = result == objectTag ? value.constructor : undefined,
+ ctorString = Ctor ? toSource(Ctor) : '';
+
+ if (ctorString) {
+ switch (ctorString) {
+ case dataViewCtorString: return dataViewTag;
+ case mapCtorString: return mapTag;
+ case promiseCtorString: return promiseTag;
+ case setCtorString: return setTag;
+ case weakMapCtorString: return weakMapTag;
+ }
+ }
+ return result;
+ };
+ }
+
+ /**
+ * Gets the view, applying any `transforms` to the `start` and `end` positions.
+ *
+ * @private
+ * @param {number} start The start of the view.
+ * @param {number} end The end of the view.
+ * @param {Array} transforms The transformations to apply to the view.
+ * @returns {Object} Returns an object containing the `start` and `end`
+ * positions of the view.
+ */
+ function getView(start, end, transforms) {
+ var index = -1,
+ length = transforms.length;
+
+ while (++index < length) {
+ var data = transforms[index],
+ size = data.size;
+
+ switch (data.type) {
+ case 'drop': start += size; break;
+ case 'dropRight': end -= size; break;
+ case 'take': end = nativeMin(end, start + size); break;
+ case 'takeRight': start = nativeMax(start, end - size); break;
+ }
+ }
+ return { 'start': start, 'end': end };
+ }
+
+ /**
+ * Extracts wrapper details from the `source` body comment.
+ *
+ * @private
+ * @param {string} source The source to inspect.
+ * @returns {Array} Returns the wrapper details.
+ */
+ function getWrapDetails(source) {
+ var match = source.match(reWrapDetails);
+ return match ? match[1].split(reSplitDetails) : [];
+ }
+
+ /**
+ * Checks if `path` exists on `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @param {Function} hasFunc The function to check properties.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ */
+ function hasPath(object, path, hasFunc) {
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length,
+ result = false;
+
+ while (++index < length) {
+ var key = toKey(path[index]);
+ if (!(result = object != null && hasFunc(object, key))) {
+ break;
+ }
+ object = object[key];
+ }
+ if (result || ++index != length) {
+ return result;
+ }
+ length = object == null ? 0 : object.length;
+ return !!length && isLength(length) && isIndex(key, length) &&
+ (isArray(object) || isArguments(object));
+ }
+
+ /**
+ * Initializes an array clone.
+ *
+ * @private
+ * @param {Array} array The array to clone.
+ * @returns {Array} Returns the initialized clone.
+ */
+ function initCloneArray(array) {
+ var length = array.length,
+ result = array.constructor(length);
+
+ // Add properties assigned by `RegExp#exec`.
+ if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
+ result.index = array.index;
+ result.input = array.input;
+ }
+ return result;
+ }
+
+ /**
+ * Initializes an object clone.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @returns {Object} Returns the initialized clone.
+ */
+ function initCloneObject(object) {
+ return (typeof object.constructor == 'function' && !isPrototype(object))
+ ? baseCreate(getPrototype(object))
+ : {};
+ }
+
+ /**
+ * Initializes an object clone based on its `toStringTag`.
+ *
+ * **Note:** This function only supports cloning values with tags of
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @param {string} tag The `toStringTag` of the object to clone.
+ * @param {Function} cloneFunc The function to clone values.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the initialized clone.
+ */
+ function initCloneByTag(object, tag, cloneFunc, isDeep) {
+ var Ctor = object.constructor;
+ switch (tag) {
+ case arrayBufferTag:
+ return cloneArrayBuffer(object);
+
+ case boolTag:
+ case dateTag:
+ return new Ctor(+object);
+
+ case dataViewTag:
+ return cloneDataView(object, isDeep);
+
+ case float32Tag: case float64Tag:
+ case int8Tag: case int16Tag: case int32Tag:
+ case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
+ return cloneTypedArray(object, isDeep);
+
+ case mapTag:
+ return cloneMap(object, isDeep, cloneFunc);
+
+ case numberTag:
+ case stringTag:
+ return new Ctor(object);
+
+ case regexpTag:
+ return cloneRegExp(object);
+
+ case setTag:
+ return cloneSet(object, isDeep, cloneFunc);
+
+ case symbolTag:
+ return cloneSymbol(object);
+ }
+ }
+
+ /**
+ * Inserts wrapper `details` in a comment at the top of the `source` body.
+ *
+ * @private
+ * @param {string} source The source to modify.
+ * @returns {Array} details The details to insert.
+ * @returns {string} Returns the modified source.
+ */
+ function insertWrapDetails(source, details) {
+ var length = details.length;
+ if (!length) {
+ return source;
+ }
+ var lastIndex = length - 1;
+ details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
+ details = details.join(length > 2 ? ', ' : ' ');
+ return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
+ }
+
+ /**
+ * Checks if `value` is a flattenable `arguments` object or array.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
+ */
+ function isFlattenable(value) {
+ return isArray(value) || isArguments(value) ||
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
+ }
+
+ /**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+ function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+ }
+
+ /**
+ * Checks if the given arguments are from an iteratee call.
+ *
+ * @private
+ * @param {*} value The potential iteratee value argument.
+ * @param {*} index The potential iteratee index or key argument.
+ * @param {*} object The potential iteratee object argument.
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
+ * else `false`.
+ */
+ function isIterateeCall(value, index, object) {
+ if (!isObject(object)) {
+ return false;
+ }
+ var type = typeof index;
+ if (type == 'number'
+ ? (isArrayLike(object) && isIndex(index, object.length))
+ : (type == 'string' && index in object)
+ ) {
+ return eq(object[index], value);
+ }
+ return false;
+ }
+
+ /**
+ * Checks if `value` is a property name and not a property path.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {Object} [object] The object to query keys on.
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
+ */
+ function isKey(value, object) {
+ if (isArray(value)) {
+ return false;
+ }
+ var type = typeof value;
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
+ value == null || isSymbol(value)) {
+ return true;
+ }
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
+ (object != null && value in Object(object));
+ }
+
+ /**
+ * Checks if `value` is suitable for use as unique object key.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
+ */
+ function isKeyable(value) {
+ var type = typeof value;
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
+ ? (value !== '__proto__')
+ : (value === null);
+ }
+
+ /**
+ * Checks if `func` has a lazy counterpart.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
+ * else `false`.
+ */
+ function isLaziable(func) {
+ var funcName = getFuncName(func),
+ other = lodash[funcName];
+
+ if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
+ return false;
+ }
+ if (func === other) {
+ return true;
+ }
+ var data = getData(other);
+ return !!data && func === data[0];
+ }
+
+ /**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+ function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+ }
+
+ /**
+ * Checks if `func` is capable of being masked.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
+ */
+ var isMaskable = coreJsData ? isFunction : stubFalse;
+
+ /**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+ function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
+
+ return value === proto;
+ }
+
+ /**
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
+ * equality comparisons, else `false`.
+ */
+ function isStrictComparable(value) {
+ return value === value && !isObject(value);
+ }
+
+ /**
+ * A specialized version of `matchesProperty` for source values suitable
+ * for strict equality comparisons, i.e. `===`.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ */
+ function matchesStrictComparable(key, srcValue) {
+ return function(object) {
+ if (object == null) {
+ return false;
+ }
+ return object[key] === srcValue &&
+ (srcValue !== undefined || (key in Object(object)));
+ };
+ }
+
+ /**
+ * A specialized version of `_.memoize` which clears the memoized function's
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
+ *
+ * @private
+ * @param {Function} func The function to have its output memoized.
+ * @returns {Function} Returns the new memoized function.
+ */
+ function memoizeCapped(func) {
+ var result = memoize(func, function(key) {
+ if (cache.size === MAX_MEMOIZE_SIZE) {
+ cache.clear();
+ }
+ return key;
+ });
+
+ var cache = result.cache;
+ return result;
+ }
+
+ /**
+ * Merges the function metadata of `source` into `data`.
+ *
+ * Merging metadata reduces the number of wrappers used to invoke a function.
+ * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
+ * may be applied regardless of execution order. Methods like `_.ary` and
+ * `_.rearg` modify function arguments, making the order in which they are
+ * executed important, preventing the merging of metadata. However, we make
+ * an exception for a safe combined case where curried functions have `_.ary`
+ * and or `_.rearg` applied.
+ *
+ * @private
+ * @param {Array} data The destination metadata.
+ * @param {Array} source The source metadata.
+ * @returns {Array} Returns `data`.
+ */
+ function mergeData(data, source) {
+ var bitmask = data[1],
+ srcBitmask = source[1],
+ newBitmask = bitmask | srcBitmask,
+ isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
+
+ var isCombo =
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
+ ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
+
+ // Exit early if metadata can't be merged.
+ if (!(isCommon || isCombo)) {
+ return data;
+ }
+ // Use source `thisArg` if available.
+ if (srcBitmask & WRAP_BIND_FLAG) {
+ data[2] = source[2];
+ // Set when currying a bound function.
+ newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
+ }
+ // Compose partial arguments.
+ var value = source[3];
+ if (value) {
+ var partials = data[3];
+ data[3] = partials ? composeArgs(partials, value, source[4]) : value;
+ data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
+ }
+ // Compose partial right arguments.
+ value = source[5];
+ if (value) {
+ partials = data[5];
+ data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
+ data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
+ }
+ // Use source `argPos` if available.
+ value = source[7];
+ if (value) {
+ data[7] = value;
+ }
+ // Use source `ary` if it's smaller.
+ if (srcBitmask & WRAP_ARY_FLAG) {
+ data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
+ }
+ // Use source `arity` if one is not provided.
+ if (data[9] == null) {
+ data[9] = source[9];
+ }
+ // Use source `func` and merge bitmasks.
+ data[0] = source[0];
+ data[1] = newBitmask;
+
+ return data;
+ }
+
+ /**
+ * Used by `_.defaultsDeep` to customize its `_.merge` use.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to merge.
+ * @param {Object} object The parent object of `objValue`.
+ * @param {Object} source The parent object of `srcValue`.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ * @returns {*} Returns the value to assign.
+ */
+ function mergeDefaults(objValue, srcValue, key, object, source, stack) {
+ if (isObject(objValue) && isObject(srcValue)) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, objValue);
+ baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
+ stack['delete'](srcValue);
+ }
+ return objValue;
+ }
+
+ /**
+ * This function is like
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * except that it includes inherited enumerable properties.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function nativeKeysIn(object) {
+ var result = [];
+ if (object != null) {
+ for (var key in Object(object)) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+ function objectToString(value) {
+ return nativeObjectToString.call(value);
+ }
+
+ /**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
+ }
+
+ /**
+ * Gets the parent value at `path` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} path The path to get the parent value of.
+ * @returns {*} Returns the parent value.
+ */
+ function parent(object, path) {
+ return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
+ }
+
+ /**
+ * Reorder `array` according to the specified indexes where the element at
+ * the first index is assigned as the first element, the element at
+ * the second index is assigned as the second element, and so on.
+ *
+ * @private
+ * @param {Array} array The array to reorder.
+ * @param {Array} indexes The arranged array indexes.
+ * @returns {Array} Returns `array`.
+ */
+ function reorder(array, indexes) {
+ var arrLength = array.length,
+ length = nativeMin(indexes.length, arrLength),
+ oldArray = copyArray(array);
+
+ while (length--) {
+ var index = indexes[length];
+ array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
+ }
+ return array;
+ }
+
+ /**
+ * Sets metadata for `func`.
+ *
+ * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
+ * period of time, it will trip its breaker and transition to an identity
+ * function to avoid garbage collection pauses in V8. See
+ * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
+ * for more details.
+ *
+ * @private
+ * @param {Function} func The function to associate metadata with.
+ * @param {*} data The metadata.
+ * @returns {Function} Returns `func`.
+ */
+ var setData = shortOut(baseSetData);
+
+ /**
+ * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
+ *
+ * @private
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @returns {number|Object} Returns the timer id or timeout object.
+ */
+ var setTimeout = ctxSetTimeout || function(func, wait) {
+ return root.setTimeout(func, wait);
+ };
+
+ /**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var setToString = shortOut(baseSetToString);
+
+ /**
+ * Sets the `toString` method of `wrapper` to mimic the source of `reference`
+ * with wrapper details in a comment at the top of the source body.
+ *
+ * @private
+ * @param {Function} wrapper The function to modify.
+ * @param {Function} reference The reference function.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Function} Returns `wrapper`.
+ */
+ function setWrapToString(wrapper, reference, bitmask) {
+ var source = (reference + '');
+ return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
+ }
+
+ /**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+ function shortOut(func) {
+ var count = 0,
+ lastCalled = 0;
+
+ return function() {
+ var stamp = nativeNow(),
+ remaining = HOT_SPAN - (stamp - lastCalled);
+
+ lastCalled = stamp;
+ if (remaining > 0) {
+ if (++count >= HOT_COUNT) {
+ return arguments[0];
+ }
+ } else {
+ count = 0;
+ }
+ return func.apply(undefined, arguments);
+ };
+ }
+
+ /**
+ * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @param {number} [size=array.length] The size of `array`.
+ * @returns {Array} Returns `array`.
+ */
+ function shuffleSelf(array, size) {
+ var index = -1,
+ length = array.length,
+ lastIndex = length - 1;
+
+ size = size === undefined ? length : size;
+ while (++index < size) {
+ var rand = baseRandom(index, lastIndex),
+ value = array[rand];
+
+ array[rand] = array[index];
+ array[index] = value;
+ }
+ array.length = size;
+ return array;
+ }
+
+ /**
+ * Converts `string` to a property path array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the property path array.
+ */
+ var stringToPath = memoizeCapped(function(string) {
+ var result = [];
+ if (reLeadingDot.test(string)) {
+ result.push('');
+ }
+ string.replace(rePropName, function(match, number, quote, string) {
+ result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
+ });
+ return result;
+ });
+
+ /**
+ * Converts `value` to a string key if it's not a string or symbol.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {string|symbol} Returns the key.
+ */
+ function toKey(value) {
+ if (typeof value == 'string' || isSymbol(value)) {
+ return value;
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+ }
+
+ /**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to convert.
+ * @returns {string} Returns the source code.
+ */
+ function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
+ }
+ return '';
+ }
+
+ /**
+ * Updates wrapper `details` based on `bitmask` flags.
+ *
+ * @private
+ * @returns {Array} details The details to modify.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Array} Returns `details`.
+ */
+ function updateWrapDetails(details, bitmask) {
+ arrayEach(wrapFlags, function(pair) {
+ var value = '_.' + pair[0];
+ if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
+ details.push(value);
+ }
+ });
+ return details.sort();
+ }
+
+ /**
+ * Creates a clone of `wrapper`.
+ *
+ * @private
+ * @param {Object} wrapper The wrapper to clone.
+ * @returns {Object} Returns the cloned wrapper.
+ */
+ function wrapperClone(wrapper) {
+ if (wrapper instanceof LazyWrapper) {
+ return wrapper.clone();
+ }
+ var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
+ result.__actions__ = copyArray(wrapper.__actions__);
+ result.__index__ = wrapper.__index__;
+ result.__values__ = wrapper.__values__;
+ return result;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an array of elements split into groups the length of `size`.
+ * If `array` can't be split evenly, the final chunk will be the remaining
+ * elements.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to process.
+ * @param {number} [size=1] The length of each chunk
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the new array of chunks.
+ * @example
+ *
+ * _.chunk(['a', 'b', 'c', 'd'], 2);
+ * // => [['a', 'b'], ['c', 'd']]
+ *
+ * _.chunk(['a', 'b', 'c', 'd'], 3);
+ * // => [['a', 'b', 'c'], ['d']]
+ */
+ function chunk(array, size, guard) {
+ if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
+ size = 1;
+ } else {
+ size = nativeMax(toInteger(size), 0);
+ }
+ var length = array == null ? 0 : array.length;
+ if (!length || size < 1) {
+ return [];
+ }
+ var index = 0,
+ resIndex = 0,
+ result = Array(nativeCeil(length / size));
+
+ while (index < length) {
+ result[resIndex++] = baseSlice(array, index, (index += size));
+ }
+ return result;
+ }
+
+ /**
+ * Creates an array with all falsey values removed. The values `false`, `null`,
+ * `0`, `""`, `undefined`, and `NaN` are falsey.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to compact.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.compact([0, 1, false, 2, '', 3]);
+ * // => [1, 2, 3]
+ */
+ function compact(array) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ resIndex = 0,
+ result = [];
+
+ while (++index < length) {
+ var value = array[index];
+ if (value) {
+ result[resIndex++] = value;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Creates a new array concatenating `array` with any additional arrays
+ * and/or values.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to concatenate.
+ * @param {...*} [values] The values to concatenate.
+ * @returns {Array} Returns the new concatenated array.
+ * @example
+ *
+ * var array = [1];
+ * var other = _.concat(array, 2, [3], [[4]]);
+ *
+ * console.log(other);
+ * // => [1, 2, 3, [4]]
+ *
+ * console.log(array);
+ * // => [1]
+ */
+ function concat() {
+ var length = arguments.length;
+ if (!length) {
+ return [];
+ }
+ var args = Array(length - 1),
+ array = arguments[0],
+ index = length;
+
+ while (index--) {
+ args[index - 1] = arguments[index];
+ }
+ return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
+ }
+
+ /**
+ * Creates an array of `array` values not included in the other given arrays
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
+ *
+ * **Note:** Unlike `_.pullAll`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.without, _.xor
+ * @example
+ *
+ * _.difference([2, 1], [2, 3]);
+ * // => [1]
+ */
+ var difference = baseRest(function(array, values) {
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
+ : [];
+ });
+
+ /**
+ * This method is like `_.difference` except that it accepts `iteratee` which
+ * is invoked for each element of `array` and `values` to generate the criterion
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
+ * // => [{ 'x': 2 }]
+ */
+ var differenceBy = baseRest(function(array, values) {
+ var iteratee = last(values);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
+ : [];
+ });
+
+ /**
+ * This method is like `_.difference` except that it accepts `comparator`
+ * which is invoked to compare elements of `array` to `values`. The order and
+ * references of result values are determined by the first array. The comparator
+ * is invoked with two arguments: (arrVal, othVal).
+ *
+ * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...Array} [values] The values to exclude.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ *
+ * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
+ * // => [{ 'x': 2, 'y': 1 }]
+ */
+ var differenceWith = baseRest(function(array, values) {
+ var comparator = last(values);
+ if (isArrayLikeObject(comparator)) {
+ comparator = undefined;
+ }
+ return isArrayLikeObject(array)
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
+ : [];
+ });
+
+ /**
+ * Creates a slice of `array` with `n` elements dropped from the beginning.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to drop.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.drop([1, 2, 3]);
+ * // => [2, 3]
+ *
+ * _.drop([1, 2, 3], 2);
+ * // => [3]
+ *
+ * _.drop([1, 2, 3], 5);
+ * // => []
+ *
+ * _.drop([1, 2, 3], 0);
+ * // => [1, 2, 3]
+ */
+ function drop(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ return baseSlice(array, n < 0 ? 0 : n, length);
+ }
+
+ /**
+ * Creates a slice of `array` with `n` elements dropped from the end.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to drop.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.dropRight([1, 2, 3]);
+ * // => [1, 2]
+ *
+ * _.dropRight([1, 2, 3], 2);
+ * // => [1]
+ *
+ * _.dropRight([1, 2, 3], 5);
+ * // => []
+ *
+ * _.dropRight([1, 2, 3], 0);
+ * // => [1, 2, 3]
+ */
+ function dropRight(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ n = length - n;
+ return baseSlice(array, 0, n < 0 ? 0 : n);
+ }
+
+ /**
+ * Creates a slice of `array` excluding elements dropped from the end.
+ * Elements are dropped until `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.dropRightWhile(users, function(o) { return !o.active; });
+ * // => objects for ['barney']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.dropRightWhile(users, ['active', false]);
+ * // => objects for ['barney']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.dropRightWhile(users, 'active');
+ * // => objects for ['barney', 'fred', 'pebbles']
+ */
+ function dropRightWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, getIteratee(predicate, 3), true, true)
+ : [];
+ }
+
+ /**
+ * Creates a slice of `array` excluding elements dropped from the beginning.
+ * Elements are dropped until `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.dropWhile(users, function(o) { return !o.active; });
+ * // => objects for ['pebbles']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.dropWhile(users, { 'user': 'barney', 'active': false });
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.dropWhile(users, ['active', false]);
+ * // => objects for ['pebbles']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.dropWhile(users, 'active');
+ * // => objects for ['barney', 'fred', 'pebbles']
+ */
+ function dropWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, getIteratee(predicate, 3), true)
+ : [];
+ }
+
+ /**
+ * Fills elements of `array` with `value` from `start` up to, but not
+ * including, `end`.
+ *
+ * **Note:** This method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Array
+ * @param {Array} array The array to fill.
+ * @param {*} value The value to fill `array` with.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _.fill(array, 'a');
+ * console.log(array);
+ * // => ['a', 'a', 'a']
+ *
+ * _.fill(Array(3), 2);
+ * // => [2, 2, 2]
+ *
+ * _.fill([4, 6, 8, 10], '*', 1, 3);
+ * // => [4, '*', '*', 10]
+ */
+ function fill(array, value, start, end) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
+ start = 0;
+ end = length;
+ }
+ return baseFill(array, value, start, end);
+ }
+
+ /**
+ * This method is like `_.find` except that it returns the index of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.findIndex(users, function(o) { return o.user == 'barney'; });
+ * // => 0
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findIndex(users, { 'user': 'fred', 'active': false });
+ * // => 1
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findIndex(users, ['active', false]);
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findIndex(users, 'active');
+ * // => 2
+ */
+ function findIndex(array, predicate, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
+ if (index < 0) {
+ index = nativeMax(length + index, 0);
+ }
+ return baseFindIndex(array, getIteratee(predicate, 3), index);
+ }
+
+ /**
+ * This method is like `_.findIndex` except that it iterates over elements
+ * of `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=array.length-1] The index to search from.
+ * @returns {number} Returns the index of the found element, else `-1`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
+ * // => 2
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findLastIndex(users, { 'user': 'barney', 'active': true });
+ * // => 0
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findLastIndex(users, ['active', false]);
+ * // => 2
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findLastIndex(users, 'active');
+ * // => 0
+ */
+ function findLastIndex(array, predicate, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = length - 1;
+ if (fromIndex !== undefined) {
+ index = toInteger(fromIndex);
+ index = fromIndex < 0
+ ? nativeMax(length + index, 0)
+ : nativeMin(index, length - 1);
+ }
+ return baseFindIndex(array, getIteratee(predicate, 3), index, true);
+ }
+
+ /**
+ * Flattens `array` a single level deep.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
+ */
+ function flatten(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, 1) : [];
+ }
+
+ /**
+ * Recursively flattens `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
+ */
+ function flattenDeep(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseFlatten(array, INFINITY) : [];
+ }
+
+ /**
+ * Recursively flatten `array` up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.4.0
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * var array = [1, [2, [3, [4]], 5]];
+ *
+ * _.flattenDepth(array, 1);
+ * // => [1, 2, [3, [4]], 5]
+ *
+ * _.flattenDepth(array, 2);
+ * // => [1, 2, 3, [4], 5]
+ */
+ function flattenDepth(array, depth) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(array, depth);
+ }
+
+ /**
+ * The inverse of `_.toPairs`; this method returns an object composed
+ * from key-value `pairs`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} pairs The key-value pairs.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.fromPairs([['a', 1], ['b', 2]]);
+ * // => { 'a': 1, 'b': 2 }
+ */
+ function fromPairs(pairs) {
+ var index = -1,
+ length = pairs == null ? 0 : pairs.length,
+ result = {};
+
+ while (++index < length) {
+ var pair = pairs[index];
+ result[pair[0]] = pair[1];
+ }
+ return result;
+ }
+
+ /**
+ * Gets the first element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias first
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the first element of `array`.
+ * @example
+ *
+ * _.head([1, 2, 3]);
+ * // => 1
+ *
+ * _.head([]);
+ * // => undefined
+ */
+ function head(array) {
+ return (array && array.length) ? array[0] : undefined;
+ }
+
+ /**
+ * Gets the index at which the first occurrence of `value` is found in `array`
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. If `fromIndex` is negative, it's used as the
+ * offset from the end of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.indexOf([1, 2, 1, 2], 2);
+ * // => 1
+ *
+ * // Search from the `fromIndex`.
+ * _.indexOf([1, 2, 1, 2], 2, 2);
+ * // => 3
+ */
+ function indexOf(array, value, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
+ if (index < 0) {
+ index = nativeMax(length + index, 0);
+ }
+ return baseIndexOf(array, value, index);
+ }
+
+ /**
+ * Gets all but the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.initial([1, 2, 3]);
+ * // => [1, 2]
+ */
+ function initial(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 0, -1) : [];
+ }
+
+ /**
+ * Creates an array of unique values that are included in all given arrays
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * _.intersection([2, 1], [2, 3]);
+ * // => [2]
+ */
+ var intersection = baseRest(function(arrays) {
+ var mapped = arrayMap(arrays, castArrayLikeObject);
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped)
+ : [];
+ });
+
+ /**
+ * This method is like `_.intersection` except that it accepts `iteratee`
+ * which is invoked for each element of each `arrays` to generate the criterion
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [2.1]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }]
+ */
+ var intersectionBy = baseRest(function(arrays) {
+ var iteratee = last(arrays),
+ mapped = arrayMap(arrays, castArrayLikeObject);
+
+ if (iteratee === last(mapped)) {
+ iteratee = undefined;
+ } else {
+ mapped.pop();
+ }
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped, getIteratee(iteratee, 2))
+ : [];
+ });
+
+ /**
+ * This method is like `_.intersection` except that it accepts `comparator`
+ * which is invoked to compare elements of `arrays`. The order and references
+ * of result values are determined by the first array. The comparator is
+ * invoked with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of intersecting values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.intersectionWith(objects, others, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }]
+ */
+ var intersectionWith = baseRest(function(arrays) {
+ var comparator = last(arrays),
+ mapped = arrayMap(arrays, castArrayLikeObject);
+
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ if (comparator) {
+ mapped.pop();
+ }
+ return (mapped.length && mapped[0] === arrays[0])
+ ? baseIntersection(mapped, undefined, comparator)
+ : [];
+ });
+
+ /**
+ * Converts all elements in `array` into a string separated by `separator`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to convert.
+ * @param {string} [separator=','] The element separator.
+ * @returns {string} Returns the joined string.
+ * @example
+ *
+ * _.join(['a', 'b', 'c'], '~');
+ * // => 'a~b~c'
+ */
+ function join(array, separator) {
+ return array == null ? '' : nativeJoin.call(array, separator);
+ }
+
+ /**
+ * Gets the last element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {*} Returns the last element of `array`.
+ * @example
+ *
+ * _.last([1, 2, 3]);
+ * // => 3
+ */
+ function last(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? array[length - 1] : undefined;
+ }
+
+ /**
+ * This method is like `_.indexOf` except that it iterates over elements of
+ * `array` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=array.length-1] The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.lastIndexOf([1, 2, 1, 2], 2);
+ * // => 3
+ *
+ * // Search from the `fromIndex`.
+ * _.lastIndexOf([1, 2, 1, 2], 2, 2);
+ * // => 1
+ */
+ function lastIndexOf(array, value, fromIndex) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return -1;
+ }
+ var index = length;
+ if (fromIndex !== undefined) {
+ index = toInteger(fromIndex);
+ index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
+ }
+ return value === value
+ ? strictLastIndexOf(array, value, index)
+ : baseFindIndex(array, baseIsNaN, index, true);
+ }
+
+ /**
+ * Gets the element at index `n` of `array`. If `n` is negative, the nth
+ * element from the end is returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.11.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=0] The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'd'];
+ *
+ * _.nth(array, 1);
+ * // => 'b'
+ *
+ * _.nth(array, -2);
+ * // => 'c';
+ */
+ function nth(array, n) {
+ return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
+ }
+
+ /**
+ * Removes all given values from `array` using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
+ * to remove elements from an array by predicate.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {...*} [values] The values to remove.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
+ *
+ * _.pull(array, 'a', 'c');
+ * console.log(array);
+ * // => ['b', 'b']
+ */
+ var pull = baseRest(pullAll);
+
+ /**
+ * This method is like `_.pull` except that it accepts an array of values to remove.
+ *
+ * **Note:** Unlike `_.difference`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
+ *
+ * _.pullAll(array, ['a', 'c']);
+ * console.log(array);
+ * // => ['b', 'b']
+ */
+ function pullAll(array, values) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values)
+ : array;
+ }
+
+ /**
+ * This method is like `_.pullAll` except that it accepts `iteratee` which is
+ * invoked for each element of `array` and `values` to generate the criterion
+ * by which they're compared. The iteratee is invoked with one argument: (value).
+ *
+ * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
+ *
+ * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
+ * console.log(array);
+ * // => [{ 'x': 2 }]
+ */
+ function pullAllBy(array, values, iteratee) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values, getIteratee(iteratee, 2))
+ : array;
+ }
+
+ /**
+ * This method is like `_.pullAll` except that it accepts `comparator` which
+ * is invoked to compare elements of `array` to `values`. The comparator is
+ * invoked with two arguments: (arrVal, othVal).
+ *
+ * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
+ *
+ * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
+ * console.log(array);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
+ */
+ function pullAllWith(array, values, comparator) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values, undefined, comparator)
+ : array;
+ }
+
+ /**
+ * Removes elements from `array` corresponding to `indexes` and returns an
+ * array of removed elements.
+ *
+ * **Note:** Unlike `_.at`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {...(number|number[])} [indexes] The indexes of elements to remove.
+ * @returns {Array} Returns the new array of removed elements.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'd'];
+ * var pulled = _.pullAt(array, [1, 3]);
+ *
+ * console.log(array);
+ * // => ['a', 'c']
+ *
+ * console.log(pulled);
+ * // => ['b', 'd']
+ */
+ var pullAt = flatRest(function(array, indexes) {
+ var length = array == null ? 0 : array.length,
+ result = baseAt(array, indexes);
+
+ basePullAt(array, arrayMap(indexes, function(index) {
+ return isIndex(index, length) ? +index : index;
+ }).sort(compareAscending));
+
+ return result;
+ });
+
+ /**
+ * Removes all elements from `array` that `predicate` returns truthy for
+ * and returns an array of the removed elements. The predicate is invoked
+ * with three arguments: (value, index, array).
+ *
+ * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
+ * to pull elements from an array by value.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new array of removed elements.
+ * @example
+ *
+ * var array = [1, 2, 3, 4];
+ * var evens = _.remove(array, function(n) {
+ * return n % 2 == 0;
+ * });
+ *
+ * console.log(array);
+ * // => [1, 3]
+ *
+ * console.log(evens);
+ * // => [2, 4]
+ */
+ function remove(array, predicate) {
+ var result = [];
+ if (!(array && array.length)) {
+ return result;
+ }
+ var index = -1,
+ indexes = [],
+ length = array.length;
+
+ predicate = getIteratee(predicate, 3);
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value, index, array)) {
+ result.push(value);
+ indexes.push(index);
+ }
+ }
+ basePullAt(array, indexes);
+ return result;
+ }
+
+ /**
+ * Reverses `array` so that the first element becomes the last, the second
+ * element becomes the second to last, and so on.
+ *
+ * **Note:** This method mutates `array` and is based on
+ * [`Array#reverse`](https://mdn.io/Array/reverse).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _.reverse(array);
+ * // => [3, 2, 1]
+ *
+ * console.log(array);
+ * // => [3, 2, 1]
+ */
+ function reverse(array) {
+ return array == null ? array : nativeReverse.call(array);
+ }
+
+ /**
+ * Creates a slice of `array` from `start` up to, but not including, `end`.
+ *
+ * **Note:** This method is used instead of
+ * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
+ * returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+ function slice(array, start, end) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
+ start = 0;
+ end = length;
+ }
+ else {
+ start = start == null ? 0 : toInteger(start);
+ end = end === undefined ? length : toInteger(end);
+ }
+ return baseSlice(array, start, end);
+ }
+
+ /**
+ * Uses a binary search to determine the lowest index at which `value`
+ * should be inserted into `array` in order to maintain its sort order.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * _.sortedIndex([30, 50], 40);
+ * // => 1
+ */
+ function sortedIndex(array, value) {
+ return baseSortedIndex(array, value);
+ }
+
+ /**
+ * This method is like `_.sortedIndex` except that it accepts `iteratee`
+ * which is invoked for `value` and each element of `array` to compute their
+ * sort ranking. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * var objects = [{ 'x': 4 }, { 'x': 5 }];
+ *
+ * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
+ * // => 0
+ */
+ function sortedIndexBy(array, value, iteratee) {
+ return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
+ }
+
+ /**
+ * This method is like `_.indexOf` except that it performs a binary
+ * search on a sorted `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
+ * // => 1
+ */
+ function sortedIndexOf(array, value) {
+ var length = array == null ? 0 : array.length;
+ if (length) {
+ var index = baseSortedIndex(array, value);
+ if (index < length && eq(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * This method is like `_.sortedIndex` except that it returns the highest
+ * index at which `value` should be inserted into `array` in order to
+ * maintain its sort order.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
+ * // => 4
+ */
+ function sortedLastIndex(array, value) {
+ return baseSortedIndex(array, value, true);
+ }
+
+ /**
+ * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
+ * which is invoked for `value` and each element of `array` to compute their
+ * sort ranking. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * var objects = [{ 'x': 4 }, { 'x': 5 }];
+ *
+ * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
+ * // => 1
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
+ * // => 1
+ */
+ function sortedLastIndexBy(array, value, iteratee) {
+ return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
+ }
+
+ /**
+ * This method is like `_.lastIndexOf` except that it performs a binary
+ * search on a sorted `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
+ * // => 3
+ */
+ function sortedLastIndexOf(array, value) {
+ var length = array == null ? 0 : array.length;
+ if (length) {
+ var index = baseSortedIndex(array, value, true) - 1;
+ if (eq(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * This method is like `_.uniq` except that it's designed and optimized
+ * for sorted arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.sortedUniq([1, 1, 2]);
+ * // => [1, 2]
+ */
+ function sortedUniq(array) {
+ return (array && array.length)
+ ? baseSortedUniq(array)
+ : [];
+ }
+
+ /**
+ * This method is like `_.uniqBy` except that it's designed and optimized
+ * for sorted arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
+ * // => [1.1, 2.3]
+ */
+ function sortedUniqBy(array, iteratee) {
+ return (array && array.length)
+ ? baseSortedUniq(array, getIteratee(iteratee, 2))
+ : [];
+ }
+
+ /**
+ * Gets all but the first element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.tail([1, 2, 3]);
+ * // => [2, 3]
+ */
+ function tail(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 1, length) : [];
+ }
+
+ /**
+ * Creates a slice of `array` with `n` elements taken from the beginning.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to take.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.take([1, 2, 3]);
+ * // => [1]
+ *
+ * _.take([1, 2, 3], 2);
+ * // => [1, 2]
+ *
+ * _.take([1, 2, 3], 5);
+ * // => [1, 2, 3]
+ *
+ * _.take([1, 2, 3], 0);
+ * // => []
+ */
+ function take(array, n, guard) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ return baseSlice(array, 0, n < 0 ? 0 : n);
+ }
+
+ /**
+ * Creates a slice of `array` with `n` elements taken from the end.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to take.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.takeRight([1, 2, 3]);
+ * // => [3]
+ *
+ * _.takeRight([1, 2, 3], 2);
+ * // => [2, 3]
+ *
+ * _.takeRight([1, 2, 3], 5);
+ * // => [1, 2, 3]
+ *
+ * _.takeRight([1, 2, 3], 0);
+ * // => []
+ */
+ function takeRight(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ n = length - n;
+ return baseSlice(array, n < 0 ? 0 : n, length);
+ }
+
+ /**
+ * Creates a slice of `array` with elements taken from the end. Elements are
+ * taken until `predicate` returns falsey. The predicate is invoked with
+ * three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.takeRightWhile(users, function(o) { return !o.active; });
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
+ * // => objects for ['pebbles']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.takeRightWhile(users, ['active', false]);
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.takeRightWhile(users, 'active');
+ * // => []
+ */
+ function takeRightWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, getIteratee(predicate, 3), false, true)
+ : [];
+ }
+
+ /**
+ * Creates a slice of `array` with elements taken from the beginning. Elements
+ * are taken until `predicate` returns falsey. The predicate is invoked with
+ * three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false},
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.takeWhile(users, function(o) { return !o.active; });
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.takeWhile(users, { 'user': 'barney', 'active': false });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.takeWhile(users, ['active', false]);
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.takeWhile(users, 'active');
+ * // => []
+ */
+ function takeWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, getIteratee(predicate, 3))
+ : [];
+ }
+
+ /**
+ * Creates an array of unique values, in order, from all given arrays using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * _.union([2], [1, 2]);
+ * // => [2, 1]
+ */
+ var union = baseRest(function(arrays) {
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
+ });
+
+ /**
+ * This method is like `_.union` except that it accepts `iteratee` which is
+ * invoked for each element of each `arrays` to generate the criterion by
+ * which uniqueness is computed. Result values are chosen from the first
+ * array in which the value occurs. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * _.unionBy([2.1], [1.2, 2.3], Math.floor);
+ * // => [2.1, 1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }, { 'x': 2 }]
+ */
+ var unionBy = baseRest(function(arrays) {
+ var iteratee = last(arrays);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
+ });
+
+ /**
+ * This method is like `_.union` except that it accepts `comparator` which
+ * is invoked to compare elements of `arrays`. Result values are chosen from
+ * the first array in which the value occurs. The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.unionWith(objects, others, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
+ */
+ var unionWith = baseRest(function(arrays) {
+ var comparator = last(arrays);
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
+ });
+
+ /**
+ * Creates a duplicate-free version of an array, using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons, in which only the first occurrence of each element
+ * is kept. The order of result values is determined by the order they occur
+ * in the array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.uniq([2, 1, 2]);
+ * // => [2, 1]
+ */
+ function uniq(array) {
+ return (array && array.length) ? baseUniq(array) : [];
+ }
+
+ /**
+ * This method is like `_.uniq` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * uniqueness is computed. The order of result values is determined by the
+ * order they occur in the array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
+ * // => [2.1, 1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }, { 'x': 2 }]
+ */
+ function uniqBy(array, iteratee) {
+ return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
+ }
+
+ /**
+ * This method is like `_.uniq` except that it accepts `comparator` which
+ * is invoked to compare elements of `array`. The order of result values is
+ * determined by the order they occur in the array.The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.uniqWith(objects, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
+ */
+ function uniqWith(array, comparator) {
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
+ }
+
+ /**
+ * This method is like `_.zip` except that it accepts an array of grouped
+ * elements and creates an array regrouping the elements to their pre-zip
+ * configuration.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.2.0
+ * @category Array
+ * @param {Array} array The array of grouped elements to process.
+ * @returns {Array} Returns the new array of regrouped elements.
+ * @example
+ *
+ * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
+ *
+ * _.unzip(zipped);
+ * // => [['a', 'b'], [1, 2], [true, false]]
+ */
+ function unzip(array) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ var length = 0;
+ array = arrayFilter(array, function(group) {
+ if (isArrayLikeObject(group)) {
+ length = nativeMax(group.length, length);
+ return true;
+ }
+ });
+ return baseTimes(length, function(index) {
+ return arrayMap(array, baseProperty(index));
+ });
+ }
+
+ /**
+ * This method is like `_.unzip` except that it accepts `iteratee` to specify
+ * how regrouped values should be combined. The iteratee is invoked with the
+ * elements of each group: (...group).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Array
+ * @param {Array} array The array of grouped elements to process.
+ * @param {Function} [iteratee=_.identity] The function to combine
+ * regrouped values.
+ * @returns {Array} Returns the new array of regrouped elements.
+ * @example
+ *
+ * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
+ * // => [[1, 10, 100], [2, 20, 200]]
+ *
+ * _.unzipWith(zipped, _.add);
+ * // => [3, 30, 300]
+ */
+ function unzipWith(array, iteratee) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ var result = unzip(array);
+ if (iteratee == null) {
+ return result;
+ }
+ return arrayMap(result, function(group) {
+ return apply(iteratee, undefined, group);
+ });
+ }
+
+ /**
+ * Creates an array excluding all given values using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * **Note:** Unlike `_.pull`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...*} [values] The values to exclude.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.difference, _.xor
+ * @example
+ *
+ * _.without([2, 1, 2, 3], 1, 2);
+ * // => [3]
+ */
+ var without = baseRest(function(array, values) {
+ return isArrayLikeObject(array)
+ ? baseDifference(array, values)
+ : [];
+ });
+
+ /**
+ * Creates an array of unique values that is the
+ * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
+ * of the given arrays. The order of result values is determined by the order
+ * they occur in the arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.difference, _.without
+ * @example
+ *
+ * _.xor([2, 1], [2, 3]);
+ * // => [1, 3]
+ */
+ var xor = baseRest(function(arrays) {
+ return baseXor(arrayFilter(arrays, isArrayLikeObject));
+ });
+
+ /**
+ * This method is like `_.xor` except that it accepts `iteratee` which is
+ * invoked for each element of each `arrays` to generate the criterion by
+ * which by which they're compared. The order of result values is determined
+ * by the order they occur in the arrays. The iteratee is invoked with one
+ * argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [1.2, 3.4]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 2 }]
+ */
+ var xorBy = baseRest(function(arrays) {
+ var iteratee = last(arrays);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
+ });
+
+ /**
+ * This method is like `_.xor` except that it accepts `comparator` which is
+ * invoked to compare elements of `arrays`. The order of result values is
+ * determined by the order they occur in the arrays. The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.xorWith(objects, others, _.isEqual);
+ * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
+ */
+ var xorWith = baseRest(function(arrays) {
+ var comparator = last(arrays);
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
+ });
+
+ /**
+ * Creates an array of grouped elements, the first of which contains the
+ * first elements of the given arrays, the second of which contains the
+ * second elements of the given arrays, and so on.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to process.
+ * @returns {Array} Returns the new array of grouped elements.
+ * @example
+ *
+ * _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
+ */
+ var zip = baseRest(unzip);
+
+ /**
+ * This method is like `_.fromPairs` except that it accepts two arrays,
+ * one of property identifiers and one of corresponding values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.4.0
+ * @category Array
+ * @param {Array} [props=[]] The property identifiers.
+ * @param {Array} [values=[]] The property values.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.zipObject(['a', 'b'], [1, 2]);
+ * // => { 'a': 1, 'b': 2 }
+ */
+ function zipObject(props, values) {
+ return baseZipObject(props || [], values || [], assignValue);
+ }
+
+ /**
+ * This method is like `_.zipObject` except that it supports property paths.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.1.0
+ * @category Array
+ * @param {Array} [props=[]] The property identifiers.
+ * @param {Array} [values=[]] The property values.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
+ * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
+ */
+ function zipObjectDeep(props, values) {
+ return baseZipObject(props || [], values || [], baseSet);
+ }
+
+ /**
+ * This method is like `_.zip` except that it accepts `iteratee` to specify
+ * how grouped values should be combined. The iteratee is invoked with the
+ * elements of each group: (...group).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to process.
+ * @param {Function} [iteratee=_.identity] The function to combine
+ * grouped values.
+ * @returns {Array} Returns the new array of grouped elements.
+ * @example
+ *
+ * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
+ * return a + b + c;
+ * });
+ * // => [111, 222]
+ */
+ var zipWith = baseRest(function(arrays) {
+ var length = arrays.length,
+ iteratee = length > 1 ? arrays[length - 1] : undefined;
+
+ iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
+ return unzipWith(arrays, iteratee);
+ });
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a `lodash` wrapper instance that wraps `value` with explicit method
+ * chain sequences enabled. The result of such sequences must be unwrapped
+ * with `_#value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Seq
+ * @param {*} value The value to wrap.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'pebbles', 'age': 1 }
+ * ];
+ *
+ * var youngest = _
+ * .chain(users)
+ * .sortBy('age')
+ * .map(function(o) {
+ * return o.user + ' is ' + o.age;
+ * })
+ * .head()
+ * .value();
+ * // => 'pebbles is 1'
+ */
+ function chain(value) {
+ var result = lodash(value);
+ result.__chain__ = true;
+ return result;
+ }
+
+ /**
+ * This method invokes `interceptor` and returns `value`. The interceptor
+ * is invoked with one argument; (value). The purpose of this method is to
+ * "tap into" a method chain sequence in order to modify intermediate results.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * _([1, 2, 3])
+ * .tap(function(array) {
+ * // Mutate input array.
+ * array.pop();
+ * })
+ * .reverse()
+ * .value();
+ * // => [2, 1]
+ */
+ function tap(value, interceptor) {
+ interceptor(value);
+ return value;
+ }
+
+ /**
+ * This method is like `_.tap` except that it returns the result of `interceptor`.
+ * The purpose of this method is to "pass thru" values replacing intermediate
+ * results in a method chain sequence.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns the result of `interceptor`.
+ * @example
+ *
+ * _(' abc ')
+ * .chain()
+ * .trim()
+ * .thru(function(value) {
+ * return [value];
+ * })
+ * .value();
+ * // => ['abc']
+ */
+ function thru(value, interceptor) {
+ return interceptor(value);
+ }
+
+ /**
+ * This method is the wrapper version of `_.at`.
+ *
+ * @name at
+ * @memberOf _
+ * @since 1.0.0
+ * @category Seq
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
+ *
+ * _(object).at(['a[0].b.c', 'a[1]']).value();
+ * // => [3, 4]
+ */
+ var wrapperAt = flatRest(function(paths) {
+ var length = paths.length,
+ start = length ? paths[0] : 0,
+ value = this.__wrapped__,
+ interceptor = function(object) { return baseAt(object, paths); };
+
+ if (length > 1 || this.__actions__.length ||
+ !(value instanceof LazyWrapper) || !isIndex(start)) {
+ return this.thru(interceptor);
+ }
+ value = value.slice(start, +start + (length ? 1 : 0));
+ value.__actions__.push({
+ 'func': thru,
+ 'args': [interceptor],
+ 'thisArg': undefined
+ });
+ return new LodashWrapper(value, this.__chain__).thru(function(array) {
+ if (length && !array.length) {
+ array.push(undefined);
+ }
+ return array;
+ });
+ });
+
+ /**
+ * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
+ *
+ * @name chain
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 }
+ * ];
+ *
+ * // A sequence without explicit chaining.
+ * _(users).head();
+ * // => { 'user': 'barney', 'age': 36 }
+ *
+ * // A sequence with explicit chaining.
+ * _(users)
+ * .chain()
+ * .head()
+ * .pick('user')
+ * .value();
+ * // => { 'user': 'barney' }
+ */
+ function wrapperChain() {
+ return chain(this);
+ }
+
+ /**
+ * Executes the chain sequence and returns the wrapped result.
+ *
+ * @name commit
+ * @memberOf _
+ * @since 3.2.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var array = [1, 2];
+ * var wrapped = _(array).push(3);
+ *
+ * console.log(array);
+ * // => [1, 2]
+ *
+ * wrapped = wrapped.commit();
+ * console.log(array);
+ * // => [1, 2, 3]
+ *
+ * wrapped.last();
+ * // => 3
+ *
+ * console.log(array);
+ * // => [1, 2, 3]
+ */
+ function wrapperCommit() {
+ return new LodashWrapper(this.value(), this.__chain__);
+ }
+
+ /**
+ * Gets the next value on a wrapped object following the
+ * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
+ *
+ * @name next
+ * @memberOf _
+ * @since 4.0.0
+ * @category Seq
+ * @returns {Object} Returns the next iterator value.
+ * @example
+ *
+ * var wrapped = _([1, 2]);
+ *
+ * wrapped.next();
+ * // => { 'done': false, 'value': 1 }
+ *
+ * wrapped.next();
+ * // => { 'done': false, 'value': 2 }
+ *
+ * wrapped.next();
+ * // => { 'done': true, 'value': undefined }
+ */
+ function wrapperNext() {
+ if (this.__values__ === undefined) {
+ this.__values__ = toArray(this.value());
+ }
+ var done = this.__index__ >= this.__values__.length,
+ value = done ? undefined : this.__values__[this.__index__++];
+
+ return { 'done': done, 'value': value };
+ }
+
+ /**
+ * Enables the wrapper to be iterable.
+ *
+ * @name Symbol.iterator
+ * @memberOf _
+ * @since 4.0.0
+ * @category Seq
+ * @returns {Object} Returns the wrapper object.
+ * @example
+ *
+ * var wrapped = _([1, 2]);
+ *
+ * wrapped[Symbol.iterator]() === wrapped;
+ * // => true
+ *
+ * Array.from(wrapped);
+ * // => [1, 2]
+ */
+ function wrapperToIterator() {
+ return this;
+ }
+
+ /**
+ * Creates a clone of the chain sequence planting `value` as the wrapped value.
+ *
+ * @name plant
+ * @memberOf _
+ * @since 3.2.0
+ * @category Seq
+ * @param {*} value The value to plant.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2]).map(square);
+ * var other = wrapped.plant([3, 4]);
+ *
+ * other.value();
+ * // => [9, 16]
+ *
+ * wrapped.value();
+ * // => [1, 4]
+ */
+ function wrapperPlant(value) {
+ var result,
+ parent = this;
+
+ while (parent instanceof baseLodash) {
+ var clone = wrapperClone(parent);
+ clone.__index__ = 0;
+ clone.__values__ = undefined;
+ if (result) {
+ previous.__wrapped__ = clone;
+ } else {
+ result = clone;
+ }
+ var previous = clone;
+ parent = parent.__wrapped__;
+ }
+ previous.__wrapped__ = value;
+ return result;
+ }
+
+ /**
+ * This method is the wrapper version of `_.reverse`.
+ *
+ * **Note:** This method mutates the wrapped array.
+ *
+ * @name reverse
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _(array).reverse().value()
+ * // => [3, 2, 1]
+ *
+ * console.log(array);
+ * // => [3, 2, 1]
+ */
+ function wrapperReverse() {
+ var value = this.__wrapped__;
+ if (value instanceof LazyWrapper) {
+ var wrapped = value;
+ if (this.__actions__.length) {
+ wrapped = new LazyWrapper(this);
+ }
+ wrapped = wrapped.reverse();
+ wrapped.__actions__.push({
+ 'func': thru,
+ 'args': [reverse],
+ 'thisArg': undefined
+ });
+ return new LodashWrapper(wrapped, this.__chain__);
+ }
+ return this.thru(reverse);
+ }
+
+ /**
+ * Executes the chain sequence to resolve the unwrapped value.
+ *
+ * @name value
+ * @memberOf _
+ * @since 0.1.0
+ * @alias toJSON, valueOf
+ * @category Seq
+ * @returns {*} Returns the resolved unwrapped value.
+ * @example
+ *
+ * _([1, 2, 3]).value();
+ * // => [1, 2, 3]
+ */
+ function wrapperValue() {
+ return baseWrapperValue(this.__wrapped__, this.__actions__);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The corresponding value of
+ * each key is the number of times the key was returned by `iteratee`. The
+ * iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * _.countBy([6.1, 4.2, 6.3], Math.floor);
+ * // => { '4': 1, '6': 2 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.countBy(['one', 'two', 'three'], 'length');
+ * // => { '3': 2, '5': 1 }
+ */
+ var countBy = createAggregator(function(result, value, key) {
+ if (hasOwnProperty.call(result, key)) {
+ ++result[key];
+ } else {
+ baseAssignValue(result, key, 1);
+ }
+ });
+
+ /**
+ * Checks if `predicate` returns truthy for **all** elements of `collection`.
+ * Iteration is stopped once `predicate` returns falsey. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * **Note:** This method returns `true` for
+ * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
+ * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
+ * elements of empty collections.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if all elements pass the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.every([true, 1, null, 'yes'], Boolean);
+ * // => false
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.every(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.every(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.every(users, 'active');
+ * // => false
+ */
+ function every(collection, predicate, guard) {
+ var func = isArray(collection) ? arrayEvery : baseEvery;
+ if (guard && isIterateeCall(collection, predicate, guard)) {
+ predicate = undefined;
+ }
+ return func(collection, getIteratee(predicate, 3));
+ }
+
+ /**
+ * Iterates over elements of `collection`, returning an array of all elements
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.reject
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * _.filter(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, { 'age': 36, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.filter(users, 'active');
+ * // => objects for ['barney']
+ */
+ function filter(collection, predicate) {
+ var func = isArray(collection) ? arrayFilter : baseFilter;
+ return func(collection, getIteratee(predicate, 3));
+ }
+
+ /**
+ * Iterates over elements of `collection`, returning the first element
+ * `predicate` returns truthy for. The predicate is invoked with three
+ * arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false },
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
+ * ];
+ *
+ * _.find(users, function(o) { return o.age < 40; });
+ * // => object for 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.find(users, { 'age': 1, 'active': true });
+ * // => object for 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.find(users, ['active', false]);
+ * // => object for 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.find(users, 'active');
+ * // => object for 'barney'
+ */
+ var find = createFind(findIndex);
+
+ /**
+ * This method is like `_.find` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param {number} [fromIndex=collection.length-1] The index to search from.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * _.findLast([1, 2, 3, 4], function(n) {
+ * return n % 2 == 1;
+ * });
+ * // => 3
+ */
+ var findLast = createFind(findLastIndex);
+
+ /**
+ * Creates a flattened array of values by running each element in `collection`
+ * thru `iteratee` and flattening the mapped results. The iteratee is invoked
+ * with three arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [n, n];
+ * }
+ *
+ * _.flatMap([1, 2], duplicate);
+ * // => [1, 1, 2, 2]
+ */
+ function flatMap(collection, iteratee) {
+ return baseFlatten(map(collection, iteratee), 1);
+ }
+
+ /**
+ * This method is like `_.flatMap` except that it recursively flattens the
+ * mapped results.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [[[n, n]]];
+ * }
+ *
+ * _.flatMapDeep([1, 2], duplicate);
+ * // => [1, 1, 2, 2]
+ */
+ function flatMapDeep(collection, iteratee) {
+ return baseFlatten(map(collection, iteratee), INFINITY);
+ }
+
+ /**
+ * This method is like `_.flatMap` except that it recursively flattens the
+ * mapped results up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * function duplicate(n) {
+ * return [[[n, n]]];
+ * }
+ *
+ * _.flatMapDepth([1, 2], duplicate, 2);
+ * // => [[1, 1], [2, 2]]
+ */
+ function flatMapDepth(collection, iteratee, depth) {
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(map(collection, iteratee), depth);
+ }
+
+ /**
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
+ * The iteratee is invoked with three arguments: (value, index|key, collection).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * **Note:** As with other "Collections" methods, objects with a "length"
+ * property are iterated like arrays. To avoid this behavior use `_.forIn`
+ * or `_.forOwn` for object iteration.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @alias each
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEachRight
+ * @example
+ *
+ * _.forEach([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `1` then `2`.
+ *
+ * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */
+ function forEach(collection, iteratee) {
+ var func = isArray(collection) ? arrayEach : baseEach;
+ return func(collection, getIteratee(iteratee, 3));
+ }
+
+ /**
+ * This method is like `_.forEach` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @alias eachRight
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array|Object} Returns `collection`.
+ * @see _.forEach
+ * @example
+ *
+ * _.forEachRight([1, 2], function(value) {
+ * console.log(value);
+ * });
+ * // => Logs `2` then `1`.
+ */
+ function forEachRight(collection, iteratee) {
+ var func = isArray(collection) ? arrayEachRight : baseEachRight;
+ return func(collection, getIteratee(iteratee, 3));
+ }
+
+ /**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The order of grouped values
+ * is determined by the order they occur in `collection`. The corresponding
+ * value of each key is an array of elements responsible for generating the
+ * key. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * _.groupBy([6.1, 4.2, 6.3], Math.floor);
+ * // => { '4': [4.2], '6': [6.1, 6.3] }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.groupBy(['one', 'two', 'three'], 'length');
+ * // => { '3': ['one', 'two'], '5': ['three'] }
+ */
+ var groupBy = createAggregator(function(result, value, key) {
+ if (hasOwnProperty.call(result, key)) {
+ result[key].push(value);
+ } else {
+ baseAssignValue(result, key, [value]);
+ }
+ });
+
+ /**
+ * Checks if `value` is in `collection`. If `collection` is a string, it's
+ * checked for a substring of `value`, otherwise
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * is used for equality comparisons. If `fromIndex` is negative, it's used as
+ * the offset from the end of `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} [fromIndex=0] The index to search from.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
+ * @returns {boolean} Returns `true` if `value` is found, else `false`.
+ * @example
+ *
+ * _.includes([1, 2, 3], 1);
+ * // => true
+ *
+ * _.includes([1, 2, 3], 1, 2);
+ * // => false
+ *
+ * _.includes({ 'a': 1, 'b': 2 }, 1);
+ * // => true
+ *
+ * _.includes('abcd', 'bc');
+ * // => true
+ */
+ function includes(collection, value, fromIndex, guard) {
+ collection = isArrayLike(collection) ? collection : values(collection);
+ fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
+
+ var length = collection.length;
+ if (fromIndex < 0) {
+ fromIndex = nativeMax(length + fromIndex, 0);
+ }
+ return isString(collection)
+ ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
+ : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
+ }
+
+ /**
+ * Invokes the method at `path` of each element in `collection`, returning
+ * an array of the results of each invoked method. Any additional arguments
+ * are provided to each invoked method. If `path` is a function, it's invoked
+ * for, and `this` bound to, each element in `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Array|Function|string} path The path of the method to invoke or
+ * the function invoked per iteration.
+ * @param {...*} [args] The arguments to invoke each method with.
+ * @returns {Array} Returns the array of results.
+ * @example
+ *
+ * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
+ * // => [[1, 5, 7], [1, 2, 3]]
+ *
+ * _.invokeMap([123, 456], String.prototype.split, '');
+ * // => [['1', '2', '3'], ['4', '5', '6']]
+ */
+ var invokeMap = baseRest(function(collection, path, args) {
+ var index = -1,
+ isFunc = typeof path == 'function',
+ result = isArrayLike(collection) ? Array(collection.length) : [];
+
+ baseEach(collection, function(value) {
+ result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
+ });
+ return result;
+ });
+
+ /**
+ * Creates an object composed of keys generated from the results of running
+ * each element of `collection` thru `iteratee`. The corresponding value of
+ * each key is the last element responsible for generating the key. The
+ * iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
+ * @returns {Object} Returns the composed aggregate object.
+ * @example
+ *
+ * var array = [
+ * { 'dir': 'left', 'code': 97 },
+ * { 'dir': 'right', 'code': 100 }
+ * ];
+ *
+ * _.keyBy(array, function(o) {
+ * return String.fromCharCode(o.code);
+ * });
+ * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
+ *
+ * _.keyBy(array, 'dir');
+ * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
+ */
+ var keyBy = createAggregator(function(result, value, key) {
+ baseAssignValue(result, key, value);
+ });
+
+ /**
+ * Creates an array of values by running each element in `collection` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
+ *
+ * The guarded methods are:
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * _.map([4, 8], square);
+ * // => [16, 64]
+ *
+ * _.map({ 'a': 4, 'b': 8 }, square);
+ * // => [16, 64] (iteration order is not guaranteed)
+ *
+ * var users = [
+ * { 'user': 'barney' },
+ * { 'user': 'fred' }
+ * ];
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, 'user');
+ * // => ['barney', 'fred']
+ */
+ function map(collection, iteratee) {
+ var func = isArray(collection) ? arrayMap : baseMap;
+ return func(collection, getIteratee(iteratee, 3));
+ }
+
+ /**
+ * This method is like `_.sortBy` except that it allows specifying the sort
+ * orders of the iteratees to sort by. If `orders` is unspecified, all values
+ * are sorted in ascending order. Otherwise, specify an order of "desc" for
+ * descending or "asc" for ascending sort order of corresponding values.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @param {string[]} [orders] The sort orders of `iteratees`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 34 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 36 }
+ * ];
+ *
+ * // Sort by `user` in ascending order and by `age` in descending order.
+ * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ */
+ function orderBy(collection, iteratees, orders, guard) {
+ if (collection == null) {
+ return [];
+ }
+ if (!isArray(iteratees)) {
+ iteratees = iteratees == null ? [] : [iteratees];
+ }
+ orders = guard ? undefined : orders;
+ if (!isArray(orders)) {
+ orders = orders == null ? [] : [orders];
+ }
+ return baseOrderBy(collection, iteratees, orders);
+ }
+
+ /**
+ * Creates an array of elements split into two groups, the first of which
+ * contains elements `predicate` returns truthy for, the second of which
+ * contains elements `predicate` returns falsey for. The predicate is
+ * invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the array of grouped elements.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': true },
+ * { 'user': 'pebbles', 'age': 1, 'active': false }
+ * ];
+ *
+ * _.partition(users, function(o) { return o.active; });
+ * // => objects for [['fred'], ['barney', 'pebbles']]
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.partition(users, { 'age': 1, 'active': false });
+ * // => objects for [['pebbles'], ['barney', 'fred']]
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.partition(users, ['active', false]);
+ * // => objects for [['barney', 'pebbles'], ['fred']]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.partition(users, 'active');
+ * // => objects for [['fred'], ['barney', 'pebbles']]
+ */
+ var partition = createAggregator(function(result, value, key) {
+ result[key ? 0 : 1].push(value);
+ }, function() { return [[], []]; });
+
+ /**
+ * Reduces `collection` to a value which is the accumulated result of running
+ * each element in `collection` thru `iteratee`, where each successive
+ * invocation is supplied the return value of the previous. If `accumulator`
+ * is not given, the first element of `collection` is used as the initial
+ * value. The iteratee is invoked with four arguments:
+ * (accumulator, value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
+ *
+ * The guarded methods are:
+ * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
+ * and `sortBy`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduceRight
+ * @example
+ *
+ * _.reduce([1, 2], function(sum, n) {
+ * return sum + n;
+ * }, 0);
+ * // => 3
+ *
+ * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * return result;
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
+ */
+ function reduce(collection, iteratee, accumulator) {
+ var func = isArray(collection) ? arrayReduce : baseReduce,
+ initAccum = arguments.length < 3;
+
+ return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
+ }
+
+ /**
+ * This method is like `_.reduce` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduce
+ * @example
+ *
+ * var array = [[0, 1], [2, 3], [4, 5]];
+ *
+ * _.reduceRight(array, function(flattened, other) {
+ * return flattened.concat(other);
+ * }, []);
+ * // => [4, 5, 2, 3, 0, 1]
+ */
+ function reduceRight(collection, iteratee, accumulator) {
+ var func = isArray(collection) ? arrayReduceRight : baseReduce,
+ initAccum = arguments.length < 3;
+
+ return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
+ }
+
+ /**
+ * The opposite of `_.filter`; this method returns the elements of `collection`
+ * that `predicate` does **not** return truthy for.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.filter
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': true }
+ * ];
+ *
+ * _.reject(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.reject(users, { 'age': 40, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.reject(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.reject(users, 'active');
+ * // => objects for ['barney']
+ */
+ function reject(collection, predicate) {
+ var func = isArray(collection) ? arrayFilter : baseFilter;
+ return func(collection, negate(getIteratee(predicate, 3)));
+ }
+
+ /**
+ * Gets a random element from `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to sample.
+ * @returns {*} Returns the random element.
+ * @example
+ *
+ * _.sample([1, 2, 3, 4]);
+ * // => 2
+ */
+ function sample(collection) {
+ var func = isArray(collection) ? arraySample : baseSample;
+ return func(collection);
+ }
+
+ /**
+ * Gets `n` random elements at unique keys from `collection` up to the
+ * size of `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to sample.
+ * @param {number} [n=1] The number of elements to sample.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the random elements.
+ * @example
+ *
+ * _.sampleSize([1, 2, 3], 2);
+ * // => [3, 1]
+ *
+ * _.sampleSize([1, 2, 3], 4);
+ * // => [2, 3, 1]
+ */
+ function sampleSize(collection, n, guard) {
+ if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
+ n = 1;
+ } else {
+ n = toInteger(n);
+ }
+ var func = isArray(collection) ? arraySampleSize : baseSampleSize;
+ return func(collection, n);
+ }
+
+ /**
+ * Creates an array of shuffled values, using a version of the
+ * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ * @example
+ *
+ * _.shuffle([1, 2, 3, 4]);
+ * // => [4, 1, 3, 2]
+ */
+ function shuffle(collection) {
+ var func = isArray(collection) ? arrayShuffle : baseShuffle;
+ return func(collection);
+ }
+
+ /**
+ * Gets the size of `collection` by returning its length for array-like
+ * values or the number of own enumerable string keyed properties for objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @returns {number} Returns the collection size.
+ * @example
+ *
+ * _.size([1, 2, 3]);
+ * // => 3
+ *
+ * _.size({ 'a': 1, 'b': 2 });
+ * // => 2
+ *
+ * _.size('pebbles');
+ * // => 7
+ */
+ function size(collection) {
+ if (collection == null) {
+ return 0;
+ }
+ if (isArrayLike(collection)) {
+ return isString(collection) ? stringSize(collection) : collection.length;
+ }
+ var tag = getTag(collection);
+ if (tag == mapTag || tag == setTag) {
+ return collection.size;
+ }
+ return baseKeys(collection).length;
+ }
+
+ /**
+ * Checks if `predicate` returns truthy for **any** element of `collection`.
+ * Iteration is stopped once `predicate` returns truthy. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.some([null, 0, 'yes', false], Boolean);
+ * // => true
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.some(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.some(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.some(users, 'active');
+ * // => true
+ */
+ function some(collection, predicate, guard) {
+ var func = isArray(collection) ? arraySome : baseSome;
+ if (guard && isIterateeCall(collection, predicate, guard)) {
+ predicate = undefined;
+ }
+ return func(collection, getIteratee(predicate, 3));
+ }
+
+ /**
+ * Creates an array of elements, sorted in ascending order by the results of
+ * running each element in a collection thru each iteratee. This method
+ * performs a stable sort, that is, it preserves the original sort order of
+ * equal elements. The iteratees are invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 34 }
+ * ];
+ *
+ * _.sortBy(users, [function(o) { return o.user; }]);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ *
+ * _.sortBy(users, ['user', 'age']);
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
+ */
+ var sortBy = baseRest(function(collection, iteratees) {
+ if (collection == null) {
+ return [];
+ }
+ var length = iteratees.length;
+ if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
+ iteratees = [];
+ } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
+ iteratees = [iteratees[0]];
+ }
+ return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
+ });
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Gets the timestamp of the number of milliseconds that have elapsed since
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Date
+ * @returns {number} Returns the timestamp.
+ * @example
+ *
+ * _.defer(function(stamp) {
+ * console.log(_.now() - stamp);
+ * }, _.now());
+ * // => Logs the number of milliseconds it took for the deferred invocation.
+ */
+ var now = ctxNow || function() {
+ return root.Date.now();
+ };
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * The opposite of `_.before`; this method creates a function that invokes
+ * `func` once it's called `n` or more times.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {number} n The number of calls before `func` is invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var saves = ['profile', 'settings'];
+ *
+ * var done = _.after(saves.length, function() {
+ * console.log('done saving!');
+ * });
+ *
+ * _.forEach(saves, function(type) {
+ * asyncSave({ 'type': type, 'complete': done });
+ * });
+ * // => Logs 'done saving!' after the two async saves have completed.
+ */
+ function after(n, func) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n < 1) {
+ return func.apply(this, arguments);
+ }
+ };
+ }
+
+ /**
+ * Creates a function that invokes `func`, with up to `n` arguments,
+ * ignoring any additional arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to cap arguments for.
+ * @param {number} [n=func.length] The arity cap.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new capped function.
+ * @example
+ *
+ * _.map(['6', '8', '10'], _.ary(parseInt, 1));
+ * // => [6, 8, 10]
+ */
+ function ary(func, n, guard) {
+ n = guard ? undefined : n;
+ n = (func && n == null) ? func.length : n;
+ return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
+ }
+
+ /**
+ * Creates a function that invokes `func`, with the `this` binding and arguments
+ * of the created function, while it's called less than `n` times. Subsequent
+ * calls to the created function return the result of the last `func` invocation.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {number} n The number of calls at which `func` is no longer invoked.
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * jQuery(element).on('click', _.before(5, addContactToList));
+ * // => Allows adding up to 4 contacts to the list.
+ */
+ function before(n, func) {
+ var result;
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ n = toInteger(n);
+ return function() {
+ if (--n > 0) {
+ result = func.apply(this, arguments);
+ }
+ if (n <= 1) {
+ func = undefined;
+ }
+ return result;
+ };
+ }
+
+ /**
+ * Creates a function that invokes `func` with the `this` binding of `thisArg`
+ * and `partials` prepended to the arguments it receives.
+ *
+ * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
+ * may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
+ * property of bound functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to bind.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new bound function.
+ * @example
+ *
+ * function greet(greeting, punctuation) {
+ * return greeting + ' ' + this.user + punctuation;
+ * }
+ *
+ * var object = { 'user': 'fred' };
+ *
+ * var bound = _.bind(greet, object, 'hi');
+ * bound('!');
+ * // => 'hi fred!'
+ *
+ * // Bound with placeholders.
+ * var bound = _.bind(greet, object, _, '!');
+ * bound('hi');
+ * // => 'hi fred!'
+ */
+ var bind = baseRest(function(func, thisArg, partials) {
+ var bitmask = WRAP_BIND_FLAG;
+ if (partials.length) {
+ var holders = replaceHolders(partials, getHolder(bind));
+ bitmask |= WRAP_PARTIAL_FLAG;
+ }
+ return createWrap(func, bitmask, thisArg, partials, holders);
+ });
+
+ /**
+ * Creates a function that invokes the method at `object[key]` with `partials`
+ * prepended to the arguments it receives.
+ *
+ * This method differs from `_.bind` by allowing bound functions to reference
+ * methods that may be redefined or don't yet exist. See
+ * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
+ * for more details.
+ *
+ * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Function
+ * @param {Object} object The object to invoke the method on.
+ * @param {string} key The key of the method.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new bound function.
+ * @example
+ *
+ * var object = {
+ * 'user': 'fred',
+ * 'greet': function(greeting, punctuation) {
+ * return greeting + ' ' + this.user + punctuation;
+ * }
+ * };
+ *
+ * var bound = _.bindKey(object, 'greet', 'hi');
+ * bound('!');
+ * // => 'hi fred!'
+ *
+ * object.greet = function(greeting, punctuation) {
+ * return greeting + 'ya ' + this.user + punctuation;
+ * };
+ *
+ * bound('!');
+ * // => 'hiya fred!'
+ *
+ * // Bound with placeholders.
+ * var bound = _.bindKey(object, 'greet', _, '!');
+ * bound('hi');
+ * // => 'hiya fred!'
+ */
+ var bindKey = baseRest(function(object, key, partials) {
+ var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
+ if (partials.length) {
+ var holders = replaceHolders(partials, getHolder(bindKey));
+ bitmask |= WRAP_PARTIAL_FLAG;
+ }
+ return createWrap(key, bitmask, object, partials, holders);
+ });
+
+ /**
+ * Creates a function that accepts arguments of `func` and either invokes
+ * `func` returning its result, if at least `arity` number of arguments have
+ * been provided, or returns a function that accepts the remaining `func`
+ * arguments, and so on. The arity of `func` may be specified if `func.length`
+ * is not sufficient.
+ *
+ * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
+ * may be used as a placeholder for provided arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of curried functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Function
+ * @param {Function} func The function to curry.
+ * @param {number} [arity=func.length] The arity of `func`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new curried function.
+ * @example
+ *
+ * var abc = function(a, b, c) {
+ * return [a, b, c];
+ * };
+ *
+ * var curried = _.curry(abc);
+ *
+ * curried(1)(2)(3);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2)(3);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2, 3);
+ * // => [1, 2, 3]
+ *
+ * // Curried with placeholders.
+ * curried(1)(_, 3)(2);
+ * // => [1, 2, 3]
+ */
+ function curry(func, arity, guard) {
+ arity = guard ? undefined : arity;
+ var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ result.placeholder = curry.placeholder;
+ return result;
+ }
+
+ /**
+ * This method is like `_.curry` except that arguments are applied to `func`
+ * in the manner of `_.partialRight` instead of `_.partial`.
+ *
+ * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for provided arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of curried functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to curry.
+ * @param {number} [arity=func.length] The arity of `func`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the new curried function.
+ * @example
+ *
+ * var abc = function(a, b, c) {
+ * return [a, b, c];
+ * };
+ *
+ * var curried = _.curryRight(abc);
+ *
+ * curried(3)(2)(1);
+ * // => [1, 2, 3]
+ *
+ * curried(2, 3)(1);
+ * // => [1, 2, 3]
+ *
+ * curried(1, 2, 3);
+ * // => [1, 2, 3]
+ *
+ * // Curried with placeholders.
+ * curried(3)(1, _)(2);
+ * // => [1, 2, 3]
+ */
+ function curryRight(func, arity, guard) {
+ arity = guard ? undefined : arity;
+ var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ result.placeholder = curryRight.placeholder;
+ return result;
+ }
+
+ /**
+ * Creates a debounced function that delays invoking `func` until after `wait`
+ * milliseconds have elapsed since the last time the debounced function was
+ * invoked. The debounced function comes with a `cancel` method to cancel
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
+ * Provide `options` to indicate whether `func` should be invoked on the
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
+ * with the last arguments provided to the debounced function. Subsequent
+ * calls to the debounced function return the result of the last `func`
+ * invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the debounced function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.debounce` and `_.throttle`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to debounce.
+ * @param {number} [wait=0] The number of milliseconds to delay.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=false]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {number} [options.maxWait]
+ * The maximum time `func` is allowed to be delayed before it's invoked.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new debounced function.
+ * @example
+ *
+ * // Avoid costly calculations while the window size is in flux.
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
+ *
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
+ * 'leading': true,
+ * 'trailing': false
+ * }));
+ *
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
+ * var source = new EventSource('/stream');
+ * jQuery(source).on('message', debounced);
+ *
+ * // Cancel the trailing debounced invocation.
+ * jQuery(window).on('popstate', debounced.cancel);
+ */
+ function debounce(func, wait, options) {
+ var lastArgs,
+ lastThis,
+ maxWait,
+ result,
+ timerId,
+ lastCallTime,
+ lastInvokeTime = 0,
+ leading = false,
+ maxing = false,
+ trailing = true;
+
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ wait = toNumber(wait) || 0;
+ if (isObject(options)) {
+ leading = !!options.leading;
+ maxing = 'maxWait' in options;
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
+ }
+
+ function invokeFunc(time) {
+ var args = lastArgs,
+ thisArg = lastThis;
+
+ lastArgs = lastThis = undefined;
+ lastInvokeTime = time;
+ result = func.apply(thisArg, args);
+ return result;
+ }
+
+ function leadingEdge(time) {
+ // Reset any `maxWait` timer.
+ lastInvokeTime = time;
+ // Start the timer for the trailing edge.
+ timerId = setTimeout(timerExpired, wait);
+ // Invoke the leading edge.
+ return leading ? invokeFunc(time) : result;
+ }
+
+ function remainingWait(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime,
+ result = wait - timeSinceLastCall;
+
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
+ }
+
+ function shouldInvoke(time) {
+ var timeSinceLastCall = time - lastCallTime,
+ timeSinceLastInvoke = time - lastInvokeTime;
+
+ // Either this is the first call, activity has stopped and we're at the
+ // trailing edge, the system time has gone backwards and we're treating
+ // it as the trailing edge, or we've hit the `maxWait` limit.
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
+ }
+
+ function timerExpired() {
+ var time = now();
+ if (shouldInvoke(time)) {
+ return trailingEdge(time);
+ }
+ // Restart the timer.
+ timerId = setTimeout(timerExpired, remainingWait(time));
+ }
+
+ function trailingEdge(time) {
+ timerId = undefined;
+
+ // Only invoke if we have `lastArgs` which means `func` has been
+ // debounced at least once.
+ if (trailing && lastArgs) {
+ return invokeFunc(time);
+ }
+ lastArgs = lastThis = undefined;
+ return result;
+ }
+
+ function cancel() {
+ if (timerId !== undefined) {
+ clearTimeout(timerId);
+ }
+ lastInvokeTime = 0;
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
+ }
+
+ function flush() {
+ return timerId === undefined ? result : trailingEdge(now());
+ }
+
+ function debounced() {
+ var time = now(),
+ isInvoking = shouldInvoke(time);
+
+ lastArgs = arguments;
+ lastThis = this;
+ lastCallTime = time;
+
+ if (isInvoking) {
+ if (timerId === undefined) {
+ return leadingEdge(lastCallTime);
+ }
+ if (maxing) {
+ // Handle invocations in a tight loop.
+ timerId = setTimeout(timerExpired, wait);
+ return invokeFunc(lastCallTime);
+ }
+ }
+ if (timerId === undefined) {
+ timerId = setTimeout(timerExpired, wait);
+ }
+ return result;
+ }
+ debounced.cancel = cancel;
+ debounced.flush = flush;
+ return debounced;
+ }
+
+ /**
+ * Defers invoking the `func` until the current call stack has cleared. Any
+ * additional arguments are provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to defer.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.defer(function(text) {
+ * console.log(text);
+ * }, 'deferred');
+ * // => Logs 'deferred' after one millisecond.
+ */
+ var defer = baseRest(function(func, args) {
+ return baseDelay(func, 1, args);
+ });
+
+ /**
+ * Invokes `func` after `wait` milliseconds. Any additional arguments are
+ * provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {number} Returns the timer id.
+ * @example
+ *
+ * _.delay(function(text) {
+ * console.log(text);
+ * }, 1000, 'later');
+ * // => Logs 'later' after one second.
+ */
+ var delay = baseRest(function(func, wait, args) {
+ return baseDelay(func, toNumber(wait) || 0, args);
+ });
+
+ /**
+ * Creates a function that invokes `func` with arguments reversed.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to flip arguments for.
+ * @returns {Function} Returns the new flipped function.
+ * @example
+ *
+ * var flipped = _.flip(function() {
+ * return _.toArray(arguments);
+ * });
+ *
+ * flipped('a', 'b', 'c', 'd');
+ * // => ['d', 'c', 'b', 'a']
+ */
+ function flip(func) {
+ return createWrap(func, WRAP_FLIP_FLAG);
+ }
+
+ /**
+ * Creates a function that memoizes the result of `func`. If `resolver` is
+ * provided, it determines the cache key for storing the result based on the
+ * arguments provided to the memoized function. By default, the first argument
+ * provided to the memoized function is used as the map cache key. The `func`
+ * is invoked with the `this` binding of the memoized function.
+ *
+ * **Note:** The cache is exposed as the `cache` property on the memoized
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
+ * constructor with one whose instances implement the
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to have its output memoized.
+ * @param {Function} [resolver] The function to resolve the cache key.
+ * @returns {Function} Returns the new memoized function.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ * var other = { 'c': 3, 'd': 4 };
+ *
+ * var values = _.memoize(_.values);
+ * values(object);
+ * // => [1, 2]
+ *
+ * values(other);
+ * // => [3, 4]
+ *
+ * object.a = 2;
+ * values(object);
+ * // => [1, 2]
+ *
+ * // Modify the result cache.
+ * values.cache.set(object, ['a', 'b']);
+ * values(object);
+ * // => ['a', 'b']
+ *
+ * // Replace `_.memoize.Cache`.
+ * _.memoize.Cache = WeakMap;
+ */
+ function memoize(func, resolver) {
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var memoized = function() {
+ var args = arguments,
+ key = resolver ? resolver.apply(this, args) : args[0],
+ cache = memoized.cache;
+
+ if (cache.has(key)) {
+ return cache.get(key);
+ }
+ var result = func.apply(this, args);
+ memoized.cache = cache.set(key, result) || cache;
+ return result;
+ };
+ memoized.cache = new (memoize.Cache || MapCache);
+ return memoized;
+ }
+
+ // Expose `MapCache`.
+ memoize.Cache = MapCache;
+
+ /**
+ * Creates a function that negates the result of the predicate `func`. The
+ * `func` predicate is invoked with the `this` binding and arguments of the
+ * created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} predicate The predicate to negate.
+ * @returns {Function} Returns the new negated function.
+ * @example
+ *
+ * function isEven(n) {
+ * return n % 2 == 0;
+ * }
+ *
+ * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
+ * // => [1, 3, 5]
+ */
+ function negate(predicate) {
+ if (typeof predicate != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return function() {
+ var args = arguments;
+ switch (args.length) {
+ case 0: return !predicate.call(this);
+ case 1: return !predicate.call(this, args[0]);
+ case 2: return !predicate.call(this, args[0], args[1]);
+ case 3: return !predicate.call(this, args[0], args[1], args[2]);
+ }
+ return !predicate.apply(this, args);
+ };
+ }
+
+ /**
+ * Creates a function that is restricted to invoking `func` once. Repeat calls
+ * to the function return the value of the first invocation. The `func` is
+ * invoked with the `this` binding and arguments of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var initialize = _.once(createApplication);
+ * initialize();
+ * initialize();
+ * // => `createApplication` is invoked once
+ */
+ function once(func) {
+ return before(2, func);
+ }
+
+ /**
+ * Creates a function that invokes `func` with its arguments transformed.
+ *
+ * @static
+ * @since 4.0.0
+ * @memberOf _
+ * @category Function
+ * @param {Function} func The function to wrap.
+ * @param {...(Function|Function[])} [transforms=[_.identity]]
+ * The argument transforms.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * function doubled(n) {
+ * return n * 2;
+ * }
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var func = _.overArgs(function(x, y) {
+ * return [x, y];
+ * }, [square, doubled]);
+ *
+ * func(9, 3);
+ * // => [81, 6]
+ *
+ * func(10, 5);
+ * // => [100, 10]
+ */
+ var overArgs = castRest(function(func, transforms) {
+ transforms = (transforms.length == 1 && isArray(transforms[0]))
+ ? arrayMap(transforms[0], baseUnary(getIteratee()))
+ : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
+
+ var funcsLength = transforms.length;
+ return baseRest(function(args) {
+ var index = -1,
+ length = nativeMin(args.length, funcsLength);
+
+ while (++index < length) {
+ args[index] = transforms[index].call(this, args[index]);
+ }
+ return apply(func, this, args);
+ });
+ });
+
+ /**
+ * Creates a function that invokes `func` with `partials` prepended to the
+ * arguments it receives. This method is like `_.bind` except it does **not**
+ * alter the `this` binding.
+ *
+ * The `_.partial.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of partially
+ * applied functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.2.0
+ * @category Function
+ * @param {Function} func The function to partially apply arguments to.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new partially applied function.
+ * @example
+ *
+ * function greet(greeting, name) {
+ * return greeting + ' ' + name;
+ * }
+ *
+ * var sayHelloTo = _.partial(greet, 'hello');
+ * sayHelloTo('fred');
+ * // => 'hello fred'
+ *
+ * // Partially applied with placeholders.
+ * var greetFred = _.partial(greet, _, 'fred');
+ * greetFred('hi');
+ * // => 'hi fred'
+ */
+ var partial = baseRest(function(func, partials) {
+ var holders = replaceHolders(partials, getHolder(partial));
+ return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
+ });
+
+ /**
+ * This method is like `_.partial` except that partially applied arguments
+ * are appended to the arguments it receives.
+ *
+ * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of partially
+ * applied functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Function
+ * @param {Function} func The function to partially apply arguments to.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new partially applied function.
+ * @example
+ *
+ * function greet(greeting, name) {
+ * return greeting + ' ' + name;
+ * }
+ *
+ * var greetFred = _.partialRight(greet, 'fred');
+ * greetFred('hi');
+ * // => 'hi fred'
+ *
+ * // Partially applied with placeholders.
+ * var sayHelloTo = _.partialRight(greet, 'hello', _);
+ * sayHelloTo('fred');
+ * // => 'hello fred'
+ */
+ var partialRight = baseRest(function(func, partials) {
+ var holders = replaceHolders(partials, getHolder(partialRight));
+ return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
+ });
+
+ /**
+ * Creates a function that invokes `func` with arguments arranged according
+ * to the specified `indexes` where the argument value at the first index is
+ * provided as the first argument, the argument value at the second index is
+ * provided as the second argument, and so on.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to rearrange arguments for.
+ * @param {...(number|number[])} indexes The arranged argument indexes.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var rearged = _.rearg(function(a, b, c) {
+ * return [a, b, c];
+ * }, [2, 0, 1]);
+ *
+ * rearged('b', 'c', 'a')
+ * // => ['a', 'b', 'c']
+ */
+ var rearg = flatRest(function(func, indexes) {
+ return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
+ });
+
+ /**
+ * Creates a function that invokes `func` with the `this` binding of the
+ * created function and arguments from `start` and beyond provided as
+ * an array.
+ *
+ * **Note:** This method is based on the
+ * [rest parameter](https://mdn.io/rest_parameters).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var say = _.rest(function(what, names) {
+ * return what + ' ' + _.initial(names).join(', ') +
+ * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
+ * });
+ *
+ * say('hello', 'fred', 'barney', 'pebbles');
+ * // => 'hello fred, barney, & pebbles'
+ */
+ function rest(func, start) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ start = start === undefined ? start : toInteger(start);
+ return baseRest(func, start);
+ }
+
+ /**
+ * Creates a function that invokes `func` with the `this` binding of the
+ * create function and an array of arguments much like
+ * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
+ *
+ * **Note:** This method is based on the
+ * [spread operator](https://mdn.io/spread_operator).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Function
+ * @param {Function} func The function to spread arguments over.
+ * @param {number} [start=0] The start position of the spread.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var say = _.spread(function(who, what) {
+ * return who + ' says ' + what;
+ * });
+ *
+ * say(['fred', 'hello']);
+ * // => 'fred says hello'
+ *
+ * var numbers = Promise.all([
+ * Promise.resolve(40),
+ * Promise.resolve(36)
+ * ]);
+ *
+ * numbers.then(_.spread(function(x, y) {
+ * return x + y;
+ * }));
+ * // => a Promise of 76
+ */
+ function spread(func, start) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
+ return baseRest(function(args) {
+ var array = args[start],
+ otherArgs = castSlice(args, 0, start);
+
+ if (array) {
+ arrayPush(otherArgs, array);
+ }
+ return apply(func, this, otherArgs);
+ });
+ }
+
+ /**
+ * Creates a throttled function that only invokes `func` at most once per
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
+ * method to cancel delayed `func` invocations and a `flush` method to
+ * immediately invoke them. Provide `options` to indicate whether `func`
+ * should be invoked on the leading and/or trailing edge of the `wait`
+ * timeout. The `func` is invoked with the last arguments provided to the
+ * throttled function. Subsequent calls to the throttled function return the
+ * result of the last `func` invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the throttled function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.throttle` and `_.debounce`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to throttle.
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=true]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new throttled function.
+ * @example
+ *
+ * // Avoid excessively updating the position while scrolling.
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
+ *
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
+ * jQuery(element).on('click', throttled);
+ *
+ * // Cancel the trailing throttled invocation.
+ * jQuery(window).on('popstate', throttled.cancel);
+ */
+ function throttle(func, wait, options) {
+ var leading = true,
+ trailing = true;
+
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ if (isObject(options)) {
+ leading = 'leading' in options ? !!options.leading : leading;
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
+ }
+ return debounce(func, wait, {
+ 'leading': leading,
+ 'maxWait': wait,
+ 'trailing': trailing
+ });
+ }
+
+ /**
+ * Creates a function that accepts up to one argument, ignoring any
+ * additional arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ * @example
+ *
+ * _.map(['6', '8', '10'], _.unary(parseInt));
+ * // => [6, 8, 10]
+ */
+ function unary(func) {
+ return ary(func, 1);
+ }
+
+ /**
+ * Creates a function that provides `value` to `wrapper` as its first
+ * argument. Any additional arguments provided to the function are appended
+ * to those provided to the `wrapper`. The wrapper is invoked with the `this`
+ * binding of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {*} value The value to wrap.
+ * @param {Function} [wrapper=identity] The wrapper function.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var p = _.wrap(_.escape, function(func, text) {
+ * return '<p>' + func(text) + '</p>';
+ * });
+ *
+ * p('fred, barney, & pebbles');
+ * // => '<p>fred, barney, &amp; pebbles</p>'
+ */
+ function wrap(value, wrapper) {
+ return partial(castFunction(wrapper), value);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Casts `value` as an array if it's not one.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.4.0
+ * @category Lang
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the cast array.
+ * @example
+ *
+ * _.castArray(1);
+ * // => [1]
+ *
+ * _.castArray({ 'a': 1 });
+ * // => [{ 'a': 1 }]
+ *
+ * _.castArray('abc');
+ * // => ['abc']
+ *
+ * _.castArray(null);
+ * // => [null]
+ *
+ * _.castArray(undefined);
+ * // => [undefined]
+ *
+ * _.castArray();
+ * // => []
+ *
+ * var array = [1, 2, 3];
+ * console.log(_.castArray(array) === array);
+ * // => true
+ */
+ function castArray() {
+ if (!arguments.length) {
+ return [];
+ }
+ var value = arguments[0];
+ return isArray(value) ? value : [value];
+ }
+
+ /**
+ * Creates a shallow clone of `value`.
+ *
+ * **Note:** This method is loosely based on the
+ * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
+ * and supports cloning arrays, array buffers, booleans, date objects, maps,
+ * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
+ * arrays. The own enumerable properties of `arguments` objects are cloned
+ * as plain objects. An empty object is returned for uncloneable values such
+ * as error objects, functions, DOM nodes, and WeakMaps.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to clone.
+ * @returns {*} Returns the cloned value.
+ * @see _.cloneDeep
+ * @example
+ *
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
+ *
+ * var shallow = _.clone(objects);
+ * console.log(shallow[0] === objects[0]);
+ * // => true
+ */
+ function clone(value) {
+ return baseClone(value, CLONE_SYMBOLS_FLAG);
+ }
+
+ /**
+ * This method is like `_.clone` except that it accepts `customizer` which
+ * is invoked to produce the cloned value. If `customizer` returns `undefined`,
+ * cloning is handled by the method instead. The `customizer` is invoked with
+ * up to four arguments; (value [, index|key, object, stack]).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to clone.
+ * @param {Function} [customizer] The function to customize cloning.
+ * @returns {*} Returns the cloned value.
+ * @see _.cloneDeepWith
+ * @example
+ *
+ * function customizer(value) {
+ * if (_.isElement(value)) {
+ * return value.cloneNode(false);
+ * }
+ * }
+ *
+ * var el = _.cloneWith(document.body, customizer);
+ *
+ * console.log(el === document.body);
+ * // => false
+ * console.log(el.nodeName);
+ * // => 'BODY'
+ * console.log(el.childNodes.length);
+ * // => 0
+ */
+ function cloneWith(value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
+ }
+
+ /**
+ * This method is like `_.clone` except that it recursively clones `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Lang
+ * @param {*} value The value to recursively clone.
+ * @returns {*} Returns the deep cloned value.
+ * @see _.clone
+ * @example
+ *
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
+ *
+ * var deep = _.cloneDeep(objects);
+ * console.log(deep[0] === objects[0]);
+ * // => false
+ */
+ function cloneDeep(value) {
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
+ }
+
+ /**
+ * This method is like `_.cloneWith` except that it recursively clones `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to recursively clone.
+ * @param {Function} [customizer] The function to customize cloning.
+ * @returns {*} Returns the deep cloned value.
+ * @see _.cloneWith
+ * @example
+ *
+ * function customizer(value) {
+ * if (_.isElement(value)) {
+ * return value.cloneNode(true);
+ * }
+ * }
+ *
+ * var el = _.cloneDeepWith(document.body, customizer);
+ *
+ * console.log(el === document.body);
+ * // => false
+ * console.log(el.nodeName);
+ * // => 'BODY'
+ * console.log(el.childNodes.length);
+ * // => 20
+ */
+ function cloneDeepWith(value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
+ }
+
+ /**
+ * Checks if `object` conforms to `source` by invoking the predicate
+ * properties of `source` with the corresponding property values of `object`.
+ *
+ * **Note:** This method is equivalent to `_.conforms` when `source` is
+ * partially applied.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
+ * // => true
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
+ * // => false
+ */
+ function conformsTo(object, source) {
+ return source == null || baseConformsTo(object, source, keys(source));
+ }
+
+ /**
+ * Performs a
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * comparison between two values to determine if they are equivalent.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.eq(object, object);
+ * // => true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+ function eq(value, other) {
+ return value === other || (value !== value && other !== other);
+ }
+
+ /**
+ * Checks if `value` is greater than `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than `other`,
+ * else `false`.
+ * @see _.lt
+ * @example
+ *
+ * _.gt(3, 1);
+ * // => true
+ *
+ * _.gt(3, 3);
+ * // => false
+ *
+ * _.gt(1, 3);
+ * // => false
+ */
+ var gt = createRelationalOperation(baseGt);
+
+ /**
+ * Checks if `value` is greater than or equal to `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is greater than or equal to
+ * `other`, else `false`.
+ * @see _.lte
+ * @example
+ *
+ * _.gte(3, 1);
+ * // => true
+ *
+ * _.gte(3, 3);
+ * // => true
+ *
+ * _.gte(1, 3);
+ * // => false
+ */
+ var gte = createRelationalOperation(function(value, other) {
+ return value >= other;
+ });
+
+ /**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+ };
+
+ /**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+ var isArray = Array.isArray;
+
+ /**
+ * Checks if `value` is classified as an `ArrayBuffer` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
+ * @example
+ *
+ * _.isArrayBuffer(new ArrayBuffer(2));
+ * // => true
+ *
+ * _.isArrayBuffer(new Array(2));
+ * // => false
+ */
+ var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
+
+ /**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+ function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+ }
+
+ /**
+ * This method is like `_.isArrayLike` except that it also checks if `value`
+ * is an object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
+ * else `false`.
+ * @example
+ *
+ * _.isArrayLikeObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLikeObject(document.body.children);
+ * // => true
+ *
+ * _.isArrayLikeObject('abc');
+ * // => false
+ *
+ * _.isArrayLikeObject(_.noop);
+ * // => false
+ */
+ function isArrayLikeObject(value) {
+ return isObjectLike(value) && isArrayLike(value);
+ }
+
+ /**
+ * Checks if `value` is classified as a boolean primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
+ * @example
+ *
+ * _.isBoolean(false);
+ * // => true
+ *
+ * _.isBoolean(null);
+ * // => false
+ */
+ function isBoolean(value) {
+ return value === true || value === false ||
+ (isObjectLike(value) && baseGetTag(value) == boolTag);
+ }
+
+ /**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+ var isBuffer = nativeIsBuffer || stubFalse;
+
+ /**
+ * Checks if `value` is classified as a `Date` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ * @example
+ *
+ * _.isDate(new Date);
+ * // => true
+ *
+ * _.isDate('Mon April 23 2012');
+ * // => false
+ */
+ var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
+
+ /**
+ * Checks if `value` is likely a DOM element.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
+ * @example
+ *
+ * _.isElement(document.body);
+ * // => true
+ *
+ * _.isElement('<body>');
+ * // => false
+ */
+ function isElement(value) {
+ return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
+ }
+
+ /**
+ * Checks if `value` is an empty object, collection, map, or set.
+ *
+ * Objects are considered empty if they have no own enumerable string keyed
+ * properties.
+ *
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
+ * @example
+ *
+ * _.isEmpty(null);
+ * // => true
+ *
+ * _.isEmpty(true);
+ * // => true
+ *
+ * _.isEmpty(1);
+ * // => true
+ *
+ * _.isEmpty([1, 2, 3]);
+ * // => false
+ *
+ * _.isEmpty({ 'a': 1 });
+ * // => false
+ */
+ function isEmpty(value) {
+ if (value == null) {
+ return true;
+ }
+ if (isArrayLike(value) &&
+ (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
+ isBuffer(value) || isTypedArray(value) || isArguments(value))) {
+ return !value.length;
+ }
+ var tag = getTag(value);
+ if (tag == mapTag || tag == setTag) {
+ return !value.size;
+ }
+ if (isPrototype(value)) {
+ return !baseKeys(value).length;
+ }
+ for (var key in value) {
+ if (hasOwnProperty.call(value, key)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Performs a deep comparison between two values to determine if they are
+ * equivalent.
+ *
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
+ * by their own, not inherited, enumerable properties. Functions and DOM
+ * nodes are **not** supported.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.isEqual(object, other);
+ * // => true
+ *
+ * object === other;
+ * // => false
+ */
+ function isEqual(value, other) {
+ return baseIsEqual(value, other);
+ }
+
+ /**
+ * This method is like `_.isEqual` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined`, comparisons
+ * are handled by the method instead. The `customizer` is invoked with up to
+ * six arguments: (objValue, othValue [, index|key, object, other, stack]).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * function isGreeting(value) {
+ * return /^h(?:i|ello)$/.test(value);
+ * }
+ *
+ * function customizer(objValue, othValue) {
+ * if (isGreeting(objValue) && isGreeting(othValue)) {
+ * return true;
+ * }
+ * }
+ *
+ * var array = ['hello', 'goodbye'];
+ * var other = ['hi', 'goodbye'];
+ *
+ * _.isEqualWith(array, other, customizer);
+ * // => true
+ */
+ function isEqualWith(value, other, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ var result = customizer ? customizer(value, other) : undefined;
+ return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
+ }
+
+ /**
+ * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
+ * `SyntaxError`, `TypeError`, or `URIError` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
+ * @example
+ *
+ * _.isError(new Error);
+ * // => true
+ *
+ * _.isError(Error);
+ * // => false
+ */
+ function isError(value) {
+ if (!isObjectLike(value)) {
+ return false;
+ }
+ var tag = baseGetTag(value);
+ return tag == errorTag || tag == domExcTag ||
+ (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
+ }
+
+ /**
+ * Checks if `value` is a finite primitive number.
+ *
+ * **Note:** This method is based on
+ * [`Number.isFinite`](https://mdn.io/Number/isFinite).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
+ * @example
+ *
+ * _.isFinite(3);
+ * // => true
+ *
+ * _.isFinite(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isFinite(Infinity);
+ * // => false
+ *
+ * _.isFinite('3');
+ * // => false
+ */
+ function isFinite(value) {
+ return typeof value == 'number' && nativeIsFinite(value);
+ }
+
+ /**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+ function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+ }
+
+ /**
+ * Checks if `value` is an integer.
+ *
+ * **Note:** This method is based on
+ * [`Number.isInteger`](https://mdn.io/Number/isInteger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
+ * @example
+ *
+ * _.isInteger(3);
+ * // => true
+ *
+ * _.isInteger(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isInteger(Infinity);
+ * // => false
+ *
+ * _.isInteger('3');
+ * // => false
+ */
+ function isInteger(value) {
+ return typeof value == 'number' && value == toInteger(value);
+ }
+
+ /**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+ function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ }
+
+ /**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+ function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+ }
+
+ /**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+ function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+ }
+
+ /**
+ * Checks if `value` is classified as a `Map` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ * @example
+ *
+ * _.isMap(new Map);
+ * // => true
+ *
+ * _.isMap(new WeakMap);
+ * // => false
+ */
+ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
+
+ /**
+ * Performs a partial deep comparison between `object` and `source` to
+ * determine if `object` contains equivalent property values.
+ *
+ * **Note:** This method is equivalent to `_.matches` when `source` is
+ * partially applied.
+ *
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ *
+ * _.isMatch(object, { 'b': 2 });
+ * // => true
+ *
+ * _.isMatch(object, { 'b': 1 });
+ * // => false
+ */
+ function isMatch(object, source) {
+ return object === source || baseIsMatch(object, source, getMatchData(source));
+ }
+
+ /**
+ * This method is like `_.isMatch` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined`, comparisons
+ * are handled by the method instead. The `customizer` is invoked with five
+ * arguments: (objValue, srcValue, index|key, object, source).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property values to match.
+ * @param {Function} [customizer] The function to customize comparisons.
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
+ * @example
+ *
+ * function isGreeting(value) {
+ * return /^h(?:i|ello)$/.test(value);
+ * }
+ *
+ * function customizer(objValue, srcValue) {
+ * if (isGreeting(objValue) && isGreeting(srcValue)) {
+ * return true;
+ * }
+ * }
+ *
+ * var object = { 'greeting': 'hello' };
+ * var source = { 'greeting': 'hi' };
+ *
+ * _.isMatchWith(object, source, customizer);
+ * // => true
+ */
+ function isMatchWith(object, source, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseIsMatch(object, source, getMatchData(source), customizer);
+ }
+
+ /**
+ * Checks if `value` is `NaN`.
+ *
+ * **Note:** This method is based on
+ * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
+ * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
+ * `undefined` and other non-number values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ * @example
+ *
+ * _.isNaN(NaN);
+ * // => true
+ *
+ * _.isNaN(new Number(NaN));
+ * // => true
+ *
+ * isNaN(undefined);
+ * // => true
+ *
+ * _.isNaN(undefined);
+ * // => false
+ */
+ function isNaN(value) {
+ // An `NaN` primitive is the only value that is not equal to itself.
+ // Perform the `toStringTag` check first to avoid errors with some
+ // ActiveX objects in IE.
+ return isNumber(value) && value != +value;
+ }
+
+ /**
+ * Checks if `value` is a pristine native function.
+ *
+ * **Note:** This method can't reliably detect native functions in the presence
+ * of the core-js package because core-js circumvents this kind of detection.
+ * Despite multiple requests, the core-js maintainer has made it clear: any
+ * attempt to fix the detection will be obstructed. As a result, we're left
+ * with little choice but to throw an error. Unfortunately, this also affects
+ * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
+ * which rely on core-js.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ * @example
+ *
+ * _.isNative(Array.prototype.push);
+ * // => true
+ *
+ * _.isNative(_);
+ * // => false
+ */
+ function isNative(value) {
+ if (isMaskable(value)) {
+ throw new Error(CORE_ERROR_TEXT);
+ }
+ return baseIsNative(value);
+ }
+
+ /**
+ * Checks if `value` is `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
+ * @example
+ *
+ * _.isNull(null);
+ * // => true
+ *
+ * _.isNull(void 0);
+ * // => false
+ */
+ function isNull(value) {
+ return value === null;
+ }
+
+ /**
+ * Checks if `value` is `null` or `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
+ * @example
+ *
+ * _.isNil(null);
+ * // => true
+ *
+ * _.isNil(void 0);
+ * // => true
+ *
+ * _.isNil(NaN);
+ * // => false
+ */
+ function isNil(value) {
+ return value == null;
+ }
+
+ /**
+ * Checks if `value` is classified as a `Number` primitive or object.
+ *
+ * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
+ * classified as numbers, use the `_.isFinite` method.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a number, else `false`.
+ * @example
+ *
+ * _.isNumber(3);
+ * // => true
+ *
+ * _.isNumber(Number.MIN_VALUE);
+ * // => true
+ *
+ * _.isNumber(Infinity);
+ * // => true
+ *
+ * _.isNumber('3');
+ * // => false
+ */
+ function isNumber(value) {
+ return typeof value == 'number' ||
+ (isObjectLike(value) && baseGetTag(value) == numberTag);
+ }
+
+ /**
+ * Checks if `value` is a plain object, that is, an object created by the
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.8.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * _.isPlainObject(new Foo);
+ * // => false
+ *
+ * _.isPlainObject([1, 2, 3]);
+ * // => false
+ *
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
+ * // => true
+ *
+ * _.isPlainObject(Object.create(null));
+ * // => true
+ */
+ function isPlainObject(value) {
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
+ return false;
+ }
+ var proto = getPrototype(value);
+ if (proto === null) {
+ return true;
+ }
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
+ funcToString.call(Ctor) == objectCtorString;
+ }
+
+ /**
+ * Checks if `value` is classified as a `RegExp` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ * @example
+ *
+ * _.isRegExp(/abc/);
+ * // => true
+ *
+ * _.isRegExp('/abc/');
+ * // => false
+ */
+ var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
+
+ /**
+ * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
+ * double precision number which isn't the result of a rounded unsafe integer.
+ *
+ * **Note:** This method is based on
+ * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
+ * @example
+ *
+ * _.isSafeInteger(3);
+ * // => true
+ *
+ * _.isSafeInteger(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isSafeInteger(Infinity);
+ * // => false
+ *
+ * _.isSafeInteger('3');
+ * // => false
+ */
+ function isSafeInteger(value) {
+ return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
+ }
+
+ /**
+ * Checks if `value` is classified as a `Set` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ * @example
+ *
+ * _.isSet(new Set);
+ * // => true
+ *
+ * _.isSet(new WeakSet);
+ * // => false
+ */
+ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
+
+ /**
+ * Checks if `value` is classified as a `String` primitive or object.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
+ * @example
+ *
+ * _.isString('abc');
+ * // => true
+ *
+ * _.isString(1);
+ * // => false
+ */
+ function isString(value) {
+ return typeof value == 'string' ||
+ (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
+ }
+
+ /**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+ function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
+ }
+
+ /**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+ /**
+ * Checks if `value` is `undefined`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
+ * @example
+ *
+ * _.isUndefined(void 0);
+ * // => true
+ *
+ * _.isUndefined(null);
+ * // => false
+ */
+ function isUndefined(value) {
+ return value === undefined;
+ }
+
+ /**
+ * Checks if `value` is classified as a `WeakMap` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
+ * @example
+ *
+ * _.isWeakMap(new WeakMap);
+ * // => true
+ *
+ * _.isWeakMap(new Map);
+ * // => false
+ */
+ function isWeakMap(value) {
+ return isObjectLike(value) && getTag(value) == weakMapTag;
+ }
+
+ /**
+ * Checks if `value` is classified as a `WeakSet` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
+ * @example
+ *
+ * _.isWeakSet(new WeakSet);
+ * // => true
+ *
+ * _.isWeakSet(new Set);
+ * // => false
+ */
+ function isWeakSet(value) {
+ return isObjectLike(value) && baseGetTag(value) == weakSetTag;
+ }
+
+ /**
+ * Checks if `value` is less than `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than `other`,
+ * else `false`.
+ * @see _.gt
+ * @example
+ *
+ * _.lt(1, 3);
+ * // => true
+ *
+ * _.lt(3, 3);
+ * // => false
+ *
+ * _.lt(3, 1);
+ * // => false
+ */
+ var lt = createRelationalOperation(baseLt);
+
+ /**
+ * Checks if `value` is less than or equal to `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than or equal to
+ * `other`, else `false`.
+ * @see _.gte
+ * @example
+ *
+ * _.lte(1, 3);
+ * // => true
+ *
+ * _.lte(3, 3);
+ * // => true
+ *
+ * _.lte(3, 1);
+ * // => false
+ */
+ var lte = createRelationalOperation(function(value, other) {
+ return value <= other;
+ });
+
+ /**
+ * Converts `value` to an array.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Array} Returns the converted array.
+ * @example
+ *
+ * _.toArray({ 'a': 1, 'b': 2 });
+ * // => [1, 2]
+ *
+ * _.toArray('abc');
+ * // => ['a', 'b', 'c']
+ *
+ * _.toArray(1);
+ * // => []
+ *
+ * _.toArray(null);
+ * // => []
+ */
+ function toArray(value) {
+ if (!value) {
+ return [];
+ }
+ if (isArrayLike(value)) {
+ return isString(value) ? stringToArray(value) : copyArray(value);
+ }
+ if (symIterator && value[symIterator]) {
+ return iteratorToArray(value[symIterator]());
+ }
+ var tag = getTag(value),
+ func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
+
+ return func(value);
+ }
+
+ /**
+ * Converts `value` to a finite number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.12.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted number.
+ * @example
+ *
+ * _.toFinite(3.2);
+ * // => 3.2
+ *
+ * _.toFinite(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toFinite(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toFinite('3.2');
+ * // => 3.2
+ */
+ function toFinite(value) {
+ if (!value) {
+ return value === 0 ? value : 0;
+ }
+ value = toNumber(value);
+ if (value === INFINITY || value === -INFINITY) {
+ var sign = (value < 0 ? -1 : 1);
+ return sign * MAX_INTEGER;
+ }
+ return value === value ? value : 0;
+ }
+
+ /**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3.2);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3.2');
+ * // => 3
+ */
+ function toInteger(value) {
+ var result = toFinite(value),
+ remainder = result % 1;
+
+ return result === result ? (remainder ? result - remainder : result) : 0;
+ }
+
+ /**
+ * Converts `value` to an integer suitable for use as the length of an
+ * array-like object.
+ *
+ * **Note:** This method is based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toLength(3.2);
+ * // => 3
+ *
+ * _.toLength(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toLength(Infinity);
+ * // => 4294967295
+ *
+ * _.toLength('3.2');
+ * // => 3
+ */
+ function toLength(value) {
+ return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
+ }
+
+ /**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3.2);
+ * // => 3.2
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3.2');
+ * // => 3.2
+ */
+ function toNumber(value) {
+ if (typeof value == 'number') {
+ return value;
+ }
+ if (isSymbol(value)) {
+ return NAN;
+ }
+ if (isObject(value)) {
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
+ value = isObject(other) ? (other + '') : other;
+ }
+ if (typeof value != 'string') {
+ return value === 0 ? value : +value;
+ }
+ value = value.replace(reTrim, '');
+ var isBinary = reIsBinary.test(value);
+ return (isBinary || reIsOctal.test(value))
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
+ : (reIsBadHex.test(value) ? NAN : +value);
+ }
+
+ /**
+ * Converts `value` to a plain object flattening inherited enumerable string
+ * keyed properties of `value` to own properties of the plain object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Object} Returns the converted plain object.
+ * @example
+ *
+ * function Foo() {
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.assign({ 'a': 1 }, new Foo);
+ * // => { 'a': 1, 'b': 2 }
+ *
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
+ */
+ function toPlainObject(value) {
+ return copyObject(value, keysIn(value));
+ }
+
+ /**
+ * Converts `value` to a safe integer. A safe integer can be compared and
+ * represented correctly.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toSafeInteger(3.2);
+ * // => 3
+ *
+ * _.toSafeInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toSafeInteger(Infinity);
+ * // => 9007199254740991
+ *
+ * _.toSafeInteger('3.2');
+ * // => 3
+ */
+ function toSafeInteger(value) {
+ return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
+ }
+
+ /**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+ function toString(value) {
+ return value == null ? '' : baseToString(value);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Assigns own enumerable string keyed properties of source objects to the
+ * destination object. Source objects are applied from left to right.
+ * Subsequent sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object` and is loosely based on
+ * [`Object.assign`](https://mdn.io/Object/assign).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assignIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ var assign = createAssigner(function(object, source) {
+ if (isPrototype(source) || isArrayLike(source)) {
+ copyObject(source, keys(source), object);
+ return;
+ }
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ assignValue(object, key, source[key]);
+ }
+ }
+ });
+
+ /**
+ * This method is like `_.assign` except that it iterates over own and
+ * inherited source properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extend
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assign
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assignIn({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
+ */
+ var assignIn = createAssigner(function(object, source) {
+ copyObject(source, keysIn(source), object);
+ });
+
+ /**
+ * This method is like `_.assignIn` except that it accepts `customizer`
+ * which is invoked to produce the assigned values. If `customizer` returns
+ * `undefined`, assignment is handled by the method instead. The `customizer`
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias extendWith
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @see _.assignWith
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * return _.isUndefined(objValue) ? srcValue : objValue;
+ * }
+ *
+ * var defaults = _.partialRight(_.assignInWith, customizer);
+ *
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+ var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
+ copyObject(source, keysIn(source), object, customizer);
+ });
+
+ /**
+ * This method is like `_.assign` except that it accepts `customizer`
+ * which is invoked to produce the assigned values. If `customizer` returns
+ * `undefined`, assignment is handled by the method instead. The `customizer`
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @see _.assignInWith
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * return _.isUndefined(objValue) ? srcValue : objValue;
+ * }
+ *
+ * var defaults = _.partialRight(_.assignWith, customizer);
+ *
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+ var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
+ copyObject(source, keys(source), object, customizer);
+ });
+
+ /**
+ * Creates an array of values corresponding to `paths` of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Array} Returns the picked values.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
+ *
+ * _.at(object, ['a[0].b.c', 'a[1]']);
+ * // => [3, 4]
+ */
+ var at = flatRest(baseAt);
+
+ /**
+ * Creates an object that inherits from the `prototype` object. If a
+ * `properties` object is given, its own enumerable string keyed properties
+ * are assigned to the created object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Object
+ * @param {Object} prototype The object to inherit from.
+ * @param {Object} [properties] The properties to assign to the object.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * function Shape() {
+ * this.x = 0;
+ * this.y = 0;
+ * }
+ *
+ * function Circle() {
+ * Shape.call(this);
+ * }
+ *
+ * Circle.prototype = _.create(Shape.prototype, {
+ * 'constructor': Circle
+ * });
+ *
+ * var circle = new Circle;
+ * circle instanceof Circle;
+ * // => true
+ *
+ * circle instanceof Shape;
+ * // => true
+ */
+ function create(prototype, properties) {
+ var result = baseCreate(prototype);
+ return properties == null ? result : baseAssign(result, properties);
+ }
+
+ /**
+ * Assigns own and inherited enumerable string keyed properties of source
+ * objects to the destination object for all destination properties that
+ * resolve to `undefined`. Source objects are applied from left to right.
+ * Once a property is set, additional values of the same property are ignored.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.defaultsDeep
+ * @example
+ *
+ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
+ */
+ var defaults = baseRest(function(args) {
+ args.push(undefined, assignInDefaults);
+ return apply(assignInWith, undefined, args);
+ });
+
+ /**
+ * This method is like `_.defaults` except that it recursively assigns
+ * default properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.defaults
+ * @example
+ *
+ * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
+ * // => { 'a': { 'b': 2, 'c': 3 } }
+ */
+ var defaultsDeep = baseRest(function(args) {
+ args.push(undefined, mergeDefaults);
+ return apply(mergeWith, undefined, args);
+ });
+
+ /**
+ * This method is like `_.find` except that it returns the key of the first
+ * element `predicate` returns truthy for instead of the element itself.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {string|undefined} Returns the key of the matched element,
+ * else `undefined`.
+ * @example
+ *
+ * var users = {
+ * 'barney': { 'age': 36, 'active': true },
+ * 'fred': { 'age': 40, 'active': false },
+ * 'pebbles': { 'age': 1, 'active': true }
+ * };
+ *
+ * _.findKey(users, function(o) { return o.age < 40; });
+ * // => 'barney' (iteration order is not guaranteed)
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findKey(users, { 'age': 1, 'active': true });
+ * // => 'pebbles'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findKey(users, ['active', false]);
+ * // => 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findKey(users, 'active');
+ * // => 'barney'
+ */
+ function findKey(object, predicate) {
+ return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
+ }
+
+ /**
+ * This method is like `_.findKey` except that it iterates over elements of
+ * a collection in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {string|undefined} Returns the key of the matched element,
+ * else `undefined`.
+ * @example
+ *
+ * var users = {
+ * 'barney': { 'age': 36, 'active': true },
+ * 'fred': { 'age': 40, 'active': false },
+ * 'pebbles': { 'age': 1, 'active': true }
+ * };
+ *
+ * _.findLastKey(users, function(o) { return o.age < 40; });
+ * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.findLastKey(users, { 'age': 36, 'active': true });
+ * // => 'barney'
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.findLastKey(users, ['active', false]);
+ * // => 'fred'
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.findLastKey(users, 'active');
+ * // => 'pebbles'
+ */
+ function findLastKey(object, predicate) {
+ return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
+ }
+
+ /**
+ * Iterates over own and inherited enumerable string keyed properties of an
+ * object and invokes `iteratee` for each property. The iteratee is invoked
+ * with three arguments: (value, key, object). Iteratee functions may exit
+ * iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forInRight
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forIn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
+ */
+ function forIn(object, iteratee) {
+ return object == null
+ ? object
+ : baseFor(object, getIteratee(iteratee, 3), keysIn);
+ }
+
+ /**
+ * This method is like `_.forIn` except that it iterates over properties of
+ * `object` in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forInRight(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
+ */
+ function forInRight(object, iteratee) {
+ return object == null
+ ? object
+ : baseForRight(object, getIteratee(iteratee, 3), keysIn);
+ }
+
+ /**
+ * Iterates over own enumerable string keyed properties of an object and
+ * invokes `iteratee` for each property. The iteratee is invoked with three
+ * arguments: (value, key, object). Iteratee functions may exit iteration
+ * early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forOwnRight
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forOwn(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'a' then 'b' (iteration order is not guaranteed).
+ */
+ function forOwn(object, iteratee) {
+ return object && baseForOwn(object, getIteratee(iteratee, 3));
+ }
+
+ /**
+ * This method is like `_.forOwn` except that it iterates over properties of
+ * `object` in the opposite order.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ * @see _.forOwn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.forOwnRight(new Foo, function(value, key) {
+ * console.log(key);
+ * });
+ * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
+ */
+ function forOwnRight(object, iteratee) {
+ return object && baseForOwnRight(object, getIteratee(iteratee, 3));
+ }
+
+ /**
+ * Creates an array of function property names from own enumerable properties
+ * of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @returns {Array} Returns the function names.
+ * @see _.functionsIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = _.constant('a');
+ * this.b = _.constant('b');
+ * }
+ *
+ * Foo.prototype.c = _.constant('c');
+ *
+ * _.functions(new Foo);
+ * // => ['a', 'b']
+ */
+ function functions(object) {
+ return object == null ? [] : baseFunctions(object, keys(object));
+ }
+
+ /**
+ * Creates an array of function property names from own and inherited
+ * enumerable properties of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to inspect.
+ * @returns {Array} Returns the function names.
+ * @see _.functions
+ * @example
+ *
+ * function Foo() {
+ * this.a = _.constant('a');
+ * this.b = _.constant('b');
+ * }
+ *
+ * Foo.prototype.c = _.constant('c');
+ *
+ * _.functionsIn(new Foo);
+ * // => ['a', 'b', 'c']
+ */
+ function functionsIn(object) {
+ return object == null ? [] : baseFunctions(object, keysIn(object));
+ }
+
+ /**
+ * Gets the value at `path` of `object`. If the resolved value is
+ * `undefined`, the `defaultValue` is returned in its place.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.get(object, 'a[0].b.c');
+ * // => 3
+ *
+ * _.get(object, ['a', '0', 'b', 'c']);
+ * // => 3
+ *
+ * _.get(object, 'a.b.c', 'default');
+ * // => 'default'
+ */
+ function get(object, path, defaultValue) {
+ var result = object == null ? undefined : baseGet(object, path);
+ return result === undefined ? defaultValue : result;
+ }
+
+ /**
+ * Checks if `path` is a direct property of `object`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = { 'a': { 'b': 2 } };
+ * var other = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.has(object, 'a');
+ * // => true
+ *
+ * _.has(object, 'a.b');
+ * // => true
+ *
+ * _.has(object, ['a', 'b']);
+ * // => true
+ *
+ * _.has(other, 'a');
+ * // => false
+ */
+ function has(object, path) {
+ return object != null && hasPath(object, path, baseHas);
+ }
+
+ /**
+ * Checks if `path` is a direct or inherited property of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path to check.
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
+ * @example
+ *
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
+ *
+ * _.hasIn(object, 'a');
+ * // => true
+ *
+ * _.hasIn(object, 'a.b');
+ * // => true
+ *
+ * _.hasIn(object, ['a', 'b']);
+ * // => true
+ *
+ * _.hasIn(object, 'b');
+ * // => false
+ */
+ function hasIn(object, path) {
+ return object != null && hasPath(object, path, baseHasIn);
+ }
+
+ /**
+ * Creates an object composed of the inverted keys and values of `object`.
+ * If `object` contains duplicate values, subsequent values overwrite
+ * property assignments of previous values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.7.0
+ * @category Object
+ * @param {Object} object The object to invert.
+ * @returns {Object} Returns the new inverted object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2, 'c': 1 };
+ *
+ * _.invert(object);
+ * // => { '1': 'c', '2': 'b' }
+ */
+ var invert = createInverter(function(result, value, key) {
+ result[value] = key;
+ }, constant(identity));
+
+ /**
+ * This method is like `_.invert` except that the inverted object is generated
+ * from the results of running each element of `object` thru `iteratee`. The
+ * corresponding inverted value of each inverted key is an array of keys
+ * responsible for generating the inverted value. The iteratee is invoked
+ * with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.1.0
+ * @category Object
+ * @param {Object} object The object to invert.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Object} Returns the new inverted object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2, 'c': 1 };
+ *
+ * _.invertBy(object);
+ * // => { '1': ['a', 'c'], '2': ['b'] }
+ *
+ * _.invertBy(object, function(value) {
+ * return 'group' + value;
+ * });
+ * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
+ */
+ var invertBy = createInverter(function(result, value, key) {
+ if (hasOwnProperty.call(result, value)) {
+ result[value].push(key);
+ } else {
+ result[value] = [key];
+ }
+ }, getIteratee);
+
+ /**
+ * Invokes the method at `path` of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {*} Returns the result of the invoked method.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
+ *
+ * _.invoke(object, 'a[0].b.c.slice', 1, 3);
+ * // => [2, 3]
+ */
+ var invoke = baseRest(baseInvoke);
+
+ /**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+ function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+ }
+
+ /**
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */
+ function keysIn(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
+ }
+
+ /**
+ * The opposite of `_.mapValues`; this method creates an object with the
+ * same values as `object` and keys generated by running each own enumerable
+ * string keyed property of `object` thru `iteratee`. The iteratee is invoked
+ * with three arguments: (value, key, object).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns the new mapped object.
+ * @see _.mapValues
+ * @example
+ *
+ * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
+ * return key + value;
+ * });
+ * // => { 'a1': 1, 'b2': 2 }
+ */
+ function mapKeys(object, iteratee) {
+ var result = {};
+ iteratee = getIteratee(iteratee, 3);
+
+ baseForOwn(object, function(value, key, object) {
+ baseAssignValue(result, iteratee(value, key, object), value);
+ });
+ return result;
+ }
+
+ /**
+ * Creates an object with the same keys as `object` and values generated
+ * by running each own enumerable string keyed property of `object` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, key, object).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns the new mapped object.
+ * @see _.mapKeys
+ * @example
+ *
+ * var users = {
+ * 'fred': { 'user': 'fred', 'age': 40 },
+ * 'pebbles': { 'user': 'pebbles', 'age': 1 }
+ * };
+ *
+ * _.mapValues(users, function(o) { return o.age; });
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.mapValues(users, 'age');
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ */
+ function mapValues(object, iteratee) {
+ var result = {};
+ iteratee = getIteratee(iteratee, 3);
+
+ baseForOwn(object, function(value, key, object) {
+ baseAssignValue(result, key, iteratee(value, key, object));
+ });
+ return result;
+ }
+
+ /**
+ * This method is like `_.assign` except that it recursively merges own and
+ * inherited enumerable string keyed properties of source objects into the
+ * destination object. Source properties that resolve to `undefined` are
+ * skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
+ * };
+ *
+ * var other = {
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
+ * };
+ *
+ * _.merge(object, other);
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
+ */
+ var merge = createAssigner(function(object, source, srcIndex) {
+ baseMerge(object, source, srcIndex);
+ });
+
+ /**
+ * This method is like `_.merge` except that it accepts `customizer` which
+ * is invoked to produce the merged values of the destination and source
+ * properties. If `customizer` returns `undefined`, merging is handled by the
+ * method instead. The `customizer` is invoked with six arguments:
+ * (objValue, srcValue, key, object, source, stack).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} customizer The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * if (_.isArray(objValue)) {
+ * return objValue.concat(srcValue);
+ * }
+ * }
+ *
+ * var object = { 'a': [1], 'b': [2] };
+ * var other = { 'a': [3], 'b': [4] };
+ *
+ * _.mergeWith(object, other, customizer);
+ * // => { 'a': [1, 3], 'b': [2, 4] }
+ */
+ var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
+ baseMerge(object, source, srcIndex, customizer);
+ });
+
+ /**
+ * The opposite of `_.pick`; this method creates an object composed of the
+ * own and inherited enumerable property paths of `object` that are not omitted.
+ *
+ * **Note:** This method is considerably slower than `_.pick`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to omit.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.omit(object, ['a', 'c']);
+ * // => { 'b': '2' }
+ */
+ var omit = flatRest(function(object, paths) {
+ var result = {};
+ if (object == null) {
+ return result;
+ }
+ var isDeep = false;
+ paths = arrayMap(paths, function(path) {
+ path = castPath(path, object);
+ isDeep || (isDeep = path.length > 1);
+ return path;
+ });
+ copyObject(object, getAllKeysIn(object), result);
+ if (isDeep) {
+ result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
+ }
+ var length = paths.length;
+ while (length--) {
+ baseUnset(result, paths[length]);
+ }
+ return result;
+ });
+
+ /**
+ * The opposite of `_.pickBy`; this method creates an object composed of
+ * the own and inherited enumerable string keyed properties of `object` that
+ * `predicate` doesn't return truthy for. The predicate is invoked with two
+ * arguments: (value, key).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.omitBy(object, _.isNumber);
+ * // => { 'b': '2' }
+ */
+ function omitBy(object, predicate) {
+ return pickBy(object, negate(getIteratee(predicate)));
+ }
+
+ /**
+ * Creates an object composed of the picked `object` properties.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pick(object, ['a', 'c']);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ var pick = flatRest(function(object, paths) {
+ return object == null ? {} : basePick(object, paths);
+ });
+
+ /**
+ * Creates an object composed of the `object` properties `predicate` returns
+ * truthy for. The predicate is invoked with two arguments: (value, key).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pickBy(object, _.isNumber);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ function pickBy(object, predicate) {
+ if (object == null) {
+ return {};
+ }
+ var props = arrayMap(getAllKeysIn(object), function(prop) {
+ return [prop];
+ });
+ predicate = getIteratee(predicate);
+ return basePickBy(object, props, function(value, path) {
+ return predicate(value, path[0]);
+ });
+ }
+
+ /**
+ * This method is like `_.get` except that if the resolved value is a
+ * function it's invoked with the `this` binding of its parent object and
+ * its result is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to resolve.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
+ *
+ * _.result(object, 'a[0].b.c1');
+ * // => 3
+ *
+ * _.result(object, 'a[0].b.c2');
+ * // => 4
+ *
+ * _.result(object, 'a[0].b.c3', 'default');
+ * // => 'default'
+ *
+ * _.result(object, 'a[0].b.c3', _.constant('default'));
+ * // => 'default'
+ */
+ function result(object, path, defaultValue) {
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length;
+
+ // Ensure the loop is entered when path is empty.
+ if (!length) {
+ length = 1;
+ object = undefined;
+ }
+ while (++index < length) {
+ var value = object == null ? undefined : object[toKey(path[index])];
+ if (value === undefined) {
+ index = length;
+ value = defaultValue;
+ }
+ object = isFunction(value) ? value.call(object) : value;
+ }
+ return object;
+ }
+
+ /**
+ * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
+ * it's created. Arrays are created for missing index properties while objects
+ * are created for all other missing properties. Use `_.setWith` to customize
+ * `path` creation.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.set(object, 'a[0].b.c', 4);
+ * console.log(object.a[0].b.c);
+ * // => 4
+ *
+ * _.set(object, ['x', '0', 'y', 'z'], 5);
+ * console.log(object.x[0].y.z);
+ * // => 5
+ */
+ function set(object, path, value) {
+ return object == null ? object : baseSet(object, path, value);
+ }
+
+ /**
+ * This method is like `_.set` except that it accepts `customizer` which is
+ * invoked to produce the objects of `path`. If `customizer` returns `undefined`
+ * path creation is handled by the method instead. The `customizer` is invoked
+ * with three arguments: (nsValue, key, nsObject).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {};
+ *
+ * _.setWith(object, '[0][1]', 'a', Object);
+ * // => { '0': { '1': 'a' } }
+ */
+ function setWith(object, path, value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return object == null ? object : baseSet(object, path, value, customizer);
+ }
+
+ /**
+ * Creates an array of own enumerable string keyed-value pairs for `object`
+ * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
+ * entries are returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias entries
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the key-value pairs.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.toPairs(new Foo);
+ * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
+ */
+ var toPairs = createToPairs(keys);
+
+ /**
+ * Creates an array of own and inherited enumerable string keyed-value pairs
+ * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
+ * or set, its entries are returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias entriesIn
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the key-value pairs.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.toPairsIn(new Foo);
+ * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
+ */
+ var toPairsIn = createToPairs(keysIn);
+
+ /**
+ * An alternative to `_.reduce`; this method transforms `object` to a new
+ * `accumulator` object which is the result of running each of its own
+ * enumerable string keyed properties thru `iteratee`, with each invocation
+ * potentially mutating the `accumulator` object. If `accumulator` is not
+ * provided, a new object with the same `[[Prototype]]` will be used. The
+ * iteratee is invoked with four arguments: (accumulator, value, key, object).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The custom accumulator value.
+ * @returns {*} Returns the accumulated value.
+ * @example
+ *
+ * _.transform([2, 3, 4], function(result, n) {
+ * result.push(n *= n);
+ * return n % 2 == 0;
+ * }, []);
+ * // => [4, 9]
+ *
+ * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] }
+ */
+ function transform(object, iteratee, accumulator) {
+ var isArr = isArray(object),
+ isArrLike = isArr || isBuffer(object) || isTypedArray(object);
+
+ iteratee = getIteratee(iteratee, 4);
+ if (accumulator == null) {
+ var Ctor = object && object.constructor;
+ if (isArrLike) {
+ accumulator = isArr ? new Ctor : [];
+ }
+ else if (isObject(object)) {
+ accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
+ }
+ else {
+ accumulator = {};
+ }
+ }
+ (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
+ return iteratee(accumulator, value, index, object);
+ });
+ return accumulator;
+ }
+
+ /**
+ * Removes the property at `path` of `object`.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to unset.
+ * @returns {boolean} Returns `true` if the property is deleted, else `false`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 7 } }] };
+ * _.unset(object, 'a[0].b.c');
+ * // => true
+ *
+ * console.log(object);
+ * // => { 'a': [{ 'b': {} }] };
+ *
+ * _.unset(object, ['a', '0', 'b', 'c']);
+ * // => true
+ *
+ * console.log(object);
+ * // => { 'a': [{ 'b': {} }] };
+ */
+ function unset(object, path) {
+ return object == null ? true : baseUnset(object, path);
+ }
+
+ /**
+ * This method is like `_.set` except that accepts `updater` to produce the
+ * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
+ * is invoked with one argument: (value).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {Function} updater The function to produce the updated value.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.update(object, 'a[0].b.c', function(n) { return n * n; });
+ * console.log(object.a[0].b.c);
+ * // => 9
+ *
+ * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
+ * console.log(object.x[0].y.z);
+ * // => 0
+ */
+ function update(object, path, updater) {
+ return object == null ? object : baseUpdate(object, path, castFunction(updater));
+ }
+
+ /**
+ * This method is like `_.update` except that it accepts `customizer` which is
+ * invoked to produce the objects of `path`. If `customizer` returns `undefined`
+ * path creation is handled by the method instead. The `customizer` is invoked
+ * with three arguments: (nsValue, key, nsObject).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {Function} updater The function to produce the updated value.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {};
+ *
+ * _.updateWith(object, '[0][1]', _.constant('a'), Object);
+ * // => { '0': { '1': 'a' } }
+ */
+ function updateWith(object, path, updater, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
+ }
+
+ /**
+ * Creates an array of the own enumerable string keyed property values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.values(new Foo);
+ * // => [1, 2] (iteration order is not guaranteed)
+ *
+ * _.values('hi');
+ * // => ['h', 'i']
+ */
+ function values(object) {
+ return object == null ? [] : baseValues(object, keys(object));
+ }
+
+ /**
+ * Creates an array of the own and inherited enumerable string keyed property
+ * values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.valuesIn(new Foo);
+ * // => [1, 2, 3] (iteration order is not guaranteed)
+ */
+ function valuesIn(object) {
+ return object == null ? [] : baseValues(object, keysIn(object));
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Clamps `number` within the inclusive `lower` and `upper` bounds.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Number
+ * @param {number} number The number to clamp.
+ * @param {number} [lower] The lower bound.
+ * @param {number} upper The upper bound.
+ * @returns {number} Returns the clamped number.
+ * @example
+ *
+ * _.clamp(-10, -5, 5);
+ * // => -5
+ *
+ * _.clamp(10, -5, 5);
+ * // => 5
+ */
+ function clamp(number, lower, upper) {
+ if (upper === undefined) {
+ upper = lower;
+ lower = undefined;
+ }
+ if (upper !== undefined) {
+ upper = toNumber(upper);
+ upper = upper === upper ? upper : 0;
+ }
+ if (lower !== undefined) {
+ lower = toNumber(lower);
+ lower = lower === lower ? lower : 0;
+ }
+ return baseClamp(toNumber(number), lower, upper);
+ }
+
+ /**
+ * Checks if `n` is between `start` and up to, but not including, `end`. If
+ * `end` is not specified, it's set to `start` with `start` then set to `0`.
+ * If `start` is greater than `end` the params are swapped to support
+ * negative ranges.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.3.0
+ * @category Number
+ * @param {number} number The number to check.
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
+ * @see _.range, _.rangeRight
+ * @example
+ *
+ * _.inRange(3, 2, 4);
+ * // => true
+ *
+ * _.inRange(4, 8);
+ * // => true
+ *
+ * _.inRange(4, 2);
+ * // => false
+ *
+ * _.inRange(2, 2);
+ * // => false
+ *
+ * _.inRange(1.2, 2);
+ * // => true
+ *
+ * _.inRange(5.2, 4);
+ * // => false
+ *
+ * _.inRange(-3, -2, -6);
+ * // => true
+ */
+ function inRange(number, start, end) {
+ start = toFinite(start);
+ if (end === undefined) {
+ end = start;
+ start = 0;
+ } else {
+ end = toFinite(end);
+ }
+ number = toNumber(number);
+ return baseInRange(number, start, end);
+ }
+
+ /**
+ * Produces a random number between the inclusive `lower` and `upper` bounds.
+ * If only one argument is provided a number between `0` and the given number
+ * is returned. If `floating` is `true`, or either `lower` or `upper` are
+ * floats, a floating-point number is returned instead of an integer.
+ *
+ * **Note:** JavaScript follows the IEEE-754 standard for resolving
+ * floating-point values which can produce unexpected results.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.7.0
+ * @category Number
+ * @param {number} [lower=0] The lower bound.
+ * @param {number} [upper=1] The upper bound.
+ * @param {boolean} [floating] Specify returning a floating-point number.
+ * @returns {number} Returns the random number.
+ * @example
+ *
+ * _.random(0, 5);
+ * // => an integer between 0 and 5
+ *
+ * _.random(5);
+ * // => also an integer between 0 and 5
+ *
+ * _.random(5, true);
+ * // => a floating-point number between 0 and 5
+ *
+ * _.random(1.2, 5.2);
+ * // => a floating-point number between 1.2 and 5.2
+ */
+ function random(lower, upper, floating) {
+ if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
+ upper = floating = undefined;
+ }
+ if (floating === undefined) {
+ if (typeof upper == 'boolean') {
+ floating = upper;
+ upper = undefined;
+ }
+ else if (typeof lower == 'boolean') {
+ floating = lower;
+ lower = undefined;
+ }
+ }
+ if (lower === undefined && upper === undefined) {
+ lower = 0;
+ upper = 1;
+ }
+ else {
+ lower = toFinite(lower);
+ if (upper === undefined) {
+ upper = lower;
+ lower = 0;
+ } else {
+ upper = toFinite(upper);
+ }
+ }
+ if (lower > upper) {
+ var temp = lower;
+ lower = upper;
+ upper = temp;
+ }
+ if (floating || lower % 1 || upper % 1) {
+ var rand = nativeRandom();
+ return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
+ }
+ return baseRandom(lower, upper);
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the camel cased string.
+ * @example
+ *
+ * _.camelCase('Foo Bar');
+ * // => 'fooBar'
+ *
+ * _.camelCase('--foo-bar--');
+ * // => 'fooBar'
+ *
+ * _.camelCase('__FOO_BAR__');
+ * // => 'fooBar'
+ */
+ var camelCase = createCompounder(function(result, word, index) {
+ word = word.toLowerCase();
+ return result + (index ? capitalize(word) : word);
+ });
+
+ /**
+ * Converts the first character of `string` to upper case and the remaining
+ * to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to capitalize.
+ * @returns {string} Returns the capitalized string.
+ * @example
+ *
+ * _.capitalize('FRED');
+ * // => 'Fred'
+ */
+ function capitalize(string) {
+ return upperFirst(toString(string).toLowerCase());
+ }
+
+ /**
+ * Deburrs `string` by converting
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
+ * letters to basic Latin letters and removing
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to deburr.
+ * @returns {string} Returns the deburred string.
+ * @example
+ *
+ * _.deburr('déjà vu');
+ * // => 'deja vu'
+ */
+ function deburr(string) {
+ string = toString(string);
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
+ }
+
+ /**
+ * Checks if `string` ends with the given target string.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {string} [target] The string to search for.
+ * @param {number} [position=string.length] The position to search up to.
+ * @returns {boolean} Returns `true` if `string` ends with `target`,
+ * else `false`.
+ * @example
+ *
+ * _.endsWith('abc', 'c');
+ * // => true
+ *
+ * _.endsWith('abc', 'b');
+ * // => false
+ *
+ * _.endsWith('abc', 'b', 2);
+ * // => true
+ */
+ function endsWith(string, target, position) {
+ string = toString(string);
+ target = baseToString(target);
+
+ var length = string.length;
+ position = position === undefined
+ ? length
+ : baseClamp(toInteger(position), 0, length);
+
+ var end = position;
+ position -= target.length;
+ return position >= 0 && string.slice(position, end) == target;
+ }
+
+ /**
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
+ * corresponding HTML entities.
+ *
+ * **Note:** No other characters are escaped. To escape additional
+ * characters use a third-party library like [_he_](https://mths.be/he).
+ *
+ * Though the ">" character is escaped for symmetry, characters like
+ * ">" and "/" don't need escaping in HTML and have no special meaning
+ * unless they're part of a tag or unquoted attribute value. See
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
+ * (under "semi-related fun fact") for more details.
+ *
+ * When working with HTML you should always
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
+ * XSS vectors.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escape('fred, barney, & pebbles');
+ * // => 'fred, barney, &amp; pebbles'
+ */
+ function escape(string) {
+ string = toString(string);
+ return (string && reHasUnescapedHtml.test(string))
+ ? string.replace(reUnescapedHtml, escapeHtmlChar)
+ : string;
+ }
+
+ /**
+ * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
+ * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to escape.
+ * @returns {string} Returns the escaped string.
+ * @example
+ *
+ * _.escapeRegExp('[lodash](https://lodash.com/)');
+ * // => '\[lodash\]\(https://lodash\.com/\)'
+ */
+ function escapeRegExp(string) {
+ string = toString(string);
+ return (string && reHasRegExpChar.test(string))
+ ? string.replace(reRegExpChar, '\\$&')
+ : string;
+ }
+
+ /**
+ * Converts `string` to
+ * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the kebab cased string.
+ * @example
+ *
+ * _.kebabCase('Foo Bar');
+ * // => 'foo-bar'
+ *
+ * _.kebabCase('fooBar');
+ * // => 'foo-bar'
+ *
+ * _.kebabCase('__FOO_BAR__');
+ * // => 'foo-bar'
+ */
+ var kebabCase = createCompounder(function(result, word, index) {
+ return result + (index ? '-' : '') + word.toLowerCase();
+ });
+
+ /**
+ * Converts `string`, as space separated words, to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the lower cased string.
+ * @example
+ *
+ * _.lowerCase('--Foo-Bar--');
+ * // => 'foo bar'
+ *
+ * _.lowerCase('fooBar');
+ * // => 'foo bar'
+ *
+ * _.lowerCase('__FOO_BAR__');
+ * // => 'foo bar'
+ */
+ var lowerCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + word.toLowerCase();
+ });
+
+ /**
+ * Converts the first character of `string` to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.lowerFirst('Fred');
+ * // => 'fred'
+ *
+ * _.lowerFirst('FRED');
+ * // => 'fRED'
+ */
+ var lowerFirst = createCaseFirst('toLowerCase');
+
+ /**
+ * Pads `string` on the left and right sides if it's shorter than `length`.
+ * Padding characters are truncated if they can't be evenly divided by `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.pad('abc', 8);
+ * // => ' abc '
+ *
+ * _.pad('abc', 8, '_-');
+ * // => '_-abc_-_'
+ *
+ * _.pad('abc', 3);
+ * // => 'abc'
+ */
+ function pad(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ if (!length || strLength >= length) {
+ return string;
+ }
+ var mid = (length - strLength) / 2;
+ return (
+ createPadding(nativeFloor(mid), chars) +
+ string +
+ createPadding(nativeCeil(mid), chars)
+ );
+ }
+
+ /**
+ * Pads `string` on the right side if it's shorter than `length`. Padding
+ * characters are truncated if they exceed `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.padEnd('abc', 6);
+ * // => 'abc '
+ *
+ * _.padEnd('abc', 6, '_-');
+ * // => 'abc_-_'
+ *
+ * _.padEnd('abc', 3);
+ * // => 'abc'
+ */
+ function padEnd(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ return (length && strLength < length)
+ ? (string + createPadding(length - strLength, chars))
+ : string;
+ }
+
+ /**
+ * Pads `string` on the left side if it's shorter than `length`. Padding
+ * characters are truncated if they exceed `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.padStart('abc', 6);
+ * // => ' abc'
+ *
+ * _.padStart('abc', 6, '_-');
+ * // => '_-_abc'
+ *
+ * _.padStart('abc', 3);
+ * // => 'abc'
+ */
+ function padStart(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ return (length && strLength < length)
+ ? (createPadding(length - strLength, chars) + string)
+ : string;
+ }
+
+ /**
+ * Converts `string` to an integer of the specified radix. If `radix` is
+ * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
+ * hexadecimal, in which case a `radix` of `16` is used.
+ *
+ * **Note:** This method aligns with the
+ * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category String
+ * @param {string} string The string to convert.
+ * @param {number} [radix=10] The radix to interpret `value` by.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.parseInt('08');
+ * // => 8
+ *
+ * _.map(['6', '08', '10'], _.parseInt);
+ * // => [6, 8, 10]
+ */
+ function parseInt(string, radix, guard) {
+ if (guard || radix == null) {
+ radix = 0;
+ } else if (radix) {
+ radix = +radix;
+ }
+ return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
+ }
+
+ /**
+ * Repeats the given string `n` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to repeat.
+ * @param {number} [n=1] The number of times to repeat the string.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the repeated string.
+ * @example
+ *
+ * _.repeat('*', 3);
+ * // => '***'
+ *
+ * _.repeat('abc', 2);
+ * // => 'abcabc'
+ *
+ * _.repeat('abc', 0);
+ * // => ''
+ */
+ function repeat(string, n, guard) {
+ if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
+ n = 1;
+ } else {
+ n = toInteger(n);
+ }
+ return baseRepeat(toString(string), n);
+ }
+
+ /**
+ * Replaces matches for `pattern` in `string` with `replacement`.
+ *
+ * **Note:** This method is based on
+ * [`String#replace`](https://mdn.io/String/replace).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to modify.
+ * @param {RegExp|string} pattern The pattern to replace.
+ * @param {Function|string} replacement The match replacement.
+ * @returns {string} Returns the modified string.
+ * @example
+ *
+ * _.replace('Hi Fred', 'Fred', 'Barney');
+ * // => 'Hi Barney'
+ */
+ function replace() {
+ var args = arguments,
+ string = toString(args[0]);
+
+ return args.length < 3 ? string : string.replace(args[1], args[2]);
+ }
+
+ /**
+ * Converts `string` to
+ * [snake case](https://en.wikipedia.org/wiki/Snake_case).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the snake cased string.
+ * @example
+ *
+ * _.snakeCase('Foo Bar');
+ * // => 'foo_bar'
+ *
+ * _.snakeCase('fooBar');
+ * // => 'foo_bar'
+ *
+ * _.snakeCase('--FOO-BAR--');
+ * // => 'foo_bar'
+ */
+ var snakeCase = createCompounder(function(result, word, index) {
+ return result + (index ? '_' : '') + word.toLowerCase();
+ });
+
+ /**
+ * Splits `string` by `separator`.
+ *
+ * **Note:** This method is based on
+ * [`String#split`](https://mdn.io/String/split).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to split.
+ * @param {RegExp|string} separator The separator pattern to split by.
+ * @param {number} [limit] The length to truncate results to.
+ * @returns {Array} Returns the string segments.
+ * @example
+ *
+ * _.split('a-b-c', '-', 2);
+ * // => ['a', 'b']
+ */
+ function split(string, separator, limit) {
+ if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
+ separator = limit = undefined;
+ }
+ limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
+ if (!limit) {
+ return [];
+ }
+ string = toString(string);
+ if (string && (
+ typeof separator == 'string' ||
+ (separator != null && !isRegExp(separator))
+ )) {
+ separator = baseToString(separator);
+ if (!separator && hasUnicode(string)) {
+ return castSlice(stringToArray(string), 0, limit);
+ }
+ }
+ return string.split(separator, limit);
+ }
+
+ /**
+ * Converts `string` to
+ * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.1.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the start cased string.
+ * @example
+ *
+ * _.startCase('--foo-bar--');
+ * // => 'Foo Bar'
+ *
+ * _.startCase('fooBar');
+ * // => 'Foo Bar'
+ *
+ * _.startCase('__FOO_BAR__');
+ * // => 'FOO BAR'
+ */
+ var startCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + upperFirst(word);
+ });
+
+ /**
+ * Checks if `string` starts with the given target string.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {string} [target] The string to search for.
+ * @param {number} [position=0] The position to search from.
+ * @returns {boolean} Returns `true` if `string` starts with `target`,
+ * else `false`.
+ * @example
+ *
+ * _.startsWith('abc', 'a');
+ * // => true
+ *
+ * _.startsWith('abc', 'b');
+ * // => false
+ *
+ * _.startsWith('abc', 'b', 1);
+ * // => true
+ */
+ function startsWith(string, target, position) {
+ string = toString(string);
+ position = baseClamp(toInteger(position), 0, string.length);
+ target = baseToString(target);
+ return string.slice(position, position + target.length) == target;
+ }
+
+ /**
+ * Creates a compiled template function that can interpolate data properties
+ * in "interpolate" delimiters, HTML-escape interpolated data properties in
+ * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
+ * properties may be accessed as free variables in the template. If a setting
+ * object is given, it takes precedence over `_.templateSettings` values.
+ *
+ * **Note:** In the development build `_.template` utilizes
+ * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
+ * for easier debugging.
+ *
+ * For more information on precompiling templates see
+ * [lodash's custom builds documentation](https://lodash.com/custom-builds).
+ *
+ * For more information on Chrome extension sandboxes see
+ * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The template string.
+ * @param {Object} [options={}] The options object.
+ * @param {RegExp} [options.escape=_.templateSettings.escape]
+ * The HTML "escape" delimiter.
+ * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
+ * The "evaluate" delimiter.
+ * @param {Object} [options.imports=_.templateSettings.imports]
+ * An object to import into the template as free variables.
+ * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
+ * The "interpolate" delimiter.
+ * @param {string} [options.sourceURL='lodash.templateSources[n]']
+ * The sourceURL of the compiled template.
+ * @param {string} [options.variable='obj']
+ * The data object variable name.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the compiled template function.
+ * @example
+ *
+ * // Use the "interpolate" delimiter to create a compiled template.
+ * var compiled = _.template('hello <%= user %>!');
+ * compiled({ 'user': 'fred' });
+ * // => 'hello fred!'
+ *
+ * // Use the HTML "escape" delimiter to escape data property values.
+ * var compiled = _.template('<b><%- value %></b>');
+ * compiled({ 'value': '<script>' });
+ * // => '<b>&lt;script&gt;</b>'
+ *
+ * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
+ * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
+ * compiled({ 'users': ['fred', 'barney'] });
+ * // => '<li>fred</li><li>barney</li>'
+ *
+ * // Use the internal `print` function in "evaluate" delimiters.
+ * var compiled = _.template('<% print("hello " + user); %>!');
+ * compiled({ 'user': 'barney' });
+ * // => 'hello barney!'
+ *
+ * // Use the ES template literal delimiter as an "interpolate" delimiter.
+ * // Disable support by replacing the "interpolate" delimiter.
+ * var compiled = _.template('hello ${ user }!');
+ * compiled({ 'user': 'pebbles' });
+ * // => 'hello pebbles!'
+ *
+ * // Use backslashes to treat delimiters as plain text.
+ * var compiled = _.template('<%= "\\<%- value %\\>" %>');
+ * compiled({ 'value': 'ignored' });
+ * // => '<%- value %>'
+ *
+ * // Use the `imports` option to import `jQuery` as `jq`.
+ * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
+ * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
+ * compiled({ 'users': ['fred', 'barney'] });
+ * // => '<li>fred</li><li>barney</li>'
+ *
+ * // Use the `sourceURL` option to specify a custom sourceURL for the template.
+ * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
+ * compiled(data);
+ * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
+ *
+ * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
+ * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
+ * compiled.source;
+ * // => function(data) {
+ * // var __t, __p = '';
+ * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
+ * // return __p;
+ * // }
+ *
+ * // Use custom template delimiters.
+ * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
+ * var compiled = _.template('hello {{ user }}!');
+ * compiled({ 'user': 'mustache' });
+ * // => 'hello mustache!'
+ *
+ * // Use the `source` property to inline compiled templates for meaningful
+ * // line numbers in error messages and stack traces.
+ * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
+ * var JST = {\
+ * "main": ' + _.template(mainText).source + '\
+ * };\
+ * ');
+ */
+ function template(string, options, guard) {
+ // Based on John Resig's `tmpl` implementation
+ // (http://ejohn.org/blog/javascript-micro-templating/)
+ // and Laura Doktorova's doT.js (https://github.com/olado/doT).
+ var settings = lodash.templateSettings;
+
+ if (guard && isIterateeCall(string, options, guard)) {
+ options = undefined;
+ }
+ string = toString(string);
+ options = assignInWith({}, options, settings, assignInDefaults);
+
+ var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
+ importsKeys = keys(imports),
+ importsValues = baseValues(imports, importsKeys);
+
+ var isEscaping,
+ isEvaluating,
+ index = 0,
+ interpolate = options.interpolate || reNoMatch,
+ source = "__p += '";
+
+ // Compile the regexp to match each delimiter.
+ var reDelimiters = RegExp(
+ (options.escape || reNoMatch).source + '|' +
+ interpolate.source + '|' +
+ (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
+ (options.evaluate || reNoMatch).source + '|$'
+ , 'g');
+
+ // Use a sourceURL for easier debugging.
+ var sourceURL = '//# sourceURL=' +
+ ('sourceURL' in options
+ ? options.sourceURL
+ : ('lodash.templateSources[' + (++templateCounter) + ']')
+ ) + '\n';
+
+ string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
+ interpolateValue || (interpolateValue = esTemplateValue);
+
+ // Escape characters that can't be included in string literals.
+ source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
+
+ // Replace delimiters with snippets.
+ if (escapeValue) {
+ isEscaping = true;
+ source += "' +\n__e(" + escapeValue + ") +\n'";
+ }
+ if (evaluateValue) {
+ isEvaluating = true;
+ source += "';\n" + evaluateValue + ";\n__p += '";
+ }
+ if (interpolateValue) {
+ source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
+ }
+ index = offset + match.length;
+
+ // The JS engine embedded in Adobe products needs `match` returned in
+ // order to produce the correct `offset` value.
+ return match;
+ });
+
+ source += "';\n";
+
+ // If `variable` is not specified wrap a with-statement around the generated
+ // code to add the data object to the top of the scope chain.
+ var variable = options.variable;
+ if (!variable) {
+ source = 'with (obj) {\n' + source + '\n}\n';
+ }
+ // Cleanup code by stripping empty strings.
+ source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
+ .replace(reEmptyStringMiddle, '$1')
+ .replace(reEmptyStringTrailing, '$1;');
+
+ // Frame code as the function body.
+ source = 'function(' + (variable || 'obj') + ') {\n' +
+ (variable
+ ? ''
+ : 'obj || (obj = {});\n'
+ ) +
+ "var __t, __p = ''" +
+ (isEscaping
+ ? ', __e = _.escape'
+ : ''
+ ) +
+ (isEvaluating
+ ? ', __j = Array.prototype.join;\n' +
+ "function print() { __p += __j.call(arguments, '') }\n"
+ : ';\n'
+ ) +
+ source +
+ 'return __p\n}';
+
+ var result = attempt(function() {
+ return Function(importsKeys, sourceURL + 'return ' + source)
+ .apply(undefined, importsValues);
+ });
+
+ // Provide the compiled function's source by its `toString` method or
+ // the `source` property as a convenience for inlining compiled templates.
+ result.source = source;
+ if (isError(result)) {
+ throw result;
+ }
+ return result;
+ }
+
+ /**
+ * Converts `string`, as a whole, to lower case just like
+ * [String#toLowerCase](https://mdn.io/toLowerCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the lower cased string.
+ * @example
+ *
+ * _.toLower('--Foo-Bar--');
+ * // => '--foo-bar--'
+ *
+ * _.toLower('fooBar');
+ * // => 'foobar'
+ *
+ * _.toLower('__FOO_BAR__');
+ * // => '__foo_bar__'
+ */
+ function toLower(value) {
+ return toString(value).toLowerCase();
+ }
+
+ /**
+ * Converts `string`, as a whole, to upper case just like
+ * [String#toUpperCase](https://mdn.io/toUpperCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the upper cased string.
+ * @example
+ *
+ * _.toUpper('--foo-bar--');
+ * // => '--FOO-BAR--'
+ *
+ * _.toUpper('fooBar');
+ * // => 'FOOBAR'
+ *
+ * _.toUpper('__foo_bar__');
+ * // => '__FOO_BAR__'
+ */
+ function toUpper(value) {
+ return toString(value).toUpperCase();
+ }
+
+ /**
+ * Removes leading and trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trim(' abc ');
+ * // => 'abc'
+ *
+ * _.trim('-_-abc-_-', '_-');
+ * // => 'abc'
+ *
+ * _.map([' foo ', ' bar '], _.trim);
+ * // => ['foo', 'bar']
+ */
+ function trim(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrim, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
+
+ return castSlice(strSymbols, start, end).join('');
+ }
+
+ /**
+ * Removes trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trimEnd(' abc ');
+ * // => ' abc'
+ *
+ * _.trimEnd('-_-abc-_-', '_-');
+ * // => '-_-abc'
+ */
+ function trimEnd(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrimEnd, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
+
+ return castSlice(strSymbols, 0, end).join('');
+ }
+
+ /**
+ * Removes leading whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trimStart(' abc ');
+ * // => 'abc '
+ *
+ * _.trimStart('-_-abc-_-', '_-');
+ * // => 'abc-_-'
+ */
+ function trimStart(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrimStart, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ start = charsStartIndex(strSymbols, stringToArray(chars));
+
+ return castSlice(strSymbols, start).join('');
+ }
+
+ /**
+ * Truncates `string` if it's longer than the given maximum string length.
+ * The last characters of the truncated string are replaced with the omission
+ * string which defaults to "...".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to truncate.
+ * @param {Object} [options={}] The options object.
+ * @param {number} [options.length=30] The maximum string length.
+ * @param {string} [options.omission='...'] The string to indicate text is omitted.
+ * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
+ * @returns {string} Returns the truncated string.
+ * @example
+ *
+ * _.truncate('hi-diddly-ho there, neighborino');
+ * // => 'hi-diddly-ho there, neighbo...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'length': 24,
+ * 'separator': ' '
+ * });
+ * // => 'hi-diddly-ho there,...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'length': 24,
+ * 'separator': /,? +/
+ * });
+ * // => 'hi-diddly-ho there...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'omission': ' [...]'
+ * });
+ * // => 'hi-diddly-ho there, neig [...]'
+ */
+ function truncate(string, options) {
+ var length = DEFAULT_TRUNC_LENGTH,
+ omission = DEFAULT_TRUNC_OMISSION;
+
+ if (isObject(options)) {
+ var separator = 'separator' in options ? options.separator : separator;
+ length = 'length' in options ? toInteger(options.length) : length;
+ omission = 'omission' in options ? baseToString(options.omission) : omission;
+ }
+ string = toString(string);
+
+ var strLength = string.length;
+ if (hasUnicode(string)) {
+ var strSymbols = stringToArray(string);
+ strLength = strSymbols.length;
+ }
+ if (length >= strLength) {
+ return string;
+ }
+ var end = length - stringSize(omission);
+ if (end < 1) {
+ return omission;
+ }
+ var result = strSymbols
+ ? castSlice(strSymbols, 0, end).join('')
+ : string.slice(0, end);
+
+ if (separator === undefined) {
+ return result + omission;
+ }
+ if (strSymbols) {
+ end += (result.length - end);
+ }
+ if (isRegExp(separator)) {
+ if (string.slice(end).search(separator)) {
+ var match,
+ substring = result;
+
+ if (!separator.global) {
+ separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
+ }
+ separator.lastIndex = 0;
+ while ((match = separator.exec(substring))) {
+ var newEnd = match.index;
+ }
+ result = result.slice(0, newEnd === undefined ? end : newEnd);
+ }
+ } else if (string.indexOf(baseToString(separator), end) != end) {
+ var index = result.lastIndexOf(separator);
+ if (index > -1) {
+ result = result.slice(0, index);
+ }
+ }
+ return result + omission;
+ }
+
+ /**
+ * The inverse of `_.escape`; this method converts the HTML entities
+ * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
+ * their corresponding characters.
+ *
+ * **Note:** No other HTML entities are unescaped. To unescape additional
+ * HTML entities use a third-party library like [_he_](https://mths.be/he).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.6.0
+ * @category String
+ * @param {string} [string=''] The string to unescape.
+ * @returns {string} Returns the unescaped string.
+ * @example
+ *
+ * _.unescape('fred, barney, &amp; pebbles');
+ * // => 'fred, barney, & pebbles'
+ */
+ function unescape(string) {
+ string = toString(string);
+ return (string && reHasEscapedHtml.test(string))
+ ? string.replace(reEscapedHtml, unescapeHtmlChar)
+ : string;
+ }
+
+ /**
+ * Converts `string`, as space separated words, to upper case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the upper cased string.
+ * @example
+ *
+ * _.upperCase('--foo-bar');
+ * // => 'FOO BAR'
+ *
+ * _.upperCase('fooBar');
+ * // => 'FOO BAR'
+ *
+ * _.upperCase('__foo_bar__');
+ * // => 'FOO BAR'
+ */
+ var upperCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + word.toUpperCase();
+ });
+
+ /**
+ * Converts the first character of `string` to upper case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.upperFirst('fred');
+ * // => 'Fred'
+ *
+ * _.upperFirst('FRED');
+ * // => 'FRED'
+ */
+ var upperFirst = createCaseFirst('toUpperCase');
+
+ /**
+ * Splits `string` into an array of its words.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {RegExp|string} [pattern] The pattern to match words.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the words of `string`.
+ * @example
+ *
+ * _.words('fred, barney, & pebbles');
+ * // => ['fred', 'barney', 'pebbles']
+ *
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
+ * // => ['fred', 'barney', '&', 'pebbles']
+ */
+ function words(string, pattern, guard) {
+ string = toString(string);
+ pattern = guard ? undefined : pattern;
+
+ if (pattern === undefined) {
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
+ }
+ return string.match(pattern) || [];
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Attempts to invoke `func`, returning either the result or the caught error
+ * object. Any additional arguments are provided to `func` when it's invoked.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Function} func The function to attempt.
+ * @param {...*} [args] The arguments to invoke `func` with.
+ * @returns {*} Returns the `func` result or error object.
+ * @example
+ *
+ * // Avoid throwing errors for invalid selectors.
+ * var elements = _.attempt(function(selector) {
+ * return document.querySelectorAll(selector);
+ * }, '>_>');
+ *
+ * if (_.isError(elements)) {
+ * elements = [];
+ * }
+ */
+ var attempt = baseRest(function(func, args) {
+ try {
+ return apply(func, undefined, args);
+ } catch (e) {
+ return isError(e) ? e : new Error(e);
+ }
+ });
+
+ /**
+ * Binds methods of an object to the object itself, overwriting the existing
+ * method.
+ *
+ * **Note:** This method doesn't set the "length" property of bound functions.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {Object} object The object to bind and assign the bound methods to.
+ * @param {...(string|string[])} methodNames The object method names to bind.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var view = {
+ * 'label': 'docs',
+ * 'click': function() {
+ * console.log('clicked ' + this.label);
+ * }
+ * };
+ *
+ * _.bindAll(view, ['click']);
+ * jQuery(element).on('click', view.click);
+ * // => Logs 'clicked docs' when clicked.
+ */
+ var bindAll = flatRest(function(object, methodNames) {
+ arrayEach(methodNames, function(key) {
+ key = toKey(key);
+ baseAssignValue(object, key, bind(object[key], object));
+ });
+ return object;
+ });
+
+ /**
+ * Creates a function that iterates over `pairs` and invokes the corresponding
+ * function of the first predicate to return truthy. The predicate-function
+ * pairs are invoked with the `this` binding and arguments of the created
+ * function.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {Array} pairs The predicate-function pairs.
+ * @returns {Function} Returns the new composite function.
+ * @example
+ *
+ * var func = _.cond([
+ * [_.matches({ 'a': 1 }), _.constant('matches A')],
+ * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
+ * [_.stubTrue, _.constant('no match')]
+ * ]);
+ *
+ * func({ 'a': 1, 'b': 2 });
+ * // => 'matches A'
+ *
+ * func({ 'a': 0, 'b': 1 });
+ * // => 'matches B'
+ *
+ * func({ 'a': '1', 'b': '2' });
+ * // => 'no match'
+ */
+ function cond(pairs) {
+ var length = pairs == null ? 0 : pairs.length,
+ toIteratee = getIteratee();
+
+ pairs = !length ? [] : arrayMap(pairs, function(pair) {
+ if (typeof pair[1] != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return [toIteratee(pair[0]), pair[1]];
+ });
+
+ return baseRest(function(args) {
+ var index = -1;
+ while (++index < length) {
+ var pair = pairs[index];
+ if (apply(pair[0], this, args)) {
+ return apply(pair[1], this, args);
+ }
+ }
+ });
+ }
+
+ /**
+ * Creates a function that invokes the predicate properties of `source` with
+ * the corresponding property values of a given object, returning `true` if
+ * all predicates return truthy, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.conformsTo` with
+ * `source` partially applied.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 2, 'b': 1 },
+ * { 'a': 1, 'b': 2 }
+ * ];
+ *
+ * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
+ * // => [{ 'a': 1, 'b': 2 }]
+ */
+ function conforms(source) {
+ return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
+ }
+
+ /**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+ function constant(value) {
+ return function() {
+ return value;
+ };
+ }
+
+ /**
+ * Checks `value` to determine whether a default value should be returned in
+ * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
+ * or `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Util
+ * @param {*} value The value to check.
+ * @param {*} defaultValue The default value.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * _.defaultTo(1, 10);
+ * // => 1
+ *
+ * _.defaultTo(undefined, 10);
+ * // => 10
+ */
+ function defaultTo(value, defaultValue) {
+ return (value == null || value !== value) ? defaultValue : value;
+ }
+
+ /**
+ * Creates a function that returns the result of invoking the given functions
+ * with the `this` binding of the created function, where each successive
+ * invocation is supplied the return value of the previous.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
+ * @returns {Function} Returns the new composite function.
+ * @see _.flowRight
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var addSquare = _.flow([_.add, square]);
+ * addSquare(1, 2);
+ * // => 9
+ */
+ var flow = createFlow();
+
+ /**
+ * This method is like `_.flow` except that it creates a function that
+ * invokes the given functions from right to left.
+ *
+ * @static
+ * @since 3.0.0
+ * @memberOf _
+ * @category Util
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
+ * @returns {Function} Returns the new composite function.
+ * @see _.flow
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var addSquare = _.flowRight([square, _.add]);
+ * addSquare(1, 2);
+ * // => 9
+ */
+ var flowRight = createFlow(true);
+
+ /**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+ function identity(value) {
+ return value;
+ }
+
+ /**
+ * Creates a function that invokes `func` with the arguments of the created
+ * function. If `func` is a property name, the created function returns the
+ * property value for a given element. If `func` is an array or object, the
+ * created function returns `true` for elements that contain the equivalent
+ * source properties, otherwise it returns `false`.
+ *
+ * @static
+ * @since 4.0.0
+ * @memberOf _
+ * @category Util
+ * @param {*} [func=_.identity] The value to convert to a callback.
+ * @returns {Function} Returns the callback.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': true },
+ * { 'user': 'fred', 'age': 40, 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
+ * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.filter(users, _.iteratee(['user', 'fred']));
+ * // => [{ 'user': 'fred', 'age': 40 }]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, _.iteratee('user'));
+ * // => ['barney', 'fred']
+ *
+ * // Create custom iteratee shorthands.
+ * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
+ * return !_.isRegExp(func) ? iteratee(func) : function(string) {
+ * return func.test(string);
+ * };
+ * });
+ *
+ * _.filter(['abc', 'def'], /ef/);
+ * // => ['def']
+ */
+ function iteratee(func) {
+ return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
+ }
+
+ /**
+ * Creates a function that performs a partial deep comparison between a given
+ * object and `source`, returning `true` if the given object has equivalent
+ * property values, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.isMatch` with `source`
+ * partially applied.
+ *
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
+ * ];
+ *
+ * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
+ * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
+ */
+ function matches(source) {
+ return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
+ }
+
+ /**
+ * Creates a function that performs a partial deep comparison between the
+ * value at `path` of a given object to `srcValue`, returning `true` if the
+ * object value is equivalent, else `false`.
+ *
+ * **Note:** Partial comparisons will match empty array and empty object
+ * `srcValue` values against any array or object value, respectively. See
+ * `_.isEqual` for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
+ * ];
+ *
+ * _.find(objects, _.matchesProperty('a', 4));
+ * // => { 'a': 4, 'b': 5, 'c': 6 }
+ */
+ function matchesProperty(path, srcValue) {
+ return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
+ }
+
+ /**
+ * Creates a function that invokes the method at `path` of a given object.
+ * Any additional arguments are provided to the invoked method.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Util
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {Function} Returns the new invoker function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': _.constant(2) } },
+ * { 'a': { 'b': _.constant(1) } }
+ * ];
+ *
+ * _.map(objects, _.method('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(objects, _.method(['a', 'b']));
+ * // => [2, 1]
+ */
+ var method = baseRest(function(path, args) {
+ return function(object) {
+ return baseInvoke(object, path, args);
+ };
+ });
+
+ /**
+ * The opposite of `_.method`; this method creates a function that invokes
+ * the method at a given path of `object`. Any additional arguments are
+ * provided to the invoked method.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Util
+ * @param {Object} object The object to query.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {Function} Returns the new invoker function.
+ * @example
+ *
+ * var array = _.times(3, _.constant),
+ * object = { 'a': array, 'b': array, 'c': array };
+ *
+ * _.map(['a[2]', 'c[0]'], _.methodOf(object));
+ * // => [2, 0]
+ *
+ * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
+ * // => [2, 0]
+ */
+ var methodOf = baseRest(function(object, args) {
+ return function(path) {
+ return baseInvoke(object, path, args);
+ };
+ });
+
+ /**
+ * Adds all own enumerable string keyed function properties of a source
+ * object to the destination object. If `object` is a function, then methods
+ * are added to its prototype as well.
+ *
+ * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
+ * avoid conflicts caused by modifying the original.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {Function|Object} [object=lodash] The destination object.
+ * @param {Object} source The object of functions to add.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
+ * @returns {Function|Object} Returns `object`.
+ * @example
+ *
+ * function vowels(string) {
+ * return _.filter(string, function(v) {
+ * return /[aeiou]/i.test(v);
+ * });
+ * }
+ *
+ * _.mixin({ 'vowels': vowels });
+ * _.vowels('fred');
+ * // => ['e']
+ *
+ * _('fred').vowels().value();
+ * // => ['e']
+ *
+ * _.mixin({ 'vowels': vowels }, { 'chain': false });
+ * _('fred').vowels();
+ * // => ['e']
+ */
+ function mixin(object, source, options) {
+ var props = keys(source),
+ methodNames = baseFunctions(source, props);
+
+ if (options == null &&
+ !(isObject(source) && (methodNames.length || !props.length))) {
+ options = source;
+ source = object;
+ object = this;
+ methodNames = baseFunctions(source, keys(source));
+ }
+ var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
+ isFunc = isFunction(object);
+
+ arrayEach(methodNames, function(methodName) {
+ var func = source[methodName];
+ object[methodName] = func;
+ if (isFunc) {
+ object.prototype[methodName] = function() {
+ var chainAll = this.__chain__;
+ if (chain || chainAll) {
+ var result = object(this.__wrapped__),
+ actions = result.__actions__ = copyArray(this.__actions__);
+
+ actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
+ result.__chain__ = chainAll;
+ return result;
+ }
+ return func.apply(object, arrayPush([this.value()], arguments));
+ };
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * Reverts the `_` variable to its previous value and returns a reference to
+ * the `lodash` function.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @returns {Function} Returns the `lodash` function.
+ * @example
+ *
+ * var lodash = _.noConflict();
+ */
+ function noConflict() {
+ if (root._ === this) {
+ root._ = oldDash;
+ }
+ return this;
+ }
+
+ /**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+ function noop() {
+ // No operation performed.
+ }
+
+ /**
+ * Creates a function that gets the argument at index `n`. If `n` is negative,
+ * the nth argument from the end is returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {number} [n=0] The index of the argument to return.
+ * @returns {Function} Returns the new pass-thru function.
+ * @example
+ *
+ * var func = _.nthArg(1);
+ * func('a', 'b', 'c', 'd');
+ * // => 'b'
+ *
+ * var func = _.nthArg(-2);
+ * func('a', 'b', 'c', 'd');
+ * // => 'c'
+ */
+ function nthArg(n) {
+ n = toInteger(n);
+ return baseRest(function(args) {
+ return baseNth(args, n);
+ });
+ }
+
+ /**
+ * Creates a function that invokes `iteratees` with the arguments it receives
+ * and returns their results.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to invoke.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.over([Math.max, Math.min]);
+ *
+ * func(1, 2, 3, 4);
+ * // => [4, 1]
+ */
+ var over = createOver(arrayMap);
+
+ /**
+ * Creates a function that checks if **all** of the `predicates` return
+ * truthy when invoked with the arguments it receives.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.overEvery([Boolean, isFinite]);
+ *
+ * func('1');
+ * // => true
+ *
+ * func(null);
+ * // => false
+ *
+ * func(NaN);
+ * // => false
+ */
+ var overEvery = createOver(arrayEvery);
+
+ /**
+ * Creates a function that checks if **any** of the `predicates` return
+ * truthy when invoked with the arguments it receives.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.overSome([Boolean, isFinite]);
+ *
+ * func('1');
+ * // => true
+ *
+ * func(null);
+ * // => true
+ *
+ * func(NaN);
+ * // => false
+ */
+ var overSome = createOver(arraySome);
+
+ /**
+ * Creates a function that returns the value at `path` of a given object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': 2 } },
+ * { 'a': { 'b': 1 } }
+ * ];
+ *
+ * _.map(objects, _.property('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
+ * // => [1, 2]
+ */
+ function property(path) {
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
+ }
+
+ /**
+ * The opposite of `_.property`; this method creates a function that returns
+ * the value at a given path of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var array = [0, 1, 2],
+ * object = { 'a': array, 'b': array, 'c': array };
+ *
+ * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
+ * // => [2, 0]
+ *
+ * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
+ * // => [2, 0]
+ */
+ function propertyOf(object) {
+ return function(path) {
+ return object == null ? undefined : baseGet(object, path);
+ };
+ }
+
+ /**
+ * Creates an array of numbers (positive and/or negative) progressing from
+ * `start` up to, but not including, `end`. A step of `-1` is used if a negative
+ * `start` is specified without an `end` or `step`. If `end` is not specified,
+ * it's set to `start` with `start` then set to `0`.
+ *
+ * **Note:** JavaScript follows the IEEE-754 standard for resolving
+ * floating-point values which can produce unexpected results.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @returns {Array} Returns the range of numbers.
+ * @see _.inRange, _.rangeRight
+ * @example
+ *
+ * _.range(4);
+ * // => [0, 1, 2, 3]
+ *
+ * _.range(-4);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 5);
+ * // => [1, 2, 3, 4]
+ *
+ * _.range(0, 20, 5);
+ * // => [0, 5, 10, 15]
+ *
+ * _.range(0, -4, -1);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 4, 0);
+ * // => [1, 1, 1]
+ *
+ * _.range(0);
+ * // => []
+ */
+ var range = createRange();
+
+ /**
+ * This method is like `_.range` except that it populates values in
+ * descending order.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @returns {Array} Returns the range of numbers.
+ * @see _.inRange, _.range
+ * @example
+ *
+ * _.rangeRight(4);
+ * // => [3, 2, 1, 0]
+ *
+ * _.rangeRight(-4);
+ * // => [-3, -2, -1, 0]
+ *
+ * _.rangeRight(1, 5);
+ * // => [4, 3, 2, 1]
+ *
+ * _.rangeRight(0, 20, 5);
+ * // => [15, 10, 5, 0]
+ *
+ * _.rangeRight(0, -4, -1);
+ * // => [-3, -2, -1, 0]
+ *
+ * _.rangeRight(1, 4, 0);
+ * // => [1, 1, 1]
+ *
+ * _.rangeRight(0);
+ * // => []
+ */
+ var rangeRight = createRange(true);
+
+ /**
+ * This method returns a new empty array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Array} Returns the new empty array.
+ * @example
+ *
+ * var arrays = _.times(2, _.stubArray);
+ *
+ * console.log(arrays);
+ * // => [[], []]
+ *
+ * console.log(arrays[0] === arrays[1]);
+ * // => false
+ */
+ function stubArray() {
+ return [];
+ }
+
+ /**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+ function stubFalse() {
+ return false;
+ }
+
+ /**
+ * This method returns a new empty object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Object} Returns the new empty object.
+ * @example
+ *
+ * var objects = _.times(2, _.stubObject);
+ *
+ * console.log(objects);
+ * // => [{}, {}]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => false
+ */
+ function stubObject() {
+ return {};
+ }
+
+ /**
+ * This method returns an empty string.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {string} Returns the empty string.
+ * @example
+ *
+ * _.times(2, _.stubString);
+ * // => ['', '']
+ */
+ function stubString() {
+ return '';
+ }
+
+ /**
+ * This method returns `true`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `true`.
+ * @example
+ *
+ * _.times(2, _.stubTrue);
+ * // => [true, true]
+ */
+ function stubTrue() {
+ return true;
+ }
+
+ /**
+ * Invokes the iteratee `n` times, returning an array of the results of
+ * each invocation. The iteratee is invoked with one argument; (index).
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ * @example
+ *
+ * _.times(3, String);
+ * // => ['0', '1', '2']
+ *
+ * _.times(4, _.constant(0));
+ * // => [0, 0, 0, 0]
+ */
+ function times(n, iteratee) {
+ n = toInteger(n);
+ if (n < 1 || n > MAX_SAFE_INTEGER) {
+ return [];
+ }
+ var index = MAX_ARRAY_LENGTH,
+ length = nativeMin(n, MAX_ARRAY_LENGTH);
+
+ iteratee = getIteratee(iteratee);
+ n -= MAX_ARRAY_LENGTH;
+
+ var result = baseTimes(length, iteratee);
+ while (++index < n) {
+ iteratee(index);
+ }
+ return result;
+ }
+
+ /**
+ * Converts `value` to a property path array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {*} value The value to convert.
+ * @returns {Array} Returns the new property path array.
+ * @example
+ *
+ * _.toPath('a.b.c');
+ * // => ['a', 'b', 'c']
+ *
+ * _.toPath('a[0].b.c');
+ * // => ['a', '0', 'b', 'c']
+ */
+ function toPath(value) {
+ if (isArray(value)) {
+ return arrayMap(value, toKey);
+ }
+ return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
+ }
+
+ /**
+ * Generates a unique ID. If `prefix` is given, the ID is appended to it.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {string} [prefix=''] The value to prefix the ID with.
+ * @returns {string} Returns the unique ID.
+ * @example
+ *
+ * _.uniqueId('contact_');
+ * // => 'contact_104'
+ *
+ * _.uniqueId();
+ * // => '105'
+ */
+ function uniqueId(prefix) {
+ var id = ++idCounter;
+ return toString(prefix) + id;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Adds two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.4.0
+ * @category Math
+ * @param {number} augend The first number in an addition.
+ * @param {number} addend The second number in an addition.
+ * @returns {number} Returns the total.
+ * @example
+ *
+ * _.add(6, 4);
+ * // => 10
+ */
+ var add = createMathOperation(function(augend, addend) {
+ return augend + addend;
+ }, 0);
+
+ /**
+ * Computes `number` rounded up to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round up.
+ * @param {number} [precision=0] The precision to round up to.
+ * @returns {number} Returns the rounded up number.
+ * @example
+ *
+ * _.ceil(4.006);
+ * // => 5
+ *
+ * _.ceil(6.004, 2);
+ * // => 6.01
+ *
+ * _.ceil(6040, -2);
+ * // => 6100
+ */
+ var ceil = createRound('ceil');
+
+ /**
+ * Divide two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {number} dividend The first number in a division.
+ * @param {number} divisor The second number in a division.
+ * @returns {number} Returns the quotient.
+ * @example
+ *
+ * _.divide(6, 4);
+ * // => 1.5
+ */
+ var divide = createMathOperation(function(dividend, divisor) {
+ return dividend / divisor;
+ }, 1);
+
+ /**
+ * Computes `number` rounded down to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round down.
+ * @param {number} [precision=0] The precision to round down to.
+ * @returns {number} Returns the rounded down number.
+ * @example
+ *
+ * _.floor(4.006);
+ * // => 4
+ *
+ * _.floor(0.046, 2);
+ * // => 0.04
+ *
+ * _.floor(4060, -2);
+ * // => 4000
+ */
+ var floor = createRound('floor');
+
+ /**
+ * Computes the maximum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * _.max([4, 2, 8, 6]);
+ * // => 8
+ *
+ * _.max([]);
+ * // => undefined
+ */
+ function max(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseGt)
+ : undefined;
+ }
+
+ /**
+ * This method is like `_.max` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * the value is ranked. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * var objects = [{ 'n': 1 }, { 'n': 2 }];
+ *
+ * _.maxBy(objects, function(o) { return o.n; });
+ * // => { 'n': 2 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.maxBy(objects, 'n');
+ * // => { 'n': 2 }
+ */
+ function maxBy(array, iteratee) {
+ return (array && array.length)
+ ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
+ : undefined;
+ }
+
+ /**
+ * Computes the mean of the values in `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {number} Returns the mean.
+ * @example
+ *
+ * _.mean([4, 2, 8, 6]);
+ * // => 5
+ */
+ function mean(array) {
+ return baseMean(array, identity);
+ }
+
+ /**
+ * This method is like `_.mean` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the value to be averaged.
+ * The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the mean.
+ * @example
+ *
+ * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
+ *
+ * _.meanBy(objects, function(o) { return o.n; });
+ * // => 5
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.meanBy(objects, 'n');
+ * // => 5
+ */
+ function meanBy(array, iteratee) {
+ return baseMean(array, getIteratee(iteratee, 2));
+ }
+
+ /**
+ * Computes the minimum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * _.min([4, 2, 8, 6]);
+ * // => 2
+ *
+ * _.min([]);
+ * // => undefined
+ */
+ function min(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseLt)
+ : undefined;
+ }
+
+ /**
+ * This method is like `_.min` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * the value is ranked. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * var objects = [{ 'n': 1 }, { 'n': 2 }];
+ *
+ * _.minBy(objects, function(o) { return o.n; });
+ * // => { 'n': 1 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.minBy(objects, 'n');
+ * // => { 'n': 1 }
+ */
+ function minBy(array, iteratee) {
+ return (array && array.length)
+ ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
+ : undefined;
+ }
+
+ /**
+ * Multiply two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {number} multiplier The first number in a multiplication.
+ * @param {number} multiplicand The second number in a multiplication.
+ * @returns {number} Returns the product.
+ * @example
+ *
+ * _.multiply(6, 4);
+ * // => 24
+ */
+ var multiply = createMathOperation(function(multiplier, multiplicand) {
+ return multiplier * multiplicand;
+ }, 1);
+
+ /**
+ * Computes `number` rounded to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round.
+ * @param {number} [precision=0] The precision to round to.
+ * @returns {number} Returns the rounded number.
+ * @example
+ *
+ * _.round(4.006);
+ * // => 4
+ *
+ * _.round(4.006, 2);
+ * // => 4.01
+ *
+ * _.round(4060, -2);
+ * // => 4100
+ */
+ var round = createRound('round');
+
+ /**
+ * Subtract two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {number} minuend The first number in a subtraction.
+ * @param {number} subtrahend The second number in a subtraction.
+ * @returns {number} Returns the difference.
+ * @example
+ *
+ * _.subtract(6, 4);
+ * // => 2
+ */
+ var subtract = createMathOperation(function(minuend, subtrahend) {
+ return minuend - subtrahend;
+ }, 0);
+
+ /**
+ * Computes the sum of the values in `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.4.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {number} Returns the sum.
+ * @example
+ *
+ * _.sum([4, 2, 8, 6]);
+ * // => 20
+ */
+ function sum(array) {
+ return (array && array.length)
+ ? baseSum(array, identity)
+ : 0;
+ }
+
+ /**
+ * This method is like `_.sum` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the value to be summed.
+ * The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the sum.
+ * @example
+ *
+ * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
+ *
+ * _.sumBy(objects, function(o) { return o.n; });
+ * // => 20
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sumBy(objects, 'n');
+ * // => 20
+ */
+ function sumBy(array, iteratee) {
+ return (array && array.length)
+ ? baseSum(array, getIteratee(iteratee, 2))
+ : 0;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return wrapped values in chain sequences.
+ lodash.after = after;
+ lodash.ary = ary;
+ lodash.assign = assign;
+ lodash.assignIn = assignIn;
+ lodash.assignInWith = assignInWith;
+ lodash.assignWith = assignWith;
+ lodash.at = at;
+ lodash.before = before;
+ lodash.bind = bind;
+ lodash.bindAll = bindAll;
+ lodash.bindKey = bindKey;
+ lodash.castArray = castArray;
+ lodash.chain = chain;
+ lodash.chunk = chunk;
+ lodash.compact = compact;
+ lodash.concat = concat;
+ lodash.cond = cond;
+ lodash.conforms = conforms;
+ lodash.constant = constant;
+ lodash.countBy = countBy;
+ lodash.create = create;
+ lodash.curry = curry;
+ lodash.curryRight = curryRight;
+ lodash.debounce = debounce;
+ lodash.defaults = defaults;
+ lodash.defaultsDeep = defaultsDeep;
+ lodash.defer = defer;
+ lodash.delay = delay;
+ lodash.difference = difference;
+ lodash.differenceBy = differenceBy;
+ lodash.differenceWith = differenceWith;
+ lodash.drop = drop;
+ lodash.dropRight = dropRight;
+ lodash.dropRightWhile = dropRightWhile;
+ lodash.dropWhile = dropWhile;
+ lodash.fill = fill;
+ lodash.filter = filter;
+ lodash.flatMap = flatMap;
+ lodash.flatMapDeep = flatMapDeep;
+ lodash.flatMapDepth = flatMapDepth;
+ lodash.flatten = flatten;
+ lodash.flattenDeep = flattenDeep;
+ lodash.flattenDepth = flattenDepth;
+ lodash.flip = flip;
+ lodash.flow = flow;
+ lodash.flowRight = flowRight;
+ lodash.fromPairs = fromPairs;
+ lodash.functions = functions;
+ lodash.functionsIn = functionsIn;
+ lodash.groupBy = groupBy;
+ lodash.initial = initial;
+ lodash.intersection = intersection;
+ lodash.intersectionBy = intersectionBy;
+ lodash.intersectionWith = intersectionWith;
+ lodash.invert = invert;
+ lodash.invertBy = invertBy;
+ lodash.invokeMap = invokeMap;
+ lodash.iteratee = iteratee;
+ lodash.keyBy = keyBy;
+ lodash.keys = keys;
+ lodash.keysIn = keysIn;
+ lodash.map = map;
+ lodash.mapKeys = mapKeys;
+ lodash.mapValues = mapValues;
+ lodash.matches = matches;
+ lodash.matchesProperty = matchesProperty;
+ lodash.memoize = memoize;
+ lodash.merge = merge;
+ lodash.mergeWith = mergeWith;
+ lodash.method = method;
+ lodash.methodOf = methodOf;
+ lodash.mixin = mixin;
+ lodash.negate = negate;
+ lodash.nthArg = nthArg;
+ lodash.omit = omit;
+ lodash.omitBy = omitBy;
+ lodash.once = once;
+ lodash.orderBy = orderBy;
+ lodash.over = over;
+ lodash.overArgs = overArgs;
+ lodash.overEvery = overEvery;
+ lodash.overSome = overSome;
+ lodash.partial = partial;
+ lodash.partialRight = partialRight;
+ lodash.partition = partition;
+ lodash.pick = pick;
+ lodash.pickBy = pickBy;
+ lodash.property = property;
+ lodash.propertyOf = propertyOf;
+ lodash.pull = pull;
+ lodash.pullAll = pullAll;
+ lodash.pullAllBy = pullAllBy;
+ lodash.pullAllWith = pullAllWith;
+ lodash.pullAt = pullAt;
+ lodash.range = range;
+ lodash.rangeRight = rangeRight;
+ lodash.rearg = rearg;
+ lodash.reject = reject;
+ lodash.remove = remove;
+ lodash.rest = rest;
+ lodash.reverse = reverse;
+ lodash.sampleSize = sampleSize;
+ lodash.set = set;
+ lodash.setWith = setWith;
+ lodash.shuffle = shuffle;
+ lodash.slice = slice;
+ lodash.sortBy = sortBy;
+ lodash.sortedUniq = sortedUniq;
+ lodash.sortedUniqBy = sortedUniqBy;
+ lodash.split = split;
+ lodash.spread = spread;
+ lodash.tail = tail;
+ lodash.take = take;
+ lodash.takeRight = takeRight;
+ lodash.takeRightWhile = takeRightWhile;
+ lodash.takeWhile = takeWhile;
+ lodash.tap = tap;
+ lodash.throttle = throttle;
+ lodash.thru = thru;
+ lodash.toArray = toArray;
+ lodash.toPairs = toPairs;
+ lodash.toPairsIn = toPairsIn;
+ lodash.toPath = toPath;
+ lodash.toPlainObject = toPlainObject;
+ lodash.transform = transform;
+ lodash.unary = unary;
+ lodash.union = union;
+ lodash.unionBy = unionBy;
+ lodash.unionWith = unionWith;
+ lodash.uniq = uniq;
+ lodash.uniqBy = uniqBy;
+ lodash.uniqWith = uniqWith;
+ lodash.unset = unset;
+ lodash.unzip = unzip;
+ lodash.unzipWith = unzipWith;
+ lodash.update = update;
+ lodash.updateWith = updateWith;
+ lodash.values = values;
+ lodash.valuesIn = valuesIn;
+ lodash.without = without;
+ lodash.words = words;
+ lodash.wrap = wrap;
+ lodash.xor = xor;
+ lodash.xorBy = xorBy;
+ lodash.xorWith = xorWith;
+ lodash.zip = zip;
+ lodash.zipObject = zipObject;
+ lodash.zipObjectDeep = zipObjectDeep;
+ lodash.zipWith = zipWith;
+
+ // Add aliases.
+ lodash.entries = toPairs;
+ lodash.entriesIn = toPairsIn;
+ lodash.extend = assignIn;
+ lodash.extendWith = assignInWith;
+
+ // Add methods to `lodash.prototype`.
+ mixin(lodash, lodash);
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return unwrapped values in chain sequences.
+ lodash.add = add;
+ lodash.attempt = attempt;
+ lodash.camelCase = camelCase;
+ lodash.capitalize = capitalize;
+ lodash.ceil = ceil;
+ lodash.clamp = clamp;
+ lodash.clone = clone;
+ lodash.cloneDeep = cloneDeep;
+ lodash.cloneDeepWith = cloneDeepWith;
+ lodash.cloneWith = cloneWith;
+ lodash.conformsTo = conformsTo;
+ lodash.deburr = deburr;
+ lodash.defaultTo = defaultTo;
+ lodash.divide = divide;
+ lodash.endsWith = endsWith;
+ lodash.eq = eq;
+ lodash.escape = escape;
+ lodash.escapeRegExp = escapeRegExp;
+ lodash.every = every;
+ lodash.find = find;
+ lodash.findIndex = findIndex;
+ lodash.findKey = findKey;
+ lodash.findLast = findLast;
+ lodash.findLastIndex = findLastIndex;
+ lodash.findLastKey = findLastKey;
+ lodash.floor = floor;
+ lodash.forEach = forEach;
+ lodash.forEachRight = forEachRight;
+ lodash.forIn = forIn;
+ lodash.forInRight = forInRight;
+ lodash.forOwn = forOwn;
+ lodash.forOwnRight = forOwnRight;
+ lodash.get = get;
+ lodash.gt = gt;
+ lodash.gte = gte;
+ lodash.has = has;
+ lodash.hasIn = hasIn;
+ lodash.head = head;
+ lodash.identity = identity;
+ lodash.includes = includes;
+ lodash.indexOf = indexOf;
+ lodash.inRange = inRange;
+ lodash.invoke = invoke;
+ lodash.isArguments = isArguments;
+ lodash.isArray = isArray;
+ lodash.isArrayBuffer = isArrayBuffer;
+ lodash.isArrayLike = isArrayLike;
+ lodash.isArrayLikeObject = isArrayLikeObject;
+ lodash.isBoolean = isBoolean;
+ lodash.isBuffer = isBuffer;
+ lodash.isDate = isDate;
+ lodash.isElement = isElement;
+ lodash.isEmpty = isEmpty;
+ lodash.isEqual = isEqual;
+ lodash.isEqualWith = isEqualWith;
+ lodash.isError = isError;
+ lodash.isFinite = isFinite;
+ lodash.isFunction = isFunction;
+ lodash.isInteger = isInteger;
+ lodash.isLength = isLength;
+ lodash.isMap = isMap;
+ lodash.isMatch = isMatch;
+ lodash.isMatchWith = isMatchWith;
+ lodash.isNaN = isNaN;
+ lodash.isNative = isNative;
+ lodash.isNil = isNil;
+ lodash.isNull = isNull;
+ lodash.isNumber = isNumber;
+ lodash.isObject = isObject;
+ lodash.isObjectLike = isObjectLike;
+ lodash.isPlainObject = isPlainObject;
+ lodash.isRegExp = isRegExp;
+ lodash.isSafeInteger = isSafeInteger;
+ lodash.isSet = isSet;
+ lodash.isString = isString;
+ lodash.isSymbol = isSymbol;
+ lodash.isTypedArray = isTypedArray;
+ lodash.isUndefined = isUndefined;
+ lodash.isWeakMap = isWeakMap;
+ lodash.isWeakSet = isWeakSet;
+ lodash.join = join;
+ lodash.kebabCase = kebabCase;
+ lodash.last = last;
+ lodash.lastIndexOf = lastIndexOf;
+ lodash.lowerCase = lowerCase;
+ lodash.lowerFirst = lowerFirst;
+ lodash.lt = lt;
+ lodash.lte = lte;
+ lodash.max = max;
+ lodash.maxBy = maxBy;
+ lodash.mean = mean;
+ lodash.meanBy = meanBy;
+ lodash.min = min;
+ lodash.minBy = minBy;
+ lodash.stubArray = stubArray;
+ lodash.stubFalse = stubFalse;
+ lodash.stubObject = stubObject;
+ lodash.stubString = stubString;
+ lodash.stubTrue = stubTrue;
+ lodash.multiply = multiply;
+ lodash.nth = nth;
+ lodash.noConflict = noConflict;
+ lodash.noop = noop;
+ lodash.now = now;
+ lodash.pad = pad;
+ lodash.padEnd = padEnd;
+ lodash.padStart = padStart;
+ lodash.parseInt = parseInt;
+ lodash.random = random;
+ lodash.reduce = reduce;
+ lodash.reduceRight = reduceRight;
+ lodash.repeat = repeat;
+ lodash.replace = replace;
+ lodash.result = result;
+ lodash.round = round;
+ lodash.runInContext = runInContext;
+ lodash.sample = sample;
+ lodash.size = size;
+ lodash.snakeCase = snakeCase;
+ lodash.some = some;
+ lodash.sortedIndex = sortedIndex;
+ lodash.sortedIndexBy = sortedIndexBy;
+ lodash.sortedIndexOf = sortedIndexOf;
+ lodash.sortedLastIndex = sortedLastIndex;
+ lodash.sortedLastIndexBy = sortedLastIndexBy;
+ lodash.sortedLastIndexOf = sortedLastIndexOf;
+ lodash.startCase = startCase;
+ lodash.startsWith = startsWith;
+ lodash.subtract = subtract;
+ lodash.sum = sum;
+ lodash.sumBy = sumBy;
+ lodash.template = template;
+ lodash.times = times;
+ lodash.toFinite = toFinite;
+ lodash.toInteger = toInteger;
+ lodash.toLength = toLength;
+ lodash.toLower = toLower;
+ lodash.toNumber = toNumber;
+ lodash.toSafeInteger = toSafeInteger;
+ lodash.toString = toString;
+ lodash.toUpper = toUpper;
+ lodash.trim = trim;
+ lodash.trimEnd = trimEnd;
+ lodash.trimStart = trimStart;
+ lodash.truncate = truncate;
+ lodash.unescape = unescape;
+ lodash.uniqueId = uniqueId;
+ lodash.upperCase = upperCase;
+ lodash.upperFirst = upperFirst;
+
+ // Add aliases.
+ lodash.each = forEach;
+ lodash.eachRight = forEachRight;
+ lodash.first = head;
+
+ mixin(lodash, (function() {
+ var source = {};
+ baseForOwn(lodash, function(func, methodName) {
+ if (!hasOwnProperty.call(lodash.prototype, methodName)) {
+ source[methodName] = func;
+ }
+ });
+ return source;
+ }()), { 'chain': false });
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * The semantic version number.
+ *
+ * @static
+ * @memberOf _
+ * @type {string}
+ */
+ lodash.VERSION = VERSION;
+
+ // Assign default placeholders.
+ arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
+ lodash[methodName].placeholder = lodash;
+ });
+
+ // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
+ arrayEach(['drop', 'take'], function(methodName, index) {
+ LazyWrapper.prototype[methodName] = function(n) {
+ var filtered = this.__filtered__;
+ if (filtered && !index) {
+ return new LazyWrapper(this);
+ }
+ n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
+
+ var result = this.clone();
+ if (filtered) {
+ result.__takeCount__ = nativeMin(n, result.__takeCount__);
+ } else {
+ result.__views__.push({
+ 'size': nativeMin(n, MAX_ARRAY_LENGTH),
+ 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
+ });
+ }
+ return result;
+ };
+
+ LazyWrapper.prototype[methodName + 'Right'] = function(n) {
+ return this.reverse()[methodName](n).reverse();
+ };
+ });
+
+ // Add `LazyWrapper` methods that accept an `iteratee` value.
+ arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
+ var type = index + 1,
+ isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
+
+ LazyWrapper.prototype[methodName] = function(iteratee) {
+ var result = this.clone();
+ result.__iteratees__.push({
+ 'iteratee': getIteratee(iteratee, 3),
+ 'type': type
+ });
+ result.__filtered__ = result.__filtered__ || isFilter;
+ return result;
+ };
+ });
+
+ // Add `LazyWrapper` methods for `_.head` and `_.last`.
+ arrayEach(['head', 'last'], function(methodName, index) {
+ var takeName = 'take' + (index ? 'Right' : '');
+
+ LazyWrapper.prototype[methodName] = function() {
+ return this[takeName](1).value()[0];
+ };
+ });
+
+ // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
+ arrayEach(['initial', 'tail'], function(methodName, index) {
+ var dropName = 'drop' + (index ? '' : 'Right');
+
+ LazyWrapper.prototype[methodName] = function() {
+ return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
+ };
+ });
+
+ LazyWrapper.prototype.compact = function() {
+ return this.filter(identity);
+ };
+
+ LazyWrapper.prototype.find = function(predicate) {
+ return this.filter(predicate).head();
+ };
+
+ LazyWrapper.prototype.findLast = function(predicate) {
+ return this.reverse().find(predicate);
+ };
+
+ LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
+ if (typeof path == 'function') {
+ return new LazyWrapper(this);
+ }
+ return this.map(function(value) {
+ return baseInvoke(value, path, args);
+ });
+ });
+
+ LazyWrapper.prototype.reject = function(predicate) {
+ return this.filter(negate(getIteratee(predicate)));
+ };
+
+ LazyWrapper.prototype.slice = function(start, end) {
+ start = toInteger(start);
+
+ var result = this;
+ if (result.__filtered__ && (start > 0 || end < 0)) {
+ return new LazyWrapper(result);
+ }
+ if (start < 0) {
+ result = result.takeRight(-start);
+ } else if (start) {
+ result = result.drop(start);
+ }
+ if (end !== undefined) {
+ end = toInteger(end);
+ result = end < 0 ? result.dropRight(-end) : result.take(end - start);
+ }
+ return result;
+ };
+
+ LazyWrapper.prototype.takeRightWhile = function(predicate) {
+ return this.reverse().takeWhile(predicate).reverse();
+ };
+
+ LazyWrapper.prototype.toArray = function() {
+ return this.take(MAX_ARRAY_LENGTH);
+ };
+
+ // Add `LazyWrapper` methods to `lodash.prototype`.
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
+ var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
+ isTaker = /^(?:head|last)$/.test(methodName),
+ lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
+ retUnwrapped = isTaker || /^find/.test(methodName);
+
+ if (!lodashFunc) {
+ return;
+ }
+ lodash.prototype[methodName] = function() {
+ var value = this.__wrapped__,
+ args = isTaker ? [1] : arguments,
+ isLazy = value instanceof LazyWrapper,
+ iteratee = args[0],
+ useLazy = isLazy || isArray(value);
+
+ var interceptor = function(value) {
+ var result = lodashFunc.apply(lodash, arrayPush([value], args));
+ return (isTaker && chainAll) ? result[0] : result;
+ };
+
+ if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
+ // Avoid lazy use if the iteratee has a "length" value other than `1`.
+ isLazy = useLazy = false;
+ }
+ var chainAll = this.__chain__,
+ isHybrid = !!this.__actions__.length,
+ isUnwrapped = retUnwrapped && !chainAll,
+ onlyLazy = isLazy && !isHybrid;
+
+ if (!retUnwrapped && useLazy) {
+ value = onlyLazy ? value : new LazyWrapper(this);
+ var result = func.apply(value, args);
+ result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
+ return new LodashWrapper(result, chainAll);
+ }
+ if (isUnwrapped && onlyLazy) {
+ return func.apply(this, args);
+ }
+ result = this.thru(interceptor);
+ return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
+ };
+ });
+
+ // Add `Array` methods to `lodash.prototype`.
+ arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
+ var func = arrayProto[methodName],
+ chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
+ retUnwrapped = /^(?:pop|shift)$/.test(methodName);
+
+ lodash.prototype[methodName] = function() {
+ var args = arguments;
+ if (retUnwrapped && !this.__chain__) {
+ var value = this.value();
+ return func.apply(isArray(value) ? value : [], args);
+ }
+ return this[chainName](function(value) {
+ return func.apply(isArray(value) ? value : [], args);
+ });
+ };
+ });
+
+ // Map minified method names to their real names.
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
+ var lodashFunc = lodash[methodName];
+ if (lodashFunc) {
+ var key = (lodashFunc.name + ''),
+ names = realNames[key] || (realNames[key] = []);
+
+ names.push({ 'name': methodName, 'func': lodashFunc });
+ }
+ });
+
+ realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
+ 'name': 'wrapper',
+ 'func': undefined
+ }];
+
+ // Add methods to `LazyWrapper`.
+ LazyWrapper.prototype.clone = lazyClone;
+ LazyWrapper.prototype.reverse = lazyReverse;
+ LazyWrapper.prototype.value = lazyValue;
+
+ // Add chain sequence methods to the `lodash` wrapper.
+ lodash.prototype.at = wrapperAt;
+ lodash.prototype.chain = wrapperChain;
+ lodash.prototype.commit = wrapperCommit;
+ lodash.prototype.next = wrapperNext;
+ lodash.prototype.plant = wrapperPlant;
+ lodash.prototype.reverse = wrapperReverse;
+ lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
+
+ // Add lazy aliases.
+ lodash.prototype.first = lodash.prototype.head;
+
+ if (symIterator) {
+ lodash.prototype[symIterator] = wrapperToIterator;
+ }
+ return lodash;
+ });
+
+ /*--------------------------------------------------------------------------*/
+
+ // Export lodash.
+ var _ = runInContext();
+
+ // Some AMD build optimizers, like r.js, check for condition patterns like:
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
+ // Expose Lodash on the global object to prevent errors when Lodash is
+ // loaded by a script tag in the presence of an AMD loader.
+ // See http://requirejs.org/docs/errors.html#mismatch for more details.
+ // Use `_.noConflict` to remove Lodash from the global object.
+ root._ = _;
+
+ // Define as an anonymous module so, through path mapping, it can be
+ // referenced as the "underscore" module.
+ define(function() {
+ return _;
+ });
+ }
+ // Check for `exports` after `define` in case a build optimizer adds it.
+ else if (freeModule) {
+ // Export for Node.js.
+ (freeModule.exports = _)._ = _;
+ // Export for CommonJS support.
+ freeExports._ = _;
+ }
+ else {
+ // Export to the global object.
+ root._ = _;
+ }
+}.call(this));
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.min.js
new file mode 100644
index 0000000..cf2fd3d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lodash.min.js
@@ -0,0 +1,136 @@
+/**
+ * @license
+ * Lodash lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
+ */
+;(function(){function n(n,t){return n.set(t[0],t[1]),n}function t(n,t){return n.add(t),n}function r(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function e(n,t,r,e){for(var u=-1,i=null==n?0:n.length;++u<i;){var o=n[u];t(e,o,r(o),n)}return e}function u(n,t){for(var r=-1,e=null==n?0:n.length;++r<e&&false!==t(n[r],r,n););return n}function i(n,t){for(var r=null==n?0:n.length;r--&&false!==t(n[r],r,n););
+return n}function o(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function f(n,t){for(var r=-1,e=null==n?0:n.length,u=0,i=[];++r<e;){var o=n[r];t(o,r,n)&&(i[u++]=o)}return i}function c(n,t){return!(null==n||!n.length)&&-1<d(n,t,0)}function a(n,t,r){for(var e=-1,u=null==n?0:n.length;++e<u;)if(r(t,n[e]))return true;return false}function l(n,t){for(var r=-1,e=null==n?0:n.length,u=Array(e);++r<e;)u[r]=t(n[r],r,n);return u}function s(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];
+return n}function h(n,t,r,e){var u=-1,i=null==n?0:n.length;for(e&&i&&(r=n[++u]);++u<i;)r=t(r,n[u],u,n);return r}function p(n,t,r,e){var u=null==n?0:n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r}function _(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return true;return false}function v(n,t,r){var e;return r(n,function(n,r,u){if(t(n,r,u))return e=r,false}),e}function g(n,t,r,e){var u=n.length;for(r+=e?1:-1;e?r--:++r<u;)if(t(n[r],r,n))return r;return-1}function d(n,t,r){if(t===t)n:{
+--r;for(var e=n.length;++r<e;)if(n[r]===t){n=r;break n}n=-1}else n=g(n,b,r);return n}function y(n,t,r,e){--r;for(var u=n.length;++r<u;)if(e(n[r],t))return r;return-1}function b(n){return n!==n}function x(n,t){var r=null==n?0:n.length;return r?k(n,t)/r:P}function j(n){return function(t){return null==t?F:t[n]}}function w(n){return function(t){return null==n?F:n[t]}}function m(n,t,r,e,u){return u(n,function(n,u,i){r=e?(e=false,n):t(r,n,u,i)}),r}function A(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;
+return n}function k(n,t){for(var r,e=-1,u=n.length;++e<u;){var i=t(n[e]);i!==F&&(r=r===F?i:r+i)}return r}function E(n,t){for(var r=-1,e=Array(n);++r<n;)e[r]=t(r);return e}function O(n,t){return l(t,function(t){return[t,n[t]]})}function S(n){return function(t){return n(t)}}function I(n,t){return l(t,function(t){return n[t]})}function R(n,t){return n.has(t)}function z(n,t){for(var r=-1,e=n.length;++r<e&&-1<d(t,n[r],0););return r}function W(n,t){for(var r=n.length;r--&&-1<d(t,n[r],0););return r}function B(n){
+return"\\"+Tn[n]}function L(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function U(n,t){return function(r){return n(t(r))}}function C(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r];o!==t&&"__lodash_placeholder__"!==o||(n[r]="__lodash_placeholder__",i[u++]=r)}return i}function D(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=n}),r}function M(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=[n,n]}),r}function T(n){if(Bn.test(n)){
+for(var t=zn.lastIndex=0;zn.test(n);)++t;n=t}else n=tt(n);return n}function $(n){return Bn.test(n)?n.match(zn)||[]:n.split("")}var F,N=1/0,P=NaN,Z=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],q=/\b__p\+='';/g,V=/\b(__p\+=)''\+/g,K=/(__e\(.*?\)|\b__t\))\+'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,H=/[&<>"']/g,J=RegExp(G.source),Y=RegExp(H.source),Q=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,nn=/<%=([\s\S]+?)%>/g,tn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rn=/^\w*$/,en=/^\./,un=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,on=/[\\^$.*+?()[\]{}|]/g,fn=RegExp(on.source),cn=/^\s+|\s+$/g,an=/^\s+/,ln=/\s+$/,sn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,hn=/\{\n\/\* \[wrapped with (.+)\] \*/,pn=/,? & /,_n=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,vn=/\\(\\)?/g,gn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dn=/\w*$/,yn=/^[-+]0x[0-9a-f]+$/i,bn=/^0b[01]+$/i,xn=/^\[object .+?Constructor\]$/,jn=/^0o[0-7]+$/i,wn=/^(?:0|[1-9]\d*)$/,mn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,An=/($^)/,kn=/['\n\r\u2028\u2029\\]/g,En="[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?)*",On="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+En,Sn="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]?|[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",In=RegExp("['\u2019]","g"),Rn=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g"),zn=RegExp("\\ud83c[\\udffb-\\udfff](?=\\ud83c[\\udffb-\\udfff])|"+Sn+En,"g"),Wn=RegExp(["[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+(?:['\u2019](?:d|ll|m|re|s|t|ve))?(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde]|$)|(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['\u2019](?:D|LL|M|RE|S|T|VE))?(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde](?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])|$)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?(?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['\u2019](?:d|ll|m|re|s|t|ve))?|[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?:['\u2019](?:D|LL|M|RE|S|T|VE))?|\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)|\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)|\\d+",On].join("|"),"g"),Bn=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),Ln=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Un="Array Buffer DataView Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Math Object Promise RegExp Set String Symbol TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap _ clearTimeout isFinite parseInt setTimeout".split(" "),Cn={};
+Cn["[object Float32Array]"]=Cn["[object Float64Array]"]=Cn["[object Int8Array]"]=Cn["[object Int16Array]"]=Cn["[object Int32Array]"]=Cn["[object Uint8Array]"]=Cn["[object Uint8ClampedArray]"]=Cn["[object Uint16Array]"]=Cn["[object Uint32Array]"]=true,Cn["[object Arguments]"]=Cn["[object Array]"]=Cn["[object ArrayBuffer]"]=Cn["[object Boolean]"]=Cn["[object DataView]"]=Cn["[object Date]"]=Cn["[object Error]"]=Cn["[object Function]"]=Cn["[object Map]"]=Cn["[object Number]"]=Cn["[object Object]"]=Cn["[object RegExp]"]=Cn["[object Set]"]=Cn["[object String]"]=Cn["[object WeakMap]"]=false;
+var Dn={};Dn["[object Arguments]"]=Dn["[object Array]"]=Dn["[object ArrayBuffer]"]=Dn["[object DataView]"]=Dn["[object Boolean]"]=Dn["[object Date]"]=Dn["[object Float32Array]"]=Dn["[object Float64Array]"]=Dn["[object Int8Array]"]=Dn["[object Int16Array]"]=Dn["[object Int32Array]"]=Dn["[object Map]"]=Dn["[object Number]"]=Dn["[object Object]"]=Dn["[object RegExp]"]=Dn["[object Set]"]=Dn["[object String]"]=Dn["[object Symbol]"]=Dn["[object Uint8Array]"]=Dn["[object Uint8ClampedArray]"]=Dn["[object Uint16Array]"]=Dn["[object Uint32Array]"]=true,
+Dn["[object Error]"]=Dn["[object Function]"]=Dn["[object WeakMap]"]=false;var Mn,Tn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$n=parseFloat,Fn=parseInt,Nn=typeof global=="object"&&global&&global.Object===Object&&global,Pn=typeof self=="object"&&self&&self.Object===Object&&self,Zn=Nn||Pn||Function("return this")(),qn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vn=qn&&typeof module=="object"&&module&&!module.nodeType&&module,Kn=Vn&&Vn.exports===qn,Gn=Kn&&Nn.process;
+n:{try{Mn=Gn&&Gn.binding&&Gn.binding("util");break n}catch(n){}Mn=void 0}var Hn=Mn&&Mn.isArrayBuffer,Jn=Mn&&Mn.isDate,Yn=Mn&&Mn.isMap,Qn=Mn&&Mn.isRegExp,Xn=Mn&&Mn.isSet,nt=Mn&&Mn.isTypedArray,tt=j("length"),rt=w({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I",
+"\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C",
+"\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i",
+"\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S",
+"\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe",
+"\u0149":"'n","\u017f":"s"}),et=w({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}),ut=w({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),it=function w(En){function On(n){if(bu(n)&&!cf(n)&&!(n instanceof Mn)){if(n instanceof zn)return n;if(fi.call(n,"__wrapped__"))return Ne(n)}return new zn(n)}function Sn(){}function zn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=F}function Mn(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,
+this.__filtered__=false,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Tn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Nn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Pn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function qn(n){var t=-1,r=null==n?0:n.length;for(this.__data__=new Pn;++t<r;)this.add(n[t])}function Vn(n){
+this.size=(this.__data__=new Nn(n)).size}function Gn(n,t){var r,e=cf(n),u=!e&&ff(n),i=!e&&!u&&lf(n),o=!e&&!u&&!i&&vf(n),u=(e=e||u||i||o)?E(n.length,ti):[],f=u.length;for(r in n)!t&&!fi.call(n,r)||e&&("length"==r||i&&("offset"==r||"parent"==r)||o&&("buffer"==r||"byteLength"==r||"byteOffset"==r)||Se(r,f))||u.push(r);return u}function tt(n){var t=n.length;return t?n[ar(0,t-1)]:F}function ot(n,t){return Me(Tr(n),dt(t,0,n.length))}function ft(n){return Me(Tr(n))}function ct(n,t,r,e){return n===F||su(n,ui[r])&&!fi.call(e,r)?t:n;
+}function at(n,t,r){(r===F||su(n[t],r))&&(r!==F||t in n)||vt(n,t,r)}function lt(n,t,r){var e=n[t];fi.call(n,t)&&su(e,r)&&(r!==F||t in n)||vt(n,t,r)}function st(n,t){for(var r=n.length;r--;)if(su(n[r][0],t))return r;return-1}function ht(n,t,r,e){return io(n,function(n,u,i){t(e,n,r(n),i)}),e}function pt(n,t){return n&&$r(t,Bu(t),n)}function _t(n,t){return n&&$r(t,Lu(t),n)}function vt(n,t,r){"__proto__"==t&&ki?ki(n,t,{configurable:true,enumerable:true,value:r,writable:true}):n[t]=r}function gt(n,t){for(var r=-1,e=t.length,u=Gu(e),i=null==n;++r<e;)u[r]=i?F:zu(n,t[r]);
+return u}function dt(n,t,r){return n===n&&(r!==F&&(n=n<=r?n:r),t!==F&&(n=n>=t?n:t)),n}function yt(n,t,r,e,i,o){var f,c=1&t,a=2&t,l=4&t;if(r&&(f=i?r(n,e,i,o):r(n)),f!==F)return f;if(!yu(n))return n;if(e=cf(n)){if(f=Ae(n),!c)return Tr(n,f)}else{var s=go(n),h="[object Function]"==s||"[object GeneratorFunction]"==s;if(lf(n))return Br(n,c);if("[object Object]"==s||"[object Arguments]"==s||h&&!i){if(f=a||h?{}:ke(n),!c)return a?Nr(n,_t(f,n)):Fr(n,pt(f,n))}else{if(!Dn[s])return i?n:{};f=Ee(n,s,yt,c)}}if(o||(o=new Vn),
+i=o.get(n))return i;o.set(n,f);var a=l?a?ge:ve:a?Lu:Bu,p=e?F:a(n);return u(p||n,function(e,u){p&&(u=e,e=n[u]),lt(f,u,yt(e,t,r,u,n,o))}),f}function bt(n){var t=Bu(n);return function(r){return xt(r,n,t)}}function xt(n,t,r){var e=r.length;if(null==n)return!e;for(n=Xu(n);e--;){var u=r[e],i=t[u],o=n[u];if(o===F&&!(u in n)||!i(o))return false}return true}function jt(n,t,r){if(typeof n!="function")throw new ri("Expected a function");return xo(function(){n.apply(F,r)},t)}function wt(n,t,r,e){var u=-1,i=c,o=true,f=n.length,s=[],h=t.length;
+if(!f)return s;r&&(t=l(t,S(r))),e?(i=a,o=false):200<=t.length&&(i=R,o=false,t=new qn(t));n:for(;++u<f;){var p=n[u],_=null==r?p:r(p),p=e||0!==p?p:0;if(o&&_===_){for(var v=h;v--;)if(t[v]===_)continue n;s.push(p)}else i(t,_,e)||s.push(p)}return s}function mt(n,t){var r=true;return io(n,function(n,e,u){return r=!!t(n,e,u)}),r}function At(n,t,r){for(var e=-1,u=n.length;++e<u;){var i=n[e],o=t(i);if(null!=o&&(f===F?o===o&&!mu(o):r(o,f)))var f=o,c=i}return c}function kt(n,t){var r=[];return io(n,function(n,e,u){
+t(n,e,u)&&r.push(n)}),r}function Et(n,t,r,e,u){var i=-1,o=n.length;for(r||(r=Oe),u||(u=[]);++i<o;){var f=n[i];0<t&&r(f)?1<t?Et(f,t-1,r,e,u):s(u,f):e||(u[u.length]=f)}return u}function Ot(n,t){return n&&fo(n,t,Bu)}function St(n,t){return n&&co(n,t,Bu)}function It(n,t){return f(t,function(t){return vu(n[t])})}function Rt(n,t){t=zr(t,n);for(var r=0,e=t.length;null!=n&&r<e;)n=n[Te(t[r++])];return r&&r==e?n:F}function zt(n,t,r){return t=t(n),cf(n)?t:s(t,r(n))}function Wt(n){if(null==n)return n===F?"[object Undefined]":"[object Null]";
+n=Xu(n);var t;if(Ai&&Ai in n){var r=fi.call(n,Ai),e=n[Ai];try{n[Ai]=F,t=true}catch(n){}var u=li.call(n);t&&(r?n[Ai]=e:delete n[Ai]),t=u}else t=li.call(n);return t}function Bt(n,t){return n>t}function Lt(n,t){return null!=n&&fi.call(n,t)}function Ut(n,t){return null!=n&&t in Xu(n)}function Ct(n,t,r){for(var e=r?a:c,u=n[0].length,i=n.length,o=i,f=Gu(i),s=1/0,h=[];o--;){var p=n[o];o&&t&&(p=l(p,S(t))),s=Di(p.length,s),f[o]=!r&&(t||120<=u&&120<=p.length)?new qn(o&&p):F}var p=n[0],_=-1,v=f[0];n:for(;++_<u&&h.length<s;){
+var g=p[_],d=t?t(g):g,g=r||0!==g?g:0;if(v?!R(v,d):!e(h,d,r)){for(o=i;--o;){var y=f[o];if(y?!R(y,d):!e(n[o],d,r))continue n}v&&v.push(d),h.push(g)}}return h}function Dt(n,t,r){var e={};return Ot(n,function(n,u,i){t(e,r(n),u,i)}),e}function Mt(n,t,e){return t=zr(t,n),n=2>t.length?n:Rt(n,gr(t,0,-1)),t=null==n?n:n[Te(Ke(t))],null==t?F:r(t,n,e)}function Tt(n){return bu(n)&&"[object Arguments]"==Wt(n)}function $t(n){return bu(n)&&"[object ArrayBuffer]"==Wt(n)}function Ft(n){return bu(n)&&"[object Date]"==Wt(n);
+}function Nt(n,t,r,e,u){if(n===t)t=true;else if(null==n||null==t||!yu(n)&&!bu(t))t=n!==n&&t!==t;else n:{var i=cf(n),o=cf(t),f="[object Array]",c="[object Array]";i||(f=go(n),f="[object Arguments]"==f?"[object Object]":f),o||(c=go(t),c="[object Arguments]"==c?"[object Object]":c);var a="[object Object]"==f,o="[object Object]"==c;if((c=f==c)&&lf(n)){if(!lf(t)){t=false;break n}i=true,a=false}if(c&&!a)u||(u=new Vn),t=i||vf(n)?he(n,t,r,e,Nt,u):pe(n,t,f,r,e,Nt,u);else{if(!(1&r)&&(i=a&&fi.call(n,"__wrapped__"),f=o&&fi.call(t,"__wrapped__"),
+i||f)){n=i?n.value():n,t=f?t.value():t,u||(u=new Vn),t=Nt(n,t,r,e,u);break n}if(c)t:if(u||(u=new Vn),i=1&r,f=Bu(n),o=f.length,c=Bu(t).length,o==c||i){for(a=o;a--;){var l=f[a];if(!(i?l in t:fi.call(t,l))){t=false;break t}}if((c=u.get(n))&&u.get(t))t=c==t;else{c=true,u.set(n,t),u.set(t,n);for(var s=i;++a<o;){var l=f[a],h=n[l],p=t[l];if(e)var _=i?e(p,h,l,t,n,u):e(h,p,l,n,t,u);if(_===F?h!==p&&!Nt(h,p,r,e,u):!_){c=false;break}s||(s="constructor"==l)}c&&!s&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(c=false)),
+u.delete(n),u.delete(t),t=c}}else t=false;else t=false}}return t}function Pt(n){return bu(n)&&"[object Map]"==go(n)}function Zt(n,t,r,e){var u=r.length,i=u,o=!e;if(null==n)return!i;for(n=Xu(n);u--;){var f=r[u];if(o&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return false}for(;++u<i;){var f=r[u],c=f[0],a=n[c],l=f[1];if(o&&f[2]){if(a===F&&!(c in n))return false}else{if(f=new Vn,e)var s=e(a,l,c,n,t,f);if(s===F?!Nt(l,a,3,e,f):!s)return false}}return true}function qt(n){return!(!yu(n)||ai&&ai in n)&&(vu(n)?pi:xn).test($e(n))}function Vt(n){
+return bu(n)&&"[object RegExp]"==Wt(n)}function Kt(n){return bu(n)&&"[object Set]"==go(n)}function Gt(n){return bu(n)&&du(n.length)&&!!Cn[Wt(n)]}function Ht(n){return typeof n=="function"?n:null==n?Fu:typeof n=="object"?cf(n)?nr(n[0],n[1]):Xt(n):qu(n)}function Jt(n){if(!We(n))return Ui(n);var t,r=[];for(t in Xu(n))fi.call(n,t)&&"constructor"!=t&&r.push(t);return r}function Yt(n,t){return n<t}function Qt(n,t){var r=-1,e=hu(n)?Gu(n.length):[];return io(n,function(n,u,i){e[++r]=t(n,u,i)}),e}function Xt(n){
+var t=je(n);return 1==t.length&&t[0][2]?Be(t[0][0],t[0][1]):function(r){return r===n||Zt(r,n,t)}}function nr(n,t){return Re(n)&&t===t&&!yu(t)?Be(Te(n),t):function(r){var e=zu(r,n);return e===F&&e===t?Wu(r,n):Nt(t,e,3)}}function tr(n,t,r,e,u){n!==t&&fo(t,function(i,o){if(yu(i)){u||(u=new Vn);var f=u,c=n[o],a=t[o],l=f.get(a);if(l)at(n,o,l);else{var l=e?e(c,a,o+"",n,t,f):F,s=l===F;if(s){var h=cf(a),p=!h&&lf(a),_=!h&&!p&&vf(a),l=a;h||p||_?cf(c)?l=c:pu(c)?l=Tr(c):p?(s=false,l=Br(a,true)):_?(s=false,l=Ur(a,true)):l=[]:ju(a)||ff(a)?(l=c,
+ff(c)?l=Iu(c):(!yu(c)||r&&vu(c))&&(l=ke(a))):s=false}s&&(f.set(a,l),tr(l,a,r,e,f),f.delete(a)),at(n,o,l)}}else f=e?e(n[o],i,o+"",n,t,u):F,f===F&&(f=i),at(n,o,f)},Lu)}function rr(n,t){var r=n.length;if(r)return t+=0>t?r:0,Se(t,r)?n[t]:F}function er(n,t,r){var e=-1;return t=l(t.length?t:[Fu],S(be())),n=Qt(n,function(n){return{a:l(t,function(t){return t(n)}),b:++e,c:n}}),A(n,function(n,t){var e;n:{e=-1;for(var u=n.a,i=t.a,o=u.length,f=r.length;++e<o;){var c=Cr(u[e],i[e]);if(c){e=e>=f?c:c*("desc"==r[e]?-1:1);
+break n}}e=n.b-t.b}return e})}function ur(n,t){return n=Xu(n),ir(n,t,function(t,r){return Wu(n,r)})}function ir(n,t,r){for(var e=-1,u=t.length,i={};++e<u;){var o=t[e],f=Rt(n,o);r(f,o)&&_r(i,zr(o,n),f)}return i}function or(n){return function(t){return Rt(t,n)}}function fr(n,t,r,e){var u=e?y:d,i=-1,o=t.length,f=n;for(n===t&&(t=Tr(t)),r&&(f=l(n,S(r)));++i<o;)for(var c=0,a=t[i],a=r?r(a):a;-1<(c=u(f,a,c,e));)f!==n&&ji.call(f,c,1),ji.call(n,c,1);return n}function cr(n,t){for(var r=n?t.length:0,e=r-1;r--;){
+var u=t[r];if(r==e||u!==i){var i=u;Se(u)?ji.call(n,u,1):Ar(n,u)}}}function ar(n,t){return n+Ri($i()*(t-n+1))}function lr(n,t){var r="";if(!n||1>t||9007199254740991<t)return r;do t%2&&(r+=n),(t=Ri(t/2))&&(n+=n);while(t);return r}function sr(n,t){return jo(Ue(n,t,Fu),n+"")}function hr(n){return tt(Cu(n))}function pr(n,t){var r=Cu(n);return Me(r,dt(t,0,r.length))}function _r(n,t,r,e){if(!yu(n))return n;t=zr(t,n);for(var u=-1,i=t.length,o=i-1,f=n;null!=f&&++u<i;){var c=Te(t[u]),a=r;if(u!=o){var l=f[c],a=e?e(l,c,f):F;
+a===F&&(a=yu(l)?l:Se(t[u+1])?[]:{})}lt(f,c,a),f=f[c]}return n}function vr(n){return Me(Cu(n))}function gr(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Gu(u);++e<u;)r[e]=n[e+t];return r}function dr(n,t){var r;return io(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function yr(n,t,r){var e=0,u=null==n?e:n.length;if(typeof t=="number"&&t===t&&2147483647>=u){for(;e<u;){var i=e+u>>>1,o=n[i];null!==o&&!mu(o)&&(r?o<=t:o<t)?e=i+1:u=i}return u}return br(n,t,Fu,r);
+}function br(n,t,r,e){t=r(t);for(var u=0,i=null==n?0:n.length,o=t!==t,f=null===t,c=mu(t),a=t===F;u<i;){var l=Ri((u+i)/2),s=r(n[l]),h=s!==F,p=null===s,_=s===s,v=mu(s);(o?e||_:a?_&&(e||h):f?_&&h&&(e||!p):c?_&&h&&!p&&(e||!v):p||v?0:e?s<=t:s<t)?u=l+1:i=l}return Di(i,4294967294)}function xr(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r],f=t?t(o):o;if(!r||!su(f,c)){var c=f;i[u++]=0===o?0:o}}return i}function jr(n){return typeof n=="number"?n:mu(n)?P:+n}function wr(n){if(typeof n=="string")return n;
+if(cf(n))return l(n,wr)+"";if(mu(n))return eo?eo.call(n):"";var t=n+"";return"0"==t&&1/n==-N?"-0":t}function mr(n,t,r){var e=-1,u=c,i=n.length,o=true,f=[],l=f;if(r)o=false,u=a;else if(200<=i){if(u=t?null:ho(n))return D(u);o=false,u=R,l=new qn}else l=t?[]:f;n:for(;++e<i;){var s=n[e],h=t?t(s):s,s=r||0!==s?s:0;if(o&&h===h){for(var p=l.length;p--;)if(l[p]===h)continue n;t&&l.push(h),f.push(s)}else u(l,h,r)||(l!==f&&l.push(h),f.push(s))}return f}function Ar(n,t){return t=zr(t,n),n=2>t.length?n:Rt(n,gr(t,0,-1)),
+null==n||delete n[Te(Ke(t))]}function kr(n,t,r,e){for(var u=n.length,i=e?u:-1;(e?i--:++i<u)&&t(n[i],i,n););return r?gr(n,e?0:i,e?i+1:u):gr(n,e?i+1:0,e?u:i)}function Er(n,t){var r=n;return r instanceof Mn&&(r=r.value()),h(t,function(n,t){return t.func.apply(t.thisArg,s([n],t.args))},r)}function Or(n,t,r){var e=n.length;if(2>e)return e?mr(n[0]):[];for(var u=-1,i=Gu(e);++u<e;)for(var o=n[u],f=-1;++f<e;)f!=u&&(i[u]=wt(i[u]||o,n[f],t,r));return mr(Et(i,1),t,r)}function Sr(n,t,r){for(var e=-1,u=n.length,i=t.length,o={};++e<u;)r(o,n[e],e<i?t[e]:F);
+return o}function Ir(n){return pu(n)?n:[]}function Rr(n){return typeof n=="function"?n:Fu}function zr(n,t){return cf(n)?n:Re(n,t)?[n]:wo(Ru(n))}function Wr(n,t,r){var e=n.length;return r=r===F?e:r,!t&&r>=e?n:gr(n,t,r)}function Br(n,t){if(t)return n.slice();var r=n.length,r=di?di(r):new n.constructor(r);return n.copy(r),r}function Lr(n){var t=new n.constructor(n.byteLength);return new gi(t).set(new gi(n)),t}function Ur(n,t){return new n.constructor(t?Lr(n.buffer):n.buffer,n.byteOffset,n.length)}function Cr(n,t){
+if(n!==t){var r=n!==F,e=null===n,u=n===n,i=mu(n),o=t!==F,f=null===t,c=t===t,a=mu(t);if(!f&&!a&&!i&&n>t||i&&o&&c&&!f&&!a||e&&o&&c||!r&&c||!u)return 1;if(!e&&!i&&!a&&n<t||a&&r&&u&&!e&&!i||f&&r&&u||!o&&u||!c)return-1}return 0}function Dr(n,t,r,e){var u=-1,i=n.length,o=r.length,f=-1,c=t.length,a=Ci(i-o,0),l=Gu(c+a);for(e=!e;++f<c;)l[f]=t[f];for(;++u<o;)(e||u<i)&&(l[r[u]]=n[u]);for(;a--;)l[f++]=n[u++];return l}function Mr(n,t,r,e){var u=-1,i=n.length,o=-1,f=r.length,c=-1,a=t.length,l=Ci(i-f,0),s=Gu(l+a);
+for(e=!e;++u<l;)s[u]=n[u];for(l=u;++c<a;)s[l+c]=t[c];for(;++o<f;)(e||u<i)&&(s[l+r[o]]=n[u++]);return s}function Tr(n,t){var r=-1,e=n.length;for(t||(t=Gu(e));++r<e;)t[r]=n[r];return t}function $r(n,t,r,e){var u=!r;r||(r={});for(var i=-1,o=t.length;++i<o;){var f=t[i],c=e?e(r[f],n[f],f,r,n):F;c===F&&(c=n[f]),u?vt(r,f,c):lt(r,f,c)}return r}function Fr(n,t){return $r(n,_o(n),t)}function Nr(n,t){return $r(n,vo(n),t)}function Pr(n,t){return function(r,u){var i=cf(r)?e:ht,o=t?t():{};return i(r,n,be(u,2),o);
+}}function Zr(n){return sr(function(t,r){var e=-1,u=r.length,i=1<u?r[u-1]:F,o=2<u?r[2]:F,i=3<n.length&&typeof i=="function"?(u--,i):F;for(o&&Ie(r[0],r[1],o)&&(i=3>u?F:i,u=1),t=Xu(t);++e<u;)(o=r[e])&&n(t,o,e,i);return t})}function qr(n,t){return function(r,e){if(null==r)return r;if(!hu(r))return n(r,e);for(var u=r.length,i=t?u:-1,o=Xu(r);(t?i--:++i<u)&&false!==e(o[i],i,o););return r}}function Vr(n){return function(t,r,e){var u=-1,i=Xu(t);e=e(t);for(var o=e.length;o--;){var f=e[n?o:++u];if(false===r(i[f],f,i))break;
+}return t}}function Kr(n,t,r){function e(){return(this&&this!==Zn&&this instanceof e?i:n).apply(u?r:this,arguments)}var u=1&t,i=Jr(n);return e}function Gr(n){return function(t){t=Ru(t);var r=Bn.test(t)?$(t):F,e=r?r[0]:t.charAt(0);return t=r?Wr(r,1).join(""):t.slice(1),e[n]()+t}}function Hr(n){return function(t){return h(Tu(Mu(t).replace(In,"")),n,"")}}function Jr(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:
+return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=uo(n.prototype),t=n.apply(r,t);return yu(t)?t:r}}function Yr(n,t,e){function u(){for(var o=arguments.length,f=Gu(o),c=o,a=ye(u);c--;)f[c]=arguments[c];return c=3>o&&f[0]!==a&&f[o-1]!==a?[]:C(f,a),o-=c.length,o<e?ce(n,t,ne,u.placeholder,F,f,c,F,F,e-o):r(this&&this!==Zn&&this instanceof u?i:n,this,f);
+}var i=Jr(n);return u}function Qr(n){return function(t,r,e){var u=Xu(t);if(!hu(t)){var i=be(r,3);t=Bu(t),r=function(n){return i(u[n],n,u)}}return r=n(t,r,e),-1<r?u[i?t[r]:r]:F}}function Xr(n){return _e(function(t){var r=t.length,e=r,u=zn.prototype.thru;for(n&&t.reverse();e--;){var i=t[e];if(typeof i!="function")throw new ri("Expected a function");if(u&&!o&&"wrapper"==de(i))var o=new zn([],true)}for(e=o?e:r;++e<r;)var i=t[e],u=de(i),f="wrapper"==u?po(i):F,o=f&&ze(f[0])&&424==f[1]&&!f[4].length&&1==f[9]?o[de(f[0])].apply(o,f[3]):1==i.length&&ze(i)?o[u]():o.thru(i);
+return function(){var n=arguments,e=n[0];if(o&&1==n.length&&cf(e)&&200<=e.length)return o.plant(e).value();for(var u=0,n=r?t[u].apply(this,n):e;++u<r;)n=t[u].call(this,n);return n}})}function ne(n,t,r,e,u,i,o,f,c,a){function l(){for(var d=arguments.length,y=Gu(d),b=d;b--;)y[b]=arguments[b];if(_){var x,j=ye(l),b=y.length;for(x=0;b--;)y[b]===j&&++x}if(e&&(y=Dr(y,e,u,_)),i&&(y=Mr(y,i,o,_)),d-=x,_&&d<a)return j=C(y,j),ce(n,t,ne,l.placeholder,r,y,j,f,c,a-d);if(j=h?r:this,b=p?j[n]:n,d=y.length,f){x=y.length;
+for(var w=Di(f.length,x),m=Tr(y);w--;){var A=f[w];y[w]=Se(A,x)?m[A]:F}}else v&&1<d&&y.reverse();return s&&c<d&&(y.length=c),this&&this!==Zn&&this instanceof l&&(b=g||Jr(b)),b.apply(j,y)}var s=128&t,h=1&t,p=2&t,_=24&t,v=512&t,g=p?F:Jr(n);return l}function te(n,t){return function(r,e){return Dt(r,n,t(e))}}function re(n,t){return function(r,e){var u;if(r===F&&e===F)return t;if(r!==F&&(u=r),e!==F){if(u===F)return e;typeof r=="string"||typeof e=="string"?(r=wr(r),e=wr(e)):(r=jr(r),e=jr(e)),u=n(r,e)}return u;
+}}function ee(n){return _e(function(t){return t=l(t,S(be())),sr(function(e){var u=this;return n(t,function(n){return r(n,u,e)})})})}function ue(n,t){t=t===F?" ":wr(t);var r=t.length;return 2>r?r?lr(t,n):t:(r=lr(t,Ii(n/T(t))),Bn.test(t)?Wr($(r),0,n).join(""):r.slice(0,n))}function ie(n,t,e,u){function i(){for(var t=-1,c=arguments.length,a=-1,l=u.length,s=Gu(l+c),h=this&&this!==Zn&&this instanceof i?f:n;++a<l;)s[a]=u[a];for(;c--;)s[a++]=arguments[++t];return r(h,o?e:this,s)}var o=1&t,f=Jr(n);return i;
+}function oe(n){return function(t,r,e){e&&typeof e!="number"&&Ie(t,r,e)&&(r=e=F),t=ku(t),r===F?(r=t,t=0):r=ku(r),e=e===F?t<r?1:-1:ku(e);var u=-1;r=Ci(Ii((r-t)/(e||1)),0);for(var i=Gu(r);r--;)i[n?r:++u]=t,t+=e;return i}}function fe(n){return function(t,r){return typeof t=="string"&&typeof r=="string"||(t=Su(t),r=Su(r)),n(t,r)}}function ce(n,t,r,e,u,i,o,f,c,a){var l=8&t,s=l?o:F;o=l?F:o;var h=l?i:F;return i=l?F:i,t=(t|(l?32:64))&~(l?64:32),4&t||(t&=-4),u=[n,t,u,h,s,i,o,f,c,a],r=r.apply(F,u),ze(n)&&bo(r,u),
+r.placeholder=e,Ce(r,n,t)}function ae(n){var t=Qu[n];return function(n,r){if(n=Su(n),r=Di(Eu(r),292)){var e=(Ru(n)+"e").split("e"),e=t(e[0]+"e"+(+e[1]+r)),e=(Ru(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return t(n)}}function le(n){return function(t){var r=go(t);return"[object Map]"==r?L(t):"[object Set]"==r?M(t):O(t,n(t))}}function se(n,t,r,e,u,i,o,f){var c=2&t;if(!c&&typeof n!="function")throw new ri("Expected a function");var a=e?e.length:0;if(a||(t&=-97,e=u=F),o=o===F?o:Ci(Eu(o),0),f=f===F?f:Eu(f),
+a-=u?u.length:0,64&t){var l=e,s=u;e=u=F}var h=c?F:po(n);return i=[n,t,r,e,u,l,s,i,o,f],h&&(r=i[1],n=h[1],t=r|n,e=128==n&&8==r||128==n&&256==r&&i[7].length<=h[8]||384==n&&h[7].length<=h[8]&&8==r,131>t||e)&&(1&n&&(i[2]=h[2],t|=1&r?0:4),(r=h[3])&&(e=i[3],i[3]=e?Dr(e,r,h[4]):r,i[4]=e?C(i[3],"__lodash_placeholder__"):h[4]),(r=h[5])&&(e=i[5],i[5]=e?Mr(e,r,h[6]):r,i[6]=e?C(i[5],"__lodash_placeholder__"):h[6]),(r=h[7])&&(i[7]=r),128&n&&(i[8]=null==i[8]?h[8]:Di(i[8],h[8])),null==i[9]&&(i[9]=h[9]),i[0]=h[0],
+i[1]=t),n=i[0],t=i[1],r=i[2],e=i[3],u=i[4],f=i[9]=null==i[9]?c?0:n.length:Ci(i[9]-a,0),!f&&24&t&&(t&=-25),Ce((h?ao:bo)(t&&1!=t?8==t||16==t?Yr(n,t,f):32!=t&&33!=t||u.length?ne.apply(F,i):ie(n,t,r,e):Kr(n,t,r),i),n,t)}function he(n,t,r,e,u,i){var o=1&r,f=n.length,c=t.length;if(f!=c&&!(o&&c>f))return false;if((c=i.get(n))&&i.get(t))return c==t;var c=-1,a=true,l=2&r?new qn:F;for(i.set(n,t),i.set(t,n);++c<f;){var s=n[c],h=t[c];if(e)var p=o?e(h,s,c,t,n,i):e(s,h,c,n,t,i);if(p!==F){if(p)continue;a=false;break}if(l){
+if(!_(t,function(n,t){if(!R(l,t)&&(s===n||u(s,n,r,e,i)))return l.push(t)})){a=false;break}}else if(s!==h&&!u(s,h,r,e,i)){a=false;break}}return i.delete(n),i.delete(t),a}function pe(n,t,r,e,u,i,o){switch(r){case"[object DataView]":if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)break;n=n.buffer,t=t.buffer;case"[object ArrayBuffer]":if(n.byteLength!=t.byteLength||!i(new gi(n),new gi(t)))break;return true;case"[object Boolean]":case"[object Date]":case"[object Number]":return su(+n,+t);case"[object Error]":
+return n.name==t.name&&n.message==t.message;case"[object RegExp]":case"[object String]":return n==t+"";case"[object Map]":var f=L;case"[object Set]":if(f||(f=D),n.size!=t.size&&!(1&e))break;return(r=o.get(n))?r==t:(e|=2,o.set(n,t),t=he(f(n),f(t),e,u,i,o),o.delete(n),t);case"[object Symbol]":if(ro)return ro.call(n)==ro.call(t)}return false}function _e(n){return jo(Ue(n,F,qe),n+"")}function ve(n){return zt(n,Bu,_o)}function ge(n){return zt(n,Lu,vo)}function de(n){for(var t=n.name+"",r=Hi[t],e=fi.call(Hi,t)?r.length:0;e--;){
+var u=r[e],i=u.func;if(null==i||i==n)return u.name}return t}function ye(n){return(fi.call(On,"placeholder")?On:n).placeholder}function be(){var n=On.iteratee||Nu,n=n===Nu?Ht:n;return arguments.length?n(arguments[0],arguments[1]):n}function xe(n,t){var r=n.__data__,e=typeof t;return("string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t)?r[typeof t=="string"?"string":"hash"]:r.map}function je(n){for(var t=Bu(n),r=t.length;r--;){var e=t[r],u=n[e];t[r]=[e,u,u===u&&!yu(u)]}return t;
+}function we(n,t){var r=null==n?F:n[t];return qt(r)?r:F}function me(n,t,r){t=zr(t,n);for(var e=-1,u=t.length,i=false;++e<u;){var o=Te(t[e]);if(!(i=null!=n&&r(n,o)))break;n=n[o]}return i||++e!=u?i:(u=null==n?0:n.length,!!u&&du(u)&&Se(o,u)&&(cf(n)||ff(n)))}function Ae(n){var t=n.length,r=n.constructor(t);return t&&"string"==typeof n[0]&&fi.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ke(n){return typeof n.constructor!="function"||We(n)?{}:uo(yi(n))}function Ee(r,e,u,i){var o=r.constructor;
+switch(e){case"[object ArrayBuffer]":return Lr(r);case"[object Boolean]":case"[object Date]":return new o(+r);case"[object DataView]":return e=i?Lr(r.buffer):r.buffer,new r.constructor(e,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Ur(r,i);case"[object Map]":return e=i?u(L(r),1):L(r),
+h(e,n,new r.constructor);case"[object Number]":case"[object String]":return new o(r);case"[object RegExp]":return e=new r.constructor(r.source,dn.exec(r)),e.lastIndex=r.lastIndex,e;case"[object Set]":return e=i?u(D(r),1):D(r),h(e,t,new r.constructor);case"[object Symbol]":return ro?Xu(ro.call(r)):{}}}function Oe(n){return cf(n)||ff(n)||!!(wi&&n&&n[wi])}function Se(n,t){return t=null==t?9007199254740991:t,!!t&&(typeof n=="number"||wn.test(n))&&-1<n&&0==n%1&&n<t}function Ie(n,t,r){if(!yu(r))return false;
+var e=typeof t;return!!("number"==e?hu(r)&&Se(t,r.length):"string"==e&&t in r)&&su(r[t],n)}function Re(n,t){if(cf(n))return false;var r=typeof n;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=n&&!mu(n))||(rn.test(n)||!tn.test(n)||null!=t&&n in Xu(t))}function ze(n){var t=de(n),r=On[t];return typeof r=="function"&&t in Mn.prototype&&(n===r||(t=po(r),!!t&&n===t[0]))}function We(n){var t=n&&n.constructor;return n===(typeof t=="function"&&t.prototype||ui)}function Be(n,t){return function(r){return null!=r&&(r[n]===t&&(t!==F||n in Xu(r)));
+}}function Le(n,t,r,e,u,i){return yu(n)&&yu(t)&&(i.set(t,n),tr(n,t,F,Le,i),i.delete(t)),n}function Ue(n,t,e){return t=Ci(t===F?n.length-1:t,0),function(){for(var u=arguments,i=-1,o=Ci(u.length-t,0),f=Gu(o);++i<o;)f[i]=u[t+i];for(i=-1,o=Gu(t+1);++i<t;)o[i]=u[i];return o[t]=e(f),r(n,this,o)}}function Ce(n,t,r){var e=t+"";t=jo;var u,i=Fe;return u=(u=e.match(hn))?u[1].split(pn):[],r=i(u,r),(i=r.length)&&(u=i-1,r[u]=(1<i?"& ":"")+r[u],r=r.join(2<i?", ":" "),e=e.replace(sn,"{\n/* [wrapped with "+r+"] */\n")),
+t(n,e)}function De(n){var t=0,r=0;return function(){var e=Mi(),u=16-(e-r);if(r=e,0<u){if(800<=++t)return arguments[0]}else t=0;return n.apply(F,arguments)}}function Me(n,t){var r=-1,e=n.length,u=e-1;for(t=t===F?e:t;++r<t;){var e=ar(r,u),i=n[e];n[e]=n[r],n[r]=i}return n.length=t,n}function Te(n){if(typeof n=="string"||mu(n))return n;var t=n+"";return"0"==t&&1/n==-N?"-0":t}function $e(n){if(null!=n){try{return oi.call(n)}catch(n){}return n+""}return""}function Fe(n,t){return u(Z,function(r){var e="_."+r[0];
+t&r[1]&&!c(n,e)&&n.push(e)}),n.sort()}function Ne(n){if(n instanceof Mn)return n.clone();var t=new zn(n.__wrapped__,n.__chain__);return t.__actions__=Tr(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Pe(n,t,r){var e=null==n?0:n.length;return e?(r=null==r?0:Eu(r),0>r&&(r=Ci(e+r,0)),g(n,be(t,3),r)):-1}function Ze(n,t,r){var e=null==n?0:n.length;if(!e)return-1;var u=e-1;return r!==F&&(u=Eu(r),u=0>r?Ci(e+u,0):Di(u,e-1)),g(n,be(t,3),u,true)}function qe(n){return(null==n?0:n.length)?Et(n,1):[];
+}function Ve(n){return n&&n.length?n[0]:F}function Ke(n){var t=null==n?0:n.length;return t?n[t-1]:F}function Ge(n,t){return n&&n.length&&t&&t.length?fr(n,t):n}function He(n){return null==n?n:Fi.call(n)}function Je(n){if(!n||!n.length)return[];var t=0;return n=f(n,function(n){if(pu(n))return t=Ci(n.length,t),true}),E(t,function(t){return l(n,j(t))})}function Ye(n,t){if(!n||!n.length)return[];var e=Je(n);return null==t?e:l(e,function(n){return r(t,F,n)})}function Qe(n){return n=On(n),n.__chain__=true,n;
+}function Xe(n,t){return t(n)}function nu(){return this}function tu(n,t){return(cf(n)?u:io)(n,be(t,3))}function ru(n,t){return(cf(n)?i:oo)(n,be(t,3))}function eu(n,t){return(cf(n)?l:Qt)(n,be(t,3))}function uu(n,t,r){return t=r?F:t,t=n&&null==t?n.length:t,se(n,128,F,F,F,F,t)}function iu(n,t){var r;if(typeof t!="function")throw new ri("Expected a function");return n=Eu(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=F),r}}function ou(n,t,r){return t=r?F:t,n=se(n,8,F,F,F,F,F,t),n.placeholder=ou.placeholder,
+n}function fu(n,t,r){return t=r?F:t,n=se(n,16,F,F,F,F,F,t),n.placeholder=fu.placeholder,n}function cu(n,t,r){function e(t){var r=c,e=a;return c=a=F,_=t,s=n.apply(e,r)}function u(n){var r=n-p;return n-=_,p===F||r>=t||0>r||g&&n>=l}function i(){var n=Ho();if(u(n))return o(n);var r,e=xo;r=n-_,n=t-(n-p),r=g?Di(n,l-r):n,h=e(i,r)}function o(n){return h=F,d&&c?e(n):(c=a=F,s)}function f(){var n=Ho(),r=u(n);if(c=arguments,a=this,p=n,r){if(h===F)return _=n=p,h=xo(i,t),v?e(n):s;if(g)return h=xo(i,t),e(p)}return h===F&&(h=xo(i,t)),
+s}var c,a,l,s,h,p,_=0,v=false,g=false,d=true;if(typeof n!="function")throw new ri("Expected a function");return t=Su(t)||0,yu(r)&&(v=!!r.leading,l=(g="maxWait"in r)?Ci(Su(r.maxWait)||0,t):l,d="trailing"in r?!!r.trailing:d),f.cancel=function(){h!==F&&so(h),_=0,c=p=a=h=F},f.flush=function(){return h===F?s:o(Ho())},f}function au(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;return i.has(u)?i.get(u):(e=n.apply(this,e),r.cache=i.set(u,e)||i,e)}if(typeof n!="function"||null!=t&&typeof t!="function")throw new ri("Expected a function");
+return r.cache=new(au.Cache||Pn),r}function lu(n){if(typeof n!="function")throw new ri("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function su(n,t){return n===t||n!==n&&t!==t}function hu(n){return null!=n&&du(n.length)&&!vu(n)}function pu(n){return bu(n)&&hu(n)}function _u(n){if(!bu(n))return false;var t=Wt(n);return"[object Error]"==t||"[object DOMException]"==t||typeof n.message=="string"&&typeof n.name=="string"&&!ju(n);
+}function vu(n){return!!yu(n)&&(n=Wt(n),"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n)}function gu(n){return typeof n=="number"&&n==Eu(n)}function du(n){return typeof n=="number"&&-1<n&&0==n%1&&9007199254740991>=n}function yu(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function bu(n){return null!=n&&typeof n=="object"}function xu(n){return typeof n=="number"||bu(n)&&"[object Number]"==Wt(n)}function ju(n){return!(!bu(n)||"[object Object]"!=Wt(n))&&(n=yi(n),
+null===n||(n=fi.call(n,"constructor")&&n.constructor,typeof n=="function"&&n instanceof n&&oi.call(n)==si))}function wu(n){return typeof n=="string"||!cf(n)&&bu(n)&&"[object String]"==Wt(n)}function mu(n){return typeof n=="symbol"||bu(n)&&"[object Symbol]"==Wt(n)}function Au(n){if(!n)return[];if(hu(n))return wu(n)?$(n):Tr(n);if(mi&&n[mi]){n=n[mi]();for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}return t=go(n),("[object Map]"==t?L:"[object Set]"==t?D:Cu)(n)}function ku(n){return n?(n=Su(n),
+n===N||n===-N?1.7976931348623157e308*(0>n?-1:1):n===n?n:0):0===n?n:0}function Eu(n){n=ku(n);var t=n%1;return n===n?t?n-t:n:0}function Ou(n){return n?dt(Eu(n),0,4294967295):0}function Su(n){if(typeof n=="number")return n;if(mu(n))return P;if(yu(n)&&(n=typeof n.valueOf=="function"?n.valueOf():n,n=yu(n)?n+"":n),typeof n!="string")return 0===n?n:+n;n=n.replace(cn,"");var t=bn.test(n);return t||jn.test(n)?Fn(n.slice(2),t?2:8):yn.test(n)?P:+n}function Iu(n){return $r(n,Lu(n))}function Ru(n){return null==n?"":wr(n);
+}function zu(n,t,r){return n=null==n?F:Rt(n,t),n===F?r:n}function Wu(n,t){return null!=n&&me(n,t,Ut)}function Bu(n){return hu(n)?Gn(n):Jt(n)}function Lu(n){if(hu(n))n=Gn(n,true);else if(yu(n)){var t,r=We(n),e=[];for(t in n)("constructor"!=t||!r&&fi.call(n,t))&&e.push(t);n=e}else{if(t=[],null!=n)for(r in Xu(n))t.push(r);n=t}return n}function Uu(n,t){if(null==n)return{};var r=l(ge(n),function(n){return[n]});return t=be(t),ir(n,r,function(n,r){return t(n,r[0])})}function Cu(n){return null==n?[]:I(n,Bu(n));
+}function Du(n){return Ff(Ru(n).toLowerCase())}function Mu(n){return(n=Ru(n))&&n.replace(mn,rt).replace(Rn,"")}function Tu(n,t,r){return n=Ru(n),t=r?F:t,t===F?Ln.test(n)?n.match(Wn)||[]:n.match(_n)||[]:n.match(t)||[]}function $u(n){return function(){return n}}function Fu(n){return n}function Nu(n){return Ht(typeof n=="function"?n:yt(n,1))}function Pu(n,t,r){var e=Bu(t),i=It(t,e);null!=r||yu(t)&&(i.length||!e.length)||(r=t,t=n,n=this,i=It(t,Bu(t)));var o=!(yu(r)&&"chain"in r&&!r.chain),f=vu(n);return u(i,function(r){
+var e=t[r];n[r]=e,f&&(n.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=n(this.__wrapped__);return(r.__actions__=Tr(this.__actions__)).push({func:e,args:arguments,thisArg:n}),r.__chain__=t,r}return e.apply(n,s([this.value()],arguments))})}),n}function Zu(){}function qu(n){return Re(n)?j(Te(n)):or(n)}function Vu(){return[]}function Ku(){return false}En=null==En?Zn:it.defaults(Zn.Object(),En,it.pick(Zn,Un));var Gu=En.Array,Hu=En.Date,Ju=En.Error,Yu=En.Function,Qu=En.Math,Xu=En.Object,ni=En.RegExp,ti=En.String,ri=En.TypeError,ei=Gu.prototype,ui=Xu.prototype,ii=En["__core-js_shared__"],oi=Yu.prototype.toString,fi=ui.hasOwnProperty,ci=0,ai=function(){
+var n=/[^.]+$/.exec(ii&&ii.keys&&ii.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),li=ui.toString,si=oi.call(Xu),hi=Zn._,pi=ni("^"+oi.call(fi).replace(on,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),_i=Kn?En.Buffer:F,vi=En.Symbol,gi=En.Uint8Array,di=_i?_i.f:F,yi=U(Xu.getPrototypeOf,Xu),bi=Xu.create,xi=ui.propertyIsEnumerable,ji=ei.splice,wi=vi?vi.isConcatSpreadable:F,mi=vi?vi.iterator:F,Ai=vi?vi.toStringTag:F,ki=function(){try{var n=we(Xu,"defineProperty");
+return n({},"",{}),n}catch(n){}}(),Ei=En.clearTimeout!==Zn.clearTimeout&&En.clearTimeout,Oi=Hu&&Hu.now!==Zn.Date.now&&Hu.now,Si=En.setTimeout!==Zn.setTimeout&&En.setTimeout,Ii=Qu.ceil,Ri=Qu.floor,zi=Xu.getOwnPropertySymbols,Wi=_i?_i.isBuffer:F,Bi=En.isFinite,Li=ei.join,Ui=U(Xu.keys,Xu),Ci=Qu.max,Di=Qu.min,Mi=Hu.now,Ti=En.parseInt,$i=Qu.random,Fi=ei.reverse,Ni=we(En,"DataView"),Pi=we(En,"Map"),Zi=we(En,"Promise"),qi=we(En,"Set"),Vi=we(En,"WeakMap"),Ki=we(Xu,"create"),Gi=Vi&&new Vi,Hi={},Ji=$e(Ni),Yi=$e(Pi),Qi=$e(Zi),Xi=$e(qi),no=$e(Vi),to=vi?vi.prototype:F,ro=to?to.valueOf:F,eo=to?to.toString:F,uo=function(){
+function n(){}return function(t){return yu(t)?bi?bi(t):(n.prototype=t,t=new n,n.prototype=F,t):{}}}();On.templateSettings={escape:Q,evaluate:X,interpolate:nn,variable:"",imports:{_:On}},On.prototype=Sn.prototype,On.prototype.constructor=On,zn.prototype=uo(Sn.prototype),zn.prototype.constructor=zn,Mn.prototype=uo(Sn.prototype),Mn.prototype.constructor=Mn,Tn.prototype.clear=function(){this.__data__=Ki?Ki(null):{},this.size=0},Tn.prototype.delete=function(n){return n=this.has(n)&&delete this.__data__[n],
+this.size-=n?1:0,n},Tn.prototype.get=function(n){var t=this.__data__;return Ki?(n=t[n],"__lodash_hash_undefined__"===n?F:n):fi.call(t,n)?t[n]:F},Tn.prototype.has=function(n){var t=this.__data__;return Ki?t[n]!==F:fi.call(t,n)},Tn.prototype.set=function(n,t){var r=this.__data__;return this.size+=this.has(n)?0:1,r[n]=Ki&&t===F?"__lodash_hash_undefined__":t,this},Nn.prototype.clear=function(){this.__data__=[],this.size=0},Nn.prototype.delete=function(n){var t=this.__data__;return n=st(t,n),!(0>n)&&(n==t.length-1?t.pop():ji.call(t,n,1),
+--this.size,true)},Nn.prototype.get=function(n){var t=this.__data__;return n=st(t,n),0>n?F:t[n][1]},Nn.prototype.has=function(n){return-1<st(this.__data__,n)},Nn.prototype.set=function(n,t){var r=this.__data__,e=st(r,n);return 0>e?(++this.size,r.push([n,t])):r[e][1]=t,this},Pn.prototype.clear=function(){this.size=0,this.__data__={hash:new Tn,map:new(Pi||Nn),string:new Tn}},Pn.prototype.delete=function(n){return n=xe(this,n).delete(n),this.size-=n?1:0,n},Pn.prototype.get=function(n){return xe(this,n).get(n);
+},Pn.prototype.has=function(n){return xe(this,n).has(n)},Pn.prototype.set=function(n,t){var r=xe(this,n),e=r.size;return r.set(n,t),this.size+=r.size==e?0:1,this},qn.prototype.add=qn.prototype.push=function(n){return this.__data__.set(n,"__lodash_hash_undefined__"),this},qn.prototype.has=function(n){return this.__data__.has(n)},Vn.prototype.clear=function(){this.__data__=new Nn,this.size=0},Vn.prototype.delete=function(n){var t=this.__data__;return n=t.delete(n),this.size=t.size,n},Vn.prototype.get=function(n){
+return this.__data__.get(n)},Vn.prototype.has=function(n){return this.__data__.has(n)},Vn.prototype.set=function(n,t){var r=this.__data__;if(r instanceof Nn){var e=r.__data__;if(!Pi||199>e.length)return e.push([n,t]),this.size=++r.size,this;r=this.__data__=new Pn(e)}return r.set(n,t),this.size=r.size,this};var io=qr(Ot),oo=qr(St,true),fo=Vr(),co=Vr(true),ao=Gi?function(n,t){return Gi.set(n,t),n}:Fu,lo=ki?function(n,t){return ki(n,"toString",{configurable:true,enumerable:false,value:$u(t),writable:true})}:Fu,so=Ei||function(n){
+return Zn.clearTimeout(n)},ho=qi&&1/D(new qi([,-0]))[1]==N?function(n){return new qi(n)}:Zu,po=Gi?function(n){return Gi.get(n)}:Zu,_o=zi?U(zi,Xu):Vu,vo=zi?function(n){for(var t=[];n;)s(t,_o(n)),n=yi(n);return t}:Vu,go=Wt;(Ni&&"[object DataView]"!=go(new Ni(new ArrayBuffer(1)))||Pi&&"[object Map]"!=go(new Pi)||Zi&&"[object Promise]"!=go(Zi.resolve())||qi&&"[object Set]"!=go(new qi)||Vi&&"[object WeakMap]"!=go(new Vi))&&(go=function(n){var t=Wt(n);if(n=(n="[object Object]"==t?n.constructor:F)?$e(n):"")switch(n){
+case Ji:return"[object DataView]";case Yi:return"[object Map]";case Qi:return"[object Promise]";case Xi:return"[object Set]";case no:return"[object WeakMap]"}return t});var yo=ii?vu:Ku,bo=De(ao),xo=Si||function(n,t){return Zn.setTimeout(n,t)},jo=De(lo),wo=function(n){n=au(n,function(n){return 500===t.size&&t.clear(),n});var t=n.cache;return n}(function(n){var t=[];return en.test(n)&&t.push(""),n.replace(un,function(n,r,e,u){t.push(e?u.replace(vn,"$1"):r||n)}),t}),mo=sr(function(n,t){return pu(n)?wt(n,Et(t,1,pu,true)):[];
+}),Ao=sr(function(n,t){var r=Ke(t);return pu(r)&&(r=F),pu(n)?wt(n,Et(t,1,pu,true),be(r,2)):[]}),ko=sr(function(n,t){var r=Ke(t);return pu(r)&&(r=F),pu(n)?wt(n,Et(t,1,pu,true),F,r):[]}),Eo=sr(function(n){var t=l(n,Ir);return t.length&&t[0]===n[0]?Ct(t):[]}),Oo=sr(function(n){var t=Ke(n),r=l(n,Ir);return t===Ke(r)?t=F:r.pop(),r.length&&r[0]===n[0]?Ct(r,be(t,2)):[]}),So=sr(function(n){var t=Ke(n),r=l(n,Ir);return(t=typeof t=="function"?t:F)&&r.pop(),r.length&&r[0]===n[0]?Ct(r,F,t):[]}),Io=sr(Ge),Ro=_e(function(n,t){
+var r=null==n?0:n.length,e=gt(n,t);return cr(n,l(t,function(n){return Se(n,r)?+n:n}).sort(Cr)),e}),zo=sr(function(n){return mr(Et(n,1,pu,true))}),Wo=sr(function(n){var t=Ke(n);return pu(t)&&(t=F),mr(Et(n,1,pu,true),be(t,2))}),Bo=sr(function(n){var t=Ke(n),t=typeof t=="function"?t:F;return mr(Et(n,1,pu,true),F,t)}),Lo=sr(function(n,t){return pu(n)?wt(n,t):[]}),Uo=sr(function(n){return Or(f(n,pu))}),Co=sr(function(n){var t=Ke(n);return pu(t)&&(t=F),Or(f(n,pu),be(t,2))}),Do=sr(function(n){var t=Ke(n),t=typeof t=="function"?t:F;
+return Or(f(n,pu),F,t)}),Mo=sr(Je),To=sr(function(n){var t=n.length,t=1<t?n[t-1]:F,t=typeof t=="function"?(n.pop(),t):F;return Ye(n,t)}),$o=_e(function(n){function t(t){return gt(t,n)}var r=n.length,e=r?n[0]:0,u=this.__wrapped__;return!(1<r||this.__actions__.length)&&u instanceof Mn&&Se(e)?(u=u.slice(e,+e+(r?1:0)),u.__actions__.push({func:Xe,args:[t],thisArg:F}),new zn(u,this.__chain__).thru(function(n){return r&&!n.length&&n.push(F),n})):this.thru(t)}),Fo=Pr(function(n,t,r){fi.call(n,r)?++n[r]:vt(n,r,1);
+}),No=Qr(Pe),Po=Qr(Ze),Zo=Pr(function(n,t,r){fi.call(n,r)?n[r].push(t):vt(n,r,[t])}),qo=sr(function(n,t,e){var u=-1,i=typeof t=="function",o=hu(n)?Gu(n.length):[];return io(n,function(n){o[++u]=i?r(t,n,e):Mt(n,t,e)}),o}),Vo=Pr(function(n,t,r){vt(n,r,t)}),Ko=Pr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Go=sr(function(n,t){if(null==n)return[];var r=t.length;return 1<r&&Ie(n,t[0],t[1])?t=[]:2<r&&Ie(t[0],t[1],t[2])&&(t=[t[0]]),er(n,Et(t,1),[])}),Ho=Oi||function(){return Zn.Date.now();
+},Jo=sr(function(n,t,r){var e=1;if(r.length)var u=C(r,ye(Jo)),e=32|e;return se(n,e,t,r,u)}),Yo=sr(function(n,t,r){var e=3;if(r.length)var u=C(r,ye(Yo)),e=32|e;return se(t,e,n,r,u)}),Qo=sr(function(n,t){return jt(n,1,t)}),Xo=sr(function(n,t,r){return jt(n,Su(t)||0,r)});au.Cache=Pn;var nf=sr(function(n,t){t=1==t.length&&cf(t[0])?l(t[0],S(be())):l(Et(t,1),S(be()));var e=t.length;return sr(function(u){for(var i=-1,o=Di(u.length,e);++i<o;)u[i]=t[i].call(this,u[i]);return r(n,this,u)})}),tf=sr(function(n,t){
+return se(n,32,F,t,C(t,ye(tf)))}),rf=sr(function(n,t){return se(n,64,F,t,C(t,ye(rf)))}),ef=_e(function(n,t){return se(n,256,F,F,F,t)}),uf=fe(Bt),of=fe(function(n,t){return n>=t}),ff=Tt(function(){return arguments}())?Tt:function(n){return bu(n)&&fi.call(n,"callee")&&!xi.call(n,"callee")},cf=Gu.isArray,af=Hn?S(Hn):$t,lf=Wi||Ku,sf=Jn?S(Jn):Ft,hf=Yn?S(Yn):Pt,pf=Qn?S(Qn):Vt,_f=Xn?S(Xn):Kt,vf=nt?S(nt):Gt,gf=fe(Yt),df=fe(function(n,t){return n<=t}),yf=Zr(function(n,t){if(We(t)||hu(t))$r(t,Bu(t),n);else for(var r in t)fi.call(t,r)&&lt(n,r,t[r]);
+}),bf=Zr(function(n,t){$r(t,Lu(t),n)}),xf=Zr(function(n,t,r,e){$r(t,Lu(t),n,e)}),jf=Zr(function(n,t,r,e){$r(t,Bu(t),n,e)}),wf=_e(gt),mf=sr(function(n){return n.push(F,ct),r(xf,F,n)}),Af=sr(function(n){return n.push(F,Le),r(If,F,n)}),kf=te(function(n,t,r){n[t]=r},$u(Fu)),Ef=te(function(n,t,r){fi.call(n,t)?n[t].push(r):n[t]=[r]},be),Of=sr(Mt),Sf=Zr(function(n,t,r){tr(n,t,r)}),If=Zr(function(n,t,r,e){tr(n,t,r,e)}),Rf=_e(function(n,t){var r={};if(null==n)return r;var e=false;t=l(t,function(t){return t=zr(t,n),
+e||(e=1<t.length),t}),$r(n,ge(n),r),e&&(r=yt(r,7));for(var u=t.length;u--;)Ar(r,t[u]);return r}),zf=_e(function(n,t){return null==n?{}:ur(n,t)}),Wf=le(Bu),Bf=le(Lu),Lf=Hr(function(n,t,r){return t=t.toLowerCase(),n+(r?Du(t):t)}),Uf=Hr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Cf=Hr(function(n,t,r){return n+(r?" ":"")+t.toLowerCase()}),Df=Gr("toLowerCase"),Mf=Hr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Tf=Hr(function(n,t,r){return n+(r?" ":"")+Ff(t)}),$f=Hr(function(n,t,r){
+return n+(r?" ":"")+t.toUpperCase()}),Ff=Gr("toUpperCase"),Nf=sr(function(n,t){try{return r(n,F,t)}catch(n){return _u(n)?n:new Ju(n)}}),Pf=_e(function(n,t){return u(t,function(t){t=Te(t),vt(n,t,Jo(n[t],n))}),n}),Zf=Xr(),qf=Xr(true),Vf=sr(function(n,t){return function(r){return Mt(r,n,t)}}),Kf=sr(function(n,t){return function(r){return Mt(n,r,t)}}),Gf=ee(l),Hf=ee(o),Jf=ee(_),Yf=oe(),Qf=oe(true),Xf=re(function(n,t){return n+t},0),nc=ae("ceil"),tc=re(function(n,t){return n/t},1),rc=ae("floor"),ec=re(function(n,t){
+return n*t},1),uc=ae("round"),ic=re(function(n,t){return n-t},0);return On.after=function(n,t){if(typeof t!="function")throw new ri("Expected a function");return n=Eu(n),function(){if(1>--n)return t.apply(this,arguments)}},On.ary=uu,On.assign=yf,On.assignIn=bf,On.assignInWith=xf,On.assignWith=jf,On.at=wf,On.before=iu,On.bind=Jo,On.bindAll=Pf,On.bindKey=Yo,On.castArray=function(){if(!arguments.length)return[];var n=arguments[0];return cf(n)?n:[n]},On.chain=Qe,On.chunk=function(n,t,r){if(t=(r?Ie(n,t,r):t===F)?1:Ci(Eu(t),0),
+r=null==n?0:n.length,!r||1>t)return[];for(var e=0,u=0,i=Gu(Ii(r/t));e<r;)i[u++]=gr(n,e,e+=t);return i},On.compact=function(n){for(var t=-1,r=null==n?0:n.length,e=0,u=[];++t<r;){var i=n[t];i&&(u[e++]=i)}return u},On.concat=function(){var n=arguments.length;if(!n)return[];for(var t=Gu(n-1),r=arguments[0];n--;)t[n-1]=arguments[n];return s(cf(r)?Tr(r):[r],Et(t,1))},On.cond=function(n){var t=null==n?0:n.length,e=be();return n=t?l(n,function(n){if("function"!=typeof n[1])throw new ri("Expected a function");
+return[e(n[0]),n[1]]}):[],sr(function(e){for(var u=-1;++u<t;){var i=n[u];if(r(i[0],this,e))return r(i[1],this,e)}})},On.conforms=function(n){return bt(yt(n,1))},On.constant=$u,On.countBy=Fo,On.create=function(n,t){var r=uo(n);return null==t?r:pt(r,t)},On.curry=ou,On.curryRight=fu,On.debounce=cu,On.defaults=mf,On.defaultsDeep=Af,On.defer=Qo,On.delay=Xo,On.difference=mo,On.differenceBy=Ao,On.differenceWith=ko,On.drop=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===F?1:Eu(t),gr(n,0>t?0:t,e)):[];
+},On.dropRight=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===F?1:Eu(t),t=e-t,gr(n,0,0>t?0:t)):[]},On.dropRightWhile=function(n,t){return n&&n.length?kr(n,be(t,3),true,true):[]},On.dropWhile=function(n,t){return n&&n.length?kr(n,be(t,3),true):[]},On.fill=function(n,t,r,e){var u=null==n?0:n.length;if(!u)return[];for(r&&typeof r!="number"&&Ie(n,t,r)&&(r=0,e=u),u=n.length,r=Eu(r),0>r&&(r=-r>u?0:u+r),e=e===F||e>u?u:Eu(e),0>e&&(e+=u),e=r>e?0:Ou(e);r<e;)n[r++]=t;return n},On.filter=function(n,t){
+return(cf(n)?f:kt)(n,be(t,3))},On.flatMap=function(n,t){return Et(eu(n,t),1)},On.flatMapDeep=function(n,t){return Et(eu(n,t),N)},On.flatMapDepth=function(n,t,r){return r=r===F?1:Eu(r),Et(eu(n,t),r)},On.flatten=qe,On.flattenDeep=function(n){return(null==n?0:n.length)?Et(n,N):[]},On.flattenDepth=function(n,t){return null!=n&&n.length?(t=t===F?1:Eu(t),Et(n,t)):[]},On.flip=function(n){return se(n,512)},On.flow=Zf,On.flowRight=qf,On.fromPairs=function(n){for(var t=-1,r=null==n?0:n.length,e={};++t<r;){
+var u=n[t];e[u[0]]=u[1]}return e},On.functions=function(n){return null==n?[]:It(n,Bu(n))},On.functionsIn=function(n){return null==n?[]:It(n,Lu(n))},On.groupBy=Zo,On.initial=function(n){return(null==n?0:n.length)?gr(n,0,-1):[]},On.intersection=Eo,On.intersectionBy=Oo,On.intersectionWith=So,On.invert=kf,On.invertBy=Ef,On.invokeMap=qo,On.iteratee=Nu,On.keyBy=Vo,On.keys=Bu,On.keysIn=Lu,On.map=eu,On.mapKeys=function(n,t){var r={};return t=be(t,3),Ot(n,function(n,e,u){vt(r,t(n,e,u),n)}),r},On.mapValues=function(n,t){
+var r={};return t=be(t,3),Ot(n,function(n,e,u){vt(r,e,t(n,e,u))}),r},On.matches=function(n){return Xt(yt(n,1))},On.matchesProperty=function(n,t){return nr(n,yt(t,1))},On.memoize=au,On.merge=Sf,On.mergeWith=If,On.method=Vf,On.methodOf=Kf,On.mixin=Pu,On.negate=lu,On.nthArg=function(n){return n=Eu(n),sr(function(t){return rr(t,n)})},On.omit=Rf,On.omitBy=function(n,t){return Uu(n,lu(be(t)))},On.once=function(n){return iu(2,n)},On.orderBy=function(n,t,r,e){return null==n?[]:(cf(t)||(t=null==t?[]:[t]),
+r=e?F:r,cf(r)||(r=null==r?[]:[r]),er(n,t,r))},On.over=Gf,On.overArgs=nf,On.overEvery=Hf,On.overSome=Jf,On.partial=tf,On.partialRight=rf,On.partition=Ko,On.pick=zf,On.pickBy=Uu,On.property=qu,On.propertyOf=function(n){return function(t){return null==n?F:Rt(n,t)}},On.pull=Io,On.pullAll=Ge,On.pullAllBy=function(n,t,r){return n&&n.length&&t&&t.length?fr(n,t,be(r,2)):n},On.pullAllWith=function(n,t,r){return n&&n.length&&t&&t.length?fr(n,t,F,r):n},On.pullAt=Ro,On.range=Yf,On.rangeRight=Qf,On.rearg=ef,On.reject=function(n,t){
+return(cf(n)?f:kt)(n,lu(be(t,3)))},On.remove=function(n,t){var r=[];if(!n||!n.length)return r;var e=-1,u=[],i=n.length;for(t=be(t,3);++e<i;){var o=n[e];t(o,e,n)&&(r.push(o),u.push(e))}return cr(n,u),r},On.rest=function(n,t){if(typeof n!="function")throw new ri("Expected a function");return t=t===F?t:Eu(t),sr(n,t)},On.reverse=He,On.sampleSize=function(n,t,r){return t=(r?Ie(n,t,r):t===F)?1:Eu(t),(cf(n)?ot:pr)(n,t)},On.set=function(n,t,r){return null==n?n:_r(n,t,r)},On.setWith=function(n,t,r,e){return e=typeof e=="function"?e:F,
+null==n?n:_r(n,t,r,e)},On.shuffle=function(n){return(cf(n)?ft:vr)(n)},On.slice=function(n,t,r){var e=null==n?0:n.length;return e?(r&&typeof r!="number"&&Ie(n,t,r)?(t=0,r=e):(t=null==t?0:Eu(t),r=r===F?e:Eu(r)),gr(n,t,r)):[]},On.sortBy=Go,On.sortedUniq=function(n){return n&&n.length?xr(n):[]},On.sortedUniqBy=function(n,t){return n&&n.length?xr(n,be(t,2)):[]},On.split=function(n,t,r){return r&&typeof r!="number"&&Ie(n,t,r)&&(t=r=F),r=r===F?4294967295:r>>>0,r?(n=Ru(n))&&(typeof t=="string"||null!=t&&!pf(t))&&(t=wr(t),
+!t&&Bn.test(n))?Wr($(n),0,r):n.split(t,r):[]},On.spread=function(n,t){if(typeof n!="function")throw new ri("Expected a function");return t=t===F?0:Ci(Eu(t),0),sr(function(e){var u=e[t];return e=Wr(e,0,t),u&&s(e,u),r(n,this,e)})},On.tail=function(n){var t=null==n?0:n.length;return t?gr(n,1,t):[]},On.take=function(n,t,r){return n&&n.length?(t=r||t===F?1:Eu(t),gr(n,0,0>t?0:t)):[]},On.takeRight=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===F?1:Eu(t),t=e-t,gr(n,0>t?0:t,e)):[]},On.takeRightWhile=function(n,t){
+return n&&n.length?kr(n,be(t,3),false,true):[]},On.takeWhile=function(n,t){return n&&n.length?kr(n,be(t,3)):[]},On.tap=function(n,t){return t(n),n},On.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new ri("Expected a function");return yu(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),cu(n,t,{leading:e,maxWait:t,trailing:u})},On.thru=Xe,On.toArray=Au,On.toPairs=Wf,On.toPairsIn=Bf,On.toPath=function(n){return cf(n)?l(n,Te):mu(n)?[n]:Tr(wo(Ru(n)))},On.toPlainObject=Iu,
+On.transform=function(n,t,r){var e=cf(n),i=e||lf(n)||vf(n);if(t=be(t,4),null==r){var o=n&&n.constructor;r=i?e?new o:[]:yu(n)&&vu(o)?uo(yi(n)):{}}return(i?u:Ot)(n,function(n,e,u){return t(r,n,e,u)}),r},On.unary=function(n){return uu(n,1)},On.union=zo,On.unionBy=Wo,On.unionWith=Bo,On.uniq=function(n){return n&&n.length?mr(n):[]},On.uniqBy=function(n,t){return n&&n.length?mr(n,be(t,2)):[]},On.uniqWith=function(n,t){return t=typeof t=="function"?t:F,n&&n.length?mr(n,F,t):[]},On.unset=function(n,t){return null==n||Ar(n,t);
+},On.unzip=Je,On.unzipWith=Ye,On.update=function(n,t,r){return null==n?n:_r(n,t,Rr(r)(Rt(n,t)),void 0)},On.updateWith=function(n,t,r,e){return e=typeof e=="function"?e:F,null!=n&&(n=_r(n,t,Rr(r)(Rt(n,t)),e)),n},On.values=Cu,On.valuesIn=function(n){return null==n?[]:I(n,Lu(n))},On.without=Lo,On.words=Tu,On.wrap=function(n,t){return tf(Rr(t),n)},On.xor=Uo,On.xorBy=Co,On.xorWith=Do,On.zip=Mo,On.zipObject=function(n,t){return Sr(n||[],t||[],lt)},On.zipObjectDeep=function(n,t){return Sr(n||[],t||[],_r);
+},On.zipWith=To,On.entries=Wf,On.entriesIn=Bf,On.extend=bf,On.extendWith=xf,Pu(On,On),On.add=Xf,On.attempt=Nf,On.camelCase=Lf,On.capitalize=Du,On.ceil=nc,On.clamp=function(n,t,r){return r===F&&(r=t,t=F),r!==F&&(r=Su(r),r=r===r?r:0),t!==F&&(t=Su(t),t=t===t?t:0),dt(Su(n),t,r)},On.clone=function(n){return yt(n,4)},On.cloneDeep=function(n){return yt(n,5)},On.cloneDeepWith=function(n,t){return t=typeof t=="function"?t:F,yt(n,5,t)},On.cloneWith=function(n,t){return t=typeof t=="function"?t:F,yt(n,4,t)},
+On.conformsTo=function(n,t){return null==t||xt(n,t,Bu(t))},On.deburr=Mu,On.defaultTo=function(n,t){return null==n||n!==n?t:n},On.divide=tc,On.endsWith=function(n,t,r){n=Ru(n),t=wr(t);var e=n.length,e=r=r===F?e:dt(Eu(r),0,e);return r-=t.length,0<=r&&n.slice(r,e)==t},On.eq=su,On.escape=function(n){return(n=Ru(n))&&Y.test(n)?n.replace(H,et):n},On.escapeRegExp=function(n){return(n=Ru(n))&&fn.test(n)?n.replace(on,"\\$&"):n},On.every=function(n,t,r){var e=cf(n)?o:mt;return r&&Ie(n,t,r)&&(t=F),e(n,be(t,3));
+},On.find=No,On.findIndex=Pe,On.findKey=function(n,t){return v(n,be(t,3),Ot)},On.findLast=Po,On.findLastIndex=Ze,On.findLastKey=function(n,t){return v(n,be(t,3),St)},On.floor=rc,On.forEach=tu,On.forEachRight=ru,On.forIn=function(n,t){return null==n?n:fo(n,be(t,3),Lu)},On.forInRight=function(n,t){return null==n?n:co(n,be(t,3),Lu)},On.forOwn=function(n,t){return n&&Ot(n,be(t,3))},On.forOwnRight=function(n,t){return n&&St(n,be(t,3))},On.get=zu,On.gt=uf,On.gte=of,On.has=function(n,t){return null!=n&&me(n,t,Lt);
+},On.hasIn=Wu,On.head=Ve,On.identity=Fu,On.includes=function(n,t,r,e){return n=hu(n)?n:Cu(n),r=r&&!e?Eu(r):0,e=n.length,0>r&&(r=Ci(e+r,0)),wu(n)?r<=e&&-1<n.indexOf(t,r):!!e&&-1<d(n,t,r)},On.indexOf=function(n,t,r){var e=null==n?0:n.length;return e?(r=null==r?0:Eu(r),0>r&&(r=Ci(e+r,0)),d(n,t,r)):-1},On.inRange=function(n,t,r){return t=ku(t),r===F?(r=t,t=0):r=ku(r),n=Su(n),n>=Di(t,r)&&n<Ci(t,r)},On.invoke=Of,On.isArguments=ff,On.isArray=cf,On.isArrayBuffer=af,On.isArrayLike=hu,On.isArrayLikeObject=pu,
+On.isBoolean=function(n){return true===n||false===n||bu(n)&&"[object Boolean]"==Wt(n)},On.isBuffer=lf,On.isDate=sf,On.isElement=function(n){return bu(n)&&1===n.nodeType&&!ju(n)},On.isEmpty=function(n){if(null==n)return true;if(hu(n)&&(cf(n)||typeof n=="string"||typeof n.splice=="function"||lf(n)||vf(n)||ff(n)))return!n.length;var t=go(n);if("[object Map]"==t||"[object Set]"==t)return!n.size;if(We(n))return!Jt(n).length;for(var r in n)if(fi.call(n,r))return false;return true},On.isEqual=function(n,t){return Nt(n,t);
+},On.isEqualWith=function(n,t,r){var e=(r=typeof r=="function"?r:F)?r(n,t):F;return e===F?Nt(n,t,F,r):!!e},On.isError=_u,On.isFinite=function(n){return typeof n=="number"&&Bi(n)},On.isFunction=vu,On.isInteger=gu,On.isLength=du,On.isMap=hf,On.isMatch=function(n,t){return n===t||Zt(n,t,je(t))},On.isMatchWith=function(n,t,r){return r=typeof r=="function"?r:F,Zt(n,t,je(t),r)},On.isNaN=function(n){return xu(n)&&n!=+n},On.isNative=function(n){if(yo(n))throw new Ju("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");
+return qt(n)},On.isNil=function(n){return null==n},On.isNull=function(n){return null===n},On.isNumber=xu,On.isObject=yu,On.isObjectLike=bu,On.isPlainObject=ju,On.isRegExp=pf,On.isSafeInteger=function(n){return gu(n)&&-9007199254740991<=n&&9007199254740991>=n},On.isSet=_f,On.isString=wu,On.isSymbol=mu,On.isTypedArray=vf,On.isUndefined=function(n){return n===F},On.isWeakMap=function(n){return bu(n)&&"[object WeakMap]"==go(n)},On.isWeakSet=function(n){return bu(n)&&"[object WeakSet]"==Wt(n)},On.join=function(n,t){
+return null==n?"":Li.call(n,t)},On.kebabCase=Uf,On.last=Ke,On.lastIndexOf=function(n,t,r){var e=null==n?0:n.length;if(!e)return-1;var u=e;if(r!==F&&(u=Eu(r),u=0>u?Ci(e+u,0):Di(u,e-1)),t===t){for(r=u+1;r--&&n[r]!==t;);n=r}else n=g(n,b,u,true);return n},On.lowerCase=Cf,On.lowerFirst=Df,On.lt=gf,On.lte=df,On.max=function(n){return n&&n.length?At(n,Fu,Bt):F},On.maxBy=function(n,t){return n&&n.length?At(n,be(t,2),Bt):F},On.mean=function(n){return x(n,Fu)},On.meanBy=function(n,t){return x(n,be(t,2))},On.min=function(n){
+return n&&n.length?At(n,Fu,Yt):F},On.minBy=function(n,t){return n&&n.length?At(n,be(t,2),Yt):F},On.stubArray=Vu,On.stubFalse=Ku,On.stubObject=function(){return{}},On.stubString=function(){return""},On.stubTrue=function(){return true},On.multiply=ec,On.nth=function(n,t){return n&&n.length?rr(n,Eu(t)):F},On.noConflict=function(){return Zn._===this&&(Zn._=hi),this},On.noop=Zu,On.now=Ho,On.pad=function(n,t,r){n=Ru(n);var e=(t=Eu(t))?T(n):0;return!t||e>=t?n:(t=(t-e)/2,ue(Ri(t),r)+n+ue(Ii(t),r))},On.padEnd=function(n,t,r){
+n=Ru(n);var e=(t=Eu(t))?T(n):0;return t&&e<t?n+ue(t-e,r):n},On.padStart=function(n,t,r){n=Ru(n);var e=(t=Eu(t))?T(n):0;return t&&e<t?ue(t-e,r)+n:n},On.parseInt=function(n,t,r){return r||null==t?t=0:t&&(t=+t),Ti(Ru(n).replace(an,""),t||0)},On.random=function(n,t,r){if(r&&typeof r!="boolean"&&Ie(n,t,r)&&(t=r=F),r===F&&(typeof t=="boolean"?(r=t,t=F):typeof n=="boolean"&&(r=n,n=F)),n===F&&t===F?(n=0,t=1):(n=ku(n),t===F?(t=n,n=0):t=ku(t)),n>t){var e=n;n=t,t=e}return r||n%1||t%1?(r=$i(),Di(n+r*(t-n+$n("1e-"+((r+"").length-1))),t)):ar(n,t);
+},On.reduce=function(n,t,r){var e=cf(n)?h:m,u=3>arguments.length;return e(n,be(t,4),r,u,io)},On.reduceRight=function(n,t,r){var e=cf(n)?p:m,u=3>arguments.length;return e(n,be(t,4),r,u,oo)},On.repeat=function(n,t,r){return t=(r?Ie(n,t,r):t===F)?1:Eu(t),lr(Ru(n),t)},On.replace=function(){var n=arguments,t=Ru(n[0]);return 3>n.length?t:t.replace(n[1],n[2])},On.result=function(n,t,r){t=zr(t,n);var e=-1,u=t.length;for(u||(u=1,n=F);++e<u;){var i=null==n?F:n[Te(t[e])];i===F&&(e=u,i=r),n=vu(i)?i.call(n):i;
+}return n},On.round=uc,On.runInContext=w,On.sample=function(n){return(cf(n)?tt:hr)(n)},On.size=function(n){if(null==n)return 0;if(hu(n))return wu(n)?T(n):n.length;var t=go(n);return"[object Map]"==t||"[object Set]"==t?n.size:Jt(n).length},On.snakeCase=Mf,On.some=function(n,t,r){var e=cf(n)?_:dr;return r&&Ie(n,t,r)&&(t=F),e(n,be(t,3))},On.sortedIndex=function(n,t){return yr(n,t)},On.sortedIndexBy=function(n,t,r){return br(n,t,be(r,2))},On.sortedIndexOf=function(n,t){var r=null==n?0:n.length;if(r){
+var e=yr(n,t);if(e<r&&su(n[e],t))return e}return-1},On.sortedLastIndex=function(n,t){return yr(n,t,true)},On.sortedLastIndexBy=function(n,t,r){return br(n,t,be(r,2),true)},On.sortedLastIndexOf=function(n,t){if(null==n?0:n.length){var r=yr(n,t,true)-1;if(su(n[r],t))return r}return-1},On.startCase=Tf,On.startsWith=function(n,t,r){return n=Ru(n),r=dt(Eu(r),0,n.length),t=wr(t),n.slice(r,r+t.length)==t},On.subtract=ic,On.sum=function(n){return n&&n.length?k(n,Fu):0},On.sumBy=function(n,t){return n&&n.length?k(n,be(t,2)):0;
+},On.template=function(n,t,r){var e=On.templateSettings;r&&Ie(n,t,r)&&(t=F),n=Ru(n),t=xf({},t,e,ct),r=xf({},t.imports,e.imports,ct);var u,i,o=Bu(r),f=I(r,o),c=0;r=t.interpolate||An;var a="__p+='";r=ni((t.escape||An).source+"|"+r.source+"|"+(r===nn?gn:An).source+"|"+(t.evaluate||An).source+"|$","g");var l="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,o,f,l){return e||(e=o),a+=n.slice(c,l).replace(kn,B),r&&(u=true,a+="'+__e("+r+")+'"),f&&(i=true,a+="';"+f+";\n__p+='"),
+e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),c=l+t.length,t}),a+="';",(t=t.variable)||(a="with(obj){"+a+"}"),a=(i?a.replace(q,""):a).replace(V,"$1").replace(K,"$1;"),a="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+a+"return __p}",t=Nf(function(){return Yu(o,l+"return "+a).apply(F,f)}),t.source=a,_u(t))throw t;return t},On.times=function(n,t){if(n=Eu(n),1>n||9007199254740991<n)return[];
+var r=4294967295,e=Di(n,4294967295);for(t=be(t),n-=4294967295,e=E(e,t);++r<n;)t(r);return e},On.toFinite=ku,On.toInteger=Eu,On.toLength=Ou,On.toLower=function(n){return Ru(n).toLowerCase()},On.toNumber=Su,On.toSafeInteger=function(n){return dt(Eu(n),-9007199254740991,9007199254740991)},On.toString=Ru,On.toUpper=function(n){return Ru(n).toUpperCase()},On.trim=function(n,t,r){return(n=Ru(n))&&(r||t===F)?n.replace(cn,""):n&&(t=wr(t))?(n=$(n),r=$(t),t=z(n,r),r=W(n,r)+1,Wr(n,t,r).join("")):n},On.trimEnd=function(n,t,r){
+return(n=Ru(n))&&(r||t===F)?n.replace(ln,""):n&&(t=wr(t))?(n=$(n),t=W(n,$(t))+1,Wr(n,0,t).join("")):n},On.trimStart=function(n,t,r){return(n=Ru(n))&&(r||t===F)?n.replace(an,""):n&&(t=wr(t))?(n=$(n),t=z(n,$(t)),Wr(n,t).join("")):n},On.truncate=function(n,t){var r=30,e="...";if(yu(t))var u="separator"in t?t.separator:u,r="length"in t?Eu(t.length):r,e="omission"in t?wr(t.omission):e;n=Ru(n);var i=n.length;if(Bn.test(n))var o=$(n),i=o.length;if(r>=i)return n;if(i=r-T(e),1>i)return e;if(r=o?Wr(o,0,i).join(""):n.slice(0,i),
+u===F)return r+e;if(o&&(i+=r.length-i),pf(u)){if(n.slice(i).search(u)){var f=r;for(u.global||(u=ni(u.source,Ru(dn.exec(u))+"g")),u.lastIndex=0;o=u.exec(f);)var c=o.index;r=r.slice(0,c===F?i:c)}}else n.indexOf(wr(u),i)!=i&&(u=r.lastIndexOf(u),-1<u&&(r=r.slice(0,u)));return r+e},On.unescape=function(n){return(n=Ru(n))&&J.test(n)?n.replace(G,ut):n},On.uniqueId=function(n){var t=++ci;return Ru(n)+t},On.upperCase=$f,On.upperFirst=Ff,On.each=tu,On.eachRight=ru,On.first=Ve,Pu(On,function(){var n={};return Ot(On,function(t,r){
+fi.call(On.prototype,r)||(n[r]=t)}),n}(),{chain:false}),On.VERSION="4.17.2",u("bind bindKey curry curryRight partial partialRight".split(" "),function(n){On[n].placeholder=On}),u(["drop","take"],function(n,t){Mn.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new Mn(this);r=r===F?1:Ci(Eu(r),0);var u=this.clone();return e?u.__takeCount__=Di(r,u.__takeCount__):u.__views__.push({size:Di(r,4294967295),type:n+(0>u.__dir__?"Right":"")}),u},Mn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse();
+}}),u(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;Mn.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:be(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),u(["head","last"],function(n,t){var r="take"+(t?"Right":"");Mn.prototype[n]=function(){return this[r](1).value()[0]}}),u(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");Mn.prototype[n]=function(){return this.__filtered__?new Mn(this):this[r](1)}}),Mn.prototype.compact=function(){
+return this.filter(Fu)},Mn.prototype.find=function(n){return this.filter(n).head()},Mn.prototype.findLast=function(n){return this.reverse().find(n)},Mn.prototype.invokeMap=sr(function(n,t){return typeof n=="function"?new Mn(this):this.map(function(r){return Mt(r,n,t)})}),Mn.prototype.reject=function(n){return this.filter(lu(be(n)))},Mn.prototype.slice=function(n,t){n=Eu(n);var r=this;return r.__filtered__&&(0<n||0>t)?new Mn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==F&&(t=Eu(t),r=0>t?r.dropRight(-t):r.take(t-n)),
+r)},Mn.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},Mn.prototype.toArray=function(){return this.take(4294967295)},Ot(Mn.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=On[e?"take"+("last"==t?"Right":""):t],i=e||/^find/.test(t);u&&(On.prototype[t]=function(){function t(n){return n=u.apply(On,s([n],f)),e&&h?n[0]:n}var o=this.__wrapped__,f=e?[1]:arguments,c=o instanceof Mn,a=f[0],l=c||cf(o);l&&r&&typeof a=="function"&&1!=a.length&&(c=l=false);
+var h=this.__chain__,p=!!this.__actions__.length,a=i&&!h,c=c&&!p;return!i&&l?(o=c?o:new Mn(this),o=n.apply(o,f),o.__actions__.push({func:Xe,args:[t],thisArg:F}),new zn(o,h)):a&&c?n.apply(this,f):(o=this.thru(t),a?e?o.value()[0]:o.value():o)})}),u("pop push shift sort splice unshift".split(" "),function(n){var t=ei[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);On.prototype[n]=function(){var n=arguments;if(e&&!this.__chain__){var u=this.value();return t.apply(cf(u)?u:[],n);
+}return this[r](function(r){return t.apply(cf(r)?r:[],n)})}}),Ot(Mn.prototype,function(n,t){var r=On[t];if(r){var e=r.name+"";(Hi[e]||(Hi[e]=[])).push({name:t,func:r})}}),Hi[ne(F,2).name]=[{name:"wrapper",func:F}],Mn.prototype.clone=function(){var n=new Mn(this.__wrapped__);return n.__actions__=Tr(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Tr(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Tr(this.__views__),n},Mn.prototype.reverse=function(){
+if(this.__filtered__){var n=new Mn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Mn.prototype.value=function(){var n,t=this.__wrapped__.value(),r=this.__dir__,e=cf(t),u=0>r,i=e?t.length:0;n=i;for(var o=this.__views__,f=0,c=-1,a=o.length;++c<a;){var l=o[c],s=l.size;switch(l.type){case"drop":f+=s;break;case"dropRight":n-=s;break;case"take":n=Di(n,f+s);break;case"takeRight":f=Ci(f,n-s)}}if(n={start:f,end:n},o=n.start,f=n.end,n=f-o,u=u?f:o-1,o=this.__iteratees__,f=o.length,
+c=0,a=Di(n,this.__takeCount__),!e||200>i||i==n&&a==n)return Er(t,this.__actions__);e=[];n:for(;n--&&c<a;){for(u+=r,i=-1,l=t[u];++i<f;){var h=o[i],s=h.type,h=(0,h.iteratee)(l);if(2==s)l=h;else if(!h){if(1==s)continue n;break n}}e[c++]=l}return e},On.prototype.at=$o,On.prototype.chain=function(){return Qe(this)},On.prototype.commit=function(){return new zn(this.value(),this.__chain__)},On.prototype.next=function(){this.__values__===F&&(this.__values__=Au(this.value()));var n=this.__index__>=this.__values__.length;
+return{done:n,value:n?F:this.__values__[this.__index__++]}},On.prototype.plant=function(n){for(var t,r=this;r instanceof Sn;){var e=Ne(r);e.__index__=0,e.__values__=F,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},On.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Mn?(this.__actions__.length&&(n=new Mn(this)),n=n.reverse(),n.__actions__.push({func:Xe,args:[He],thisArg:F}),new zn(n,this.__chain__)):this.thru(He)},On.prototype.toJSON=On.prototype.valueOf=On.prototype.value=function(){
+return Er(this.__wrapped__,this.__actions__)},On.prototype.first=On.prototype.head,mi&&(On.prototype[mi]=nu),On}();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zn._=it, define(function(){return it})):Vn?((Vn.exports=it)._=it,qn._=it):Zn._=it}).call(this); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerCase.js
new file mode 100644
index 0000000..66c1f49
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerCase.js
@@ -0,0 +1,27 @@
+var createCompounder = require('./_createCompounder');
+
+/**
+ * Converts `string`, as space separated words, to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the lower cased string.
+ * @example
+ *
+ * _.lowerCase('--Foo-Bar--');
+ * // => 'foo bar'
+ *
+ * _.lowerCase('fooBar');
+ * // => 'foo bar'
+ *
+ * _.lowerCase('__FOO_BAR__');
+ * // => 'foo bar'
+ */
+var lowerCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + word.toLowerCase();
+});
+
+module.exports = lowerCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerFirst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerFirst.js
new file mode 100644
index 0000000..c08f082
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lowerFirst.js
@@ -0,0 +1,22 @@
+var createCaseFirst = require('./_createCaseFirst');
+
+/**
+ * Converts the first character of `string` to lower case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.lowerFirst('Fred');
+ * // => 'fred'
+ *
+ * _.lowerFirst('FRED');
+ * // => 'fRED'
+ */
+var lowerFirst = createCaseFirst('toLowerCase');
+
+module.exports = lowerFirst;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lt.js
new file mode 100644
index 0000000..813866e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lt.js
@@ -0,0 +1,29 @@
+var baseLt = require('./_baseLt'),
+ createRelationalOperation = require('./_createRelationalOperation');
+
+/**
+ * Checks if `value` is less than `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than `other`,
+ * else `false`.
+ * @see _.gt
+ * @example
+ *
+ * _.lt(1, 3);
+ * // => true
+ *
+ * _.lt(3, 3);
+ * // => false
+ *
+ * _.lt(3, 1);
+ * // => false
+ */
+var lt = createRelationalOperation(baseLt);
+
+module.exports = lt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lte.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lte.js
new file mode 100644
index 0000000..382f661
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/lte.js
@@ -0,0 +1,30 @@
+var createRelationalOperation = require('./_createRelationalOperation');
+
+/**
+ * Checks if `value` is less than or equal to `other`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.9.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if `value` is less than or equal to
+ * `other`, else `false`.
+ * @see _.gte
+ * @example
+ *
+ * _.lte(1, 3);
+ * // => true
+ *
+ * _.lte(3, 3);
+ * // => true
+ *
+ * _.lte(3, 1);
+ * // => false
+ */
+var lte = createRelationalOperation(function(value, other) {
+ return value <= other;
+});
+
+module.exports = lte;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/map.js
new file mode 100644
index 0000000..22efee7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/map.js
@@ -0,0 +1,53 @@
+var arrayMap = require('./_arrayMap'),
+ baseIteratee = require('./_baseIteratee'),
+ baseMap = require('./_baseMap'),
+ isArray = require('./isArray');
+
+/**
+ * Creates an array of values by running each element in `collection` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
+ *
+ * The guarded methods are:
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * _.map([4, 8], square);
+ * // => [16, 64]
+ *
+ * _.map({ 'a': 4, 'b': 8 }, square);
+ * // => [16, 64] (iteration order is not guaranteed)
+ *
+ * var users = [
+ * { 'user': 'barney' },
+ * { 'user': 'fred' }
+ * ];
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.map(users, 'user');
+ * // => ['barney', 'fred']
+ */
+function map(collection, iteratee) {
+ var func = isArray(collection) ? arrayMap : baseMap;
+ return func(collection, baseIteratee(iteratee, 3));
+}
+
+module.exports = map;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapKeys.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapKeys.js
new file mode 100644
index 0000000..3b68797
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapKeys.js
@@ -0,0 +1,36 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ baseForOwn = require('./_baseForOwn'),
+ baseIteratee = require('./_baseIteratee');
+
+/**
+ * The opposite of `_.mapValues`; this method creates an object with the
+ * same values as `object` and keys generated by running each own enumerable
+ * string keyed property of `object` thru `iteratee`. The iteratee is invoked
+ * with three arguments: (value, key, object).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns the new mapped object.
+ * @see _.mapValues
+ * @example
+ *
+ * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
+ * return key + value;
+ * });
+ * // => { 'a1': 1, 'b2': 2 }
+ */
+function mapKeys(object, iteratee) {
+ var result = {};
+ iteratee = baseIteratee(iteratee, 3);
+
+ baseForOwn(object, function(value, key, object) {
+ baseAssignValue(result, iteratee(value, key, object), value);
+ });
+ return result;
+}
+
+module.exports = mapKeys;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapValues.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapValues.js
new file mode 100644
index 0000000..4ec0825
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mapValues.js
@@ -0,0 +1,43 @@
+var baseAssignValue = require('./_baseAssignValue'),
+ baseForOwn = require('./_baseForOwn'),
+ baseIteratee = require('./_baseIteratee');
+
+/**
+ * Creates an object with the same keys as `object` and values generated
+ * by running each own enumerable string keyed property of `object` thru
+ * `iteratee`. The iteratee is invoked with three arguments:
+ * (value, key, object).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Object} Returns the new mapped object.
+ * @see _.mapKeys
+ * @example
+ *
+ * var users = {
+ * 'fred': { 'user': 'fred', 'age': 40 },
+ * 'pebbles': { 'user': 'pebbles', 'age': 1 }
+ * };
+ *
+ * _.mapValues(users, function(o) { return o.age; });
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.mapValues(users, 'age');
+ * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
+ */
+function mapValues(object, iteratee) {
+ var result = {};
+ iteratee = baseIteratee(iteratee, 3);
+
+ baseForOwn(object, function(value, key, object) {
+ baseAssignValue(result, key, iteratee(value, key, object));
+ });
+ return result;
+}
+
+module.exports = mapValues;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matches.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matches.js
new file mode 100644
index 0000000..11145db
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matches.js
@@ -0,0 +1,39 @@
+var baseClone = require('./_baseClone'),
+ baseMatches = require('./_baseMatches');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a function that performs a partial deep comparison between a given
+ * object and `source`, returning `true` if the given object has equivalent
+ * property values, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.isMatch` with `source`
+ * partially applied.
+ *
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Object} source The object of property values to match.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
+ * ];
+ *
+ * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
+ * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
+ */
+function matches(source) {
+ return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
+}
+
+module.exports = matches;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matchesProperty.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matchesProperty.js
new file mode 100644
index 0000000..cc062ac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/matchesProperty.js
@@ -0,0 +1,37 @@
+var baseClone = require('./_baseClone'),
+ baseMatchesProperty = require('./_baseMatchesProperty');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1;
+
+/**
+ * Creates a function that performs a partial deep comparison between the
+ * value at `path` of a given object to `srcValue`, returning `true` if the
+ * object value is equivalent, else `false`.
+ *
+ * **Note:** Partial comparisons will match empty array and empty object
+ * `srcValue` values against any array or object value, respectively. See
+ * `_.isEqual` for a list of supported value comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} srcValue The value to match.
+ * @returns {Function} Returns the new spec function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
+ * ];
+ *
+ * _.find(objects, _.matchesProperty('a', 4));
+ * // => { 'a': 4, 'b': 5, 'c': 6 }
+ */
+function matchesProperty(path, srcValue) {
+ return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
+}
+
+module.exports = matchesProperty;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/math.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/math.js
new file mode 100644
index 0000000..5966887
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/math.js
@@ -0,0 +1,17 @@
+module.exports = {
+ 'add': require('./add'),
+ 'ceil': require('./ceil'),
+ 'divide': require('./divide'),
+ 'floor': require('./floor'),
+ 'max': require('./max'),
+ 'maxBy': require('./maxBy'),
+ 'mean': require('./mean'),
+ 'meanBy': require('./meanBy'),
+ 'min': require('./min'),
+ 'minBy': require('./minBy'),
+ 'multiply': require('./multiply'),
+ 'round': require('./round'),
+ 'subtract': require('./subtract'),
+ 'sum': require('./sum'),
+ 'sumBy': require('./sumBy')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/max.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/max.js
new file mode 100644
index 0000000..142ad8c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/max.js
@@ -0,0 +1,29 @@
+var baseExtremum = require('./_baseExtremum'),
+ baseGt = require('./_baseGt'),
+ identity = require('./identity');
+
+/**
+ * Computes the maximum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * _.max([4, 2, 8, 6]);
+ * // => 8
+ *
+ * _.max([]);
+ * // => undefined
+ */
+function max(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseGt)
+ : undefined;
+}
+
+module.exports = max;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/maxBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/maxBy.js
new file mode 100644
index 0000000..2eba9c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/maxBy.js
@@ -0,0 +1,34 @@
+var baseExtremum = require('./_baseExtremum'),
+ baseGt = require('./_baseGt'),
+ baseIteratee = require('./_baseIteratee');
+
+/**
+ * This method is like `_.max` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * the value is ranked. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {*} Returns the maximum value.
+ * @example
+ *
+ * var objects = [{ 'n': 1 }, { 'n': 2 }];
+ *
+ * _.maxBy(objects, function(o) { return o.n; });
+ * // => { 'n': 2 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.maxBy(objects, 'n');
+ * // => { 'n': 2 }
+ */
+function maxBy(array, iteratee) {
+ return (array && array.length)
+ ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt)
+ : undefined;
+}
+
+module.exports = maxBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mean.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mean.js
new file mode 100644
index 0000000..e3ffff6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mean.js
@@ -0,0 +1,22 @@
+var baseMean = require('./_baseMean'),
+ identity = require('./identity');
+
+/**
+ * Computes the mean of the values in `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {number} Returns the mean.
+ * @example
+ *
+ * _.mean([4, 2, 8, 6]);
+ * // => 5
+ */
+function mean(array) {
+ return baseMean(array, identity);
+}
+
+module.exports = mean;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/meanBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/meanBy.js
new file mode 100644
index 0000000..b031671
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/meanBy.js
@@ -0,0 +1,31 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseMean = require('./_baseMean');
+
+/**
+ * This method is like `_.mean` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the value to be averaged.
+ * The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the mean.
+ * @example
+ *
+ * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
+ *
+ * _.meanBy(objects, function(o) { return o.n; });
+ * // => 5
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.meanBy(objects, 'n');
+ * // => 5
+ */
+function meanBy(array, iteratee) {
+ return baseMean(array, baseIteratee(iteratee, 2));
+}
+
+module.exports = meanBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/memoize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/memoize.js
new file mode 100644
index 0000000..d6035af
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/memoize.js
@@ -0,0 +1,73 @@
+var MapCache = require('./_MapCache');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that memoizes the result of `func`. If `resolver` is
+ * provided, it determines the cache key for storing the result based on the
+ * arguments provided to the memoized function. By default, the first argument
+ * provided to the memoized function is used as the map cache key. The `func`
+ * is invoked with the `this` binding of the memoized function.
+ *
+ * **Note:** The cache is exposed as the `cache` property on the memoized
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
+ * constructor with one whose instances implement the
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to have its output memoized.
+ * @param {Function} [resolver] The function to resolve the cache key.
+ * @returns {Function} Returns the new memoized function.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ * var other = { 'c': 3, 'd': 4 };
+ *
+ * var values = _.memoize(_.values);
+ * values(object);
+ * // => [1, 2]
+ *
+ * values(other);
+ * // => [3, 4]
+ *
+ * object.a = 2;
+ * values(object);
+ * // => [1, 2]
+ *
+ * // Modify the result cache.
+ * values.cache.set(object, ['a', 'b']);
+ * values(object);
+ * // => ['a', 'b']
+ *
+ * // Replace `_.memoize.Cache`.
+ * _.memoize.Cache = WeakMap;
+ */
+function memoize(func, resolver) {
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ var memoized = function() {
+ var args = arguments,
+ key = resolver ? resolver.apply(this, args) : args[0],
+ cache = memoized.cache;
+
+ if (cache.has(key)) {
+ return cache.get(key);
+ }
+ var result = func.apply(this, args);
+ memoized.cache = cache.set(key, result) || cache;
+ return result;
+ };
+ memoized.cache = new (memoize.Cache || MapCache);
+ return memoized;
+}
+
+// Expose `MapCache`.
+memoize.Cache = MapCache;
+
+module.exports = memoize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/merge.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/merge.js
new file mode 100644
index 0000000..4bbc3a1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/merge.js
@@ -0,0 +1,39 @@
+var baseMerge = require('./_baseMerge'),
+ createAssigner = require('./_createAssigner');
+
+/**
+ * This method is like `_.assign` except that it recursively merges own and
+ * inherited enumerable string keyed properties of source objects into the
+ * destination object. Source properties that resolve to `undefined` are
+ * skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
+ * };
+ *
+ * var other = {
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
+ * };
+ *
+ * _.merge(object, other);
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
+ */
+var merge = createAssigner(function(object, source, srcIndex) {
+ baseMerge(object, source, srcIndex);
+});
+
+module.exports = merge;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mergeWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mergeWith.js
new file mode 100644
index 0000000..1b43a2c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mergeWith.js
@@ -0,0 +1,39 @@
+var baseMerge = require('./_baseMerge'),
+ createAssigner = require('./_createAssigner');
+
+/**
+ * This method is like `_.merge` except that it accepts `customizer` which
+ * is invoked to produce the merged values of the destination and source
+ * properties. If `customizer` returns `undefined`, merging is handled by the
+ * method instead. The `customizer` is invoked with six arguments:
+ * (objValue, srcValue, key, object, source, stack).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} sources The source objects.
+ * @param {Function} customizer The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * function customizer(objValue, srcValue) {
+ * if (_.isArray(objValue)) {
+ * return objValue.concat(srcValue);
+ * }
+ * }
+ *
+ * var object = { 'a': [1], 'b': [2] };
+ * var other = { 'a': [3], 'b': [4] };
+ *
+ * _.mergeWith(object, other, customizer);
+ * // => { 'a': [1, 3], 'b': [2, 4] }
+ */
+var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
+ baseMerge(object, source, srcIndex, customizer);
+});
+
+module.exports = mergeWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/method.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/method.js
new file mode 100644
index 0000000..23ec32d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/method.js
@@ -0,0 +1,34 @@
+var baseInvoke = require('./_baseInvoke'),
+ baseRest = require('./_baseRest');
+
+/**
+ * Creates a function that invokes the method at `path` of a given object.
+ * Any additional arguments are provided to the invoked method.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Util
+ * @param {Array|string} path The path of the method to invoke.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {Function} Returns the new invoker function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': _.constant(2) } },
+ * { 'a': { 'b': _.constant(1) } }
+ * ];
+ *
+ * _.map(objects, _.method('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(objects, _.method(['a', 'b']));
+ * // => [2, 1]
+ */
+var method = baseRest(function(path, args) {
+ return function(object) {
+ return baseInvoke(object, path, args);
+ };
+});
+
+module.exports = method;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/methodOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/methodOf.js
new file mode 100644
index 0000000..df59b57
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/methodOf.js
@@ -0,0 +1,33 @@
+var baseInvoke = require('./_baseInvoke'),
+ baseRest = require('./_baseRest');
+
+/**
+ * The opposite of `_.method`; this method creates a function that invokes
+ * the method at a given path of `object`. Any additional arguments are
+ * provided to the invoked method.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Util
+ * @param {Object} object The object to query.
+ * @param {...*} [args] The arguments to invoke the method with.
+ * @returns {Function} Returns the new invoker function.
+ * @example
+ *
+ * var array = _.times(3, _.constant),
+ * object = { 'a': array, 'b': array, 'c': array };
+ *
+ * _.map(['a[2]', 'c[0]'], _.methodOf(object));
+ * // => [2, 0]
+ *
+ * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
+ * // => [2, 0]
+ */
+var methodOf = baseRest(function(object, args) {
+ return function(path) {
+ return baseInvoke(object, path, args);
+ };
+});
+
+module.exports = methodOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/min.js
new file mode 100644
index 0000000..428f571
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/min.js
@@ -0,0 +1,29 @@
+var baseExtremum = require('./_baseExtremum'),
+ baseLt = require('./_baseLt'),
+ identity = require('./identity');
+
+/**
+ * Computes the minimum value of `array`. If `array` is empty or falsey,
+ * `undefined` is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * _.min([4, 2, 8, 6]);
+ * // => 2
+ *
+ * _.min([]);
+ * // => undefined
+ */
+function min(array) {
+ return (array && array.length)
+ ? baseExtremum(array, identity, baseLt)
+ : undefined;
+}
+
+module.exports = min;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/minBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/minBy.js
new file mode 100644
index 0000000..b2697e4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/minBy.js
@@ -0,0 +1,34 @@
+var baseExtremum = require('./_baseExtremum'),
+ baseIteratee = require('./_baseIteratee'),
+ baseLt = require('./_baseLt');
+
+/**
+ * This method is like `_.min` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * the value is ranked. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {*} Returns the minimum value.
+ * @example
+ *
+ * var objects = [{ 'n': 1 }, { 'n': 2 }];
+ *
+ * _.minBy(objects, function(o) { return o.n; });
+ * // => { 'n': 1 }
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.minBy(objects, 'n');
+ * // => { 'n': 1 }
+ */
+function minBy(array, iteratee) {
+ return (array && array.length)
+ ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt)
+ : undefined;
+}
+
+module.exports = minBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mixin.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mixin.js
new file mode 100644
index 0000000..6dc9674
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/mixin.js
@@ -0,0 +1,74 @@
+var arrayEach = require('./_arrayEach'),
+ arrayPush = require('./_arrayPush'),
+ baseFunctions = require('./_baseFunctions'),
+ copyArray = require('./_copyArray'),
+ isFunction = require('./isFunction'),
+ isObject = require('./isObject'),
+ keys = require('./keys');
+
+/**
+ * Adds all own enumerable string keyed function properties of a source
+ * object to the destination object. If `object` is a function, then methods
+ * are added to its prototype as well.
+ *
+ * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
+ * avoid conflicts caused by modifying the original.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {Function|Object} [object=lodash] The destination object.
+ * @param {Object} source The object of functions to add.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
+ * @returns {Function|Object} Returns `object`.
+ * @example
+ *
+ * function vowels(string) {
+ * return _.filter(string, function(v) {
+ * return /[aeiou]/i.test(v);
+ * });
+ * }
+ *
+ * _.mixin({ 'vowels': vowels });
+ * _.vowels('fred');
+ * // => ['e']
+ *
+ * _('fred').vowels().value();
+ * // => ['e']
+ *
+ * _.mixin({ 'vowels': vowels }, { 'chain': false });
+ * _('fred').vowels();
+ * // => ['e']
+ */
+function mixin(object, source, options) {
+ var props = keys(source),
+ methodNames = baseFunctions(source, props);
+
+ var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
+ isFunc = isFunction(object);
+
+ arrayEach(methodNames, function(methodName) {
+ var func = source[methodName];
+ object[methodName] = func;
+ if (isFunc) {
+ object.prototype[methodName] = function() {
+ var chainAll = this.__chain__;
+ if (chain || chainAll) {
+ var result = object(this.__wrapped__),
+ actions = result.__actions__ = copyArray(this.__actions__);
+
+ actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
+ result.__chain__ = chainAll;
+ return result;
+ }
+ return func.apply(object, arrayPush([this.value()], arguments));
+ };
+ }
+ });
+
+ return object;
+}
+
+module.exports = mixin;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/multiply.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/multiply.js
new file mode 100644
index 0000000..d7876e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/multiply.js
@@ -0,0 +1,22 @@
+var createMathOperation = require('./_createMathOperation');
+
+/**
+ * Multiply two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.7.0
+ * @category Math
+ * @param {number} multiplier The first number in a multiplication.
+ * @param {number} multiplicand The second number in a multiplication.
+ * @returns {number} Returns the product.
+ * @example
+ *
+ * _.multiply(6, 4);
+ * // => 24
+ */
+var multiply = createMathOperation(function(multiplier, multiplicand) {
+ return multiplier * multiplicand;
+}, 1);
+
+module.exports = multiply;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/negate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/negate.js
new file mode 100644
index 0000000..5a65cd1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/negate.js
@@ -0,0 +1,40 @@
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that negates the result of the predicate `func`. The
+ * `func` predicate is invoked with the `this` binding and arguments of the
+ * created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} predicate The predicate to negate.
+ * @returns {Function} Returns the new negated function.
+ * @example
+ *
+ * function isEven(n) {
+ * return n % 2 == 0;
+ * }
+ *
+ * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
+ * // => [1, 3, 5]
+ */
+function negate(predicate) {
+ if (typeof predicate != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ return function() {
+ var args = arguments;
+ switch (args.length) {
+ case 0: return !predicate.call(this);
+ case 1: return !predicate.call(this, args[0]);
+ case 2: return !predicate.call(this, args[0], args[1]);
+ case 3: return !predicate.call(this, args[0], args[1], args[2]);
+ }
+ return !predicate.apply(this, args);
+ };
+}
+
+module.exports = negate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/next.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/next.js
new file mode 100644
index 0000000..55f949c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/next.js
@@ -0,0 +1,35 @@
+var toArray = require('./toArray');
+
+/**
+ * Gets the next value on a wrapped object following the
+ * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
+ *
+ * @name next
+ * @memberOf _
+ * @since 4.0.0
+ * @category Seq
+ * @returns {Object} Returns the next iterator value.
+ * @example
+ *
+ * var wrapped = _([1, 2]);
+ *
+ * wrapped.next();
+ * // => { 'done': false, 'value': 1 }
+ *
+ * wrapped.next();
+ * // => { 'done': false, 'value': 2 }
+ *
+ * wrapped.next();
+ * // => { 'done': true, 'value': undefined }
+ */
+function wrapperNext() {
+ if (this.__values__ === undefined) {
+ this.__values__ = toArray(this.value());
+ }
+ var done = this.__index__ >= this.__values__.length,
+ value = done ? undefined : this.__values__[this.__index__++];
+
+ return { 'done': done, 'value': value };
+}
+
+module.exports = wrapperNext;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/noop.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/noop.js
new file mode 100644
index 0000000..3c0862e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/noop.js
@@ -0,0 +1,17 @@
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop() {
+ // No operation performed.
+}
+
+module.exports = noop;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/now.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/now.js
new file mode 100644
index 0000000..44a0562
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/now.js
@@ -0,0 +1,23 @@
+var root = require('./_root');
+
+/**
+ * Gets the timestamp of the number of milliseconds that have elapsed since
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Date
+ * @returns {number} Returns the timestamp.
+ * @example
+ *
+ * _.defer(function(stamp) {
+ * console.log(_.now() - stamp);
+ * }, _.now());
+ * // => Logs the number of milliseconds it took for the deferred invocation.
+ */
+var now = function() {
+ return root.Date.now();
+};
+
+module.exports = now;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nth.js
new file mode 100644
index 0000000..8a344de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nth.js
@@ -0,0 +1,29 @@
+var baseNth = require('./_baseNth'),
+ toInteger = require('./toInteger');
+
+/**
+ * Gets the element at index `n` of `array`. If `n` is negative, the nth
+ * element from the end is returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.11.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=0] The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'd'];
+ *
+ * _.nth(array, 1);
+ * // => 'b'
+ *
+ * _.nth(array, -2);
+ * // => 'c';
+ */
+function nth(array, n) {
+ return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
+}
+
+module.exports = nth;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nthArg.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nthArg.js
new file mode 100644
index 0000000..09406dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/nthArg.js
@@ -0,0 +1,32 @@
+var baseNth = require('./_baseNth'),
+ baseRest = require('./_baseRest'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a function that gets the argument at index `n`. If `n` is negative,
+ * the nth argument from the end is returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {number} [n=0] The index of the argument to return.
+ * @returns {Function} Returns the new pass-thru function.
+ * @example
+ *
+ * var func = _.nthArg(1);
+ * func('a', 'b', 'c', 'd');
+ * // => 'b'
+ *
+ * var func = _.nthArg(-2);
+ * func('a', 'b', 'c', 'd');
+ * // => 'c'
+ */
+function nthArg(n) {
+ n = toInteger(n);
+ return baseRest(function(args) {
+ return baseNth(args, n);
+ });
+}
+
+module.exports = nthArg;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/number.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/number.js
new file mode 100644
index 0000000..c3b0100
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/number.js
@@ -0,0 +1,5 @@
+module.exports = {
+ 'clamp': require('./clamp'),
+ 'inRange': require('./inRange'),
+ 'random': require('./random')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/object.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/object.js
new file mode 100644
index 0000000..f046b05
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/object.js
@@ -0,0 +1,49 @@
+module.exports = {
+ 'assign': require('./assign'),
+ 'assignIn': require('./assignIn'),
+ 'assignInWith': require('./assignInWith'),
+ 'assignWith': require('./assignWith'),
+ 'at': require('./at'),
+ 'create': require('./create'),
+ 'defaults': require('./defaults'),
+ 'defaultsDeep': require('./defaultsDeep'),
+ 'entries': require('./entries'),
+ 'entriesIn': require('./entriesIn'),
+ 'extend': require('./extend'),
+ 'extendWith': require('./extendWith'),
+ 'findKey': require('./findKey'),
+ 'findLastKey': require('./findLastKey'),
+ 'forIn': require('./forIn'),
+ 'forInRight': require('./forInRight'),
+ 'forOwn': require('./forOwn'),
+ 'forOwnRight': require('./forOwnRight'),
+ 'functions': require('./functions'),
+ 'functionsIn': require('./functionsIn'),
+ 'get': require('./get'),
+ 'has': require('./has'),
+ 'hasIn': require('./hasIn'),
+ 'invert': require('./invert'),
+ 'invertBy': require('./invertBy'),
+ 'invoke': require('./invoke'),
+ 'keys': require('./keys'),
+ 'keysIn': require('./keysIn'),
+ 'mapKeys': require('./mapKeys'),
+ 'mapValues': require('./mapValues'),
+ 'merge': require('./merge'),
+ 'mergeWith': require('./mergeWith'),
+ 'omit': require('./omit'),
+ 'omitBy': require('./omitBy'),
+ 'pick': require('./pick'),
+ 'pickBy': require('./pickBy'),
+ 'result': require('./result'),
+ 'set': require('./set'),
+ 'setWith': require('./setWith'),
+ 'toPairs': require('./toPairs'),
+ 'toPairsIn': require('./toPairsIn'),
+ 'transform': require('./transform'),
+ 'unset': require('./unset'),
+ 'update': require('./update'),
+ 'updateWith': require('./updateWith'),
+ 'values': require('./values'),
+ 'valuesIn': require('./valuesIn')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omit.js
new file mode 100644
index 0000000..75d40aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omit.js
@@ -0,0 +1,56 @@
+var arrayMap = require('./_arrayMap'),
+ baseClone = require('./_baseClone'),
+ baseUnset = require('./_baseUnset'),
+ castPath = require('./_castPath'),
+ copyObject = require('./_copyObject'),
+ flatRest = require('./_flatRest'),
+ getAllKeysIn = require('./_getAllKeysIn');
+
+/** Used to compose bitmasks for cloning. */
+var CLONE_DEEP_FLAG = 1,
+ CLONE_FLAT_FLAG = 2,
+ CLONE_SYMBOLS_FLAG = 4;
+
+/**
+ * The opposite of `_.pick`; this method creates an object composed of the
+ * own and inherited enumerable property paths of `object` that are not omitted.
+ *
+ * **Note:** This method is considerably slower than `_.pick`.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to omit.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.omit(object, ['a', 'c']);
+ * // => { 'b': '2' }
+ */
+var omit = flatRest(function(object, paths) {
+ var result = {};
+ if (object == null) {
+ return result;
+ }
+ var isDeep = false;
+ paths = arrayMap(paths, function(path) {
+ path = castPath(path, object);
+ isDeep || (isDeep = path.length > 1);
+ return path;
+ });
+ copyObject(object, getAllKeysIn(object), result);
+ if (isDeep) {
+ result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
+ }
+ var length = paths.length;
+ while (length--) {
+ baseUnset(result, paths[length]);
+ }
+ return result;
+});
+
+module.exports = omit;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omitBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omitBy.js
new file mode 100644
index 0000000..a064036
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/omitBy.js
@@ -0,0 +1,29 @@
+var baseIteratee = require('./_baseIteratee'),
+ negate = require('./negate'),
+ pickBy = require('./pickBy');
+
+/**
+ * The opposite of `_.pickBy`; this method creates an object composed of
+ * the own and inherited enumerable string keyed properties of `object` that
+ * `predicate` doesn't return truthy for. The predicate is invoked with two
+ * arguments: (value, key).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.omitBy(object, _.isNumber);
+ * // => { 'b': '2' }
+ */
+function omitBy(object, predicate) {
+ return pickBy(object, negate(baseIteratee(predicate)));
+}
+
+module.exports = omitBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/once.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/once.js
new file mode 100644
index 0000000..0706fc3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/once.js
@@ -0,0 +1,25 @@
+var before = require('./before');
+
+/**
+ * Creates a function that is restricted to invoking `func` once. Repeat calls
+ * to the function return the value of the first invocation. The `func` is
+ * invoked with the `this` binding and arguments of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new restricted function.
+ * @example
+ *
+ * var initialize = _.once(createApplication);
+ * initialize();
+ * initialize();
+ * // => `createApplication` is invoked once
+ */
+function once(func) {
+ return before(2, func);
+}
+
+module.exports = once;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/orderBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/orderBy.js
new file mode 100644
index 0000000..7195c8c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/orderBy.js
@@ -0,0 +1,47 @@
+var baseOrderBy = require('./_baseOrderBy'),
+ isArray = require('./isArray');
+
+/**
+ * This method is like `_.sortBy` except that it allows specifying the sort
+ * orders of the iteratees to sort by. If `orders` is unspecified, all values
+ * are sorted in ascending order. Otherwise, specify an order of "desc" for
+ * descending or "asc" for ascending sort order of corresponding values.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @param {string[]} [orders] The sort orders of `iteratees`.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 34 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 36 }
+ * ];
+ *
+ * // Sort by `user` in ascending order and by `age` in descending order.
+ * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ */
+function orderBy(collection, iteratees, orders, guard) {
+ if (collection == null) {
+ return [];
+ }
+ if (!isArray(iteratees)) {
+ iteratees = iteratees == null ? [] : [iteratees];
+ }
+ orders = guard ? undefined : orders;
+ if (!isArray(orders)) {
+ orders = orders == null ? [] : [orders];
+ }
+ return baseOrderBy(collection, iteratees, orders);
+}
+
+module.exports = orderBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/over.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/over.js
new file mode 100644
index 0000000..bea2f91
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/over.js
@@ -0,0 +1,24 @@
+var arrayMap = require('./_arrayMap'),
+ createOver = require('./_createOver');
+
+/**
+ * Creates a function that invokes `iteratees` with the arguments it receives
+ * and returns their results.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to invoke.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.over([Math.max, Math.min]);
+ *
+ * func(1, 2, 3, 4);
+ * // => [4, 1]
+ */
+var over = createOver(arrayMap);
+
+module.exports = over;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overArgs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overArgs.js
new file mode 100644
index 0000000..f0067db
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overArgs.js
@@ -0,0 +1,61 @@
+var apply = require('./_apply'),
+ arrayMap = require('./_arrayMap'),
+ baseFlatten = require('./_baseFlatten'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ baseUnary = require('./_baseUnary'),
+ castRest = require('./_castRest'),
+ isArray = require('./isArray');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Creates a function that invokes `func` with its arguments transformed.
+ *
+ * @static
+ * @since 4.0.0
+ * @memberOf _
+ * @category Function
+ * @param {Function} func The function to wrap.
+ * @param {...(Function|Function[])} [transforms=[_.identity]]
+ * The argument transforms.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * function doubled(n) {
+ * return n * 2;
+ * }
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var func = _.overArgs(function(x, y) {
+ * return [x, y];
+ * }, [square, doubled]);
+ *
+ * func(9, 3);
+ * // => [81, 6]
+ *
+ * func(10, 5);
+ * // => [100, 10]
+ */
+var overArgs = castRest(function(func, transforms) {
+ transforms = (transforms.length == 1 && isArray(transforms[0]))
+ ? arrayMap(transforms[0], baseUnary(baseIteratee))
+ : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee));
+
+ var funcsLength = transforms.length;
+ return baseRest(function(args) {
+ var index = -1,
+ length = nativeMin(args.length, funcsLength);
+
+ while (++index < length) {
+ args[index] = transforms[index].call(this, args[index]);
+ }
+ return apply(func, this, args);
+ });
+});
+
+module.exports = overArgs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overEvery.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overEvery.js
new file mode 100644
index 0000000..c115d15
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overEvery.js
@@ -0,0 +1,30 @@
+var arrayEvery = require('./_arrayEvery'),
+ createOver = require('./_createOver');
+
+/**
+ * Creates a function that checks if **all** of the `predicates` return
+ * truthy when invoked with the arguments it receives.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.overEvery([Boolean, isFinite]);
+ *
+ * func('1');
+ * // => true
+ *
+ * func(null);
+ * // => false
+ *
+ * func(NaN);
+ * // => false
+ */
+var overEvery = createOver(arrayEvery);
+
+module.exports = overEvery;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overSome.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overSome.js
new file mode 100644
index 0000000..f902907
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/overSome.js
@@ -0,0 +1,30 @@
+var arraySome = require('./_arraySome'),
+ createOver = require('./_createOver');
+
+/**
+ * Creates a function that checks if **any** of the `predicates` return
+ * truthy when invoked with the arguments it receives.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var func = _.overSome([Boolean, isFinite]);
+ *
+ * func('1');
+ * // => true
+ *
+ * func(null);
+ * // => true
+ *
+ * func(NaN);
+ * // => false
+ */
+var overSome = createOver(arraySome);
+
+module.exports = overSome;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/package.json
new file mode 100644
index 0000000..da0e1a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/package.json
@@ -0,0 +1,70 @@
+{
+ "name": "lodash",
+ "version": "4.17.2",
+ "description": "Lodash modular utilities.",
+ "keywords": [
+ "modules",
+ "stdlib",
+ "util"
+ ],
+ "homepage": "https://lodash.com/",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/lodash/lodash.git"
+ },
+ "icon": "https://lodash.com/icon.svg",
+ "license": "MIT",
+ "main": "lodash.js",
+ "author": {
+ "name": "John-David Dalton",
+ "email": "john.david.dalton@gmail.com",
+ "url": "http://allyoucanleet.com/"
+ },
+ "contributors": [
+ {
+ "name": "John-David Dalton",
+ "email": "john.david.dalton@gmail.com",
+ "url": "http://allyoucanleet.com/"
+ },
+ {
+ "name": "Mathias Bynens",
+ "email": "mathias@qiwi.be",
+ "url": "https://mathiasbynens.be/"
+ }
+ ],
+ "scripts": {
+ "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\""
+ },
+ "bugs": {
+ "url": "https://github.com/lodash/lodash/issues"
+ },
+ "_id": "lodash@4.17.2",
+ "_shasum": "34a3055babe04ce42467b607d700072c7ff6bf42",
+ "_from": "lodash@>=4.14.0 <5.0.0",
+ "_npmVersion": "2.15.11",
+ "_nodeVersion": "7.1.0",
+ "_npmUser": {
+ "name": "jdalton",
+ "email": "john.david.dalton@gmail.com"
+ },
+ "dist": {
+ "shasum": "34a3055babe04ce42467b607d700072c7ff6bf42",
+ "tarball": "https://registry.npmjs.org/lodash/-/lodash-4.17.2.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "jdalton",
+ "email": "john.david.dalton@gmail.com"
+ },
+ {
+ "name": "mathias",
+ "email": "mathias@qiwi.be"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-18-east.internal.npmjs.com",
+ "tmp": "tmp/lodash-4.17.2.tgz_1479280899250_0.8391377755906433"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.2.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pad.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pad.js
new file mode 100644
index 0000000..77e1f1c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pad.js
@@ -0,0 +1,49 @@
+var createPadding = require('./_createPadding'),
+ stringSize = require('./_stringSize'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil,
+ nativeFloor = Math.floor;
+
+/**
+ * Pads `string` on the left and right sides if it's shorter than `length`.
+ * Padding characters are truncated if they can't be evenly divided by `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.pad('abc', 8);
+ * // => ' abc '
+ *
+ * _.pad('abc', 8, '_-');
+ * // => '_-abc_-_'
+ *
+ * _.pad('abc', 3);
+ * // => 'abc'
+ */
+function pad(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ if (!length || strLength >= length) {
+ return string;
+ }
+ var mid = (length - strLength) / 2;
+ return (
+ createPadding(nativeFloor(mid), chars) +
+ string +
+ createPadding(nativeCeil(mid), chars)
+ );
+}
+
+module.exports = pad;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padEnd.js
new file mode 100644
index 0000000..224eb80
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padEnd.js
@@ -0,0 +1,39 @@
+var createPadding = require('./_createPadding'),
+ stringSize = require('./_stringSize'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/**
+ * Pads `string` on the right side if it's shorter than `length`. Padding
+ * characters are truncated if they exceed `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.padEnd('abc', 6);
+ * // => 'abc '
+ *
+ * _.padEnd('abc', 6, '_-');
+ * // => 'abc_-_'
+ *
+ * _.padEnd('abc', 3);
+ * // => 'abc'
+ */
+function padEnd(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ return (length && strLength < length)
+ ? (string + createPadding(length - strLength, chars))
+ : string;
+}
+
+module.exports = padEnd;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padStart.js
new file mode 100644
index 0000000..f991866
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/padStart.js
@@ -0,0 +1,39 @@
+var createPadding = require('./_createPadding'),
+ stringSize = require('./_stringSize'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/**
+ * Pads `string` on the left side if it's shorter than `length`. Padding
+ * characters are truncated if they exceed `length`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to pad.
+ * @param {number} [length=0] The padding length.
+ * @param {string} [chars=' '] The string used as padding.
+ * @returns {string} Returns the padded string.
+ * @example
+ *
+ * _.padStart('abc', 6);
+ * // => ' abc'
+ *
+ * _.padStart('abc', 6, '_-');
+ * // => '_-_abc'
+ *
+ * _.padStart('abc', 3);
+ * // => 'abc'
+ */
+function padStart(string, length, chars) {
+ string = toString(string);
+ length = toInteger(length);
+
+ var strLength = length ? stringSize(string) : 0;
+ return (length && strLength < length)
+ ? (createPadding(length - strLength, chars) + string)
+ : string;
+}
+
+module.exports = padStart;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/parseInt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/parseInt.js
new file mode 100644
index 0000000..82badf0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/parseInt.js
@@ -0,0 +1,43 @@
+var root = require('./_root'),
+ toString = require('./toString');
+
+/** Used to match leading and trailing whitespace. */
+var reTrimStart = /^\s+/;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeParseInt = root.parseInt;
+
+/**
+ * Converts `string` to an integer of the specified radix. If `radix` is
+ * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
+ * hexadecimal, in which case a `radix` of `16` is used.
+ *
+ * **Note:** This method aligns with the
+ * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.1.0
+ * @category String
+ * @param {string} string The string to convert.
+ * @param {number} [radix=10] The radix to interpret `value` by.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.parseInt('08');
+ * // => 8
+ *
+ * _.map(['6', '08', '10'], _.parseInt);
+ * // => [6, 8, 10]
+ */
+function parseInt(string, radix, guard) {
+ if (guard || radix == null) {
+ radix = 0;
+ } else if (radix) {
+ radix = +radix;
+ }
+ return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
+}
+
+module.exports = parseInt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partial.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partial.js
new file mode 100644
index 0000000..05fe8d3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partial.js
@@ -0,0 +1,50 @@
+var baseRest = require('./_baseRest'),
+ createWrap = require('./_createWrap'),
+ getHolder = require('./_getHolder'),
+ replaceHolders = require('./_replaceHolders');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_PARTIAL_FLAG = 32;
+
+/**
+ * Creates a function that invokes `func` with `partials` prepended to the
+ * arguments it receives. This method is like `_.bind` except it does **not**
+ * alter the `this` binding.
+ *
+ * The `_.partial.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of partially
+ * applied functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.2.0
+ * @category Function
+ * @param {Function} func The function to partially apply arguments to.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new partially applied function.
+ * @example
+ *
+ * function greet(greeting, name) {
+ * return greeting + ' ' + name;
+ * }
+ *
+ * var sayHelloTo = _.partial(greet, 'hello');
+ * sayHelloTo('fred');
+ * // => 'hello fred'
+ *
+ * // Partially applied with placeholders.
+ * var greetFred = _.partial(greet, _, 'fred');
+ * greetFred('hi');
+ * // => 'hi fred'
+ */
+var partial = baseRest(function(func, partials) {
+ var holders = replaceHolders(partials, getHolder(partial));
+ return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
+});
+
+// Assign default placeholders.
+partial.placeholder = {};
+
+module.exports = partial;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partialRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partialRight.js
new file mode 100644
index 0000000..eee031f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partialRight.js
@@ -0,0 +1,49 @@
+var baseRest = require('./_baseRest'),
+ createWrap = require('./_createWrap'),
+ getHolder = require('./_getHolder'),
+ replaceHolders = require('./_replaceHolders');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_PARTIAL_RIGHT_FLAG = 64;
+
+/**
+ * This method is like `_.partial` except that partially applied arguments
+ * are appended to the arguments it receives.
+ *
+ * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
+ * builds, may be used as a placeholder for partially applied arguments.
+ *
+ * **Note:** This method doesn't set the "length" property of partially
+ * applied functions.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.0.0
+ * @category Function
+ * @param {Function} func The function to partially apply arguments to.
+ * @param {...*} [partials] The arguments to be partially applied.
+ * @returns {Function} Returns the new partially applied function.
+ * @example
+ *
+ * function greet(greeting, name) {
+ * return greeting + ' ' + name;
+ * }
+ *
+ * var greetFred = _.partialRight(greet, 'fred');
+ * greetFred('hi');
+ * // => 'hi fred'
+ *
+ * // Partially applied with placeholders.
+ * var sayHelloTo = _.partialRight(greet, 'hello', _);
+ * sayHelloTo('fred');
+ * // => 'hello fred'
+ */
+var partialRight = baseRest(function(func, partials) {
+ var holders = replaceHolders(partials, getHolder(partialRight));
+ return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
+});
+
+// Assign default placeholders.
+partialRight.placeholder = {};
+
+module.exports = partialRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partition.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partition.js
new file mode 100644
index 0000000..6b814a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/partition.js
@@ -0,0 +1,43 @@
+var createAggregator = require('./_createAggregator');
+
+/**
+ * Creates an array of elements split into two groups, the first of which
+ * contains elements `predicate` returns truthy for, the second of which
+ * contains elements `predicate` returns falsey for. The predicate is
+ * invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the array of grouped elements.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': true },
+ * { 'user': 'pebbles', 'age': 1, 'active': false }
+ * ];
+ *
+ * _.partition(users, function(o) { return o.active; });
+ * // => objects for [['fred'], ['barney', 'pebbles']]
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.partition(users, { 'age': 1, 'active': false });
+ * // => objects for [['pebbles'], ['barney', 'fred']]
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.partition(users, ['active', false]);
+ * // => objects for [['barney', 'pebbles'], ['fred']]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.partition(users, 'active');
+ * // => objects for [['fred'], ['barney', 'pebbles']]
+ */
+var partition = createAggregator(function(result, value, key) {
+ result[key ? 0 : 1].push(value);
+}, function() { return [[], []]; });
+
+module.exports = partition;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pick.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pick.js
new file mode 100644
index 0000000..3160199
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pick.js
@@ -0,0 +1,25 @@
+var basePick = require('./_basePick'),
+ flatRest = require('./_flatRest');
+
+/**
+ * Creates an object composed of the picked `object` properties.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pick(object, ['a', 'c']);
+ * // => { 'a': 1, 'c': 3 }
+ */
+var pick = flatRest(function(object, paths) {
+ return object == null ? {} : basePick(object, paths);
+});
+
+module.exports = pick;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pickBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pickBy.js
new file mode 100644
index 0000000..ae7c271
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pickBy.js
@@ -0,0 +1,37 @@
+var arrayMap = require('./_arrayMap'),
+ baseIteratee = require('./_baseIteratee'),
+ basePickBy = require('./_basePickBy'),
+ getAllKeysIn = require('./_getAllKeysIn');
+
+/**
+ * Creates an object composed of the `object` properties `predicate` returns
+ * truthy for. The predicate is invoked with two arguments: (value, key).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The source object.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
+ *
+ * _.pickBy(object, _.isNumber);
+ * // => { 'a': 1, 'c': 3 }
+ */
+function pickBy(object, predicate) {
+ if (object == null) {
+ return {};
+ }
+ var props = arrayMap(getAllKeysIn(object), function(prop) {
+ return [prop];
+ });
+ predicate = baseIteratee(predicate);
+ return basePickBy(object, props, function(value, path) {
+ return predicate(value, path[0]);
+ });
+}
+
+module.exports = pickBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/plant.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/plant.js
new file mode 100644
index 0000000..23776f3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/plant.js
@@ -0,0 +1,48 @@
+var baseLodash = require('./_baseLodash'),
+ wrapperClone = require('./_wrapperClone');
+
+/**
+ * Creates a clone of the chain sequence planting `value` as the wrapped value.
+ *
+ * @name plant
+ * @memberOf _
+ * @since 3.2.0
+ * @category Seq
+ * @param {*} value The value to plant.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2]).map(square);
+ * var other = wrapped.plant([3, 4]);
+ *
+ * other.value();
+ * // => [9, 16]
+ *
+ * wrapped.value();
+ * // => [1, 4]
+ */
+function wrapperPlant(value) {
+ var result,
+ parent = this;
+
+ while (parent instanceof baseLodash) {
+ var clone = wrapperClone(parent);
+ clone.__index__ = 0;
+ clone.__values__ = undefined;
+ if (result) {
+ previous.__wrapped__ = clone;
+ } else {
+ result = clone;
+ }
+ var previous = clone;
+ parent = parent.__wrapped__;
+ }
+ previous.__wrapped__ = value;
+ return result;
+}
+
+module.exports = wrapperPlant;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/property.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/property.js
new file mode 100644
index 0000000..ca8202f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/property.js
@@ -0,0 +1,32 @@
+var baseProperty = require('./_baseProperty'),
+ basePropertyDeep = require('./_basePropertyDeep'),
+ isKey = require('./_isKey'),
+ toKey = require('./_toKey');
+
+/**
+ * Creates a function that returns the value at `path` of a given object.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {Array|string} path The path of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var objects = [
+ * { 'a': { 'b': 2 } },
+ * { 'a': { 'b': 1 } }
+ * ];
+ *
+ * _.map(objects, _.property('a.b'));
+ * // => [2, 1]
+ *
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
+ * // => [1, 2]
+ */
+function property(path) {
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
+}
+
+module.exports = property;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/propertyOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/propertyOf.js
new file mode 100644
index 0000000..384044d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/propertyOf.js
@@ -0,0 +1,30 @@
+var baseGet = require('./_baseGet');
+
+/**
+ * The opposite of `_.property`; this method creates a function that returns
+ * the value at a given path of `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Util
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ * @example
+ *
+ * var array = [0, 1, 2],
+ * object = { 'a': array, 'b': array, 'c': array };
+ *
+ * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
+ * // => [2, 0]
+ *
+ * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
+ * // => [2, 0]
+ */
+function propertyOf(object) {
+ return function(path) {
+ return object == null ? undefined : baseGet(object, path);
+ };
+}
+
+module.exports = propertyOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pull.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pull.js
new file mode 100644
index 0000000..a2efcb5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pull.js
@@ -0,0 +1,29 @@
+var baseRest = require('./_baseRest'),
+ pullAll = require('./pullAll');
+
+/**
+ * Removes all given values from `array` using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
+ * to remove elements from an array by predicate.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {...*} [values] The values to remove.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
+ *
+ * _.pull(array, 'a', 'c');
+ * console.log(array);
+ * // => ['b', 'b']
+ */
+var pull = baseRest(pullAll);
+
+module.exports = pull;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAll.js
new file mode 100644
index 0000000..f4605c2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAll.js
@@ -0,0 +1,29 @@
+var basePullAll = require('./_basePullAll');
+
+/**
+ * This method is like `_.pull` except that it accepts an array of values to remove.
+ *
+ * **Note:** Unlike `_.difference`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
+ *
+ * _.pullAll(array, ['a', 'c']);
+ * console.log(array);
+ * // => ['b', 'b']
+ */
+function pullAll(array, values) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values)
+ : array;
+}
+
+module.exports = pullAll;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllBy.js
new file mode 100644
index 0000000..74025e8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllBy.js
@@ -0,0 +1,33 @@
+var baseIteratee = require('./_baseIteratee'),
+ basePullAll = require('./_basePullAll');
+
+/**
+ * This method is like `_.pullAll` except that it accepts `iteratee` which is
+ * invoked for each element of `array` and `values` to generate the criterion
+ * by which they're compared. The iteratee is invoked with one argument: (value).
+ *
+ * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
+ *
+ * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
+ * console.log(array);
+ * // => [{ 'x': 2 }]
+ */
+function pullAllBy(array, values, iteratee) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values, baseIteratee(iteratee, 2))
+ : array;
+}
+
+module.exports = pullAllBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllWith.js
new file mode 100644
index 0000000..1d2fd9f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAllWith.js
@@ -0,0 +1,32 @@
+var basePullAll = require('./_basePullAll');
+
+/**
+ * This method is like `_.pullAll` except that it accepts `comparator` which
+ * is invoked to compare elements of `array` to `values`. The comparator is
+ * invoked with two arguments: (arrVal, othVal).
+ *
+ * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Array} values The values to remove.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
+ *
+ * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
+ * console.log(array);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
+ */
+function pullAllWith(array, values, comparator) {
+ return (array && array.length && values && values.length)
+ ? basePullAll(array, values, undefined, comparator)
+ : array;
+}
+
+module.exports = pullAllWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAt.js
new file mode 100644
index 0000000..6ed84e0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/pullAt.js
@@ -0,0 +1,43 @@
+var arrayMap = require('./_arrayMap'),
+ baseAt = require('./_baseAt'),
+ basePullAt = require('./_basePullAt'),
+ compareAscending = require('./_compareAscending'),
+ flatRest = require('./_flatRest'),
+ isIndex = require('./_isIndex');
+
+/**
+ * Removes elements from `array` corresponding to `indexes` and returns an
+ * array of removed elements.
+ *
+ * **Note:** Unlike `_.at`, this method mutates `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {...(number|number[])} [indexes] The indexes of elements to remove.
+ * @returns {Array} Returns the new array of removed elements.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'd'];
+ * var pulled = _.pullAt(array, [1, 3]);
+ *
+ * console.log(array);
+ * // => ['a', 'c']
+ *
+ * console.log(pulled);
+ * // => ['b', 'd']
+ */
+var pullAt = flatRest(function(array, indexes) {
+ var length = array == null ? 0 : array.length,
+ result = baseAt(array, indexes);
+
+ basePullAt(array, arrayMap(indexes, function(index) {
+ return isIndex(index, length) ? +index : index;
+ }).sort(compareAscending));
+
+ return result;
+});
+
+module.exports = pullAt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/random.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/random.js
new file mode 100644
index 0000000..8067711
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/random.js
@@ -0,0 +1,82 @@
+var baseRandom = require('./_baseRandom'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toFinite = require('./toFinite');
+
+/** Built-in method references without a dependency on `root`. */
+var freeParseFloat = parseFloat;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min,
+ nativeRandom = Math.random;
+
+/**
+ * Produces a random number between the inclusive `lower` and `upper` bounds.
+ * If only one argument is provided a number between `0` and the given number
+ * is returned. If `floating` is `true`, or either `lower` or `upper` are
+ * floats, a floating-point number is returned instead of an integer.
+ *
+ * **Note:** JavaScript follows the IEEE-754 standard for resolving
+ * floating-point values which can produce unexpected results.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.7.0
+ * @category Number
+ * @param {number} [lower=0] The lower bound.
+ * @param {number} [upper=1] The upper bound.
+ * @param {boolean} [floating] Specify returning a floating-point number.
+ * @returns {number} Returns the random number.
+ * @example
+ *
+ * _.random(0, 5);
+ * // => an integer between 0 and 5
+ *
+ * _.random(5);
+ * // => also an integer between 0 and 5
+ *
+ * _.random(5, true);
+ * // => a floating-point number between 0 and 5
+ *
+ * _.random(1.2, 5.2);
+ * // => a floating-point number between 1.2 and 5.2
+ */
+function random(lower, upper, floating) {
+ if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
+ upper = floating = undefined;
+ }
+ if (floating === undefined) {
+ if (typeof upper == 'boolean') {
+ floating = upper;
+ upper = undefined;
+ }
+ else if (typeof lower == 'boolean') {
+ floating = lower;
+ lower = undefined;
+ }
+ }
+ if (lower === undefined && upper === undefined) {
+ lower = 0;
+ upper = 1;
+ }
+ else {
+ lower = toFinite(lower);
+ if (upper === undefined) {
+ upper = lower;
+ lower = 0;
+ } else {
+ upper = toFinite(upper);
+ }
+ }
+ if (lower > upper) {
+ var temp = lower;
+ lower = upper;
+ upper = temp;
+ }
+ if (floating || lower % 1 || upper % 1) {
+ var rand = nativeRandom();
+ return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
+ }
+ return baseRandom(lower, upper);
+}
+
+module.exports = random;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/range.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/range.js
new file mode 100644
index 0000000..fa63b09
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/range.js
@@ -0,0 +1,46 @@
+var createRange = require('./_createRange');
+
+/**
+ * Creates an array of numbers (positive and/or negative) progressing from
+ * `start` up to, but not including, `end`. A step of `-1` is used if a negative
+ * `start` is specified without an `end` or `step`. If `end` is not specified,
+ * it's set to `start` with `start` then set to `0`.
+ *
+ * **Note:** JavaScript follows the IEEE-754 standard for resolving
+ * floating-point values which can produce unexpected results.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @returns {Array} Returns the range of numbers.
+ * @see _.inRange, _.rangeRight
+ * @example
+ *
+ * _.range(4);
+ * // => [0, 1, 2, 3]
+ *
+ * _.range(-4);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 5);
+ * // => [1, 2, 3, 4]
+ *
+ * _.range(0, 20, 5);
+ * // => [0, 5, 10, 15]
+ *
+ * _.range(0, -4, -1);
+ * // => [0, -1, -2, -3]
+ *
+ * _.range(1, 4, 0);
+ * // => [1, 1, 1]
+ *
+ * _.range(0);
+ * // => []
+ */
+var range = createRange();
+
+module.exports = range;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rangeRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rangeRight.js
new file mode 100644
index 0000000..271fafc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rangeRight.js
@@ -0,0 +1,41 @@
+var createRange = require('./_createRange');
+
+/**
+ * This method is like `_.range` except that it populates values in
+ * descending order.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {number} [start=0] The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} [step=1] The value to increment or decrement by.
+ * @returns {Array} Returns the range of numbers.
+ * @see _.inRange, _.range
+ * @example
+ *
+ * _.rangeRight(4);
+ * // => [3, 2, 1, 0]
+ *
+ * _.rangeRight(-4);
+ * // => [-3, -2, -1, 0]
+ *
+ * _.rangeRight(1, 5);
+ * // => [4, 3, 2, 1]
+ *
+ * _.rangeRight(0, 20, 5);
+ * // => [15, 10, 5, 0]
+ *
+ * _.rangeRight(0, -4, -1);
+ * // => [-3, -2, -1, 0]
+ *
+ * _.rangeRight(1, 4, 0);
+ * // => [1, 1, 1]
+ *
+ * _.rangeRight(0);
+ * // => []
+ */
+var rangeRight = createRange(true);
+
+module.exports = rangeRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rearg.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rearg.js
new file mode 100644
index 0000000..a3e1970
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rearg.js
@@ -0,0 +1,33 @@
+var createWrap = require('./_createWrap'),
+ flatRest = require('./_flatRest');
+
+/** Used to compose bitmasks for function metadata. */
+var WRAP_REARG_FLAG = 256;
+
+/**
+ * Creates a function that invokes `func` with arguments arranged according
+ * to the specified `indexes` where the argument value at the first index is
+ * provided as the first argument, the argument value at the second index is
+ * provided as the second argument, and so on.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Function
+ * @param {Function} func The function to rearrange arguments for.
+ * @param {...(number|number[])} indexes The arranged argument indexes.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var rearged = _.rearg(function(a, b, c) {
+ * return [a, b, c];
+ * }, [2, 0, 1]);
+ *
+ * rearged('b', 'c', 'a')
+ * // => ['a', 'b', 'c']
+ */
+var rearg = flatRest(function(func, indexes) {
+ return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
+});
+
+module.exports = rearg;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduce.js
new file mode 100644
index 0000000..5a1df4d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduce.js
@@ -0,0 +1,51 @@
+var arrayReduce = require('./_arrayReduce'),
+ baseEach = require('./_baseEach'),
+ baseIteratee = require('./_baseIteratee'),
+ baseReduce = require('./_baseReduce'),
+ isArray = require('./isArray');
+
+/**
+ * Reduces `collection` to a value which is the accumulated result of running
+ * each element in `collection` thru `iteratee`, where each successive
+ * invocation is supplied the return value of the previous. If `accumulator`
+ * is not given, the first element of `collection` is used as the initial
+ * value. The iteratee is invoked with four arguments:
+ * (accumulator, value, index|key, collection).
+ *
+ * Many lodash methods are guarded to work as iteratees for methods like
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
+ *
+ * The guarded methods are:
+ * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
+ * and `sortBy`
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduceRight
+ * @example
+ *
+ * _.reduce([1, 2], function(sum, n) {
+ * return sum + n;
+ * }, 0);
+ * // => 3
+ *
+ * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * return result;
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
+ */
+function reduce(collection, iteratee, accumulator) {
+ var func = isArray(collection) ? arrayReduce : baseReduce,
+ initAccum = arguments.length < 3;
+
+ return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach);
+}
+
+module.exports = reduce;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduceRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduceRight.js
new file mode 100644
index 0000000..e06a7cb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reduceRight.js
@@ -0,0 +1,36 @@
+var arrayReduceRight = require('./_arrayReduceRight'),
+ baseEachRight = require('./_baseEachRight'),
+ baseIteratee = require('./_baseIteratee'),
+ baseReduce = require('./_baseReduce'),
+ isArray = require('./isArray');
+
+/**
+ * This method is like `_.reduce` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The initial value.
+ * @returns {*} Returns the accumulated value.
+ * @see _.reduce
+ * @example
+ *
+ * var array = [[0, 1], [2, 3], [4, 5]];
+ *
+ * _.reduceRight(array, function(flattened, other) {
+ * return flattened.concat(other);
+ * }, []);
+ * // => [4, 5, 2, 3, 0, 1]
+ */
+function reduceRight(collection, iteratee, accumulator) {
+ var func = isArray(collection) ? arrayReduceRight : baseReduce,
+ initAccum = arguments.length < 3;
+
+ return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
+}
+
+module.exports = reduceRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reject.js
new file mode 100644
index 0000000..a13e554
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reject.js
@@ -0,0 +1,46 @@
+var arrayFilter = require('./_arrayFilter'),
+ baseFilter = require('./_baseFilter'),
+ baseIteratee = require('./_baseIteratee'),
+ isArray = require('./isArray'),
+ negate = require('./negate');
+
+/**
+ * The opposite of `_.filter`; this method returns the elements of `collection`
+ * that `predicate` does **not** return truthy for.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new filtered array.
+ * @see _.filter
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36, 'active': false },
+ * { 'user': 'fred', 'age': 40, 'active': true }
+ * ];
+ *
+ * _.reject(users, function(o) { return !o.active; });
+ * // => objects for ['fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.reject(users, { 'age': 40, 'active': true });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.reject(users, ['active', false]);
+ * // => objects for ['fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.reject(users, 'active');
+ * // => objects for ['barney']
+ */
+function reject(collection, predicate) {
+ var func = isArray(collection) ? arrayFilter : baseFilter;
+ return func(collection, negate(baseIteratee(predicate, 3)));
+}
+
+module.exports = reject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/remove.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/remove.js
new file mode 100644
index 0000000..87b1898
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/remove.js
@@ -0,0 +1,53 @@
+var baseIteratee = require('./_baseIteratee'),
+ basePullAt = require('./_basePullAt');
+
+/**
+ * Removes all elements from `array` that `predicate` returns truthy for
+ * and returns an array of the removed elements. The predicate is invoked
+ * with three arguments: (value, index, array).
+ *
+ * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
+ * to pull elements from an array by value.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the new array of removed elements.
+ * @example
+ *
+ * var array = [1, 2, 3, 4];
+ * var evens = _.remove(array, function(n) {
+ * return n % 2 == 0;
+ * });
+ *
+ * console.log(array);
+ * // => [1, 3]
+ *
+ * console.log(evens);
+ * // => [2, 4]
+ */
+function remove(array, predicate) {
+ var result = [];
+ if (!(array && array.length)) {
+ return result;
+ }
+ var index = -1,
+ indexes = [],
+ length = array.length;
+
+ predicate = baseIteratee(predicate, 3);
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value, index, array)) {
+ result.push(value);
+ indexes.push(index);
+ }
+ }
+ basePullAt(array, indexes);
+ return result;
+}
+
+module.exports = remove;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/repeat.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/repeat.js
new file mode 100644
index 0000000..f4d8c69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/repeat.js
@@ -0,0 +1,37 @@
+var baseRepeat = require('./_baseRepeat'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/**
+ * Repeats the given string `n` times.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to repeat.
+ * @param {number} [n=1] The number of times to repeat the string.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the repeated string.
+ * @example
+ *
+ * _.repeat('*', 3);
+ * // => '***'
+ *
+ * _.repeat('abc', 2);
+ * // => 'abcabc'
+ *
+ * _.repeat('abc', 0);
+ * // => ''
+ */
+function repeat(string, n, guard) {
+ if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
+ n = 1;
+ } else {
+ n = toInteger(n);
+ }
+ return baseRepeat(toString(string), n);
+}
+
+module.exports = repeat;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/replace.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/replace.js
new file mode 100644
index 0000000..6e26ecd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/replace.js
@@ -0,0 +1,29 @@
+var toString = require('./toString');
+
+/**
+ * Replaces matches for `pattern` in `string` with `replacement`.
+ *
+ * **Note:** This method is based on
+ * [`String#replace`](https://mdn.io/String/replace).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to modify.
+ * @param {RegExp|string} pattern The pattern to replace.
+ * @param {Function|string} replacement The match replacement.
+ * @returns {string} Returns the modified string.
+ * @example
+ *
+ * _.replace('Hi Fred', 'Fred', 'Barney');
+ * // => 'Hi Barney'
+ */
+function replace() {
+ var args = arguments,
+ string = toString(args[0]);
+
+ return args.length < 3 ? string : string.replace(args[1], args[2]);
+}
+
+module.exports = replace;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rest.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rest.js
new file mode 100644
index 0000000..eaaad00
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/rest.js
@@ -0,0 +1,40 @@
+var baseRest = require('./_baseRest'),
+ toInteger = require('./toInteger');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a function that invokes `func` with the `this` binding of the
+ * created function and arguments from `start` and beyond provided as
+ * an array.
+ *
+ * **Note:** This method is based on the
+ * [rest parameter](https://mdn.io/rest_parameters).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var say = _.rest(function(what, names) {
+ * return what + ' ' + _.initial(names).join(', ') +
+ * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
+ * });
+ *
+ * say('hello', 'fred', 'barney', 'pebbles');
+ * // => 'hello fred, barney, & pebbles'
+ */
+function rest(func, start) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ start = start === undefined ? start : toInteger(start);
+ return baseRest(func, start);
+}
+
+module.exports = rest;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/result.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/result.js
new file mode 100644
index 0000000..eae1250
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/result.js
@@ -0,0 +1,56 @@
+var castPath = require('./_castPath'),
+ isFunction = require('./isFunction'),
+ toKey = require('./_toKey');
+
+/**
+ * This method is like `_.get` except that if the resolved value is a
+ * function it's invoked with the `this` binding of its parent object and
+ * its result is returned.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to resolve.
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
+ *
+ * _.result(object, 'a[0].b.c1');
+ * // => 3
+ *
+ * _.result(object, 'a[0].b.c2');
+ * // => 4
+ *
+ * _.result(object, 'a[0].b.c3', 'default');
+ * // => 'default'
+ *
+ * _.result(object, 'a[0].b.c3', _.constant('default'));
+ * // => 'default'
+ */
+function result(object, path, defaultValue) {
+ path = castPath(path, object);
+
+ var index = -1,
+ length = path.length;
+
+ // Ensure the loop is entered when path is empty.
+ if (!length) {
+ length = 1;
+ object = undefined;
+ }
+ while (++index < length) {
+ var value = object == null ? undefined : object[toKey(path[index])];
+ if (value === undefined) {
+ index = length;
+ value = defaultValue;
+ }
+ object = isFunction(value) ? value.call(object) : value;
+ }
+ return object;
+}
+
+module.exports = result;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reverse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reverse.js
new file mode 100644
index 0000000..21764af
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/reverse.js
@@ -0,0 +1,34 @@
+/** Used for built-in method references. */
+var arrayProto = Array.prototype;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeReverse = arrayProto.reverse;
+
+/**
+ * Reverses `array` so that the first element becomes the last, the second
+ * element becomes the second to last, and so on.
+ *
+ * **Note:** This method mutates `array` and is based on
+ * [`Array#reverse`](https://mdn.io/Array/reverse).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to modify.
+ * @returns {Array} Returns `array`.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _.reverse(array);
+ * // => [3, 2, 1]
+ *
+ * console.log(array);
+ * // => [3, 2, 1]
+ */
+function reverse(array) {
+ return array == null ? array : nativeReverse.call(array);
+}
+
+module.exports = reverse;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/round.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/round.js
new file mode 100644
index 0000000..fccc831
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/round.js
@@ -0,0 +1,26 @@
+var createRound = require('./_createRound');
+
+/**
+ * Computes `number` rounded to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.10.0
+ * @category Math
+ * @param {number} number The number to round.
+ * @param {number} [precision=0] The precision to round to.
+ * @returns {number} Returns the rounded number.
+ * @example
+ *
+ * _.round(4.006);
+ * // => 4
+ *
+ * _.round(4.006, 2);
+ * // => 4.01
+ *
+ * _.round(4060, -2);
+ * // => 4100
+ */
+var round = createRound('round');
+
+module.exports = round;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sample.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sample.js
new file mode 100644
index 0000000..39c3560
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sample.js
@@ -0,0 +1,24 @@
+var arraySample = require('./_arraySample'),
+ baseSample = require('./_baseSample'),
+ isArray = require('./isArray');
+
+/**
+ * Gets a random element from `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to sample.
+ * @returns {*} Returns the random element.
+ * @example
+ *
+ * _.sample([1, 2, 3, 4]);
+ * // => 2
+ */
+function sample(collection) {
+ var func = isArray(collection) ? arraySample : baseSample;
+ return func(collection);
+}
+
+module.exports = sample;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sampleSize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sampleSize.js
new file mode 100644
index 0000000..a303686
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sampleSize.js
@@ -0,0 +1,37 @@
+var arraySampleSize = require('./_arraySampleSize'),
+ baseSampleSize = require('./_baseSampleSize'),
+ isArray = require('./isArray'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toInteger = require('./toInteger');
+
+/**
+ * Gets `n` random elements at unique keys from `collection` up to the
+ * size of `collection`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to sample.
+ * @param {number} [n=1] The number of elements to sample.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the random elements.
+ * @example
+ *
+ * _.sampleSize([1, 2, 3], 2);
+ * // => [3, 1]
+ *
+ * _.sampleSize([1, 2, 3], 4);
+ * // => [2, 3, 1]
+ */
+function sampleSize(collection, n, guard) {
+ if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
+ n = 1;
+ } else {
+ n = toInteger(n);
+ }
+ var func = isArray(collection) ? arraySampleSize : baseSampleSize;
+ return func(collection, n);
+}
+
+module.exports = sampleSize;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/seq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/seq.js
new file mode 100644
index 0000000..1570c2d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/seq.js
@@ -0,0 +1,16 @@
+module.exports = {
+ 'at': require('./wrapperAt'),
+ 'chain': require('./chain'),
+ 'commit': require('./commit'),
+ 'lodash': require('./wrapperLodash'),
+ 'next': require('./next'),
+ 'plant': require('./plant'),
+ 'reverse': require('./wrapperReverse'),
+ 'tap': require('./tap'),
+ 'thru': require('./thru'),
+ 'toIterator': require('./toIterator'),
+ 'toJSON': require('./toJSON'),
+ 'value': require('./wrapperValue'),
+ 'valueOf': require('./valueOf'),
+ 'wrapperChain': require('./wrapperChain')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/set.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/set.js
new file mode 100644
index 0000000..d663002
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/set.js
@@ -0,0 +1,35 @@
+var baseSet = require('./_baseSet');
+
+/**
+ * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
+ * it's created. Arrays are created for missing index properties while objects
+ * are created for all other missing properties. Use `_.setWith` to customize
+ * `path` creation.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.7.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.set(object, 'a[0].b.c', 4);
+ * console.log(object.a[0].b.c);
+ * // => 4
+ *
+ * _.set(object, ['x', '0', 'y', 'z'], 5);
+ * console.log(object.x[0].y.z);
+ * // => 5
+ */
+function set(object, path, value) {
+ return object == null ? object : baseSet(object, path, value);
+}
+
+module.exports = set;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/setWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/setWith.js
new file mode 100644
index 0000000..fb3e0f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/setWith.js
@@ -0,0 +1,32 @@
+var baseSet = require('./_baseSet');
+
+/**
+ * This method is like `_.set` except that it accepts `customizer` which is
+ * invoked to produce the objects of `path`. If `customizer` returns `undefined`
+ * path creation is handled by the method instead. The `customizer` is invoked
+ * with three arguments: (nsValue, key, nsObject).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {*} value The value to set.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {};
+ *
+ * _.setWith(object, '[0][1]', 'a', Object);
+ * // => { '0': { '1': 'a' } }
+ */
+function setWith(object, path, value, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return object == null ? object : baseSet(object, path, value, customizer);
+}
+
+module.exports = setWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/shuffle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/shuffle.js
new file mode 100644
index 0000000..2b72da7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/shuffle.js
@@ -0,0 +1,25 @@
+var arrayShuffle = require('./_arrayShuffle'),
+ baseShuffle = require('./_baseShuffle'),
+ isArray = require('./isArray');
+
+/**
+ * Creates an array of shuffled values, using a version of the
+ * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ * @example
+ *
+ * _.shuffle([1, 2, 3, 4]);
+ * // => [4, 1, 3, 2]
+ */
+function shuffle(collection) {
+ var func = isArray(collection) ? arrayShuffle : baseShuffle;
+ return func(collection);
+}
+
+module.exports = shuffle;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/size.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/size.js
new file mode 100644
index 0000000..3561fc1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/size.js
@@ -0,0 +1,46 @@
+var baseKeys = require('./_baseKeys'),
+ getTag = require('./_getTag'),
+ isArrayLike = require('./isArrayLike'),
+ isString = require('./isString'),
+ stringSize = require('./_stringSize');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ setTag = '[object Set]';
+
+/**
+ * Gets the size of `collection` by returning its length for array-like
+ * values or the number of own enumerable string keyed properties for objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object|string} collection The collection to inspect.
+ * @returns {number} Returns the collection size.
+ * @example
+ *
+ * _.size([1, 2, 3]);
+ * // => 3
+ *
+ * _.size({ 'a': 1, 'b': 2 });
+ * // => 2
+ *
+ * _.size('pebbles');
+ * // => 7
+ */
+function size(collection) {
+ if (collection == null) {
+ return 0;
+ }
+ if (isArrayLike(collection)) {
+ return isString(collection) ? stringSize(collection) : collection.length;
+ }
+ var tag = getTag(collection);
+ if (tag == mapTag || tag == setTag) {
+ return collection.size;
+ }
+ return baseKeys(collection).length;
+}
+
+module.exports = size;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/slice.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/slice.js
new file mode 100644
index 0000000..f732442
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/slice.js
@@ -0,0 +1,37 @@
+var baseSlice = require('./_baseSlice'),
+ isIterateeCall = require('./_isIterateeCall'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a slice of `array` from `start` up to, but not including, `end`.
+ *
+ * **Note:** This method is used instead of
+ * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
+ * returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function slice(array, start, end) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
+ start = 0;
+ end = length;
+ }
+ else {
+ start = start == null ? 0 : toInteger(start);
+ end = end === undefined ? length : toInteger(end);
+ }
+ return baseSlice(array, start, end);
+}
+
+module.exports = slice;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/snakeCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/snakeCase.js
new file mode 100644
index 0000000..27f2a76
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/snakeCase.js
@@ -0,0 +1,28 @@
+var createCompounder = require('./_createCompounder');
+
+/**
+ * Converts `string` to
+ * [snake case](https://en.wikipedia.org/wiki/Snake_case).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the snake cased string.
+ * @example
+ *
+ * _.snakeCase('Foo Bar');
+ * // => 'foo_bar'
+ *
+ * _.snakeCase('fooBar');
+ * // => 'foo_bar'
+ *
+ * _.snakeCase('--FOO-BAR--');
+ * // => 'foo_bar'
+ */
+var snakeCase = createCompounder(function(result, word, index) {
+ return result + (index ? '_' : '') + word.toLowerCase();
+});
+
+module.exports = snakeCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/some.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/some.js
new file mode 100644
index 0000000..9c1d08c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/some.js
@@ -0,0 +1,51 @@
+var arraySome = require('./_arraySome'),
+ baseIteratee = require('./_baseIteratee'),
+ baseSome = require('./_baseSome'),
+ isArray = require('./isArray'),
+ isIterateeCall = require('./_isIterateeCall');
+
+/**
+ * Checks if `predicate` returns truthy for **any** element of `collection`.
+ * Iteration is stopped once `predicate` returns truthy. The predicate is
+ * invoked with three arguments: (value, index|key, collection).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
+ * else `false`.
+ * @example
+ *
+ * _.some([null, 0, 'yes', false], Boolean);
+ * // => true
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false }
+ * ];
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.some(users, { 'user': 'barney', 'active': false });
+ * // => false
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.some(users, ['active', false]);
+ * // => true
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.some(users, 'active');
+ * // => true
+ */
+function some(collection, predicate, guard) {
+ var func = isArray(collection) ? arraySome : baseSome;
+ if (guard && isIterateeCall(collection, predicate, guard)) {
+ predicate = undefined;
+ }
+ return func(collection, baseIteratee(predicate, 3));
+}
+
+module.exports = some;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortBy.js
new file mode 100644
index 0000000..4ba8f7a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortBy.js
@@ -0,0 +1,48 @@
+var baseFlatten = require('./_baseFlatten'),
+ baseOrderBy = require('./_baseOrderBy'),
+ baseRest = require('./_baseRest'),
+ isIterateeCall = require('./_isIterateeCall');
+
+/**
+ * Creates an array of elements, sorted in ascending order by the results of
+ * running each element in a collection thru each iteratee. This method
+ * performs a stable sort, that is, it preserves the original sort order of
+ * equal elements. The iteratees are invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
+ * @returns {Array} Returns the new sorted array.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'fred', 'age': 48 },
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 34 }
+ * ];
+ *
+ * _.sortBy(users, [function(o) { return o.user; }]);
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
+ *
+ * _.sortBy(users, ['user', 'age']);
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
+ */
+var sortBy = baseRest(function(collection, iteratees) {
+ if (collection == null) {
+ return [];
+ }
+ var length = iteratees.length;
+ if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
+ iteratees = [];
+ } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
+ iteratees = [iteratees[0]];
+ }
+ return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
+});
+
+module.exports = sortBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndex.js
new file mode 100644
index 0000000..e763473
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndex.js
@@ -0,0 +1,24 @@
+var baseSortedIndex = require('./_baseSortedIndex');
+
+/**
+ * Uses a binary search to determine the lowest index at which `value`
+ * should be inserted into `array` in order to maintain its sort order.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * _.sortedIndex([30, 50], 40);
+ * // => 1
+ */
+function sortedIndex(array, value) {
+ return baseSortedIndex(array, value);
+}
+
+module.exports = sortedIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexBy.js
new file mode 100644
index 0000000..945f23c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexBy.js
@@ -0,0 +1,33 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseSortedIndexBy = require('./_baseSortedIndexBy');
+
+/**
+ * This method is like `_.sortedIndex` except that it accepts `iteratee`
+ * which is invoked for `value` and each element of `array` to compute their
+ * sort ranking. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * var objects = [{ 'x': 4 }, { 'x': 5 }];
+ *
+ * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
+ * // => 0
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
+ * // => 0
+ */
+function sortedIndexBy(array, value, iteratee) {
+ return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
+}
+
+module.exports = sortedIndexBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexOf.js
new file mode 100644
index 0000000..e2d3b7a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedIndexOf.js
@@ -0,0 +1,31 @@
+var baseSortedIndex = require('./_baseSortedIndex'),
+ eq = require('./eq');
+
+/**
+ * This method is like `_.indexOf` except that it performs a binary
+ * search on a sorted `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
+ * // => 1
+ */
+function sortedIndexOf(array, value) {
+ var length = array == null ? 0 : array.length;
+ if (length) {
+ var index = baseSortedIndex(array, value);
+ if (index < length && eq(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = sortedIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndex.js
new file mode 100644
index 0000000..9380cb9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndex.js
@@ -0,0 +1,25 @@
+var baseSortedIndex = require('./_baseSortedIndex');
+
+/**
+ * This method is like `_.sortedIndex` except that it returns the highest
+ * index at which `value` should be inserted into `array` in order to
+ * maintain its sort order.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
+ * // => 4
+ */
+function sortedLastIndex(array, value) {
+ return baseSortedIndex(array, value, true);
+}
+
+module.exports = sortedLastIndex;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexBy.js
new file mode 100644
index 0000000..9225eeb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexBy.js
@@ -0,0 +1,33 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseSortedIndexBy = require('./_baseSortedIndexBy');
+
+/**
+ * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
+ * which is invoked for `value` and each element of `array` to compute their
+ * sort ranking. The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The sorted array to inspect.
+ * @param {*} value The value to evaluate.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the index at which `value` should be inserted
+ * into `array`.
+ * @example
+ *
+ * var objects = [{ 'x': 4 }, { 'x': 5 }];
+ *
+ * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
+ * // => 1
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
+ * // => 1
+ */
+function sortedLastIndexBy(array, value, iteratee) {
+ return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true);
+}
+
+module.exports = sortedLastIndexBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexOf.js
new file mode 100644
index 0000000..18bc4c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedLastIndexOf.js
@@ -0,0 +1,31 @@
+var baseSortedIndex = require('./_baseSortedIndex'),
+ eq = require('./eq');
+
+/**
+ * This method is like `_.lastIndexOf` except that it performs a binary
+ * search on a sorted `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ * @example
+ *
+ * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
+ * // => 3
+ */
+function sortedLastIndexOf(array, value) {
+ var length = array == null ? 0 : array.length;
+ if (length) {
+ var index = baseSortedIndex(array, value, true) - 1;
+ if (eq(array[index], value)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+module.exports = sortedLastIndexOf;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniq.js
new file mode 100644
index 0000000..866db31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniq.js
@@ -0,0 +1,24 @@
+var baseSortedUniq = require('./_baseSortedUniq');
+
+/**
+ * This method is like `_.uniq` except that it's designed and optimized
+ * for sorted arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.sortedUniq([1, 1, 2]);
+ * // => [1, 2]
+ */
+function sortedUniq(array) {
+ return (array && array.length)
+ ? baseSortedUniq(array)
+ : [];
+}
+
+module.exports = sortedUniq;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniqBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniqBy.js
new file mode 100644
index 0000000..4f05ebe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sortedUniqBy.js
@@ -0,0 +1,26 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseSortedUniq = require('./_baseSortedUniq');
+
+/**
+ * This method is like `_.uniqBy` except that it's designed and optimized
+ * for sorted arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
+ * // => [1.1, 2.3]
+ */
+function sortedUniqBy(array, iteratee) {
+ return (array && array.length)
+ ? baseSortedUniq(array, baseIteratee(iteratee, 2))
+ : [];
+}
+
+module.exports = sortedUniqBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/split.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/split.js
new file mode 100644
index 0000000..956b48a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/split.js
@@ -0,0 +1,52 @@
+var baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ hasUnicode = require('./_hasUnicode'),
+ isIterateeCall = require('./_isIterateeCall'),
+ isRegExp = require('./isRegExp'),
+ stringToArray = require('./_stringToArray'),
+ toString = require('./toString');
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295;
+
+/**
+ * Splits `string` by `separator`.
+ *
+ * **Note:** This method is based on
+ * [`String#split`](https://mdn.io/String/split).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to split.
+ * @param {RegExp|string} separator The separator pattern to split by.
+ * @param {number} [limit] The length to truncate results to.
+ * @returns {Array} Returns the string segments.
+ * @example
+ *
+ * _.split('a-b-c', '-', 2);
+ * // => ['a', 'b']
+ */
+function split(string, separator, limit) {
+ if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
+ separator = limit = undefined;
+ }
+ limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
+ if (!limit) {
+ return [];
+ }
+ string = toString(string);
+ if (string && (
+ typeof separator == 'string' ||
+ (separator != null && !isRegExp(separator))
+ )) {
+ separator = baseToString(separator);
+ if (!separator && hasUnicode(string)) {
+ return castSlice(stringToArray(string), 0, limit);
+ }
+ }
+ return string.split(separator, limit);
+}
+
+module.exports = split;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/spread.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/spread.js
new file mode 100644
index 0000000..ee44c8d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/spread.js
@@ -0,0 +1,63 @@
+var apply = require('./_apply'),
+ arrayPush = require('./_arrayPush'),
+ baseRest = require('./_baseRest'),
+ castSlice = require('./_castSlice'),
+ toInteger = require('./toInteger');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * Creates a function that invokes `func` with the `this` binding of the
+ * create function and an array of arguments much like
+ * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
+ *
+ * **Note:** This method is based on the
+ * [spread operator](https://mdn.io/spread_operator).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.2.0
+ * @category Function
+ * @param {Function} func The function to spread arguments over.
+ * @param {number} [start=0] The start position of the spread.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var say = _.spread(function(who, what) {
+ * return who + ' says ' + what;
+ * });
+ *
+ * say(['fred', 'hello']);
+ * // => 'fred says hello'
+ *
+ * var numbers = Promise.all([
+ * Promise.resolve(40),
+ * Promise.resolve(36)
+ * ]);
+ *
+ * numbers.then(_.spread(function(x, y) {
+ * return x + y;
+ * }));
+ * // => a Promise of 76
+ */
+function spread(func, start) {
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
+ return baseRest(function(args) {
+ var array = args[start],
+ otherArgs = castSlice(args, 0, start);
+
+ if (array) {
+ arrayPush(otherArgs, array);
+ }
+ return apply(func, this, otherArgs);
+ });
+}
+
+module.exports = spread;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startCase.js
new file mode 100644
index 0000000..a48f21c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startCase.js
@@ -0,0 +1,29 @@
+var createCompounder = require('./_createCompounder'),
+ upperFirst = require('./upperFirst');
+
+/**
+ * Converts `string` to
+ * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.1.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the start cased string.
+ * @example
+ *
+ * _.startCase('--foo-bar--');
+ * // => 'Foo Bar'
+ *
+ * _.startCase('fooBar');
+ * // => 'Foo Bar'
+ *
+ * _.startCase('__FOO_BAR__');
+ * // => 'FOO BAR'
+ */
+var startCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + upperFirst(word);
+});
+
+module.exports = startCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startsWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startsWith.js
new file mode 100644
index 0000000..359e5ad
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/startsWith.js
@@ -0,0 +1,36 @@
+var baseClamp = require('./_baseClamp'),
+ baseToString = require('./_baseToString'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/**
+ * Checks if `string` starts with the given target string.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {string} [target] The string to search for.
+ * @param {number} [position=0] The position to search from.
+ * @returns {boolean} Returns `true` if `string` starts with `target`,
+ * else `false`.
+ * @example
+ *
+ * _.startsWith('abc', 'a');
+ * // => true
+ *
+ * _.startsWith('abc', 'b');
+ * // => false
+ *
+ * _.startsWith('abc', 'b', 1);
+ * // => true
+ */
+function startsWith(string, target, position) {
+ string = toString(string);
+ position = baseClamp(toInteger(position), 0, string.length);
+ target = baseToString(target);
+ return string.slice(position, position + target.length) == target;
+}
+
+module.exports = startsWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/string.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/string.js
new file mode 100644
index 0000000..2c829c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/string.js
@@ -0,0 +1,33 @@
+module.exports = {
+ 'camelCase': require('./camelCase'),
+ 'capitalize': require('./capitalize'),
+ 'deburr': require('./deburr'),
+ 'endsWith': require('./endsWith'),
+ 'escape': require('./escape'),
+ 'escapeRegExp': require('./escapeRegExp'),
+ 'kebabCase': require('./kebabCase'),
+ 'lowerCase': require('./lowerCase'),
+ 'lowerFirst': require('./lowerFirst'),
+ 'pad': require('./pad'),
+ 'padEnd': require('./padEnd'),
+ 'padStart': require('./padStart'),
+ 'parseInt': require('./parseInt'),
+ 'repeat': require('./repeat'),
+ 'replace': require('./replace'),
+ 'snakeCase': require('./snakeCase'),
+ 'split': require('./split'),
+ 'startCase': require('./startCase'),
+ 'startsWith': require('./startsWith'),
+ 'template': require('./template'),
+ 'templateSettings': require('./templateSettings'),
+ 'toLower': require('./toLower'),
+ 'toUpper': require('./toUpper'),
+ 'trim': require('./trim'),
+ 'trimEnd': require('./trimEnd'),
+ 'trimStart': require('./trimStart'),
+ 'truncate': require('./truncate'),
+ 'unescape': require('./unescape'),
+ 'upperCase': require('./upperCase'),
+ 'upperFirst': require('./upperFirst'),
+ 'words': require('./words')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubArray.js
new file mode 100644
index 0000000..f460c15
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubArray.js
@@ -0,0 +1,23 @@
+/**
+ * This method returns a new empty array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Array} Returns the new empty array.
+ * @example
+ *
+ * var arrays = _.times(2, _.stubArray);
+ *
+ * console.log(arrays);
+ * // => [[], []]
+ *
+ * console.log(arrays[0] === arrays[1]);
+ * // => false
+ */
+function stubArray() {
+ return [];
+}
+
+module.exports = stubArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubFalse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubFalse.js
new file mode 100644
index 0000000..9b346fc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubFalse.js
@@ -0,0 +1,18 @@
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse() {
+ return false;
+}
+
+module.exports = stubFalse;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubObject.js
new file mode 100644
index 0000000..1d190a1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubObject.js
@@ -0,0 +1,23 @@
+/**
+ * This method returns a new empty object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {Object} Returns the new empty object.
+ * @example
+ *
+ * var objects = _.times(2, _.stubObject);
+ *
+ * console.log(objects);
+ * // => [{}, {}]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => false
+ */
+function stubObject() {
+ return {};
+}
+
+module.exports = stubObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubString.js
new file mode 100644
index 0000000..2db0bed
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubString.js
@@ -0,0 +1,18 @@
+/**
+ * This method returns an empty string.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {string} Returns the empty string.
+ * @example
+ *
+ * _.times(2, _.stubString);
+ * // => ['', '']
+ */
+function stubString() {
+ return '';
+}
+
+module.exports = stubString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubTrue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubTrue.js
new file mode 100644
index 0000000..af3cc9e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/stubTrue.js
@@ -0,0 +1,18 @@
+/**
+ * This method returns `true`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `true`.
+ * @example
+ *
+ * _.times(2, _.stubTrue);
+ * // => [true, true]
+ */
+function stubTrue() {
+ return true;
+}
+
+module.exports = stubTrue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/subtract.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/subtract.js
new file mode 100644
index 0000000..6720778
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/subtract.js
@@ -0,0 +1,22 @@
+var createMathOperation = require('./_createMathOperation');
+
+/**
+ * Subtract two numbers.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {number} minuend The first number in a subtraction.
+ * @param {number} subtrahend The second number in a subtraction.
+ * @returns {number} Returns the difference.
+ * @example
+ *
+ * _.subtract(6, 4);
+ * // => 2
+ */
+var subtract = createMathOperation(function(minuend, subtrahend) {
+ return minuend - subtrahend;
+}, 0);
+
+module.exports = subtract;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sum.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sum.js
new file mode 100644
index 0000000..3b07ee4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sum.js
@@ -0,0 +1,24 @@
+var baseSum = require('./_baseSum'),
+ identity = require('./identity');
+
+/**
+ * Computes the sum of the values in `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.4.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @returns {number} Returns the sum.
+ * @example
+ *
+ * _.sum([4, 2, 8, 6]);
+ * // => 20
+ */
+function sum(array) {
+ return (array && array.length)
+ ? baseSum(array, identity)
+ : 0;
+}
+
+module.exports = sum;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sumBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sumBy.js
new file mode 100644
index 0000000..00e36d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/sumBy.js
@@ -0,0 +1,33 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseSum = require('./_baseSum');
+
+/**
+ * This method is like `_.sum` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the value to be summed.
+ * The iteratee is invoked with one argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Math
+ * @param {Array} array The array to iterate over.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {number} Returns the sum.
+ * @example
+ *
+ * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
+ *
+ * _.sumBy(objects, function(o) { return o.n; });
+ * // => 20
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.sumBy(objects, 'n');
+ * // => 20
+ */
+function sumBy(array, iteratee) {
+ return (array && array.length)
+ ? baseSum(array, baseIteratee(iteratee, 2))
+ : 0;
+}
+
+module.exports = sumBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tail.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tail.js
new file mode 100644
index 0000000..001c22d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tail.js
@@ -0,0 +1,22 @@
+var baseSlice = require('./_baseSlice');
+
+/**
+ * Gets all but the first element of `array`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.tail([1, 2, 3]);
+ * // => [2, 3]
+ */
+function tail(array) {
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 1, length) : [];
+}
+
+module.exports = tail;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/take.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/take.js
new file mode 100644
index 0000000..b7da712
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/take.js
@@ -0,0 +1,37 @@
+var baseSlice = require('./_baseSlice'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a slice of `array` with `n` elements taken from the beginning.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to take.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.take([1, 2, 3]);
+ * // => [1]
+ *
+ * _.take([1, 2, 3], 2);
+ * // => [1, 2]
+ *
+ * _.take([1, 2, 3], 5);
+ * // => [1, 2, 3]
+ *
+ * _.take([1, 2, 3], 0);
+ * // => []
+ */
+function take(array, n, guard) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ return baseSlice(array, 0, n < 0 ? 0 : n);
+}
+
+module.exports = take;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRight.js
new file mode 100644
index 0000000..6c37506
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRight.js
@@ -0,0 +1,39 @@
+var baseSlice = require('./_baseSlice'),
+ toInteger = require('./toInteger');
+
+/**
+ * Creates a slice of `array` with `n` elements taken from the end.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=1] The number of elements to take.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * _.takeRight([1, 2, 3]);
+ * // => [3]
+ *
+ * _.takeRight([1, 2, 3], 2);
+ * // => [2, 3]
+ *
+ * _.takeRight([1, 2, 3], 5);
+ * // => [1, 2, 3]
+ *
+ * _.takeRight([1, 2, 3], 0);
+ * // => []
+ */
+function takeRight(array, n, guard) {
+ var length = array == null ? 0 : array.length;
+ if (!length) {
+ return [];
+ }
+ n = (guard || n === undefined) ? 1 : toInteger(n);
+ n = length - n;
+ return baseSlice(array, n < 0 ? 0 : n, length);
+}
+
+module.exports = takeRight;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRightWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRightWhile.js
new file mode 100644
index 0000000..94ab783
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeRightWhile.js
@@ -0,0 +1,45 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseWhile = require('./_baseWhile');
+
+/**
+ * Creates a slice of `array` with elements taken from the end. Elements are
+ * taken until `predicate` returns falsey. The predicate is invoked with
+ * three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': true },
+ * { 'user': 'fred', 'active': false },
+ * { 'user': 'pebbles', 'active': false }
+ * ];
+ *
+ * _.takeRightWhile(users, function(o) { return !o.active; });
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
+ * // => objects for ['pebbles']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.takeRightWhile(users, ['active', false]);
+ * // => objects for ['fred', 'pebbles']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.takeRightWhile(users, 'active');
+ * // => []
+ */
+function takeRightWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, baseIteratee(predicate, 3), false, true)
+ : [];
+}
+
+module.exports = takeRightWhile;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeWhile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeWhile.js
new file mode 100644
index 0000000..dc84d69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/takeWhile.js
@@ -0,0 +1,45 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseWhile = require('./_baseWhile');
+
+/**
+ * Creates a slice of `array` with elements taken from the beginning. Elements
+ * are taken until `predicate` returns falsey. The predicate is invoked with
+ * three arguments: (value, index, array).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the slice of `array`.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'active': false },
+ * { 'user': 'fred', 'active': false},
+ * { 'user': 'pebbles', 'active': true }
+ * ];
+ *
+ * _.takeWhile(users, function(o) { return !o.active; });
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.matches` iteratee shorthand.
+ * _.takeWhile(users, { 'user': 'barney', 'active': false });
+ * // => objects for ['barney']
+ *
+ * // The `_.matchesProperty` iteratee shorthand.
+ * _.takeWhile(users, ['active', false]);
+ * // => objects for ['barney', 'fred']
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.takeWhile(users, 'active');
+ * // => []
+ */
+function takeWhile(array, predicate) {
+ return (array && array.length)
+ ? baseWhile(array, baseIteratee(predicate, 3))
+ : [];
+}
+
+module.exports = takeWhile;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tap.js
new file mode 100644
index 0000000..d007285
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/tap.js
@@ -0,0 +1,29 @@
+/**
+ * This method invokes `interceptor` and returns `value`. The interceptor
+ * is invoked with one argument; (value). The purpose of this method is to
+ * "tap into" a method chain sequence in order to modify intermediate results.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * _([1, 2, 3])
+ * .tap(function(array) {
+ * // Mutate input array.
+ * array.pop();
+ * })
+ * .reverse()
+ * .value();
+ * // => [2, 1]
+ */
+function tap(value, interceptor) {
+ interceptor(value);
+ return value;
+}
+
+module.exports = tap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/template.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/template.js
new file mode 100644
index 0000000..2df417f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/template.js
@@ -0,0 +1,238 @@
+var assignInDefaults = require('./_assignInDefaults'),
+ assignInWith = require('./assignInWith'),
+ attempt = require('./attempt'),
+ baseValues = require('./_baseValues'),
+ escapeStringChar = require('./_escapeStringChar'),
+ isError = require('./isError'),
+ isIterateeCall = require('./_isIterateeCall'),
+ keys = require('./keys'),
+ reInterpolate = require('./_reInterpolate'),
+ templateSettings = require('./templateSettings'),
+ toString = require('./toString');
+
+/** Used to match empty string literals in compiled template source. */
+var reEmptyStringLeading = /\b__p \+= '';/g,
+ reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
+ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
+
+/**
+ * Used to match
+ * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
+ */
+var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
+
+/** Used to ensure capturing order of template delimiters. */
+var reNoMatch = /($^)/;
+
+/** Used to match unescaped characters in compiled string literals. */
+var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
+
+/**
+ * Creates a compiled template function that can interpolate data properties
+ * in "interpolate" delimiters, HTML-escape interpolated data properties in
+ * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
+ * properties may be accessed as free variables in the template. If a setting
+ * object is given, it takes precedence over `_.templateSettings` values.
+ *
+ * **Note:** In the development build `_.template` utilizes
+ * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
+ * for easier debugging.
+ *
+ * For more information on precompiling templates see
+ * [lodash's custom builds documentation](https://lodash.com/custom-builds).
+ *
+ * For more information on Chrome extension sandboxes see
+ * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category String
+ * @param {string} [string=''] The template string.
+ * @param {Object} [options={}] The options object.
+ * @param {RegExp} [options.escape=_.templateSettings.escape]
+ * The HTML "escape" delimiter.
+ * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
+ * The "evaluate" delimiter.
+ * @param {Object} [options.imports=_.templateSettings.imports]
+ * An object to import into the template as free variables.
+ * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
+ * The "interpolate" delimiter.
+ * @param {string} [options.sourceURL='templateSources[n]']
+ * The sourceURL of the compiled template.
+ * @param {string} [options.variable='obj']
+ * The data object variable name.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Function} Returns the compiled template function.
+ * @example
+ *
+ * // Use the "interpolate" delimiter to create a compiled template.
+ * var compiled = _.template('hello <%= user %>!');
+ * compiled({ 'user': 'fred' });
+ * // => 'hello fred!'
+ *
+ * // Use the HTML "escape" delimiter to escape data property values.
+ * var compiled = _.template('<b><%- value %></b>');
+ * compiled({ 'value': '<script>' });
+ * // => '<b>&lt;script&gt;</b>'
+ *
+ * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
+ * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
+ * compiled({ 'users': ['fred', 'barney'] });
+ * // => '<li>fred</li><li>barney</li>'
+ *
+ * // Use the internal `print` function in "evaluate" delimiters.
+ * var compiled = _.template('<% print("hello " + user); %>!');
+ * compiled({ 'user': 'barney' });
+ * // => 'hello barney!'
+ *
+ * // Use the ES template literal delimiter as an "interpolate" delimiter.
+ * // Disable support by replacing the "interpolate" delimiter.
+ * var compiled = _.template('hello ${ user }!');
+ * compiled({ 'user': 'pebbles' });
+ * // => 'hello pebbles!'
+ *
+ * // Use backslashes to treat delimiters as plain text.
+ * var compiled = _.template('<%= "\\<%- value %\\>" %>');
+ * compiled({ 'value': 'ignored' });
+ * // => '<%- value %>'
+ *
+ * // Use the `imports` option to import `jQuery` as `jq`.
+ * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
+ * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
+ * compiled({ 'users': ['fred', 'barney'] });
+ * // => '<li>fred</li><li>barney</li>'
+ *
+ * // Use the `sourceURL` option to specify a custom sourceURL for the template.
+ * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
+ * compiled(data);
+ * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
+ *
+ * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
+ * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
+ * compiled.source;
+ * // => function(data) {
+ * // var __t, __p = '';
+ * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
+ * // return __p;
+ * // }
+ *
+ * // Use custom template delimiters.
+ * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
+ * var compiled = _.template('hello {{ user }}!');
+ * compiled({ 'user': 'mustache' });
+ * // => 'hello mustache!'
+ *
+ * // Use the `source` property to inline compiled templates for meaningful
+ * // line numbers in error messages and stack traces.
+ * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
+ * var JST = {\
+ * "main": ' + _.template(mainText).source + '\
+ * };\
+ * ');
+ */
+function template(string, options, guard) {
+ // Based on John Resig's `tmpl` implementation
+ // (http://ejohn.org/blog/javascript-micro-templating/)
+ // and Laura Doktorova's doT.js (https://github.com/olado/doT).
+ var settings = templateSettings.imports._.templateSettings || templateSettings;
+
+ if (guard && isIterateeCall(string, options, guard)) {
+ options = undefined;
+ }
+ string = toString(string);
+ options = assignInWith({}, options, settings, assignInDefaults);
+
+ var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
+ importsKeys = keys(imports),
+ importsValues = baseValues(imports, importsKeys);
+
+ var isEscaping,
+ isEvaluating,
+ index = 0,
+ interpolate = options.interpolate || reNoMatch,
+ source = "__p += '";
+
+ // Compile the regexp to match each delimiter.
+ var reDelimiters = RegExp(
+ (options.escape || reNoMatch).source + '|' +
+ interpolate.source + '|' +
+ (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
+ (options.evaluate || reNoMatch).source + '|$'
+ , 'g');
+
+ // Use a sourceURL for easier debugging.
+ var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : '';
+
+ string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
+ interpolateValue || (interpolateValue = esTemplateValue);
+
+ // Escape characters that can't be included in string literals.
+ source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
+
+ // Replace delimiters with snippets.
+ if (escapeValue) {
+ isEscaping = true;
+ source += "' +\n__e(" + escapeValue + ") +\n'";
+ }
+ if (evaluateValue) {
+ isEvaluating = true;
+ source += "';\n" + evaluateValue + ";\n__p += '";
+ }
+ if (interpolateValue) {
+ source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
+ }
+ index = offset + match.length;
+
+ // The JS engine embedded in Adobe products needs `match` returned in
+ // order to produce the correct `offset` value.
+ return match;
+ });
+
+ source += "';\n";
+
+ // If `variable` is not specified wrap a with-statement around the generated
+ // code to add the data object to the top of the scope chain.
+ var variable = options.variable;
+ if (!variable) {
+ source = 'with (obj) {\n' + source + '\n}\n';
+ }
+ // Cleanup code by stripping empty strings.
+ source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
+ .replace(reEmptyStringMiddle, '$1')
+ .replace(reEmptyStringTrailing, '$1;');
+
+ // Frame code as the function body.
+ source = 'function(' + (variable || 'obj') + ') {\n' +
+ (variable
+ ? ''
+ : 'obj || (obj = {});\n'
+ ) +
+ "var __t, __p = ''" +
+ (isEscaping
+ ? ', __e = _.escape'
+ : ''
+ ) +
+ (isEvaluating
+ ? ', __j = Array.prototype.join;\n' +
+ "function print() { __p += __j.call(arguments, '') }\n"
+ : ';\n'
+ ) +
+ source +
+ 'return __p\n}';
+
+ var result = attempt(function() {
+ return Function(importsKeys, sourceURL + 'return ' + source)
+ .apply(undefined, importsValues);
+ });
+
+ // Provide the compiled function's source by its `toString` method or
+ // the `source` property as a convenience for inlining compiled templates.
+ result.source = source;
+ if (isError(result)) {
+ throw result;
+ }
+ return result;
+}
+
+module.exports = template;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/templateSettings.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/templateSettings.js
new file mode 100644
index 0000000..bce2f74
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/templateSettings.js
@@ -0,0 +1,67 @@
+var escape = require('./escape'),
+ reEscape = require('./_reEscape'),
+ reEvaluate = require('./_reEvaluate'),
+ reInterpolate = require('./_reInterpolate');
+
+/**
+ * By default, the template delimiters used by lodash are like those in
+ * embedded Ruby (ERB). Change the following template settings to use
+ * alternative delimiters.
+ *
+ * @static
+ * @memberOf _
+ * @type {Object}
+ */
+var templateSettings = {
+
+ /**
+ * Used to detect `data` property values to be HTML-escaped.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'escape': reEscape,
+
+ /**
+ * Used to detect code to be evaluated.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'evaluate': reEvaluate,
+
+ /**
+ * Used to detect `data` property values to inject.
+ *
+ * @memberOf _.templateSettings
+ * @type {RegExp}
+ */
+ 'interpolate': reInterpolate,
+
+ /**
+ * Used to reference the data object in the template text.
+ *
+ * @memberOf _.templateSettings
+ * @type {string}
+ */
+ 'variable': '',
+
+ /**
+ * Used to import variables into the compiled template.
+ *
+ * @memberOf _.templateSettings
+ * @type {Object}
+ */
+ 'imports': {
+
+ /**
+ * A reference to the `lodash` function.
+ *
+ * @memberOf _.templateSettings.imports
+ * @type {Function}
+ */
+ '_': { 'escape': escape }
+ }
+};
+
+module.exports = templateSettings;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/throttle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/throttle.js
new file mode 100644
index 0000000..e2bb806
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/throttle.js
@@ -0,0 +1,69 @@
+var debounce = require('./debounce'),
+ isObject = require('./isObject');
+
+/** Error message constants. */
+var FUNC_ERROR_TEXT = 'Expected a function';
+
+/**
+ * Creates a throttled function that only invokes `func` at most once per
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
+ * method to cancel delayed `func` invocations and a `flush` method to
+ * immediately invoke them. Provide `options` to indicate whether `func`
+ * should be invoked on the leading and/or trailing edge of the `wait`
+ * timeout. The `func` is invoked with the last arguments provided to the
+ * throttled function. Subsequent calls to the throttled function return the
+ * result of the last `func` invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the throttled function
+ * is invoked more than once during the `wait` timeout.
+ *
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
+ * for details over the differences between `_.throttle` and `_.debounce`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {Function} func The function to throttle.
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
+ * @param {Object} [options={}] The options object.
+ * @param {boolean} [options.leading=true]
+ * Specify invoking on the leading edge of the timeout.
+ * @param {boolean} [options.trailing=true]
+ * Specify invoking on the trailing edge of the timeout.
+ * @returns {Function} Returns the new throttled function.
+ * @example
+ *
+ * // Avoid excessively updating the position while scrolling.
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
+ *
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
+ * jQuery(element).on('click', throttled);
+ *
+ * // Cancel the trailing throttled invocation.
+ * jQuery(window).on('popstate', throttled.cancel);
+ */
+function throttle(func, wait, options) {
+ var leading = true,
+ trailing = true;
+
+ if (typeof func != 'function') {
+ throw new TypeError(FUNC_ERROR_TEXT);
+ }
+ if (isObject(options)) {
+ leading = 'leading' in options ? !!options.leading : leading;
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
+ }
+ return debounce(func, wait, {
+ 'leading': leading,
+ 'maxWait': wait,
+ 'trailing': trailing
+ });
+}
+
+module.exports = throttle;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/thru.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/thru.js
new file mode 100644
index 0000000..91e132e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/thru.js
@@ -0,0 +1,28 @@
+/**
+ * This method is like `_.tap` except that it returns the result of `interceptor`.
+ * The purpose of this method is to "pass thru" values replacing intermediate
+ * results in a method chain sequence.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Seq
+ * @param {*} value The value to provide to `interceptor`.
+ * @param {Function} interceptor The function to invoke.
+ * @returns {*} Returns the result of `interceptor`.
+ * @example
+ *
+ * _(' abc ')
+ * .chain()
+ * .trim()
+ * .thru(function(value) {
+ * return [value];
+ * })
+ * .value();
+ * // => ['abc']
+ */
+function thru(value, interceptor) {
+ return interceptor(value);
+}
+
+module.exports = thru;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/times.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/times.js
new file mode 100644
index 0000000..266c90c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/times.js
@@ -0,0 +1,51 @@
+var baseTimes = require('./_baseTimes'),
+ castFunction = require('./_castFunction'),
+ toInteger = require('./toInteger');
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMin = Math.min;
+
+/**
+ * Invokes the iteratee `n` times, returning an array of the results of
+ * each invocation. The iteratee is invoked with one argument; (index).
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ * @example
+ *
+ * _.times(3, String);
+ * // => ['0', '1', '2']
+ *
+ * _.times(4, _.constant(0));
+ * // => [0, 0, 0, 0]
+ */
+function times(n, iteratee) {
+ n = toInteger(n);
+ if (n < 1 || n > MAX_SAFE_INTEGER) {
+ return [];
+ }
+ var index = MAX_ARRAY_LENGTH,
+ length = nativeMin(n, MAX_ARRAY_LENGTH);
+
+ iteratee = castFunction(iteratee);
+ n -= MAX_ARRAY_LENGTH;
+
+ var result = baseTimes(length, iteratee);
+ while (++index < n) {
+ iteratee(index);
+ }
+ return result;
+}
+
+module.exports = times;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toArray.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toArray.js
new file mode 100644
index 0000000..9809584
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toArray.js
@@ -0,0 +1,58 @@
+var Symbol = require('./_Symbol'),
+ copyArray = require('./_copyArray'),
+ getTag = require('./_getTag'),
+ isArrayLike = require('./isArrayLike'),
+ isString = require('./isString'),
+ iteratorToArray = require('./_iteratorToArray'),
+ mapToArray = require('./_mapToArray'),
+ setToArray = require('./_setToArray'),
+ stringToArray = require('./_stringToArray'),
+ values = require('./values');
+
+/** `Object#toString` result references. */
+var mapTag = '[object Map]',
+ setTag = '[object Set]';
+
+/** Built-in value references. */
+var symIterator = Symbol ? Symbol.iterator : undefined;
+
+/**
+ * Converts `value` to an array.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Array} Returns the converted array.
+ * @example
+ *
+ * _.toArray({ 'a': 1, 'b': 2 });
+ * // => [1, 2]
+ *
+ * _.toArray('abc');
+ * // => ['a', 'b', 'c']
+ *
+ * _.toArray(1);
+ * // => []
+ *
+ * _.toArray(null);
+ * // => []
+ */
+function toArray(value) {
+ if (!value) {
+ return [];
+ }
+ if (isArrayLike(value)) {
+ return isString(value) ? stringToArray(value) : copyArray(value);
+ }
+ if (symIterator && value[symIterator]) {
+ return iteratorToArray(value[symIterator]());
+ }
+ var tag = getTag(value),
+ func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
+
+ return func(value);
+}
+
+module.exports = toArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toFinite.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toFinite.js
new file mode 100644
index 0000000..3b5bba6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toFinite.js
@@ -0,0 +1,42 @@
+var toNumber = require('./toNumber');
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0,
+ MAX_INTEGER = 1.7976931348623157e+308;
+
+/**
+ * Converts `value` to a finite number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.12.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted number.
+ * @example
+ *
+ * _.toFinite(3.2);
+ * // => 3.2
+ *
+ * _.toFinite(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toFinite(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toFinite('3.2');
+ * // => 3.2
+ */
+function toFinite(value) {
+ if (!value) {
+ return value === 0 ? value : 0;
+ }
+ value = toNumber(value);
+ if (value === INFINITY || value === -INFINITY) {
+ var sign = (value < 0 ? -1 : 1);
+ return sign * MAX_INTEGER;
+ }
+ return value === value ? value : 0;
+}
+
+module.exports = toFinite;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toInteger.js
new file mode 100644
index 0000000..c6aadf8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toInteger.js
@@ -0,0 +1,36 @@
+var toFinite = require('./toFinite');
+
+/**
+ * Converts `value` to an integer.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toInteger(3.2);
+ * // => 3
+ *
+ * _.toInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toInteger(Infinity);
+ * // => 1.7976931348623157e+308
+ *
+ * _.toInteger('3.2');
+ * // => 3
+ */
+function toInteger(value) {
+ var result = toFinite(value),
+ remainder = result % 1;
+
+ return result === result ? (remainder ? result - remainder : result) : 0;
+}
+
+module.exports = toInteger;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toIterator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toIterator.js
new file mode 100644
index 0000000..beeed5d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toIterator.js
@@ -0,0 +1,23 @@
+/**
+ * Enables the wrapper to be iterable.
+ *
+ * @name Symbol.iterator
+ * @memberOf _
+ * @since 4.0.0
+ * @category Seq
+ * @returns {Object} Returns the wrapper object.
+ * @example
+ *
+ * var wrapped = _([1, 2]);
+ *
+ * wrapped[Symbol.iterator]() === wrapped;
+ * // => true
+ *
+ * Array.from(wrapped);
+ * // => [1, 2]
+ */
+function wrapperToIterator() {
+ return this;
+}
+
+module.exports = wrapperToIterator;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toJSON.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toJSON.js
new file mode 100644
index 0000000..5e751a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toJSON.js
@@ -0,0 +1 @@
+module.exports = require('./wrapperValue');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLength.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLength.js
new file mode 100644
index 0000000..be8f2a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLength.js
@@ -0,0 +1,38 @@
+var baseClamp = require('./_baseClamp'),
+ toInteger = require('./toInteger');
+
+/** Used as references for the maximum length and index of an array. */
+var MAX_ARRAY_LENGTH = 4294967295;
+
+/**
+ * Converts `value` to an integer suitable for use as the length of an
+ * array-like object.
+ *
+ * **Note:** This method is based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toLength(3.2);
+ * // => 3
+ *
+ * _.toLength(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toLength(Infinity);
+ * // => 4294967295
+ *
+ * _.toLength('3.2');
+ * // => 3
+ */
+function toLength(value) {
+ return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
+}
+
+module.exports = toLength;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLower.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLower.js
new file mode 100644
index 0000000..b4b7858
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toLower.js
@@ -0,0 +1,28 @@
+var toString = require('./toString');
+
+/**
+ * Converts `string`, as a whole, to lower case just like
+ * [String#toLowerCase](https://mdn.io/toLowerCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the lower cased string.
+ * @example
+ *
+ * _.toLower('--Foo-Bar--');
+ * // => '--foo-bar--'
+ *
+ * _.toLower('fooBar');
+ * // => 'foobar'
+ *
+ * _.toLower('__FOO_BAR__');
+ * // => '__foo_bar__'
+ */
+function toLower(value) {
+ return toString(value).toLowerCase();
+}
+
+module.exports = toLower;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toNumber.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toNumber.js
new file mode 100644
index 0000000..b0f72de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toNumber.js
@@ -0,0 +1,66 @@
+var isObject = require('./isObject'),
+ isSymbol = require('./isSymbol');
+
+/** Used as references for various `Number` constants. */
+var NAN = 0 / 0;
+
+/** Used to match leading and trailing whitespace. */
+var reTrim = /^\s+|\s+$/g;
+
+/** Used to detect bad signed hexadecimal string values. */
+var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
+
+/** Used to detect binary string values. */
+var reIsBinary = /^0b[01]+$/i;
+
+/** Used to detect octal string values. */
+var reIsOctal = /^0o[0-7]+$/i;
+
+/** Built-in method references without a dependency on `root`. */
+var freeParseInt = parseInt;
+
+/**
+ * Converts `value` to a number.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to process.
+ * @returns {number} Returns the number.
+ * @example
+ *
+ * _.toNumber(3.2);
+ * // => 3.2
+ *
+ * _.toNumber(Number.MIN_VALUE);
+ * // => 5e-324
+ *
+ * _.toNumber(Infinity);
+ * // => Infinity
+ *
+ * _.toNumber('3.2');
+ * // => 3.2
+ */
+function toNumber(value) {
+ if (typeof value == 'number') {
+ return value;
+ }
+ if (isSymbol(value)) {
+ return NAN;
+ }
+ if (isObject(value)) {
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
+ value = isObject(other) ? (other + '') : other;
+ }
+ if (typeof value != 'string') {
+ return value === 0 ? value : +value;
+ }
+ value = value.replace(reTrim, '');
+ var isBinary = reIsBinary.test(value);
+ return (isBinary || reIsOctal.test(value))
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
+ : (reIsBadHex.test(value) ? NAN : +value);
+}
+
+module.exports = toNumber;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairs.js
new file mode 100644
index 0000000..c4f52ae
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairs.js
@@ -0,0 +1,30 @@
+var createToPairs = require('./_createToPairs'),
+ keys = require('./keys');
+
+/**
+ * Creates an array of own enumerable string keyed-value pairs for `object`
+ * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
+ * entries are returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias entries
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the key-value pairs.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.toPairs(new Foo);
+ * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
+ */
+var toPairs = createToPairs(keys);
+
+module.exports = toPairs;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairsIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairsIn.js
new file mode 100644
index 0000000..32c562c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPairsIn.js
@@ -0,0 +1,30 @@
+var createToPairs = require('./_createToPairs'),
+ keysIn = require('./keysIn');
+
+/**
+ * Creates an array of own and inherited enumerable string keyed-value pairs
+ * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
+ * or set, its entries are returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @alias entriesIn
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the key-value pairs.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.toPairsIn(new Foo);
+ * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
+ */
+var toPairsIn = createToPairs(keysIn);
+
+module.exports = toPairsIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPath.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPath.js
new file mode 100644
index 0000000..d3e96ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPath.js
@@ -0,0 +1,33 @@
+var arrayMap = require('./_arrayMap'),
+ copyArray = require('./_copyArray'),
+ isArray = require('./isArray'),
+ isSymbol = require('./isSymbol'),
+ stringToPath = require('./_stringToPath'),
+ toKey = require('./_toKey'),
+ toString = require('./toString');
+
+/**
+ * Converts `value` to a property path array.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Util
+ * @param {*} value The value to convert.
+ * @returns {Array} Returns the new property path array.
+ * @example
+ *
+ * _.toPath('a.b.c');
+ * // => ['a', 'b', 'c']
+ *
+ * _.toPath('a[0].b.c');
+ * // => ['a', '0', 'b', 'c']
+ */
+function toPath(value) {
+ if (isArray(value)) {
+ return arrayMap(value, toKey);
+ }
+ return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
+}
+
+module.exports = toPath;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPlainObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPlainObject.js
new file mode 100644
index 0000000..5de79b8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toPlainObject.js
@@ -0,0 +1,32 @@
+var copyObject = require('./_copyObject'),
+ keysIn = require('./keysIn');
+
+/**
+ * Converts `value` to a plain object flattening inherited enumerable string
+ * keyed properties of `value` to own properties of the plain object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Object} Returns the converted plain object.
+ * @example
+ *
+ * function Foo() {
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.assign({ 'a': 1 }, new Foo);
+ * // => { 'a': 1, 'b': 2 }
+ *
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
+ */
+function toPlainObject(value) {
+ return copyObject(value, keysIn(value));
+}
+
+module.exports = toPlainObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toSafeInteger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toSafeInteger.js
new file mode 100644
index 0000000..885c5fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toSafeInteger.js
@@ -0,0 +1,35 @@
+var baseClamp = require('./_baseClamp'),
+ toInteger = require('./toInteger');
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Converts `value` to a safe integer. A safe integer can be compared and
+ * represented correctly.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {number} Returns the converted integer.
+ * @example
+ *
+ * _.toSafeInteger(3.2);
+ * // => 3
+ *
+ * _.toSafeInteger(Number.MIN_VALUE);
+ * // => 0
+ *
+ * _.toSafeInteger(Infinity);
+ * // => 9007199254740991
+ *
+ * _.toSafeInteger('3.2');
+ * // => 3
+ */
+function toSafeInteger(value) {
+ return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
+}
+
+module.exports = toSafeInteger;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toString.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toString.js
new file mode 100644
index 0000000..daaf681
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toString.js
@@ -0,0 +1,28 @@
+var baseToString = require('./_baseToString');
+
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+
+module.exports = toString;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toUpper.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toUpper.js
new file mode 100644
index 0000000..b3648e8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/toUpper.js
@@ -0,0 +1,28 @@
+var toString = require('./toString');
+
+/**
+ * Converts `string`, as a whole, to upper case just like
+ * [String#toUpperCase](https://mdn.io/toUpperCase).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the upper cased string.
+ * @example
+ *
+ * _.toUpper('--foo-bar--');
+ * // => '--FOO-BAR--'
+ *
+ * _.toUpper('fooBar');
+ * // => 'FOOBAR'
+ *
+ * _.toUpper('__foo_bar__');
+ * // => '__FOO_BAR__'
+ */
+function toUpper(value) {
+ return toString(value).toUpperCase();
+}
+
+module.exports = toUpper;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/transform.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/transform.js
new file mode 100644
index 0000000..d755a15
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/transform.js
@@ -0,0 +1,65 @@
+var arrayEach = require('./_arrayEach'),
+ baseCreate = require('./_baseCreate'),
+ baseForOwn = require('./_baseForOwn'),
+ baseIteratee = require('./_baseIteratee'),
+ getPrototype = require('./_getPrototype'),
+ isArray = require('./isArray'),
+ isBuffer = require('./isBuffer'),
+ isFunction = require('./isFunction'),
+ isObject = require('./isObject'),
+ isTypedArray = require('./isTypedArray');
+
+/**
+ * An alternative to `_.reduce`; this method transforms `object` to a new
+ * `accumulator` object which is the result of running each of its own
+ * enumerable string keyed properties thru `iteratee`, with each invocation
+ * potentially mutating the `accumulator` object. If `accumulator` is not
+ * provided, a new object with the same `[[Prototype]]` will be used. The
+ * iteratee is invoked with four arguments: (accumulator, value, key, object).
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.3.0
+ * @category Object
+ * @param {Object} object The object to iterate over.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
+ * @param {*} [accumulator] The custom accumulator value.
+ * @returns {*} Returns the accumulated value.
+ * @example
+ *
+ * _.transform([2, 3, 4], function(result, n) {
+ * result.push(n *= n);
+ * return n % 2 == 0;
+ * }, []);
+ * // => [4, 9]
+ *
+ * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
+ * (result[value] || (result[value] = [])).push(key);
+ * }, {});
+ * // => { '1': ['a', 'c'], '2': ['b'] }
+ */
+function transform(object, iteratee, accumulator) {
+ var isArr = isArray(object),
+ isArrLike = isArr || isBuffer(object) || isTypedArray(object);
+
+ iteratee = baseIteratee(iteratee, 4);
+ if (accumulator == null) {
+ var Ctor = object && object.constructor;
+ if (isArrLike) {
+ accumulator = isArr ? new Ctor : [];
+ }
+ else if (isObject(object)) {
+ accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
+ }
+ else {
+ accumulator = {};
+ }
+ }
+ (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
+ return iteratee(accumulator, value, index, object);
+ });
+ return accumulator;
+}
+
+module.exports = transform;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trim.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trim.js
new file mode 100644
index 0000000..5e38c8e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trim.js
@@ -0,0 +1,49 @@
+var baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ charsEndIndex = require('./_charsEndIndex'),
+ charsStartIndex = require('./_charsStartIndex'),
+ stringToArray = require('./_stringToArray'),
+ toString = require('./toString');
+
+/** Used to match leading and trailing whitespace. */
+var reTrim = /^\s+|\s+$/g;
+
+/**
+ * Removes leading and trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trim(' abc ');
+ * // => 'abc'
+ *
+ * _.trim('-_-abc-_-', '_-');
+ * // => 'abc'
+ *
+ * _.map([' foo ', ' bar '], _.trim);
+ * // => ['foo', 'bar']
+ */
+function trim(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrim, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
+
+ return castSlice(strSymbols, start, end).join('');
+}
+
+module.exports = trim;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimEnd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimEnd.js
new file mode 100644
index 0000000..82c54a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimEnd.js
@@ -0,0 +1,43 @@
+var baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ charsEndIndex = require('./_charsEndIndex'),
+ stringToArray = require('./_stringToArray'),
+ toString = require('./toString');
+
+/** Used to match leading and trailing whitespace. */
+var reTrimEnd = /\s+$/;
+
+/**
+ * Removes trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trimEnd(' abc ');
+ * // => ' abc'
+ *
+ * _.trimEnd('-_-abc-_-', '_-');
+ * // => '-_-abc'
+ */
+function trimEnd(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrimEnd, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
+
+ return castSlice(strSymbols, 0, end).join('');
+}
+
+module.exports = trimEnd;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimStart.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimStart.js
new file mode 100644
index 0000000..30f4f47
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/trimStart.js
@@ -0,0 +1,43 @@
+var baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ charsStartIndex = require('./_charsStartIndex'),
+ stringToArray = require('./_stringToArray'),
+ toString = require('./toString');
+
+/** Used to match leading and trailing whitespace. */
+var reTrimStart = /^\s+/;
+
+/**
+ * Removes leading whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trimStart(' abc ');
+ * // => 'abc '
+ *
+ * _.trimStart('-_-abc-_-', '_-');
+ * // => 'abc-_-'
+ */
+function trimStart(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrimStart, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ start = charsStartIndex(strSymbols, stringToArray(chars));
+
+ return castSlice(strSymbols, start).join('');
+}
+
+module.exports = trimStart;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/truncate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/truncate.js
new file mode 100644
index 0000000..21fcdfe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/truncate.js
@@ -0,0 +1,111 @@
+var baseToString = require('./_baseToString'),
+ castSlice = require('./_castSlice'),
+ hasUnicode = require('./_hasUnicode'),
+ isObject = require('./isObject'),
+ isRegExp = require('./isRegExp'),
+ stringSize = require('./_stringSize'),
+ stringToArray = require('./_stringToArray'),
+ toInteger = require('./toInteger'),
+ toString = require('./toString');
+
+/** Used as default options for `_.truncate`. */
+var DEFAULT_TRUNC_LENGTH = 30,
+ DEFAULT_TRUNC_OMISSION = '...';
+
+/** Used to match `RegExp` flags from their coerced string values. */
+var reFlags = /\w*$/;
+
+/**
+ * Truncates `string` if it's longer than the given maximum string length.
+ * The last characters of the truncated string are replaced with the omission
+ * string which defaults to "...".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to truncate.
+ * @param {Object} [options={}] The options object.
+ * @param {number} [options.length=30] The maximum string length.
+ * @param {string} [options.omission='...'] The string to indicate text is omitted.
+ * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
+ * @returns {string} Returns the truncated string.
+ * @example
+ *
+ * _.truncate('hi-diddly-ho there, neighborino');
+ * // => 'hi-diddly-ho there, neighbo...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'length': 24,
+ * 'separator': ' '
+ * });
+ * // => 'hi-diddly-ho there,...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'length': 24,
+ * 'separator': /,? +/
+ * });
+ * // => 'hi-diddly-ho there...'
+ *
+ * _.truncate('hi-diddly-ho there, neighborino', {
+ * 'omission': ' [...]'
+ * });
+ * // => 'hi-diddly-ho there, neig [...]'
+ */
+function truncate(string, options) {
+ var length = DEFAULT_TRUNC_LENGTH,
+ omission = DEFAULT_TRUNC_OMISSION;
+
+ if (isObject(options)) {
+ var separator = 'separator' in options ? options.separator : separator;
+ length = 'length' in options ? toInteger(options.length) : length;
+ omission = 'omission' in options ? baseToString(options.omission) : omission;
+ }
+ string = toString(string);
+
+ var strLength = string.length;
+ if (hasUnicode(string)) {
+ var strSymbols = stringToArray(string);
+ strLength = strSymbols.length;
+ }
+ if (length >= strLength) {
+ return string;
+ }
+ var end = length - stringSize(omission);
+ if (end < 1) {
+ return omission;
+ }
+ var result = strSymbols
+ ? castSlice(strSymbols, 0, end).join('')
+ : string.slice(0, end);
+
+ if (separator === undefined) {
+ return result + omission;
+ }
+ if (strSymbols) {
+ end += (result.length - end);
+ }
+ if (isRegExp(separator)) {
+ if (string.slice(end).search(separator)) {
+ var match,
+ substring = result;
+
+ if (!separator.global) {
+ separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
+ }
+ separator.lastIndex = 0;
+ while ((match = separator.exec(substring))) {
+ var newEnd = match.index;
+ }
+ result = result.slice(0, newEnd === undefined ? end : newEnd);
+ }
+ } else if (string.indexOf(baseToString(separator), end) != end) {
+ var index = result.lastIndexOf(separator);
+ if (index > -1) {
+ result = result.slice(0, index);
+ }
+ }
+ return result + omission;
+}
+
+module.exports = truncate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unary.js
new file mode 100644
index 0000000..76f48f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unary.js
@@ -0,0 +1,22 @@
+var ary = require('./ary');
+
+/**
+ * Creates a function that accepts up to one argument, ignoring any
+ * additional arguments.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Function
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ * @example
+ *
+ * _.map(['6', '8', '10'], _.unary(parseInt));
+ * // => [6, 8, 10]
+ */
+function unary(func) {
+ return ary(func, 1);
+}
+
+module.exports = unary;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unescape.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unescape.js
new file mode 100644
index 0000000..3b6efd5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unescape.js
@@ -0,0 +1,34 @@
+var toString = require('./toString'),
+ unescapeHtmlChar = require('./_unescapeHtmlChar');
+
+/** Used to match HTML entities and HTML characters. */
+var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
+ reHasEscapedHtml = RegExp(reEscapedHtml.source);
+
+/**
+ * The inverse of `_.escape`; this method converts the HTML entities
+ * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
+ * their corresponding characters.
+ *
+ * **Note:** No other HTML entities are unescaped. To unescape additional
+ * HTML entities use a third-party library like [_he_](https://mths.be/he).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.6.0
+ * @category String
+ * @param {string} [string=''] The string to unescape.
+ * @returns {string} Returns the unescaped string.
+ * @example
+ *
+ * _.unescape('fred, barney, &amp; pebbles');
+ * // => 'fred, barney, & pebbles'
+ */
+function unescape(string) {
+ string = toString(string);
+ return (string && reHasEscapedHtml.test(string))
+ ? string.replace(reEscapedHtml, unescapeHtmlChar)
+ : string;
+}
+
+module.exports = unescape;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/union.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/union.js
new file mode 100644
index 0000000..e676dfe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/union.js
@@ -0,0 +1,26 @@
+var baseFlatten = require('./_baseFlatten'),
+ baseRest = require('./_baseRest'),
+ baseUniq = require('./_baseUniq'),
+ isArrayLikeObject = require('./isArrayLikeObject');
+
+/**
+ * Creates an array of unique values, in order, from all given arrays using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * _.union([2], [1, 2]);
+ * // => [2, 1]
+ */
+var union = baseRest(function(arrays) {
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
+});
+
+module.exports = union;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionBy.js
new file mode 100644
index 0000000..6ae8ccd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionBy.js
@@ -0,0 +1,39 @@
+var baseFlatten = require('./_baseFlatten'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ baseUniq = require('./_baseUniq'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.union` except that it accepts `iteratee` which is
+ * invoked for each element of each `arrays` to generate the criterion by
+ * which uniqueness is computed. Result values are chosen from the first
+ * array in which the value occurs. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * _.unionBy([2.1], [1.2, 2.3], Math.floor);
+ * // => [2.1, 1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }, { 'x': 2 }]
+ */
+var unionBy = baseRest(function(arrays) {
+ var iteratee = last(arrays);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2));
+});
+
+module.exports = unionBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionWith.js
new file mode 100644
index 0000000..78736b2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unionWith.js
@@ -0,0 +1,34 @@
+var baseFlatten = require('./_baseFlatten'),
+ baseRest = require('./_baseRest'),
+ baseUniq = require('./_baseUniq'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.union` except that it accepts `comparator` which
+ * is invoked to compare elements of `arrays`. Result values are chosen from
+ * the first array in which the value occurs. The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of combined values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.unionWith(objects, others, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
+ */
+var unionWith = baseRest(function(arrays) {
+ var comparator = last(arrays);
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
+});
+
+module.exports = unionWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniq.js
new file mode 100644
index 0000000..157d1cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniq.js
@@ -0,0 +1,25 @@
+var baseUniq = require('./_baseUniq');
+
+/**
+ * Creates a duplicate-free version of an array, using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons, in which only the first occurrence of each element
+ * is kept. The order of result values is determined by the order they occur
+ * in the array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.uniq([2, 1, 2]);
+ * // => [2, 1]
+ */
+function uniq(array) {
+ return (array && array.length) ? baseUniq(array) : [];
+}
+
+module.exports = uniq;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqBy.js
new file mode 100644
index 0000000..53402a9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqBy.js
@@ -0,0 +1,31 @@
+var baseIteratee = require('./_baseIteratee'),
+ baseUniq = require('./_baseUniq');
+
+/**
+ * This method is like `_.uniq` except that it accepts `iteratee` which is
+ * invoked for each element in `array` to generate the criterion by which
+ * uniqueness is computed. The order of result values is determined by the
+ * order they occur in the array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
+ * // => [2.1, 1.2]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 1 }, { 'x': 2 }]
+ */
+function uniqBy(array, iteratee) {
+ return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
+}
+
+module.exports = uniqBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqWith.js
new file mode 100644
index 0000000..18d72aa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqWith.js
@@ -0,0 +1,28 @@
+var baseUniq = require('./_baseUniq');
+
+/**
+ * This method is like `_.uniq` except that it accepts `comparator` which
+ * is invoked to compare elements of `array`. The order of result values is
+ * determined by the order they occur in the array.The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new duplicate free array.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.uniqWith(objects, _.isEqual);
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
+ */
+function uniqWith(array, comparator) {
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
+}
+
+module.exports = uniqWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqueId.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqueId.js
new file mode 100644
index 0000000..ffa8c03
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/uniqueId.js
@@ -0,0 +1,28 @@
+var toString = require('./toString');
+
+/** Used to generate unique IDs. */
+var idCounter = 0;
+
+/**
+ * Generates a unique ID. If `prefix` is given, the ID is appended to it.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {string} [prefix=''] The value to prefix the ID with.
+ * @returns {string} Returns the unique ID.
+ * @example
+ *
+ * _.uniqueId('contact_');
+ * // => 'contact_104'
+ *
+ * _.uniqueId();
+ * // => '105'
+ */
+function uniqueId(prefix) {
+ var id = ++idCounter;
+ return toString(prefix) + id;
+}
+
+module.exports = uniqueId;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unset.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unset.js
new file mode 100644
index 0000000..723c3d4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unset.js
@@ -0,0 +1,34 @@
+var baseUnset = require('./_baseUnset');
+
+/**
+ * Removes the property at `path` of `object`.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to unset.
+ * @returns {boolean} Returns `true` if the property is deleted, else `false`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 7 } }] };
+ * _.unset(object, 'a[0].b.c');
+ * // => true
+ *
+ * console.log(object);
+ * // => { 'a': [{ 'b': {} }] };
+ *
+ * _.unset(object, ['a', '0', 'b', 'c']);
+ * // => true
+ *
+ * console.log(object);
+ * // => { 'a': [{ 'b': {} }] };
+ */
+function unset(object, path) {
+ return object == null ? true : baseUnset(object, path);
+}
+
+module.exports = unset;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzip.js
new file mode 100644
index 0000000..fce0ec7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzip.js
@@ -0,0 +1,45 @@
+var arrayFilter = require('./_arrayFilter'),
+ arrayMap = require('./_arrayMap'),
+ baseProperty = require('./_baseProperty'),
+ baseTimes = require('./_baseTimes'),
+ isArrayLikeObject = require('./isArrayLikeObject');
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
+/**
+ * This method is like `_.zip` except that it accepts an array of grouped
+ * elements and creates an array regrouping the elements to their pre-zip
+ * configuration.
+ *
+ * @static
+ * @memberOf _
+ * @since 1.2.0
+ * @category Array
+ * @param {Array} array The array of grouped elements to process.
+ * @returns {Array} Returns the new array of regrouped elements.
+ * @example
+ *
+ * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
+ *
+ * _.unzip(zipped);
+ * // => [['a', 'b'], [1, 2], [true, false]]
+ */
+function unzip(array) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ var length = 0;
+ array = arrayFilter(array, function(group) {
+ if (isArrayLikeObject(group)) {
+ length = nativeMax(group.length, length);
+ return true;
+ }
+ });
+ return baseTimes(length, function(index) {
+ return arrayMap(array, baseProperty(index));
+ });
+}
+
+module.exports = unzip;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzipWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzipWith.js
new file mode 100644
index 0000000..926c899
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/unzipWith.js
@@ -0,0 +1,39 @@
+var apply = require('./_apply'),
+ arrayMap = require('./_arrayMap'),
+ unzip = require('./unzip');
+
+/**
+ * This method is like `_.unzip` except that it accepts `iteratee` to specify
+ * how regrouped values should be combined. The iteratee is invoked with the
+ * elements of each group: (...group).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Array
+ * @param {Array} array The array of grouped elements to process.
+ * @param {Function} [iteratee=_.identity] The function to combine
+ * regrouped values.
+ * @returns {Array} Returns the new array of regrouped elements.
+ * @example
+ *
+ * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
+ * // => [[1, 10, 100], [2, 20, 200]]
+ *
+ * _.unzipWith(zipped, _.add);
+ * // => [3, 30, 300]
+ */
+function unzipWith(array, iteratee) {
+ if (!(array && array.length)) {
+ return [];
+ }
+ var result = unzip(array);
+ if (iteratee == null) {
+ return result;
+ }
+ return arrayMap(result, function(group) {
+ return apply(iteratee, undefined, group);
+ });
+}
+
+module.exports = unzipWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/update.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/update.js
new file mode 100644
index 0000000..b90098e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/update.js
@@ -0,0 +1,35 @@
+var baseUpdate = require('./_baseUpdate'),
+ castFunction = require('./_castFunction');
+
+/**
+ * This method is like `_.set` except that accepts `updater` to produce the
+ * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
+ * is invoked with one argument: (value).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {Function} updater The function to produce the updated value.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.update(object, 'a[0].b.c', function(n) { return n * n; });
+ * console.log(object.a[0].b.c);
+ * // => 9
+ *
+ * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
+ * console.log(object.x[0].y.z);
+ * // => 0
+ */
+function update(object, path, updater) {
+ return object == null ? object : baseUpdate(object, path, castFunction(updater));
+}
+
+module.exports = update;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/updateWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/updateWith.js
new file mode 100644
index 0000000..a2f4a2c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/updateWith.js
@@ -0,0 +1,33 @@
+var baseUpdate = require('./_baseUpdate'),
+ castFunction = require('./_castFunction');
+
+/**
+ * This method is like `_.update` except that it accepts `customizer` which is
+ * invoked to produce the objects of `path`. If `customizer` returns `undefined`
+ * path creation is handled by the method instead. The `customizer` is invoked
+ * with three arguments: (nsValue, key, nsObject).
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.6.0
+ * @category Object
+ * @param {Object} object The object to modify.
+ * @param {Array|string} path The path of the property to set.
+ * @param {Function} updater The function to produce the updated value.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {};
+ *
+ * _.updateWith(object, '[0][1]', _.constant('a'), Object);
+ * // => { '0': { '1': 'a' } }
+ */
+function updateWith(object, path, updater, customizer) {
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
+}
+
+module.exports = updateWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperCase.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperCase.js
new file mode 100644
index 0000000..efbb8b0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperCase.js
@@ -0,0 +1,27 @@
+var createCompounder = require('./_createCompounder');
+
+/**
+ * Converts `string`, as space separated words, to upper case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the upper cased string.
+ * @example
+ *
+ * _.upperCase('--foo-bar');
+ * // => 'FOO BAR'
+ *
+ * _.upperCase('fooBar');
+ * // => 'FOO BAR'
+ *
+ * _.upperCase('__foo_bar__');
+ * // => 'FOO BAR'
+ */
+var upperCase = createCompounder(function(result, word, index) {
+ return result + (index ? ' ' : '') + word.toUpperCase();
+});
+
+module.exports = upperCase;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperFirst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperFirst.js
new file mode 100644
index 0000000..1dd64e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/upperFirst.js
@@ -0,0 +1,22 @@
+var createCaseFirst = require('./_createCaseFirst');
+
+/**
+ * Converts the first character of `string` to upper case.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category String
+ * @param {string} [string=''] The string to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.upperFirst('fred');
+ * // => 'Fred'
+ *
+ * _.upperFirst('FRED');
+ * // => 'FRED'
+ */
+var upperFirst = createCaseFirst('toUpperCase');
+
+module.exports = upperFirst;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/util.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/util.js
new file mode 100644
index 0000000..d244dc2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/util.js
@@ -0,0 +1,34 @@
+module.exports = {
+ 'attempt': require('./attempt'),
+ 'bindAll': require('./bindAll'),
+ 'cond': require('./cond'),
+ 'conforms': require('./conforms'),
+ 'constant': require('./constant'),
+ 'defaultTo': require('./defaultTo'),
+ 'flow': require('./flow'),
+ 'flowRight': require('./flowRight'),
+ 'identity': require('./identity'),
+ 'iteratee': require('./iteratee'),
+ 'matches': require('./matches'),
+ 'matchesProperty': require('./matchesProperty'),
+ 'method': require('./method'),
+ 'methodOf': require('./methodOf'),
+ 'mixin': require('./mixin'),
+ 'noop': require('./noop'),
+ 'nthArg': require('./nthArg'),
+ 'over': require('./over'),
+ 'overEvery': require('./overEvery'),
+ 'overSome': require('./overSome'),
+ 'property': require('./property'),
+ 'propertyOf': require('./propertyOf'),
+ 'range': require('./range'),
+ 'rangeRight': require('./rangeRight'),
+ 'stubArray': require('./stubArray'),
+ 'stubFalse': require('./stubFalse'),
+ 'stubObject': require('./stubObject'),
+ 'stubString': require('./stubString'),
+ 'stubTrue': require('./stubTrue'),
+ 'times': require('./times'),
+ 'toPath': require('./toPath'),
+ 'uniqueId': require('./uniqueId')
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/value.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/value.js
new file mode 100644
index 0000000..5e751a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/value.js
@@ -0,0 +1 @@
+module.exports = require('./wrapperValue');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valueOf.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valueOf.js
new file mode 100644
index 0000000..5e751a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valueOf.js
@@ -0,0 +1 @@
+module.exports = require('./wrapperValue');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/values.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/values.js
new file mode 100644
index 0000000..b069654
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/values.js
@@ -0,0 +1,34 @@
+var baseValues = require('./_baseValues'),
+ keys = require('./keys');
+
+/**
+ * Creates an array of the own enumerable string keyed property values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.values(new Foo);
+ * // => [1, 2] (iteration order is not guaranteed)
+ *
+ * _.values('hi');
+ * // => ['h', 'i']
+ */
+function values(object) {
+ return object == null ? [] : baseValues(object, keys(object));
+}
+
+module.exports = values;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valuesIn.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valuesIn.js
new file mode 100644
index 0000000..6296094
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/valuesIn.js
@@ -0,0 +1,32 @@
+var baseValues = require('./_baseValues'),
+ keysIn = require('./keysIn');
+
+/**
+ * Creates an array of the own and inherited enumerable string keyed property
+ * values of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property values.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.valuesIn(new Foo);
+ * // => [1, 2, 3] (iteration order is not guaranteed)
+ */
+function valuesIn(object) {
+ return object == null ? [] : baseValues(object, keysIn(object));
+}
+
+module.exports = valuesIn;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/without.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/without.js
new file mode 100644
index 0000000..3a28e8a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/without.js
@@ -0,0 +1,31 @@
+var baseDifference = require('./_baseDifference'),
+ baseRest = require('./_baseRest'),
+ isArrayLikeObject = require('./isArrayLikeObject');
+
+/**
+ * Creates an array excluding all given values using
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * **Note:** Unlike `_.pull`, this method returns a new array.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {Array} array The array to inspect.
+ * @param {...*} [values] The values to exclude.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.difference, _.xor
+ * @example
+ *
+ * _.without([2, 1, 2, 3], 1, 2);
+ * // => [3]
+ */
+var without = baseRest(function(array, values) {
+ return isArrayLikeObject(array)
+ ? baseDifference(array, values)
+ : [];
+});
+
+module.exports = without;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/words.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/words.js
new file mode 100644
index 0000000..6d7cdd1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/words.js
@@ -0,0 +1,35 @@
+var asciiWords = require('./_asciiWords'),
+ hasUnicodeWord = require('./_hasUnicodeWord'),
+ toString = require('./toString'),
+ unicodeWords = require('./_unicodeWords');
+
+/**
+ * Splits `string` into an array of its words.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to inspect.
+ * @param {RegExp|string} [pattern] The pattern to match words.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {Array} Returns the words of `string`.
+ * @example
+ *
+ * _.words('fred, barney, & pebbles');
+ * // => ['fred', 'barney', 'pebbles']
+ *
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
+ * // => ['fred', 'barney', '&', 'pebbles']
+ */
+function words(string, pattern, guard) {
+ string = toString(string);
+ pattern = guard ? undefined : pattern;
+
+ if (pattern === undefined) {
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
+ }
+ return string.match(pattern) || [];
+}
+
+module.exports = words;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrap.js
new file mode 100644
index 0000000..cad3c50
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrap.js
@@ -0,0 +1,30 @@
+var castFunction = require('./_castFunction'),
+ partial = require('./partial');
+
+/**
+ * Creates a function that provides `value` to `wrapper` as its first
+ * argument. Any additional arguments provided to the function are appended
+ * to those provided to the `wrapper`. The wrapper is invoked with the `this`
+ * binding of the created function.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Function
+ * @param {*} value The value to wrap.
+ * @param {Function} [wrapper=identity] The wrapper function.
+ * @returns {Function} Returns the new function.
+ * @example
+ *
+ * var p = _.wrap(_.escape, function(func, text) {
+ * return '<p>' + func(text) + '</p>';
+ * });
+ *
+ * p('fred, barney, & pebbles');
+ * // => '<p>fred, barney, &amp; pebbles</p>'
+ */
+function wrap(value, wrapper) {
+ return partial(castFunction(wrapper), value);
+}
+
+module.exports = wrap;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperAt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperAt.js
new file mode 100644
index 0000000..6f6a1d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperAt.js
@@ -0,0 +1,48 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ LodashWrapper = require('./_LodashWrapper'),
+ baseAt = require('./_baseAt'),
+ flatRest = require('./_flatRest'),
+ isIndex = require('./_isIndex'),
+ thru = require('./thru');
+
+/**
+ * This method is the wrapper version of `_.at`.
+ *
+ * @name at
+ * @memberOf _
+ * @since 1.0.0
+ * @category Seq
+ * @param {...(string|string[])} [paths] The property paths to pick.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
+ *
+ * _(object).at(['a[0].b.c', 'a[1]']).value();
+ * // => [3, 4]
+ */
+var wrapperAt = flatRest(function(paths) {
+ var length = paths.length,
+ start = length ? paths[0] : 0,
+ value = this.__wrapped__,
+ interceptor = function(object) { return baseAt(object, paths); };
+
+ if (length > 1 || this.__actions__.length ||
+ !(value instanceof LazyWrapper) || !isIndex(start)) {
+ return this.thru(interceptor);
+ }
+ value = value.slice(start, +start + (length ? 1 : 0));
+ value.__actions__.push({
+ 'func': thru,
+ 'args': [interceptor],
+ 'thisArg': undefined
+ });
+ return new LodashWrapper(value, this.__chain__).thru(function(array) {
+ if (length && !array.length) {
+ array.push(undefined);
+ }
+ return array;
+ });
+});
+
+module.exports = wrapperAt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperChain.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperChain.js
new file mode 100644
index 0000000..bda2ce6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperChain.js
@@ -0,0 +1,34 @@
+var chain = require('./chain');
+
+/**
+ * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
+ *
+ * @name chain
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var users = [
+ * { 'user': 'barney', 'age': 36 },
+ * { 'user': 'fred', 'age': 40 }
+ * ];
+ *
+ * // A sequence without explicit chaining.
+ * _(users).head();
+ * // => { 'user': 'barney', 'age': 36 }
+ *
+ * // A sequence with explicit chaining.
+ * _(users)
+ * .chain()
+ * .head()
+ * .pick('user')
+ * .value();
+ * // => { 'user': 'barney' }
+ */
+function wrapperChain() {
+ return chain(this);
+}
+
+module.exports = wrapperChain;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperLodash.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperLodash.js
new file mode 100644
index 0000000..bf27a3c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperLodash.js
@@ -0,0 +1,147 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ LodashWrapper = require('./_LodashWrapper'),
+ baseLodash = require('./_baseLodash'),
+ isArray = require('./isArray'),
+ isObjectLike = require('./isObjectLike'),
+ wrapperClone = require('./_wrapperClone');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Creates a `lodash` object which wraps `value` to enable implicit method
+ * chain sequences. Methods that operate on and return arrays, collections,
+ * and functions can be chained together. Methods that retrieve a single value
+ * or may return a primitive value will automatically end the chain sequence
+ * and return the unwrapped value. Otherwise, the value must be unwrapped
+ * with `_#value`.
+ *
+ * Explicit chain sequences, which must be unwrapped with `_#value`, may be
+ * enabled using `_.chain`.
+ *
+ * The execution of chained methods is lazy, that is, it's deferred until
+ * `_#value` is implicitly or explicitly called.
+ *
+ * Lazy evaluation allows several methods to support shortcut fusion.
+ * Shortcut fusion is an optimization to merge iteratee calls; this avoids
+ * the creation of intermediate arrays and can greatly reduce the number of
+ * iteratee executions. Sections of a chain sequence qualify for shortcut
+ * fusion if the section is applied to an array of at least `200` elements
+ * and any iteratees accept only one argument. The heuristic for whether a
+ * section qualifies for shortcut fusion is subject to change.
+ *
+ * Chaining is supported in custom builds as long as the `_#value` method is
+ * directly or indirectly included in the build.
+ *
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
+ *
+ * The wrapper methods that support shortcut fusion are:
+ * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
+ * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
+ * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
+ *
+ * The chainable wrapper methods are:
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
+ * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
+ * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
+ * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
+ * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
+ * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
+ * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
+ * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
+ * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
+ * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
+ * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
+ * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
+ * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
+ * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
+ * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
+ * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
+ * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
+ * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
+ * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
+ * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
+ * `zipObject`, `zipObjectDeep`, and `zipWith`
+ *
+ * The wrapper methods that are **not** chainable by default are:
+ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
+ * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
+ * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
+ * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
+ * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
+ * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
+ * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
+ * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
+ * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
+ * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
+ * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
+ * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
+ * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
+ * `upperFirst`, `value`, and `words`
+ *
+ * @name _
+ * @constructor
+ * @category Seq
+ * @param {*} value The value to wrap in a `lodash` instance.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2, 3]);
+ *
+ * // Returns an unwrapped value.
+ * wrapped.reduce(_.add);
+ * // => 6
+ *
+ * // Returns a wrapped value.
+ * var squares = wrapped.map(square);
+ *
+ * _.isArray(squares);
+ * // => false
+ *
+ * _.isArray(squares.value());
+ * // => true
+ */
+function lodash(value) {
+ if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
+ if (value instanceof LodashWrapper) {
+ return value;
+ }
+ if (hasOwnProperty.call(value, '__wrapped__')) {
+ return wrapperClone(value);
+ }
+ }
+ return new LodashWrapper(value);
+}
+
+// Ensure wrappers are instances of `baseLodash`.
+lodash.prototype = baseLodash.prototype;
+lodash.prototype.constructor = lodash;
+
+module.exports = lodash;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperReverse.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperReverse.js
new file mode 100644
index 0000000..e93112a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperReverse.js
@@ -0,0 +1,44 @@
+var LazyWrapper = require('./_LazyWrapper'),
+ LodashWrapper = require('./_LodashWrapper'),
+ reverse = require('./reverse'),
+ thru = require('./thru');
+
+/**
+ * This method is the wrapper version of `_.reverse`.
+ *
+ * **Note:** This method mutates the wrapped array.
+ *
+ * @name reverse
+ * @memberOf _
+ * @since 0.1.0
+ * @category Seq
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * var array = [1, 2, 3];
+ *
+ * _(array).reverse().value()
+ * // => [3, 2, 1]
+ *
+ * console.log(array);
+ * // => [3, 2, 1]
+ */
+function wrapperReverse() {
+ var value = this.__wrapped__;
+ if (value instanceof LazyWrapper) {
+ var wrapped = value;
+ if (this.__actions__.length) {
+ wrapped = new LazyWrapper(this);
+ }
+ wrapped = wrapped.reverse();
+ wrapped.__actions__.push({
+ 'func': thru,
+ 'args': [reverse],
+ 'thisArg': undefined
+ });
+ return new LodashWrapper(wrapped, this.__chain__);
+ }
+ return this.thru(reverse);
+}
+
+module.exports = wrapperReverse;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperValue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperValue.js
new file mode 100644
index 0000000..f56c2da
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/wrapperValue.js
@@ -0,0 +1,21 @@
+var baseWrapperValue = require('./_baseWrapperValue');
+
+/**
+ * Executes the chain sequence to resolve the unwrapped value.
+ *
+ * @name value
+ * @memberOf _
+ * @since 0.1.0
+ * @alias toJSON, valueOf
+ * @category Seq
+ * @returns {*} Returns the resolved unwrapped value.
+ * @example
+ *
+ * _([1, 2, 3]).value();
+ * // => [1, 2, 3]
+ */
+function wrapperValue() {
+ return baseWrapperValue(this.__wrapped__, this.__actions__);
+}
+
+module.exports = wrapperValue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xor.js
new file mode 100644
index 0000000..d4d2860
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xor.js
@@ -0,0 +1,28 @@
+var arrayFilter = require('./_arrayFilter'),
+ baseRest = require('./_baseRest'),
+ baseXor = require('./_baseXor'),
+ isArrayLikeObject = require('./isArrayLikeObject');
+
+/**
+ * Creates an array of unique values that is the
+ * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
+ * of the given arrays. The order of result values is determined by the order
+ * they occur in the arrays.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @returns {Array} Returns the new array of filtered values.
+ * @see _.difference, _.without
+ * @example
+ *
+ * _.xor([2, 1], [2, 3]);
+ * // => [1, 3]
+ */
+var xor = baseRest(function(arrays) {
+ return baseXor(arrayFilter(arrays, isArrayLikeObject));
+});
+
+module.exports = xor;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorBy.js
new file mode 100644
index 0000000..e047895
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorBy.js
@@ -0,0 +1,39 @@
+var arrayFilter = require('./_arrayFilter'),
+ baseIteratee = require('./_baseIteratee'),
+ baseRest = require('./_baseRest'),
+ baseXor = require('./_baseXor'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.xor` except that it accepts `iteratee` which is
+ * invoked for each element of each `arrays` to generate the criterion by
+ * which by which they're compared. The order of result values is determined
+ * by the order they occur in the arrays. The iteratee is invoked with one
+ * argument: (value).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
+ * // => [1.2, 3.4]
+ *
+ * // The `_.property` iteratee shorthand.
+ * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
+ * // => [{ 'x': 2 }]
+ */
+var xorBy = baseRest(function(arrays) {
+ var iteratee = last(arrays);
+ if (isArrayLikeObject(iteratee)) {
+ iteratee = undefined;
+ }
+ return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2));
+});
+
+module.exports = xorBy;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorWith.js
new file mode 100644
index 0000000..e3a8ac6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/xorWith.js
@@ -0,0 +1,34 @@
+var arrayFilter = require('./_arrayFilter'),
+ baseRest = require('./_baseRest'),
+ baseXor = require('./_baseXor'),
+ isArrayLikeObject = require('./isArrayLikeObject'),
+ last = require('./last');
+
+/**
+ * This method is like `_.xor` except that it accepts `comparator` which is
+ * invoked to compare elements of `arrays`. The order of result values is
+ * determined by the order they occur in the arrays. The comparator is invoked
+ * with two arguments: (arrVal, othVal).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to inspect.
+ * @param {Function} [comparator] The comparator invoked per element.
+ * @returns {Array} Returns the new array of filtered values.
+ * @example
+ *
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
+ * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
+ *
+ * _.xorWith(objects, others, _.isEqual);
+ * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
+ */
+var xorWith = baseRest(function(arrays) {
+ var comparator = last(arrays);
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
+});
+
+module.exports = xorWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zip.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zip.js
new file mode 100644
index 0000000..c800ab3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zip.js
@@ -0,0 +1,22 @@
+var baseRest = require('./_baseRest'),
+ unzip = require('./unzip');
+
+/**
+ * Creates an array of grouped elements, the first of which contains the
+ * first elements of the given arrays, the second of which contains the
+ * second elements of the given arrays, and so on.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to process.
+ * @returns {Array} Returns the new array of grouped elements.
+ * @example
+ *
+ * _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
+ */
+var zip = baseRest(unzip);
+
+module.exports = zip;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObject.js
new file mode 100644
index 0000000..23fdf14
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObject.js
@@ -0,0 +1,24 @@
+var assignValue = require('./_assignValue'),
+ baseZipObject = require('./_baseZipObject');
+
+/**
+ * This method is like `_.fromPairs` except that it accepts two arrays,
+ * one of property identifiers and one of corresponding values.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.4.0
+ * @category Array
+ * @param {Array} [props=[]] The property identifiers.
+ * @param {Array} [values=[]] The property values.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.zipObject(['a', 'b'], [1, 2]);
+ * // => { 'a': 1, 'b': 2 }
+ */
+function zipObject(props, values) {
+ return baseZipObject(props || [], values || [], assignValue);
+}
+
+module.exports = zipObject;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObjectDeep.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObjectDeep.js
new file mode 100644
index 0000000..7c858f8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipObjectDeep.js
@@ -0,0 +1,23 @@
+var baseSet = require('./_baseSet'),
+ baseZipObject = require('./_baseZipObject');
+
+/**
+ * This method is like `_.zipObject` except that it supports property paths.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.1.0
+ * @category Array
+ * @param {Array} [props=[]] The property identifiers.
+ * @param {Array} [values=[]] The property values.
+ * @returns {Object} Returns the new object.
+ * @example
+ *
+ * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
+ * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
+ */
+function zipObjectDeep(props, values) {
+ return baseZipObject(props || [], values || [], baseSet);
+}
+
+module.exports = zipObjectDeep;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipWith.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipWith.js
new file mode 100644
index 0000000..d7a1f91
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/node_modules/lodash/zipWith.js
@@ -0,0 +1,32 @@
+var baseRest = require('./_baseRest'),
+ unzipWith = require('./unzipWith');
+
+/**
+ * This method is like `_.zip` except that it accepts `iteratee` to specify
+ * how grouped values should be combined. The iteratee is invoked with the
+ * elements of each group: (...group).
+ *
+ * @static
+ * @memberOf _
+ * @since 3.8.0
+ * @category Array
+ * @param {...Array} [arrays] The arrays to process.
+ * @param {Function} [iteratee=_.identity] The function to combine
+ * grouped values.
+ * @returns {Array} Returns the new array of grouped elements.
+ * @example
+ *
+ * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
+ * return a + b + c;
+ * });
+ * // => [111, 222]
+ */
+var zipWith = baseRest(function(arrays) {
+ var length = arrays.length,
+ iteratee = length > 1 ? arrays[length - 1] : undefined;
+
+ iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
+ return unzipWith(arrays, iteratee);
+});
+
+module.exports = zipWith;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/package.json
new file mode 100644
index 0000000..a74c00f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/package.json
@@ -0,0 +1,121 @@
+{
+ "name": "async",
+ "description": "Higher-order functions and common patterns for asynchronous code",
+ "version": "2.1.2",
+ "main": "dist/async.js",
+ "author": {
+ "name": "Caolan McMahon"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/caolan/async.git"
+ },
+ "bugs": {
+ "url": "https://github.com/caolan/async/issues"
+ },
+ "keywords": [
+ "async",
+ "callback",
+ "module",
+ "utility"
+ ],
+ "dependencies": {
+ "lodash": "^4.14.0"
+ },
+ "devDependencies": {
+ "babel-cli": "^6.16.0",
+ "babel-core": "^6.3.26",
+ "babel-plugin-add-module-exports": "^0.2.1",
+ "babel-plugin-istanbul": "^2.0.1",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
+ "babel-preset-es2015": "^6.3.13",
+ "babelify": "^7.2.0",
+ "benchmark": "^2.1.1",
+ "bluebird": "^3.4.6",
+ "chai": "^3.1.0",
+ "cheerio": "^0.22.0",
+ "coveralls": "^2.11.2",
+ "es6-promise": "^2.3.0",
+ "eslint": "^2.13.1",
+ "fs-extra": "^0.26.7",
+ "gh-pages-deploy": "^0.4.2",
+ "jsdoc": "^3.4.0",
+ "karma": "^1.3.0",
+ "karma-browserify": "^5.1.0",
+ "karma-firefox-launcher": "^1.0.0",
+ "karma-mocha": "^1.2.0",
+ "karma-mocha-reporter": "^2.2.0",
+ "mocha": "^3.1.2",
+ "native-promise-only": "^0.8.0-a",
+ "nyc": "^7.0.0",
+ "recursive-readdir": "^1.3.0",
+ "rimraf": "^2.5.0",
+ "rollup": "^0.36.3",
+ "rollup-plugin-node-resolve": "^2.0.0",
+ "rollup-plugin-npm": "^2.0.0",
+ "rsvp": "^3.0.18",
+ "semver": "^4.3.6",
+ "uglify-js": "~2.7.3",
+ "vinyl-buffer": "^1.0.0",
+ "vinyl-source-stream": "^1.1.0",
+ "watchify": "^3.7.0",
+ "yargs": "~3.9.1"
+ },
+ "scripts": {
+ "coverage": "nyc npm run mocha-node-test -- --grep @nycinvalid --invert",
+ "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
+ "jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js",
+ "lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/build/ support/*.js karma.conf.js",
+ "mocha-browser-test": "karma start",
+ "mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
+ "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
+ "test": "npm run lint && npm run mocha-node-test"
+ },
+ "license": "MIT",
+ "gh-pages-deploy": {
+ "staticpath": "docs"
+ },
+ "nyc": {
+ "exclude": [
+ "mocha_test"
+ ]
+ },
+ "homepage": "https://github.com/caolan/async#readme",
+ "_id": "async@2.1.2",
+ "_shasum": "612a4ab45ef42a70cde806bad86ee6db047e8385",
+ "_from": "async@2.1.2",
+ "_npmVersion": "3.10.8",
+ "_nodeVersion": "6.8.0",
+ "_npmUser": {
+ "name": "megawac",
+ "email": "megawac@gmail.com"
+ },
+ "dist": {
+ "shasum": "612a4ab45ef42a70cde806bad86ee6db047e8385",
+ "tarball": "https://registry.npmjs.org/async/-/async-2.1.2.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "caolan",
+ "email": "caolan.mcmahon@gmail.com"
+ },
+ {
+ "name": "beaugunderson",
+ "email": "beau@beaugunderson.com"
+ },
+ {
+ "name": "aearly",
+ "email": "alexander.early@gmail.com"
+ },
+ {
+ "name": "megawac",
+ "email": "megawac@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/async-2.1.2.tgz_1476657994986_0.4750206011813134"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/async/-/async-2.1.2.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallel.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallel.js
new file mode 100644
index 0000000..99053a2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallel.js
@@ -0,0 +1,87 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = parallelLimit;
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code. If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series. Any synchronous setup
+ * sections for each task will happen one after the other. JavaScript remains
+ * single-threaded.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ * @example
+ * async.parallel([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // the results array will equal ['one','two'] even though
+ * // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+function parallelLimit(tasks, callback) {
+ (0, _parallel2.default)(_eachOf2.default, tasks, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallelLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallelLimit.js
new file mode 100644
index 0000000..b0bc746
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/parallelLimit.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = parallelLimit;
+
+var _eachOfLimit = require('./internal/eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Collection} tasks - A collection containing functions to run.
+ * Each function is passed a `callback(err, result)` which it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+function parallelLimit(tasks, limit, callback) {
+ (0, _parallel2.default)((0, _eachOfLimit2.default)(limit), tasks, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/priorityQueue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/priorityQueue.js
new file mode 100644
index 0000000..4e37149
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/priorityQueue.js
@@ -0,0 +1,99 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (worker, concurrency) {
+ // Start with a normal queue
+ var q = (0, _queue2.default)(worker, concurrency);
+
+ // Override push to accept second parameter representing priority
+ q.push = function (data, priority, callback) {
+ if (callback == null) callback = _noop2.default;
+ if (typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!(0, _isArray2.default)(data)) {
+ data = [data];
+ }
+ if (data.length === 0) {
+ // call drain immediately if there are no tasks
+ return (0, _setImmediate2.default)(function () {
+ q.drain();
+ });
+ }
+
+ priority = priority || 0;
+ var nextNode = q._tasks.head;
+ while (nextNode && priority >= nextNode.priority) {
+ nextNode = nextNode.next;
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ priority: priority,
+ callback: callback
+ };
+
+ if (nextNode) {
+ q._tasks.insertBefore(nextNode, item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ (0, _setImmediate2.default)(q.process);
+ };
+
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+};
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _queue = require('./queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel. If omitted, the concurrency defaults to
+ * `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ * array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */ \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/queue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/queue.js
new file mode 100644
index 0000000..b991f31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/queue.js
@@ -0,0 +1,120 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (worker, concurrency) {
+ return (0, _queue2.default)(function (items, cb) {
+ worker(items[0], cb);
+ }, concurrency, 1);
+};
+
+var _queue = require('./internal/queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} worker - An asynchronous function for processing a queued
+ * task, which must call its `callback(err)` argument when finished, with an
+ * optional `error` as an argument. If you want to handle errors from an
+ * individual task, pass a callback to `q.push()`. Invoked with
+ * (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel. If omitted, the concurrency
+ * defaults to `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ * console.log('hello ' + task.name);
+ * callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ * console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ * console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ */ \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/race.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/race.js
new file mode 100644
index 0000000..4d0625b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/race.js
@@ -0,0 +1,67 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = race;
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing functions to run. Each function
+ * is passed a `callback(err, result)` which it must call on completion with an
+ * error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // main callback
+ * function(err, result) {
+ * // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (!(0, _isArray2.default)(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+ if (!tasks.length) return callback();
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ tasks[i](callback);
+ }
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduce.js
new file mode 100644
index 0000000..15e26ea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduce.js
@@ -0,0 +1,73 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduce;
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ (0, _eachOfSeries2.default)(coll, function (x, i, callback) {
+ iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduceRight.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduceRight.js
new file mode 100644
index 0000000..3ffdd8e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reduceRight.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduceRight;
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var slice = Array.prototype.slice;
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {Function} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction. The `iteratee` is passed a
+ * `callback(err, reduction)` which accepts an optional error as its first
+ * argument, and the state of the reduction as the second. If an error is
+ * passed to the callback, the reduction is stopped and the main `callback` is
+ * immediately called with the error. Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight(array, memo, iteratee, callback) {
+ var reversed = slice.call(array).reverse();
+ (0, _reduce2.default)(reversed, memo, iteratee, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflect.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflect.js
new file mode 100644
index 0000000..e4fabcc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflect.js
@@ -0,0 +1,80 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reflect;
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Wraps the function in another function that always returns data even when it
+ * errors.
+ *
+ * The object returned has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ * async.reflect(function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff but error ...
+ * callback('bad stuff happened');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = 'bad stuff happened'
+ * // results[2].value = 'two'
+ * });
+ */
+function reflect(fn) {
+ return (0, _initialParams2.default)(function reflectOn(args, reflectCallback) {
+ args.push((0, _baseRest2.default)(function callback(err, cbArgs) {
+ if (err) {
+ reflectCallback(null, {
+ error: err
+ });
+ } else {
+ var value = null;
+ if (cbArgs.length === 1) {
+ value = cbArgs[0];
+ } else if (cbArgs.length > 1) {
+ value = cbArgs;
+ }
+ reflectCallback(null, {
+ value: value
+ });
+ }
+ }));
+
+ return fn.apply(this, args);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflectAll.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflectAll.js
new file mode 100644
index 0000000..fc0f401
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reflectAll.js
@@ -0,0 +1,104 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reflectAll;
+
+var _reflect = require('./reflect');
+
+var _reflect2 = _interopRequireDefault(_reflect);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _arrayMap2 = require('lodash/_arrayMap');
+
+var _arrayMap3 = _interopRequireDefault(_arrayMap2);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A helper function that wraps an array or an object of functions with reflect.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of functions, each function wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * // do some more stuff but error ...
+ * callback(new Error('bad stuff happened'));
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = Error('bad stuff happened')
+ * // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * callback('two');
+ * },
+ * three: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'three');
+ * }, 100);
+ * }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results.one.value = 'one'
+ * // results.two.error = 'two'
+ * // results.three.value = 'three'
+ * });
+ */
+function reflectAll(tasks) {
+ var results;
+ if ((0, _isArray2.default)(tasks)) {
+ results = (0, _arrayMap3.default)(tasks, _reflect2.default);
+ } else {
+ results = {};
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ results[key] = _reflect2.default.call(this, task);
+ });
+ }
+ return results;
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reject.js
new file mode 100644
index 0000000..5fc5c9c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/reject.js
@@ -0,0 +1,44 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _reject = require('./internal/reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of missing files
+ * createFiles(results);
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_reject2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectLimit.js
new file mode 100644
index 0000000..600087c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectLimit.js
@@ -0,0 +1,36 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _reject = require('./internal/reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_reject2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectSeries.js
new file mode 100644
index 0000000..57f49de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/rejectSeries.js
@@ -0,0 +1,34 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _rejectLimit = require('./rejectLimit');
+
+var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doLimit2.default)(_rejectLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retry.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retry.js
new file mode 100644
index 0000000..3738be2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retry.js
@@ -0,0 +1,152 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = retry;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _constant = require('lodash/constant');
+
+var _constant2 = _interopRequireDefault(_constant);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up. The default
+ * is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds. The
+ * default is `0`. The interval may also be specified as a function of the
+ * retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ * erroneous result. If it returns `true` the retry attempts will continue;
+ * if the function returns `false` the retry flow is aborted with the current
+ * attempt's error and result being returned to the final callback.
+ * Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ * with the default interval of `0`.
+ * @param {Function} task - A function which receives two arguments: (1) a
+ * `callback(err, result)` which must be called when finished, passing `err`
+ * (which can be `null`) and the `result` of the function's execution, and (2)
+ * a `results` object, containing the results of the previously executed
+ * functions (if nested inside another control flow). Invoked with
+ * (callback, results).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ * times: 10,
+ * interval: function(retryCount) {
+ * return 50 * Math.pow(2, retryCount);
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ * errorFilter: function(err) {
+ * return err.message === 'Temporary error'; // only retry on a specific error
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // It can also be embedded within other control flow functions to retry
+ * // individual methods that are not as reliable, like this:
+ * async.auto({
+ * users: api.getUsers.bind(api),
+ * payments: async.retry(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ * // do something with the results
+ * });
+ *
+ */
+function retry(opts, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
+
+ var options = {
+ times: DEFAULT_TIMES,
+ intervalFunc: (0, _constant2.default)(DEFAULT_INTERVAL)
+ };
+
+ function parseTimes(acc, t) {
+ if (typeof t === 'object') {
+ acc.times = +t.times || DEFAULT_TIMES;
+
+ acc.intervalFunc = typeof t.interval === 'function' ? t.interval : (0, _constant2.default)(+t.interval || DEFAULT_INTERVAL);
+
+ acc.errorFilter = t.errorFilter;
+ } else if (typeof t === 'number' || typeof t === 'string') {
+ acc.times = +t || DEFAULT_TIMES;
+ } else {
+ throw new Error("Invalid arguments for async.retry");
+ }
+ }
+
+ if (arguments.length < 3 && typeof opts === 'function') {
+ callback = task || _noop2.default;
+ task = opts;
+ } else {
+ parseTimes(options, opts);
+ callback = callback || _noop2.default;
+ }
+
+ if (typeof task !== 'function') {
+ throw new Error("Invalid arguments for async.retry");
+ }
+
+ var attempt = 1;
+ function retryAttempt() {
+ task(function (err) {
+ if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
+ setTimeout(retryAttempt, options.intervalFunc(attempt));
+ } else {
+ callback.apply(null, arguments);
+ }
+ });
+ }
+
+ retryAttempt();
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retryable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retryable.js
new file mode 100644
index 0000000..bf6e2fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/retryable.js
@@ -0,0 +1,56 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (opts, task) {
+ if (!task) {
+ task = opts;
+ opts = null;
+ }
+ return (0, _initialParams2.default)(function (args, callback) {
+ function taskFn(cb) {
+ task.apply(null, args.concat([cb]));
+ }
+
+ if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
+ });
+};
+
+var _retry = require('./retry');
+
+var _retry2 = _interopRequireDefault(_retry);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
+ * retryable, rather than immediately calling it with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {Function} task - the asynchronous function to wrap
+ * @returns {Functions} The wrapped function, which when invoked, will retry on
+ * an error, based on the parameters specified in `opts`.
+ * @example
+ *
+ * async.auto({
+ * dep1: async.retryable(3, getFromFlakyService),
+ * process: ["dep1", async.retryable(3, function (results, cb) {
+ * maybeProcessData(results.dep1, cb);
+ * })]
+ * }, callback);
+ */ \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/seq.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/seq.js
new file mode 100644
index 0000000..fc91fac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/seq.js
@@ -0,0 +1,79 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...Function} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ * var User = request.models.User;
+ * async.seq(
+ * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
+ * function(user, fn) {
+ * user.getCats(fn); // 'getCats' has signature (callback(err, data))
+ * }
+ * )(req.session.user_id, function (err, cats) {
+ * if (err) {
+ * console.error(err);
+ * response.json({ status: 'error', message: err.message });
+ * } else {
+ * response.json({ status: 'ok', message: 'Cats found', data: cats });
+ * }
+ * });
+ * });
+ */
+exports.default = (0, _baseRest2.default)(function seq(functions) {
+ return (0, _baseRest2.default)(function (args) {
+ var that = this;
+
+ var cb = args[args.length - 1];
+ if (typeof cb == 'function') {
+ args.pop();
+ } else {
+ cb = _noop2.default;
+ }
+
+ (0, _reduce2.default)(functions, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat([(0, _baseRest2.default)(function (err, nextargs) {
+ cb(err, nextargs);
+ })]));
+ }, function (err, results) {
+ cb.apply(that, [err].concat(results));
+ });
+ });
+});
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/series.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/series.js
new file mode 100644
index 0000000..668f9d6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/series.js
@@ -0,0 +1,85 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = series;
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each
+ * function is passed a `callback(err, result)` it must call on completion with
+ * an error `err` (which can be `null`) and an optional `result` value.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ * function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * },
+ * function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback){
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+function series(tasks, callback) {
+ (0, _parallel2.default)(_eachOfSeries2.default, tasks, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/setImmediate.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/setImmediate.js
new file mode 100644
index 0000000..23d48e2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/setImmediate.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name setImmediate
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias nextTick
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+exports.default = _setImmediate2.default;
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/some.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/some.js
new file mode 100644
index 0000000..acb3544
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/some.js
@@ -0,0 +1,52 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+exports.default = (0, _createTester2.default)(_eachOf2.default, Boolean, _identity2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someLimit.js
new file mode 100644
index 0000000..c241818
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someLimit.js
@@ -0,0 +1,43 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _createTester2.default)(_eachOfLimit2.default, Boolean, _identity2.default);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someSeries.js
new file mode 100644
index 0000000..96d77ac
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/someSeries.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _someLimit = require('./someLimit');
+
+var _someLimit2 = _interopRequireDefault(_someLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in the array
+ * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
+ * be called with a boolean argument once it has completed. Invoked with
+ * (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_someLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/sortBy.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/sortBy.js
new file mode 100644
index 0000000..b89acbd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/sortBy.js
@@ -0,0 +1,85 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = sortBy;
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _baseProperty = require('lodash/_baseProperty');
+
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A function to apply to each item in `coll`.
+ * The iteratee is passed a `callback(err, sortValue)` which must be called once
+ * it has completed with an error (which can be `null`) and a value to use as
+ * the sort criteria. Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ * fs.stat(file, function(err, stats) {
+ * callback(err, stats.mtime);
+ * });
+ * }, function(err, results) {
+ * // results is now the original array of files sorted by
+ * // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x);
+ * }, function(err,result) {
+ * // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ * // result callback
+ * });
+ */
+function sortBy(coll, iteratee, callback) {
+ (0, _map2.default)(coll, function (x, callback) {
+ iteratee(x, function (err, criteria) {
+ if (err) return callback(err);
+ callback(null, { value: x, criteria: criteria });
+ });
+ }, function (err, results) {
+ if (err) return callback(err);
+ callback(null, (0, _arrayMap2.default)(results.sort(comparator), (0, _baseProperty2.default)('value')));
+ });
+
+ function comparator(left, right) {
+ var a = left.criteria,
+ b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timeout.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timeout.js
new file mode 100644
index 0000000..81a5b7a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timeout.js
@@ -0,0 +1,85 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = timeout;
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} asyncFn - The asynchronous function you want to set the
+ * time limit.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {Function} Returns a wrapped function that can be used with any of
+ * the control flow functions. Invoke this function with the same
+ * parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ * doAsyncTask(foo, function(err, data) {
+ * // handle errors
+ * if (err) return callback(err);
+ *
+ * // do some stuff ...
+ *
+ * // return processed data
+ * return callback(null, data);
+ * });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ * // if `myFunction` takes < 1000 ms to execute, `err`
+ * // and `data` will have their expected values
+ *
+ * // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+function timeout(asyncFn, milliseconds, info) {
+ var originalCallback, timer;
+ var timedOut = false;
+
+ function injectedCallback() {
+ if (!timedOut) {
+ originalCallback.apply(null, arguments);
+ clearTimeout(timer);
+ }
+ }
+
+ function timeoutCallback() {
+ var name = asyncFn.name || 'anonymous';
+ var error = new Error('Callback function "' + name + '" timed out.');
+ error.code = 'ETIMEDOUT';
+ if (info) {
+ error.info = info;
+ }
+ timedOut = true;
+ originalCallback(error);
+ }
+
+ return (0, _initialParams2.default)(function (args, origCallback) {
+ originalCallback = origCallback;
+ // setup timer and call original function
+ timer = setTimeout(timeoutCallback, milliseconds);
+ asyncFn.apply(null, args.concat(injectedCallback));
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/times.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/times.js
new file mode 100644
index 0000000..fad418f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/times.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ * callback(null, {
+ * id: 'user' + id
+ * });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ * createUser(n, function(err, user) {
+ * next(err, user);
+ * });
+ * }, function(err, users) {
+ * // we should now have 5 users
+ * });
+ */
+exports.default = (0, _doLimit2.default)(_timesLimit2.default, Infinity);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesLimit.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesLimit.js
new file mode 100644
index 0000000..d38e531
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = timeLimit;
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _baseRange = require('lodash/_baseRange');
+
+var _baseRange2 = _interopRequireDefault(_baseRange);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+function timeLimit(count, limit, iteratee, callback) {
+ (0, _mapLimit2.default)((0, _baseRange2.default)(0, count, 1), limit, iteratee, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesSeries.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesSeries.js
new file mode 100644
index 0000000..55e112a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/timesSeries.js
@@ -0,0 +1,32 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {Function} iteratee - The function to call `n` times. Invoked with the
+ * iteration index and a callback (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+exports.default = (0, _doLimit2.default)(_timesLimit2.default, 1);
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/transform.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/transform.js
new file mode 100644
index 0000000..e80d1ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/transform.js
@@ -0,0 +1,85 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = transform;
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A relative of `reduce`. Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform. If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {Function} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator. The `iteratee` is
+ * passed a `callback(err)` which accepts an optional error as its first
+ * argument. If an error is passed to the callback, the transform is stopped
+ * and the main `callback` is immediately called with the error.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * acc.push(item * 2)
+ * callback(null)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ * setImmediate(function () {
+ * obj[key] = val * 2;
+ * callback();
+ * })
+ * }, function (err, result) {
+ * // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+function transform(coll, accumulator, iteratee, callback) {
+ if (arguments.length === 3) {
+ callback = iteratee;
+ iteratee = accumulator;
+ accumulator = (0, _isArray2.default)(coll) ? [] : {};
+ }
+ callback = (0, _once2.default)(callback || _noop2.default);
+
+ (0, _eachOf2.default)(coll, function (v, k, cb) {
+ iteratee(accumulator, v, k, cb);
+ }, function (err) {
+ callback(err, accumulator);
+ });
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/unmemoize.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/unmemoize.js
new file mode 100644
index 0000000..dbe7931
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/unmemoize.js
@@ -0,0 +1,25 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = unmemoize;
+/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {Function} fn - the memoized function
+ * @returns {Function} a function that calls the original unmemoized function
+ */
+function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+}
+module.exports = exports["default"]; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/until.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/until.js
new file mode 100644
index 0000000..d895867
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/until.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = until;
+
+var _whilst = require('./whilst');
+
+var _whilst2 = _interopRequireDefault(_whilst);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `fn`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `fn`. Invoked with ().
+ * @param {Function} fn - A function which is called each time `test` fails.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `fn`'s
+ * callback. Invoked with (err, [results]);
+ */
+function until(test, fn, callback) {
+ (0, _whilst2.default)(function () {
+ return !test.apply(this, arguments);
+ }, fn, callback);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/waterfall.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/waterfall.js
new file mode 100644
index 0000000..07611f4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/waterfall.js
@@ -0,0 +1,114 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (tasks, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (!(0, _isArray2.default)(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+ if (!tasks.length) return callback();
+ var taskIndex = 0;
+
+ function nextTask(args) {
+ if (taskIndex === tasks.length) {
+ return callback.apply(null, [null].concat(args));
+ }
+
+ var taskCallback = (0, _onlyOnce2.default)((0, _baseRest2.default)(function (err, args) {
+ if (err) {
+ return callback.apply(null, [err].concat(args));
+ }
+ nextTask(args);
+ }));
+
+ args.push(taskCallback);
+
+ var task = tasks[taskIndex++];
+ task.apply(null, args);
+ }
+
+ nextTask([]);
+};
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of functions to run, each function is passed
+ * a `callback(err, result1, result2, ...)` it must call on completion. The
+ * first argument is an error (which can be `null`) and any further arguments
+ * will be passed as arguments in order to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ * function(callback) {
+ * callback(null, 'one', 'two');
+ * },
+ * function(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * },
+ * function(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ * myFirstFunction,
+ * mySecondFunction,
+ * myLastFunction,
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ * callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ */ \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/whilst.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/whilst.js
new file mode 100644
index 0000000..9145e2e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/async/whilst.js
@@ -0,0 +1,67 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = whilst;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _baseRest = require('lodash/_baseRest');
+
+var _baseRest2 = _interopRequireDefault(_baseRest);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {Function} iteratee - A function which is called each time `test` passes.
+ * The function is passed a `callback(err)`, which must be called once it has
+ * completed with an optional `err` argument. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ * function() { return count < 5; },
+ * function(callback) {
+ * count++;
+ * setTimeout(function() {
+ * callback(null, count);
+ * }, 1000);
+ * },
+ * function (err, n) {
+ * // 5 seconds have passed, n = 5
+ * }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+ callback = (0, _onlyOnce2.default)(callback || _noop2.default);
+ if (!test()) return callback(null);
+ var next = (0, _baseRest2.default)(function (err, args) {
+ if (err) return callback(err);
+ if (test()) return iteratee(next);
+ callback.apply(null, [null].concat(args));
+ });
+ iteratee(next);
+}
+module.exports = exports['default']; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/HISTORY.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/HISTORY.md
new file mode 100644
index 0000000..59e2084
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/HISTORY.md
@@ -0,0 +1,179 @@
+0.5.7 2016-11-18
+-----------------
+- NODE-848 BSON Regex flags must be alphabetically ordered.
+
+0.5.6 2016-10-19
+-----------------
+- NODE-833, Detects cyclic dependencies in documents and throws error if one is found.
+- Fix(deserializer): corrected the check for (size + index) comparison… (Issue #195, https://github.com/JoelParke).
+
+0.5.5 2016-09-15
+-----------------
+- Added DBPointer up conversion to DBRef
+
+0.5.4 2016-08-23
+-----------------
+- Added promoteValues flag (default to true) allowing user to specify if deserialization should be into wrapper classes only.
+
+0.5.3 2016-07-11
+-----------------
+- Throw error if ObjectId is not a string or a buffer.
+
+0.5.2 2016-07-11
+-----------------
+- All values encoded big-endian style for ObjectId.
+
+0.5.1 2016-07-11
+-----------------
+- Fixed encoding/decoding issue in ObjectId timestamp generation.
+- Removed BinaryParser dependency from the serializer/deserializer.
+
+0.5.0 2016-07-05
+-----------------
+- Added Decimal128 type and extended test suite to include entire bson corpus.
+
+0.4.23 2016-04-08
+-----------------
+- Allow for proper detection of ObjectId or objects that look like ObjectId, improving compatibility across third party libraries.
+- Remove one package from dependency due to having been pulled from NPM.
+
+0.4.22 2016-03-04
+-----------------
+- Fix "TypeError: data.copy is not a function" in Electron (Issue #170, https://github.com/kangas).
+- Fixed issue with undefined type on deserializing.
+
+0.4.21 2016-01-12
+-----------------
+- Minor optimizations to avoid non needed object creation.
+
+0.4.20 2015-10-15
+-----------------
+- Added bower file to repository.
+- Fixed browser pid sometimes set greater than 0xFFFF on browsers (Issue #155, https://github.com/rahatarmanahmed)
+
+0.4.19 2015-10-15
+-----------------
+- Remove all support for bson-ext.
+
+0.4.18 2015-10-15
+-----------------
+- ObjectID equality check should return boolean instead of throwing exception for invalid oid string #139
+- add option for deserializing binary into Buffer object #116
+
+0.4.17 2015-10-15
+-----------------
+- Validate regexp string for null bytes and throw if there is one.
+
+0.4.16 2015-10-07
+-----------------
+- Fixed issue with return statement in Map.js.
+
+0.4.15 2015-10-06
+-----------------
+- Exposed Map correctly via index.js file.
+
+0.4.14 2015-10-06
+-----------------
+- Exposed Map correctly via bson.js file.
+
+0.4.13 2015-10-06
+-----------------
+- Added ES6 Map type serialization as well as a polyfill for ES5.
+
+0.4.12 2015-09-18
+-----------------
+- Made ignore undefined an optional parameter.
+
+0.4.11 2015-08-06
+-----------------
+- Minor fix for invalid key checking.
+
+0.4.10 2015-08-06
+-----------------
+- NODE-38 Added new BSONRegExp type to allow direct serialization to MongoDB type.
+- Some performance improvements by in lining code.
+
+0.4.9 2015-08-06
+----------------
+- Undefined fields are omitted from serialization in objects.
+
+0.4.8 2015-07-14
+----------------
+- Fixed size validation to ensure we can deserialize from dumped files.
+
+0.4.7 2015-06-26
+----------------
+- Added ability to instruct deserializer to return raw BSON buffers for named array fields.
+- Minor deserialization optimization by moving inlined function out.
+
+0.4.6 2015-06-17
+----------------
+- Fixed serializeWithBufferAndIndex bug.
+
+0.4.5 2015-06-17
+----------------
+- Removed any references to the shared buffer to avoid non GC collectible bson instances.
+
+0.4.4 2015-06-17
+----------------
+- Fixed rethrowing of error when not RangeError.
+
+0.4.3 2015-06-17
+----------------
+- Start buffer at 64K and double as needed, meaning we keep a low memory profile until needed.
+
+0.4.2 2015-06-16
+----------------
+- More fixes for corrupt Bson
+
+0.4.1 2015-06-16
+----------------
+- More fixes for corrupt Bson
+
+0.4.0 2015-06-16
+----------------
+- New JS serializer serializing into a single buffer then copying out the new buffer. Performance is similar to current C++ parser.
+- Removed bson-ext extension dependency for now.
+
+0.3.2 2015-03-27
+----------------
+- Removed node-gyp from install script in package.json.
+
+0.3.1 2015-03-27
+----------------
+- Return pure js version on native() call if failed to initialize.
+
+0.3.0 2015-03-26
+----------------
+- Pulled out all C++ code into bson-ext and made it an optional dependency.
+
+0.2.21 2015-03-21
+-----------------
+- Updated Nan to 1.7.0 to support io.js and node 0.12.0
+
+0.2.19 2015-02-16
+-----------------
+- Updated Nan to 1.6.2 to support io.js and node 0.12.0
+
+0.2.18 2015-01-20
+-----------------
+- Updated Nan to 1.5.1 to support io.js
+
+0.2.16 2014-12-17
+-----------------
+- Made pid cycle on 0xffff to avoid weird overflows on creation of ObjectID's
+
+0.2.12 2014-08-24
+-----------------
+- Fixes for fortify review of c++ extension
+- toBSON correctly allows returns of non objects
+
+0.2.3 2013-10-01
+----------------
+- Drying of ObjectId code for generation of id (Issue #54, https://github.com/moredip)
+- Fixed issue where corrupt CString's could cause endless loop
+- Support for Node 0.11.X > (Issue #49, https://github.com/kkoopa)
+
+0.1.4 2012-09-25
+----------------
+- Added precompiled c++ native extensions for win32 ia32 and x64
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/LICENSE.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/LICENSE.md
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/LICENSE.md
@@ -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.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/README.md
new file mode 100644
index 0000000..749275d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/README.md
@@ -0,0 +1,95 @@
+# BSON parser
+
+If you don't yet know what BSON actually is, read [the spec](http://bsonspec.org).
+
+This package can be used to serialize JSON documents into the BSON format or the other way around. If you want to use it within the browser, give [browserify](https://github.com/substack/node-browserify) a try (it will help you add this package to your bundle). The current build is located in the `browser_build/bson.js` file.
+
+A simple example of how to use BSON in the browser:
+
+```html
+<script src="./browser_build/bson.js"></script>
+
+<script>
+ function start() {
+ var BSON = bson().BSON
+ var Long = bson().Long
+
+ var doc = { long: Long.fromNumber(100) }
+
+ // Serialize a document
+ var data = BSON.serialize(doc, false, true, false)
+ // De serialize it again
+ var doc_2 = BSON.deserialize(data)
+ }
+</script>
+```
+
+A simple example of how to use BSON in `node.js`:
+
+```js
+var bson = require('bson')
+var BSON = new bson.BSONPure.BSON()
+var Long = bson.BSONPure.Long
+
+var doc = { long: Long.fromNumber(100) }
+
+// Serialize a document
+var data = BSON.serialize(doc, false, true, false)
+console.log('data:', data)
+
+// Deserialize the resulting Buffer
+var doc_2 = BSON.deserialize(data)
+console.log('doc_2:', doc_2)
+```
+
+## API
+
+The API consists of two simple methods to serialize/deserialize objects to/from BSON format:
+=======
+## Installation
+
+`npm install bson`
+
+## API
+
+### BSON serialization and deserialiation
+
+**`new bson.BSONPure.BSON()`** - Creates a new BSON seralizer/deserializer you can use to serialize and deserialize BSON.
+
+ * BSON.serialize(object, checkKeys, asBuffer, serializeFunctions)
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**
+ * @return {TypedArray/Array} returns a TypedArray or Array depending on what your browser supports
+
+ * BSON.deserialize(buffer, options, isArray)
+ * Options
+ * **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * **promoteBuffers** {Boolean, default:false}, deserialize Binary data directly into node.js Buffer object.
+ * @param {TypedArray/Array} a TypedArray/Array containing the BSON data
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+
+### ObjectId
+
+**`bson.ObjectId.isValid(id)`** - Returns true if `id` is a valid number or hexadecimal string representing an ObjectId.
+**`bson.ObjectId.createFromHexString(hexString)`** - Returns the ObjectId the `hexString` represents.
+**`bson.ObjectId.createFromTime(time)`** - Returns an ObjectId containing the passed time.
+* `time` - A Unix timestamp (number of seconds since the epoch).
+
+**`var objectId = new bson.ObjectId(id)`** - Creates a new `ObjectId`.
+* `id` - Must either be a 24-character hex string or a 12 byte binary string.
+
+**`objectId.toJSON()`**
+**`objectId.toString()`**
+**`objectId.toHexString()`** - Returns a hexadecimal string representation of the ObjectId.
+
+**`objectId.equals(otherObjectId)`** - Returns true if the ObjectIds are the same, false otherwise.
+
+**`objectId.getTimestamp()`** - Returns a `Date` object containing the time the objectId was created for.
+
+**`objectId.getTimestamp()`** - Returns a `Date` object containing the time the objectId contains.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/bson.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/bson.js
new file mode 100644
index 0000000..555aa79
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/bson.js
@@ -0,0 +1,1574 @@
+var Long = require('../lib/bson/long').Long
+ , Double = require('../lib/bson/double').Double
+ , Timestamp = require('../lib/bson/timestamp').Timestamp
+ , ObjectID = require('../lib/bson/objectid').ObjectID
+ , Symbol = require('../lib/bson/symbol').Symbol
+ , Code = require('../lib/bson/code').Code
+ , MinKey = require('../lib/bson/min_key').MinKey
+ , MaxKey = require('../lib/bson/max_key').MaxKey
+ , DBRef = require('../lib/bson/db_ref').DBRef
+ , Binary = require('../lib/bson/binary').Binary
+ , BinaryParser = require('../lib/bson/binary_parser').BinaryParser
+ , writeIEEE754 = require('../lib/bson/float_parser').writeIEEE754
+ , readIEEE754 = require('../lib/bson/float_parser').readIEEE754
+
+// 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]';
+}
+
+/**
+ * Create a new BSON instance
+ *
+ * @class
+ * @return {BSON} instance of BSON Parser.
+ */
+function BSON () {};
+
+/**
+ * @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;
+/**
+ * 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_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;
+
+/**
+ * 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} [serializeFunctions] serialize all functions in the object **(default:false)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.calculateObjectSize = function calculateObjectSize(object, serializeFunctions) {
+ var totalLength = (4 + 1);
+
+ if(Array.isArray(object)) {
+ for(var i = 0; i < object.length; i++) {
+ totalLength += calculateElement(i.toString(), object[i], serializeFunctions)
+ }
+ } 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)
+ }
+ }
+
+ return totalLength;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+function calculateElement(name, value, serializeFunctions) {
+ var isBuffer = typeof Buffer !== 'undefined';
+
+ // If we have toBSON defined, override the current object
+ if(value && value.toBSON){
+ value = value.toBSON();
+ }
+
+ switch(typeof value) {
+ case 'string':
+ return 1 + (!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1 + 4 + (!isBuffer ? numberOfBytes(value) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (4 + 1);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ }
+ } else { // 64 bit
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ }
+ case 'undefined':
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (1);
+ case 'boolean':
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (1);
+ } else if(value instanceof ObjectID || value['_bsontype'] == 'ObjectID') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (12 + 1);
+ } else if(value instanceof Date || isDate(value)) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ } else if(typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + 4 + (!isBuffer ? numberOfBytes(value.code.toString()) : Buffer.byteLength(value.code.toString(), 'utf8')) + 1 + BSON.calculateObjectSize(value.scope, serializeFunctions);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + (!isBuffer ? numberOfBytes(value.code.toString()) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (value.position + 1 + 4 + 1 + 4);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (value.position + 1 + 4 + 1);
+ }
+ } else if(value instanceof Symbol || value['_bsontype'] == 'Symbol') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + ((!isBuffer ? numberOfBytes(value.value) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + BSON.calculateObjectSize(ordered_values, serializeFunctions);
+ } else if(value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + (!isBuffer ? numberOfBytes(value.source) : Buffer.byteLength(value.source, 'utf8')) + 1
+ + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + BSON.calculateObjectSize(value, serializeFunctions) + 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + (!isBuffer ? numberOfBytes(value.source) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + 4 + (!isBuffer ? numberOfBytes(value.toString()) : Buffer.byteLength(value.toString(), 'utf8')) + 1 + BSON.calculateObjectSize(value.scope, serializeFunctions);
+ } else if(serializeFunctions) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + (!isBuffer ? numberOfBytes(value.toString()) : Buffer.byteLength(value.toString(), 'utf8')) + 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * 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 {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Number} index the index in the buffer where we wish to start serializing into.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Number} returns the new write index in the Buffer.
+ * @api public
+ */
+BSON.serializeWithBufferAndIndex = function serializeWithBufferAndIndex(object, checkKeys, buffer, index, serializeFunctions) {
+ // Default setting false
+ serializeFunctions = serializeFunctions == null ? false : serializeFunctions;
+ // Write end information (length of the object)
+ var size = buffer.length;
+ // Write the size of the object
+ buffer[index++] = size & 0xff;
+ buffer[index++] = (size >> 8) & 0xff;
+ buffer[index++] = (size >> 16) & 0xff;
+ buffer[index++] = (size >> 24) & 0xff;
+ return serializeObject(object, checkKeys, buffer, index, serializeFunctions) - 1;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var serializeObject = function(object, checkKeys, buffer, index, serializeFunctions) {
+ 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");
+ }
+
+ // Process the object
+ if(Array.isArray(object)) {
+ for(var i = 0; i < object.length; i++) {
+ index = packElement(i.toString(), object[i], checkKeys, buffer, index, serializeFunctions);
+ }
+ } else {
+ // If we have toBSON defined, override the current object
+ if(object.toBSON) {
+ object = object.toBSON();
+ }
+
+ // Serialize the object
+ for(var key in object) {
+ // Check the key and throw error if it's illegal
+ if (key != '$db' && key != '$ref' && key != '$id') {
+ // dollars and dots ok
+ BSON.checkKey(key, !checkKeys);
+ }
+
+ // Pack the element
+ index = packElement(key, object[key], checkKeys, buffer, index, serializeFunctions);
+ }
+ }
+
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+}
+
+var stringToBytes = function(str) {
+ var ch, st, re = [];
+ for (var i = 0; i < str.length; i++ ) {
+ ch = str.charCodeAt(i); // get char
+ st = []; // set up "stack"
+ do {
+ st.push( ch & 0xFF ); // push byte to stack
+ ch = ch >> 8; // shift value down by 1 byte
+ }
+ while ( ch );
+ // add stack contents to result
+ // done because chars have "wrong" endianness
+ re = re.concat( st.reverse() );
+ }
+ // return an array of bytes
+ return re;
+}
+
+var numberOfBytes = function(str) {
+ var ch, st, re = 0;
+ for (var i = 0; i < str.length; i++ ) {
+ ch = str.charCodeAt(i); // get char
+ st = []; // set up "stack"
+ do {
+ st.push( ch & 0xFF ); // push byte to stack
+ ch = ch >> 8; // shift value down by 1 byte
+ }
+ while ( ch );
+ // add stack contents to result
+ // done because chars have "wrong" endianness
+ re = re + st.length;
+ }
+ // return an array of bytes
+ return re;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var writeToTypedArray = function(buffer, string, index) {
+ var bytes = stringToBytes(string);
+ for(var i = 0; i < bytes.length; i++) {
+ buffer[index + i] = bytes[i];
+ }
+ return bytes.length;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var supportsBuffer = typeof Buffer != 'undefined';
+
+/**
+ * @ignore
+ * @api private
+ */
+var packElement = function(name, value, checkKeys, buffer, index, serializeFunctions) {
+
+ // If we have toBSON defined, override the current object
+ if(value && value.toBSON){
+ value = value.toBSON();
+ }
+
+ var startIndex = index;
+
+ switch(typeof value) {
+ case 'string':
+ // console.log("+++++++++++ index string:: " + index)
+ // Encode String type
+ buffer[index++] = BSON.BSON_DATA_STRING;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Calculate size
+ var size = supportsBuffer ? Buffer.byteLength(value) + 1 : numberOfBytes(value) + 1;
+ // console.log("====== key :: " + name + " size ::" + size)
+ // Write the size of the string to buffer
+ buffer[index + 3] = (size >> 24) & 0xff;
+ buffer[index + 2] = (size >> 16) & 0xff;
+ buffer[index + 1] = (size >> 8) & 0xff;
+ buffer[index] = size & 0xff;
+ // Ajust the index
+ index = index + 4;
+ // Write the string
+ supportsBuffer ? buffer.write(value, index, 'utf8') : writeToTypedArray(buffer, value, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Return index
+ return index;
+ case 'number':
+ // 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 = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Write float
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
+ // Ajust index
+ index = index + 8;
+ }
+
+ return index;
+ case 'undefined':
+ // Set long type
+ buffer[index++] = BSON.BSON_DATA_NULL;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ return index;
+ case 'boolean':
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BOOLEAN;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Encode the boolean value
+ buffer[index++] = value ? 1 : 0;
+ return index;
+ case 'object':
+ if(value === null || value instanceof MinKey || value instanceof MaxKey
+ || value['_bsontype'] == 'MinKey' || value['_bsontype'] == 'MaxKey') {
+ // 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 = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ return index;
+ } else if(value instanceof ObjectID || value['_bsontype'] == 'ObjectID') {
+ // console.log("+++++++++++ index OBJECTID:: " + index)
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_OID;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write objectid
+ supportsBuffer ? buffer.write(value.id, index, 'binary') : writeToTypedArray(buffer, value.id, index);
+ // Ajust index
+ index = index + 12;
+ return index;
+ } else if(value instanceof Date || isDate(value)) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_DATE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BINARY;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(value instanceof Long || value instanceof Timestamp || value['_bsontype'] == 'Long' || value['_bsontype'] == 'Timestamp') {
+ // Write the type
+ buffer[index++] = value instanceof Long || value['_bsontype'] == 'Long' ? BSON.BSON_DATA_LONG : BSON.BSON_DATA_TIMESTAMP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(value instanceof Double || value['_bsontype'] == 'Double') {
+ // Encode as double
+ buffer[index++] = BSON.BSON_DATA_NUMBER;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Write float
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
+ // Ajust index
+ index = index + 8;
+ return index;
+ } else if(value instanceof Code || value['_bsontype'] == 'Code') {
+ if(value.scope != null && Object.keys(value.scope).length > 0) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate the scope size
+ var scopeSize = BSON.calculateObjectSize(value.scope, serializeFunctions);
+ // Function string
+ var functionString = value.code.toString();
+ // Function Size
+ var codeSize = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+
+ // Calculate full size of the object
+ var totalSize = 4 + codeSize + scopeSize + 4;
+
+ // Write the total size of the object
+ buffer[index++] = totalSize & 0xff;
+ buffer[index++] = (totalSize >> 8) & 0xff;
+ buffer[index++] = (totalSize >> 16) & 0xff;
+ buffer[index++] = (totalSize >> 24) & 0xff;
+
+ // Write the size of the string to buffer
+ buffer[index++] = codeSize & 0xff;
+ buffer[index++] = (codeSize >> 8) & 0xff;
+ buffer[index++] = (codeSize >> 16) & 0xff;
+ buffer[index++] = (codeSize >> 24) & 0xff;
+
+ // Write the string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + codeSize - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Serialize the scope object
+ var scopeObjectBuffer = supportsBuffer ? new Buffer(scopeSize) : new Uint8Array(new ArrayBuffer(scopeSize));
+ // Execute the serialization into a seperate buffer
+ serializeObject(value.scope, checkKeys, scopeObjectBuffer, 0, serializeFunctions);
+
+ // Adjusted scope Size (removing the header)
+ var scopeDocSize = scopeSize;
+ // Write scope object size
+ buffer[index++] = scopeDocSize & 0xff;
+ buffer[index++] = (scopeDocSize >> 8) & 0xff;
+ buffer[index++] = (scopeDocSize >> 16) & 0xff;
+ buffer[index++] = (scopeDocSize >> 24) & 0xff;
+
+ // Write the scopeObject into the buffer
+ supportsBuffer ? scopeObjectBuffer.copy(buffer, index, 0, scopeSize) : buffer.set(scopeObjectBuffer, index);
+ // Adjust index, removing the empty size of the doc (5 bytes 0000000005)
+ index = index + scopeDocSize - 5;
+ // Write trailing zero
+ buffer[index++] = 0;
+ return index
+ } else {
+ buffer[index++] = BSON.BSON_DATA_CODE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Function string
+ var functionString = value.code.toString();
+ // Function Size
+ var size = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+ // 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 string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+ }
+ } else if(value instanceof Binary || value['_bsontype'] == 'Binary') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BINARY;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Extract the buffer
+ var data = value.value(true);
+ // Calculate size
+ var size = value.position;
+ // 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) {
+ 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
+ supportsBuffer ? data.copy(buffer, index, 0, value.position) : buffer.set(data, index);
+ // Ajust index
+ index = index + value.position;
+ return index;
+ } else if(value instanceof Symbol || value['_bsontype'] == 'Symbol') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_SYMBOL;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate size
+ var size = supportsBuffer ? Buffer.byteLength(value.value) + 1 : numberOfBytes(value.value) + 1;
+ // 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 string
+ buffer.write(value.value, index, 'utf8');
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0x00;
+ return index;
+ } else if(value instanceof DBRef || value['_bsontype'] == 'DBRef') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_OBJECT;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // 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;
+ }
+
+ // Message size
+ var size = BSON.calculateObjectSize(ordered_values, serializeFunctions);
+ // Serialize the object
+ var endIndex = BSON.serializeWithBufferAndIndex(ordered_values, checkKeys, buffer, index, serializeFunctions);
+ // 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 zero for object
+ buffer[endIndex++] = 0x00;
+ // Return the end index
+ return endIndex;
+ } else if(value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_REGEXP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write the regular expression string
+ supportsBuffer ? buffer.write(value.source, index, 'utf8') : writeToTypedArray(buffer, value.source, index);
+ // Adjust the index
+ index = index + (supportsBuffer ? Buffer.byteLength(value.source) : numberOfBytes(value.source));
+ // 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;
+ } else {
+ // Write the type
+ buffer[index++] = Array.isArray(value) ? BSON.BSON_DATA_ARRAY : BSON.BSON_DATA_OBJECT;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Adjust the index
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ var endIndex = serializeObject(value, checkKeys, buffer, index + 4, serializeFunctions);
+ // Write size
+ var size = endIndex - index;
+ // 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;
+ return endIndex;
+ }
+ 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]') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_REGEXP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write the regular expression string
+ buffer.write(value.source, index, 'utf8');
+ // Adjust the index
+ index = index + (supportsBuffer ? Buffer.byteLength(value.source) : numberOfBytes(value.source));
+ // 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;
+ } else {
+ if(serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate the scope size
+ var scopeSize = BSON.calculateObjectSize(value.scope, serializeFunctions);
+ // Function string
+ var functionString = value.toString();
+ // Function Size
+ var codeSize = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+
+ // Calculate full size of the object
+ var totalSize = 4 + codeSize + scopeSize;
+
+ // Write the total size of the object
+ buffer[index++] = totalSize & 0xff;
+ buffer[index++] = (totalSize >> 8) & 0xff;
+ buffer[index++] = (totalSize >> 16) & 0xff;
+ buffer[index++] = (totalSize >> 24) & 0xff;
+
+ // Write the size of the string to buffer
+ buffer[index++] = codeSize & 0xff;
+ buffer[index++] = (codeSize >> 8) & 0xff;
+ buffer[index++] = (codeSize >> 16) & 0xff;
+ buffer[index++] = (codeSize >> 24) & 0xff;
+
+ // Write the string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + codeSize - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Serialize the scope object
+ var scopeObjectBuffer = new Buffer(scopeSize);
+ // Execute the serialization into a seperate buffer
+ serializeObject(value.scope, checkKeys, scopeObjectBuffer, 0, serializeFunctions);
+
+ // Adjusted scope Size (removing the header)
+ var scopeDocSize = scopeSize - 4;
+ // Write scope object size
+ buffer[index++] = scopeDocSize & 0xff;
+ buffer[index++] = (scopeDocSize >> 8) & 0xff;
+ buffer[index++] = (scopeDocSize >> 16) & 0xff;
+ buffer[index++] = (scopeDocSize >> 24) & 0xff;
+
+ // Write the scopeObject into the buffer
+ scopeObjectBuffer.copy(buffer, index, 0, scopeSize);
+
+ // Adjust index, removing the empty size of the doc (5 bytes 0000000005)
+ index = index + scopeDocSize - 5;
+ // Write trailing zero
+ buffer[index++] = 0;
+ return index
+ } else if(serializeFunctions) {
+ buffer[index++] = BSON.BSON_DATA_CODE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Function string
+ var functionString = value.toString();
+ // Function Size
+ var size = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+ // 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 string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+ }
+ }
+ }
+
+ // If no value to serialize
+ return index;
+}
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.serialize = function(object, checkKeys, asBuffer, serializeFunctions) {
+ // Throw error if we are trying serialize an illegal type
+ if(object == null || typeof object != 'object' || Array.isArray(object))
+ throw new Error("Only javascript objects supported");
+
+ // Emoty target buffer
+ var buffer = null;
+ // Calculate the size of the object
+ var size = BSON.calculateObjectSize(object, serializeFunctions);
+ // Fetch the best available type for storing the binary data
+ if(buffer = typeof Buffer != 'undefined') {
+ buffer = new Buffer(size);
+ asBuffer = true;
+ } else if(typeof Uint8Array != 'undefined') {
+ buffer = new Uint8Array(new ArrayBuffer(size));
+ } else {
+ buffer = new Array(size);
+ }
+
+ // If asBuffer is false use typed arrays
+ BSON.serializeWithBufferAndIndex(object, checkKeys, buffer, 0, serializeFunctions);
+ // console.log("++++++++++++++++++++++++++++++++++++ OLDJS :: " + buffer.length)
+ // console.log(buffer.toString('hex'))
+ // console.log(buffer.toString('ascii'))
+ return buffer;
+}
+
+/**
+ * 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 = {};
+
+/**
+ * Crc state variables shared by function
+ *
+ * @ignore
+ * @api private
+ */
+var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D];
+
+/**
+ * CRC32 hash method, Fast and enough versitility for our usage
+ *
+ * @ignore
+ * @api private
+ */
+var crc32 = function(string, start, end) {
+ var crc = 0
+ var x = 0;
+ var y = 0;
+ crc = crc ^ (-1);
+
+ for(var i = start, iTop = end; i < iTop;i++) {
+ y = (crc ^ string[i]) & 0xFF;
+ x = table[y];
+ crc = (crc >>> 8) ^ x;
+ }
+
+ return crc ^ (-1);
+}
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @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.
+ * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
+ * @api public
+ */
+BSON.deserializeStream = function(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
+ // if(numberOfDocuments !== documents.length) throw new Error("Number of expected results back is less than the number of documents");
+ 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] = BSON.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;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Convert Uint8Array to String
+ *
+ * @ignore
+ * @api private
+ */
+var convertUint8ArrayToUtf8String = function(byteArray, startIndex, endIndex) {
+ return BinaryParser.decode_utf8(convertArraytoUtf8BinaryString(byteArray, startIndex, endIndex));
+}
+
+var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) {
+ var result = "";
+ for(var i = startIndex; i < endIndex; i++) {
+ result = result + String.fromCharCode(byteArray[i]);
+ }
+
+ return result;
+};
+
+/**
+ * Deserialize data as BSON.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.deserialize = function(buffer, options, isArray) {
+ // Options
+ options = options == null ? {} : options;
+ var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
+ var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
+ var cacheFunctionsCrc32 = options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32'];
+ var promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs'];
+
+ // Validate that we have at least 4 bytes of buffer
+ if(buffer.length < 5) throw new Error("corrupt bson message < 5 bytes long");
+
+ // Set up index
+ var index = typeof options['index'] == 'number' ? options['index'] : 0;
+ // Reads in a C style string
+ var readCStyleString = function() {
+ // 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")
+ // Grab utf8 encoded string
+ var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i);
+ // Update index position
+ index = i + 1;
+ // Return string
+ return string;
+ }
+
+ // Create holding object
+ var object = isArray ? [] : {};
+
+ // 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");
+
+ // While we have more left data left keep parsing
+ while(true) {
+ // Read the type
+ var elementType = buffer[index++];
+ // If we get a zero it's the last byte, exit
+ if(elementType == 0) break;
+ // Read the name of the field
+ var name = readCStyleString();
+ // Switch on the type
+ switch(elementType) {
+ case BSON.BSON_DATA_OID:
+ var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('binary', index, index + 12) : convertArraytoUtf8BinaryString(buffer, index, index + 12);
+ // Decode the oid
+ object[name] = new ObjectID(string);
+ // Update index
+ index = index + 12;
+ break;
+ case BSON.BSON_DATA_STRING:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Add string to object
+ object[name] = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_INT:
+ // Decode the 32bit value
+ object[name] = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ break;
+ case BSON.BSON_DATA_NUMBER:
+ // Decode the double value
+ object[name] = readIEEE754(buffer, index, 'little', 52, 8);
+ // Update the index
+ index = index + 8;
+ break;
+ case BSON.BSON_DATA_DATE:
+ // Unpack the low and high bits
+ 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;
+ // Set date object
+ object[name] = new Date(new Long(lowBits, highBits).toNumber());
+ break;
+ case BSON.BSON_DATA_BOOLEAN:
+ // Parse the boolean value
+ object[name] = buffer[index++] == 1;
+ break;
+ case BSON.BSON_DATA_UNDEFINED:
+ case BSON.BSON_DATA_NULL:
+ // Parse the boolean value
+ object[name] = null;
+ break;
+ case BSON.BSON_DATA_BINARY:
+ // Decode the size of the binary blob
+ var binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Decode the subtype
+ var subType = buffer[index++];
+ // 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;
+ }
+ // Slice the data
+ 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;
+ }
+ // Copy the data
+ for(var i = 0; i < binarySize; i++) {
+ _buffer[i] = buffer[index + i];
+ }
+ // Create the binary object
+ object[name] = new Binary(_buffer, subType);
+ }
+ // Update the index
+ index = index + binarySize;
+ break;
+ case BSON.BSON_DATA_ARRAY:
+ options['index'] = index;
+ // Decode the size of the array document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Set the array to the object
+ object[name] = BSON.deserialize(buffer, options, true);
+ // Adjust the index
+ index = index + objectSize;
+ break;
+ case BSON.BSON_DATA_OBJECT:
+ options['index'] = index;
+ // Decode the size of the object document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Set the array to the object
+ object[name] = BSON.deserialize(buffer, options, false);
+ // Adjust the index
+ index = index + objectSize;
+ break;
+ case BSON.BSON_DATA_REGEXP:
+ // Create the regexp
+ var source = readCStyleString();
+ var regExpOptions = readCStyleString();
+ // For each option add the corresponding one for javascript
+ var optionsArray = new Array(regExpOptions.length);
+
+ // Parse options
+ for(var 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(''));
+ break;
+ case BSON.BSON_DATA_LONG:
+ // Unpack the low and high bits
+ 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;
+ // Create long object
+ var long = new Long(lowBits, highBits);
+ // Promote the long if possible
+ if(promoteLongs) {
+ object[name] = long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) ? long.toNumber() : long;
+ } else {
+ object[name] = long;
+ }
+ break;
+ case BSON.BSON_DATA_SYMBOL:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Add string to object
+ object[name] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1));
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_TIMESTAMP:
+ // Unpack the low and high bits
+ 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;
+ // Set the object
+ object[name] = new Timestamp(lowBits, highBits);
+ break;
+ case BSON.BSON_DATA_MIN_KEY:
+ // Parse the object
+ object[name] = new MinKey();
+ break;
+ case BSON.BSON_DATA_MAX_KEY:
+ // Parse the object
+ object[name] = new MaxKey();
+ break;
+ case BSON.BSON_DATA_CODE:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Function string
+ var functionString = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+
+ // If we are evaluating the functions
+ if(evalFunctions) {
+ // Contains the value we are going to set
+ var value = null;
+ // 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 {
+ // Set directly
+ object[name] = isolateEval(functionString);
+ }
+ } else {
+ object[name] = new Code(functionString, {});
+ }
+
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_CODE_W_SCOPE:
+ // Read the content of the field
+ var totalSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Javascript function
+ var functionString = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+ // Update parse index position
+ index = index + stringSize;
+ // Parse the element
+ options['index'] = index;
+ // Decode the size of the object document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Decode the scope object
+ var scopeObject = BSON.deserialize(buffer, options, false);
+ // Adjust the index
+ index = index + objectSize;
+
+ // If we are evaluating the functions
+ if(evalFunctions) {
+ // Contains the value we are going to set
+ var value = null;
+ // 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 {
+ // Set directly
+ object[name] = isolateEval(functionString);
+ }
+
+ // Set the scope on the object
+ object[name].scope = scopeObject;
+ } else {
+ object[name] = new Code(functionString, scopeObject);
+ }
+
+ // Add string to object
+ break;
+ }
+ }
+
+ // Check if we have a db ref object
+ if(object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']);
+
+ // Return the final objects
+ return object;
+}
+
+/**
+ * Check if key name is valid.
+ *
+ * @ignore
+ * @api private
+ */
+BSON.checkKey = function checkKey (key, dollarsAndDotsOk) {
+ if (!key.length) return;
+ // Check if we have a legal key for the object
+ if (!!~key.indexOf("\x00")) {
+ // 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 (!dollarsAndDotsOk) {
+ if('$' == key[0]) {
+ throw Error("key " + key + " must not start with '$'");
+ } else if (!!~key.indexOf('.')) {
+ throw Error("key " + key + " must not contain '.'");
+ }
+ }
+};
+
+/**
+ * Deserialize data as BSON.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.prototype.deserialize = function(data, options) {
+ return BSON.deserialize(data, options);
+}
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ *
+ * @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.
+ * @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) {
+ return BSON.deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options);
+}
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.prototype.serialize = function(object, checkKeys, asBuffer, serializeFunctions) {
+ return BSON.serialize(object, checkKeys, asBuffer, serializeFunctions);
+}
+
+/**
+ * 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} [serializeFunctions] serialize all functions in the object **(default:false)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.prototype.calculateObjectSize = function(object, serializeFunctions) {
+ return BSON.calculateObjectSize(object, serializeFunctions);
+}
+
+/**
+ * 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 {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Number} index the index in the buffer where we wish to start serializing into.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Number} returns the new write index in the Buffer.
+ * @api public
+ */
+BSON.prototype.serializeWithBufferAndIndex = function(object, checkKeys, buffer, startIndex, serializeFunctions) {
+ return BSON.serializeWithBufferAndIndex(object, checkKeys, buffer, startIndex, serializeFunctions);
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+module.exports = BSON;
+module.exports.Code = Code;
+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.MinKey = MinKey;
+module.exports.MaxKey = MaxKey;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/faster_bson.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/faster_bson.js
new file mode 100644
index 0000000..f19e44f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/alternate_parsers/faster_bson.js
@@ -0,0 +1,429 @@
+/// reduced to ~ 410 LOCs (parser only 300 vs. 1400+) with (some, needed) BSON classes "inlined".
+/// Compare ~ 4,300 (22KB vs. 157KB) in browser build at: https://github.com/mongodb/js-bson/blob/master/browser_build/bson.js
+
+module.exports.calculateObjectSize = calculateObjectSize;
+
+function calculateObjectSize(object) {
+ var totalLength = (4 + 1); /// handles the obj.length prefix + terminating '0' ?!
+ for(var key in object) { /// looks like it handles arrays under the same for...in loop!?
+ totalLength += calculateElement(key, object[key])
+ }
+ return totalLength;
+}
+
+function calculateElement(name, value) {
+ var len = 1; /// always starting with 1 for the data type byte!
+ if (name) len += Buffer.byteLength(name, 'utf8') + 1; /// cstring: name + '0' termination
+
+ if (value === undefined || value === null) return len; /// just the type byte plus name cstring
+ switch( value.constructor ) { /// removed all checks 'isBuffer' if Node.js Buffer class is present!?
+
+ case ObjectID: /// we want these sorted from most common case to least common/deprecated;
+ return len + 12;
+ case String:
+ return len + 4 + Buffer.byteLength(value, 'utf8') +1; ///
+ case Number:
+ if (Math.floor(value) === value) { /// case: integer; pos.# more common, '&&' stops if 1st fails!
+ if ( value <= 2147483647 && value >= -2147483647 ) // 32 bit
+ return len + 4;
+ else return len + 8; /// covers Long-ish JS integers as Longs!
+ } else return len + 8; /// 8+1 --- covers Double & std. float
+ case Boolean:
+ return len + 1;
+
+ case Array:
+ case Object:
+ return len + calculateObjectSize(value);
+
+ case Buffer: /// replaces the entire Binary class!
+ return len + 4 + value.length + 1;
+
+ case Regex: /// these are handled as strings by serializeFast() later, hence 'gim' opts = 3 + 1 chars
+ return len + Buffer.byteLength(value.source, 'utf8') + 1
+ + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) +1;
+ case Date:
+ case Long:
+ case Timestamp:
+ case Double:
+ return len + 8;
+
+ case MinKey:
+ case MaxKey:
+ return len; /// these two return the type byte and name cstring only!
+ }
+ return 0;
+}
+
+module.exports.serializeFast = serializeFast;
+module.exports.serialize = function(object, checkKeys, asBuffer, serializeFunctions, index) {
+ var buffer = new Buffer(calculateObjectSize(object));
+ return serializeFast(object, checkKeys, buffer, 0);
+}
+
+function serializeFast(object, checkKeys, buffer, i) { /// set checkKeys = false in query(..., options object to save performance IFF you're certain your keys are safe/system-set!
+ var size = buffer.length;
+ buffer[i++] = size & 0xff; buffer[i++] = (size >> 8) & 0xff; /// these get overwritten later!
+ buffer[i++] = (size >> 16) & 0xff; buffer[i++] = (size >> 24) & 0xff;
+
+ if (object.constructor === Array) { /// any need to checkKeys here?!? since we're doing for rather than for...in, should be safe from extra (non-numeric) keys added to the array?!
+ for(var j = 0; j < object.length; j++) {
+ i = packElement(j.toString(), object[j], checkKeys, buffer, i);
+ }
+ } else { /// checkKeys is needed if any suspicion of end-user key tampering/"injection" (a la SQL)
+ for(var key in object) { /// mostly there should never be direct access to them!?
+ if (checkKeys && (key.indexOf('\x00') >= 0 || key === '$where') ) { /// = "no script"?!; could add back key.indexOf('$') or maybe check for 'eval'?!
+/// took out: || key.indexOf('.') >= 0... Don't we allow dot notation queries?!
+ console.log('checkKeys error: ');
+ return new Error('Illegal object key!');
+ }
+ i = packElement(key, object[key], checkKeys, buffer, i); /// checkKeys pass needed for recursion!
+ }
+ }
+ buffer[i++] = 0; /// write terminating zero; !we do NOT -1 the index increase here as original does!
+ return i;
+}
+
+function packElement(name, value, checkKeys, buffer, i) { /// serializeFunctions removed! checkKeys needed for Array & Object cases pass through (calling serializeFast recursively!)
+ if (value === undefined || value === null){
+ buffer[i++] = 10; /// = BSON.BSON_DATA_NULL;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0; /// buffer.write(...) returns bytesWritten!
+ return i;
+ }
+ switch(value.constructor) {
+
+ case ObjectID:
+ buffer[i++] = 7; /// = BSON.BSON_DATA_OID;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+/// i += buffer.write(value.id, i, 'binary'); /// OLD: writes a String to a Buffer; 'binary' deprecated!!
+ value.id.copy(buffer, i); /// NEW ObjectID version has this.id = Buffer at the ready!
+ return i += 12;
+
+ case String:
+ buffer[i++] = 2; /// = BSON.BSON_DATA_STRING;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+
+ var size = Buffer.byteLength(value) + 1; /// includes the terminating '0'!?
+ buffer[i++] = size & 0xff; buffer[i++] = (size >> 8) & 0xff;
+ buffer[i++] = (size >> 16) & 0xff; buffer[i++] = (size >> 24) & 0xff;
+
+ i += buffer.write(value, i, 'utf8'); buffer[i++] = 0;
+ return i;
+
+ case Number:
+ if ( ~~(value) === value) { /// double-Tilde is equiv. to Math.floor(value)
+ if ( value <= 2147483647 && value >= -2147483647){ /// = BSON.BSON_INT32_MAX / MIN asf.
+ buffer[i++] = 16; /// = BSON.BSON_DATA_INT;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ buffer[i++] = value & 0xff; buffer[i++] = (value >> 8) & 0xff;
+ buffer[i++] = (value >> 16) & 0xff; buffer[i++] = (value >> 24) & 0xff;
+
+// Else large-ish JS int!? to Long!?
+ } else { /// if (value <= BSON.JS_INT_MAX && value >= BSON.JS_INT_MIN){ /// 9007199254740992 asf.
+ buffer[i++] = 18; /// = BSON.BSON_DATA_LONG;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ var lowBits = ( value % 4294967296 ) | 0, highBits = ( value / 4294967296 ) | 0;
+
+ buffer[i++] = lowBits & 0xff; buffer[i++] = (lowBits >> 8) & 0xff;
+ buffer[i++] = (lowBits >> 16) & 0xff; buffer[i++] = (lowBits >> 24) & 0xff;
+ buffer[i++] = highBits & 0xff; buffer[i++] = (highBits >> 8) & 0xff;
+ buffer[i++] = (highBits >> 16) & 0xff; buffer[i++] = (highBits >> 24) & 0xff;
+ }
+ } else { /// we have a float / Double
+ buffer[i++] = 1; /// = BSON.BSON_DATA_NUMBER;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+/// OLD: writeIEEE754(buffer, value, i, 'little', 52, 8);
+ buffer.writeDoubleLE(value, i); i += 8;
+ }
+ return i;
+
+ case Boolean:
+ buffer[i++] = 8; /// = BSON.BSON_DATA_BOOLEAN;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ buffer[i++] = value ? 1 : 0;
+ return i;
+
+ case Array:
+ case Object:
+ buffer[i++] = value.constructor === Array ? 4 : 3; /// = BSON.BSON_DATA_ARRAY / _OBJECT;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+
+ var endIndex = serializeFast(value, checkKeys, buffer, i); /// + 4); no longer needed b/c serializeFast writes a temp 4 bytes for length
+ var size = endIndex - i;
+ buffer[i++] = size & 0xff; buffer[i++] = (size >> 8) & 0xff;
+ buffer[i++] = (size >> 16) & 0xff; buffer[i++] = (size >> 24) & 0xff;
+ return endIndex;
+
+ /// case Binary: /// is basically identical unless special/deprecated options!
+ case Buffer: /// solves ALL of our Binary needs without the BSON.Binary class!?
+ buffer[i++] = 5; /// = BSON.BSON_DATA_BINARY;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ var size = value.length;
+ buffer[i++] = size & 0xff; buffer[i++] = (size >> 8) & 0xff;
+ buffer[i++] = (size >> 16) & 0xff; buffer[i++] = (size >> 24) & 0xff;
+
+ buffer[i++] = 0; /// write BSON.BSON_BINARY_SUBTYPE_DEFAULT;
+ value.copy(buffer, i); ///, 0, size); << defaults to sourceStart=0, sourceEnd=sourceBuffer.length);
+ i += size;
+ return i;
+
+ case RegExp:
+ buffer[i++] = 11; /// = BSON.BSON_DATA_REGEXP;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ i += buffer.write(value.source, i, 'utf8'); buffer[i++] = 0x00;
+
+ if (value.global) buffer[i++] = 0x73; // s = 'g' for JS Regex!
+ if (value.ignoreCase) buffer[i++] = 0x69; // i
+ if (value.multiline) buffer[i++] = 0x6d; // m
+ buffer[i++] = 0x00;
+ return i;
+
+ case Date:
+ buffer[i++] = 9; /// = BSON.BSON_DATA_DATE;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ var millis = value.getTime();
+ var lowBits = ( millis % 4294967296 ) | 0, highBits = ( millis / 4294967296 ) | 0;
+
+ buffer[i++] = lowBits & 0xff; buffer[i++] = (lowBits >> 8) & 0xff;
+ buffer[i++] = (lowBits >> 16) & 0xff; buffer[i++] = (lowBits >> 24) & 0xff;
+ buffer[i++] = highBits & 0xff; buffer[i++] = (highBits >> 8) & 0xff;
+ buffer[i++] = (highBits >> 16) & 0xff; buffer[i++] = (highBits >> 24) & 0xff;
+ return i;
+
+ case Long:
+ case Timestamp:
+ buffer[i++] = value.constructor === Long ? 18 : 17; /// = BSON.BSON_DATA_LONG / _TIMESTAMP
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ var lowBits = value.getLowBits(), highBits = value.getHighBits();
+
+ buffer[i++] = lowBits & 0xff; buffer[i++] = (lowBits >> 8) & 0xff;
+ buffer[i++] = (lowBits >> 16) & 0xff; buffer[i++] = (lowBits >> 24) & 0xff;
+ buffer[i++] = highBits & 0xff; buffer[i++] = (highBits >> 8) & 0xff;
+ buffer[i++] = (highBits >> 16) & 0xff; buffer[i++] = (highBits >> 24) & 0xff;
+ return i;
+
+ case Double:
+ buffer[i++] = 1; /// = BSON.BSON_DATA_NUMBER;
+ i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+/// OLD: writeIEEE754(buffer, value, i, 'little', 52, 8); i += 8;
+ buffer.writeDoubleLE(value, i); i += 8;
+ return i
+
+ case MinKey: /// = BSON.BSON_DATA_MINKEY;
+ buffer[i++] = 127; i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ return i;
+ case MaxKey: /// = BSON.BSON_DATA_MAXKEY;
+ buffer[i++] = 255; i += buffer.write(name, i, 'utf8'); buffer[i++] = 0;
+ return i;
+
+ } /// end of switch
+ return i; /// ?! If no value to serialize
+}
+
+
+module.exports.deserializeFast = deserializeFast;
+
+function deserializeFast(buffer, i, isArray){ //// , options, isArray) { //// no more options!
+ if (buffer.length < 5) return new Error('Corrupt bson message < 5 bytes long'); /// from 'throw'
+ var elementType, tempindex = 0, name;
+ var string, low, high; /// = lowBits / highBits
+ /// using 'i' as the index to keep the lines shorter:
+ i || ( i = 0 ); /// for parseResponse it's 0; set to running index in deserialize(object/array) recursion
+ var object = isArray ? [] : {}; /// needed for type ARRAY recursion later!
+ var size = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ if(size < 5 || size > buffer.length) return new Error('Corrupt BSON message');
+/// 'size' var was not used by anything after this, so we can reuse it
+
+ while(true) { // While we have more left data left keep parsing
+ elementType = buffer[i++]; // Read the type
+ if (elementType === 0) break; // If we get a zero it's the last byte, exit
+
+ tempindex = i; /// inlined readCStyleString & removed extra i<buffer.length check slowing EACH loop!
+ while( buffer[tempindex] !== 0x00 ) tempindex++; /// read ahead w/out changing main 'i' index
+ if (tempindex >= buffer.length) return new Error('Corrupt BSON document: illegal CString')
+ name = buffer.toString('utf8', i, tempindex);
+ i = tempindex + 1; /// Update index position to after the string + '0' termination
+
+ switch(elementType) {
+
+ case 7: /// = BSON.BSON_DATA_OID:
+ var buf = new Buffer(12);
+ buffer.copy(buf, 0, i, i += 12 ); /// copy 12 bytes from the current 'i' offset into fresh Buffer
+ object[name] = new ObjectID(buf); ///... & attach to the new ObjectID instance
+ break;
+
+ case 2: /// = BSON.BSON_DATA_STRING:
+ size = buffer[i++] | buffer[i++] <<8 | buffer[i++] <<16 | buffer[i++] <<24;
+ object[name] = buffer.toString('utf8', i, i += size -1 );
+ i++; break; /// need to get the '0' index "tick-forward" back!
+
+ case 16: /// = BSON.BSON_DATA_INT: // Decode the 32bit value
+ object[name] = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24; break;
+
+ case 1: /// = BSON.BSON_DATA_NUMBER: // Decode the double value
+ object[name] = buffer.readDoubleLE(i); /// slightly faster depending on dec.points; a LOT cleaner
+ /// OLD: object[name] = readIEEE754(buffer, i, 'little', 52, 8);
+ i += 8; break;
+
+ case 8: /// = BSON.BSON_DATA_BOOLEAN:
+ object[name] = buffer[i++] == 1; break;
+
+ case 6: /// = BSON.BSON_DATA_UNDEFINED: /// deprecated
+ case 10: /// = BSON.BSON_DATA_NULL:
+ object[name] = null; break;
+
+ case 4: /// = BSON.BSON_DATA_ARRAY
+ size = buffer[i] | buffer[i+1] <<8 | buffer[i+2] <<16 | buffer[i+3] <<24; /// NO 'i' increment since the size bytes are reread during the recursion!
+ object[name] = deserializeFast(buffer, i, true ); /// pass current index & set isArray = true
+ i += size; break;
+ case 3: /// = BSON.BSON_DATA_OBJECT:
+ size = buffer[i] | buffer[i+1] <<8 | buffer[i+2] <<16 | buffer[i+3] <<24;
+ object[name] = deserializeFast(buffer, i, false ); /// isArray = false => Object
+ i += size; break;
+
+ case 5: /// = BSON.BSON_DATA_BINARY: // Decode the size of the binary blob
+ size = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ buffer[i++]; /// Skip, as we assume always default subtype, i.e. 0!
+ object[name] = buffer.slice(i, i += size); /// creates a new Buffer "slice" view of the same memory!
+ break;
+
+ case 9: /// = BSON.BSON_DATA_DATE: /// SEE notes below on the Date type vs. other options...
+ low = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ high = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ object[name] = new Date( high * 4294967296 + (low < 0 ? low + 4294967296 : low) ); break;
+
+ case 18: /// = BSON.BSON_DATA_LONG: /// usage should be somewhat rare beyond parseResponse() -> cursorId, where it is handled inline, NOT as part of deserializeFast(returnedObjects); get lowBits, highBits:
+ low = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ high = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+
+ size = high * 4294967296 + (low < 0 ? low + 4294967296 : low); /// from long.toNumber()
+ if (size < JS_INT_MAX && size > JS_INT_MIN) object[name] = size; /// positive # more likely!
+ else object[name] = new Long(low, high); break;
+
+ case 127: /// = BSON.BSON_DATA_MIN_KEY: /// do we EVER actually get these BACK from MongoDB server?!
+ object[name] = new MinKey(); break;
+ case 255: /// = BSON.BSON_DATA_MAX_KEY:
+ object[name] = new MaxKey(); break;
+
+ case 17: /// = BSON.BSON_DATA_TIMESTAMP: /// somewhat obscure internal BSON type; MongoDB uses it for (pseudo) high-res time timestamp (past millisecs precision is just a counter!) in the Oplog ts: field, etc.
+ low = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ high = buffer[i++] | buffer[i++] << 8 | buffer[i++] << 16 | buffer[i++] << 24;
+ object[name] = new Timestamp(low, high); break;
+
+/// case 11: /// = RegExp is skipped; we should NEVER be getting any from the MongoDB server!?
+ } /// end of switch(elementType)
+ } /// end of while(1)
+ return object; // Return the finalized object
+}
+
+
+function MinKey() { this._bsontype = 'MinKey'; } /// these are merely placeholders/stubs to signify the type!?
+
+function MaxKey() { this._bsontype = 'MaxKey'; }
+
+function Long(low, high) {
+ this._bsontype = 'Long';
+ this.low_ = low | 0; this.high_ = high | 0; /// force into 32 signed bits.
+}
+Long.prototype.getLowBits = function(){ return this.low_; }
+Long.prototype.getHighBits = function(){ return this.high_; }
+
+Long.prototype.toNumber = function(){
+ return this.high_ * 4294967296 + (this.low_ < 0 ? this.low_ + 4294967296 : this.low_);
+}
+Long.fromNumber = function(num){
+ return new Long(num % 4294967296, num / 4294967296); /// |0 is forced in the constructor!
+}
+function Double(value) {
+ this._bsontype = 'Double';
+ this.value = value;
+}
+function Timestamp(low, high) {
+ this._bsontype = 'Timestamp';
+ this.low_ = low | 0; this.high_ = high | 0; /// force into 32 signed bits.
+}
+Timestamp.prototype.getLowBits = function(){ return this.low_; }
+Timestamp.prototype.getHighBits = function(){ return this.high_; }
+
+/////////////////////////////// ObjectID /////////////////////////////////
+/// machine & proc IDs stored as 1 string, b/c Buffer shouldn't be held for long periods (could use SlowBuffer?!)
+
+var MACHINE = parseInt(Math.random() * 0xFFFFFF, 10);
+var PROCESS = process.pid % 0xFFFF;
+var MACHINE_AND_PROC = encodeIntBE(MACHINE, 3) + encodeIntBE(PROCESS, 2); /// keep as ONE string, ready to go.
+
+function encodeIntBE(data, bytes){ /// encode the bytes to a string
+ var result = '';
+ if (bytes >= 4){ result += String.fromCharCode(Math.floor(data / 0x1000000)); data %= 0x1000000; }
+ if (bytes >= 3){ result += String.fromCharCode(Math.floor(data / 0x10000)); data %= 0x10000; }
+ if (bytes >= 2){ result += String.fromCharCode(Math.floor(data / 0x100)); data %= 0x100; }
+ result += String.fromCharCode(Math.floor(data));
+ return result;
+}
+var _counter = ~~(Math.random() * 0xFFFFFF); /// double-tilde is equivalent to Math.floor()
+var checkForHex = new RegExp('^[0-9a-fA-F]{24}$');
+
+function ObjectID(id) {
+ this._bsontype = 'ObjectID';
+ if (!id){ this.id = createFromScratch(); /// base case, DONE.
+ } else {
+ if (id.constructor === Buffer){
+ this.id = id; /// case of
+ } else if (id.constructor === String) {
+ if ( id.length === 24 && checkForHex.test(id) ) {
+ this.id = new Buffer(id, 'hex');
+ } else {
+ this.id = new Error('Illegal/faulty Hexadecimal string supplied!'); /// changed from 'throw'
+ }
+ } else if (id.constructor === Number) {
+ this.id = createFromTime(id); /// this is what should be the only interface for this!?
+ }
+ }
+}
+function createFromScratch() {
+ var buf = new Buffer(12), i = 0;
+ var ts = ~~(Date.now()/1000); /// 4 bytes timestamp in seconds, BigEndian notation!
+ buf[i++] = (ts >> 24) & 0xFF; buf[i++] = (ts >> 16) & 0xFF;
+ buf[i++] = (ts >> 8) & 0xFF; buf[i++] = (ts) & 0xFF;
+
+ buf.write(MACHINE_AND_PROC, i, 5, 'utf8'); i += 5; /// write 3 bytes + 2 bytes MACHINE_ID and PROCESS_ID
+ _counter = ++_counter % 0xFFFFFF; /// 3 bytes internal _counter for subsecond resolution; BigEndian
+ buf[i++] = (_counter >> 16) & 0xFF;
+ buf[i++] = (_counter >> 8) & 0xFF;
+ buf[i++] = (_counter) & 0xFF;
+ return buf;
+}
+function createFromTime(ts) {
+ ts || ( ts = ~~(Date.now()/1000) ); /// 4 bytes timestamp in seconds only
+ var buf = new Buffer(12), i = 0;
+ buf[i++] = (ts >> 24) & 0xFF; buf[i++] = (ts >> 16) & 0xFF;
+ buf[i++] = (ts >> 8) & 0xFF; buf[i++] = (ts) & 0xFF;
+
+ for (;i < 12; ++i) buf[i] = 0x00; /// indeces 4 through 11 (8 bytes) get filled up with nulls
+ return buf;
+}
+ObjectID.prototype.toHexString = function toHexString() {
+ return this.id.toString('hex');
+}
+ObjectID.prototype.getTimestamp = function getTimestamp() {
+ return this.id.readUIntBE(0, 4);
+}
+ObjectID.prototype.getTimestampDate = function getTimestampDate() {
+ var ts = new Date();
+ ts.setTime(this.id.readUIntBE(0, 4) * 1000);
+ return ts;
+}
+ObjectID.createPk = function createPk () { ///?override if a PrivateKey factory w/ unique factors is warranted?!
+ return new ObjectID();
+}
+ObjectID.prototype.toJSON = function toJSON() {
+ return "ObjectID('" +this.id.toString('hex')+ "')";
+}
+
+/// module.exports.BSON = BSON; /// not needed anymore!? exports.Binary = Binary;
+module.exports.ObjectID = ObjectID;
+module.exports.MinKey = MinKey;
+module.exports.MaxKey = MaxKey;
+module.exports.Long = Long; /// ?! we really don't want to do the complicated Long math anywhere for now!?
+
+//module.exports.Double = Double;
+//module.exports.Timestamp = Timestamp;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/bower.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/bower.json
new file mode 100644
index 0000000..b32140e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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 <christkv@gmail.com>",
+ "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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/bson.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/bson.js
new file mode 100644
index 0000000..8e942dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/bson.js
@@ -0,0 +1,4843 @@
+var bson = (function(){
+
+ var pkgmap = {},
+ global = {},
+ nativeRequire = typeof require != 'undefined' && require,
+ lib, ties, main, async;
+
+ function exports(){ return main(); };
+
+ exports.main = exports;
+ exports.module = module;
+ exports.packages = pkgmap;
+ exports.pkg = pkg;
+ exports.require = function require(uri){
+ return pkgmap.main.index.require(uri);
+ };
+
+
+ ties = {};
+
+ aliases = {};
+
+
+ return exports;
+
+function join() {
+ return normalize(Array.prototype.join.call(arguments, "/"));
+};
+
+function normalize(path) {
+ var ret = [], parts = path.split('/'), cur, prev;
+
+ var i = 0, l = parts.length-1;
+ for (; i <= l; i++) {
+ cur = parts[i];
+
+ if (cur === "." && prev !== undefined) continue;
+
+ if (cur === ".." && ret.length && prev !== ".." && prev !== "." && prev !== undefined) {
+ ret.pop();
+ prev = ret.slice(-1)[0];
+ } else {
+ if (prev === ".") ret.pop();
+ ret.push(cur);
+ prev = cur;
+ }
+ }
+
+ return ret.join("/");
+};
+
+function dirname(path) {
+ return path && path.substr(0, path.lastIndexOf("/")) || ".";
+};
+
+function findModule(workingModule, uri){
+ var moduleId = join(dirname(workingModule.id), /\.\/$/.test(uri) ? (uri + 'index') : uri ).replace(/\.js$/, ''),
+ moduleIndexId = join(moduleId, 'index'),
+ pkg = workingModule.pkg,
+ module;
+
+ var i = pkg.modules.length,
+ id;
+
+ while(i-->0){
+ id = pkg.modules[i].id;
+
+ if(id==moduleId || id == moduleIndexId){
+ module = pkg.modules[i];
+ break;
+ }
+ }
+
+ return module;
+}
+
+function newRequire(callingModule){
+ function require(uri){
+ var module, pkg;
+
+ if(/^\./.test(uri)){
+ module = findModule(callingModule, uri);
+ } else if ( ties && ties.hasOwnProperty( uri ) ) {
+ return ties[uri];
+ } else if ( aliases && aliases.hasOwnProperty( uri ) ) {
+ return require(aliases[uri]);
+ } else {
+ pkg = pkgmap[uri];
+
+ if(!pkg && nativeRequire){
+ try {
+ pkg = nativeRequire(uri);
+ } catch (nativeRequireError) {}
+
+ if(pkg) return pkg;
+ }
+
+ if(!pkg){
+ throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
+ }
+
+ module = pkg.index;
+ }
+
+ if(!module){
+ throw new Error('Cannot find module "'+uri+'" @[module: '+callingModule.id+' package: '+callingModule.pkg.name+']');
+ }
+
+ module.parent = callingModule;
+ return module.call();
+ };
+
+
+ return require;
+}
+
+
+function module(parent, id, wrapper){
+ var mod = { pkg: parent, id: id, wrapper: wrapper },
+ cached = false;
+
+ mod.exports = {};
+ mod.require = newRequire(mod);
+
+ mod.call = function(){
+ if(cached) {
+ return mod.exports;
+ }
+
+ cached = true;
+
+ global.require = mod.require;
+
+ mod.wrapper(mod, mod.exports, global, global.require);
+ return mod.exports;
+ };
+
+ if(parent.mainModuleId == mod.id){
+ parent.index = mod;
+ parent.parents.length === 0 && ( main = mod.call );
+ }
+
+ parent.modules.push(mod);
+}
+
+function pkg(/* [ parentId ...], wrapper */){
+ var wrapper = arguments[ arguments.length - 1 ],
+ parents = Array.prototype.slice.call(arguments, 0, arguments.length - 1),
+ ctx = wrapper(parents);
+
+
+ pkgmap[ctx.name] = ctx;
+
+ arguments.length == 1 && ( pkgmap.main = ctx );
+
+ return function(modules){
+ var id;
+ for(id in modules){
+ module(ctx, id, modules[id]);
+ }
+ };
+}
+
+
+}(this));
+
+bson.pkg(function(parents){
+
+ return {
+ 'name' : 'bson',
+ 'mainModuleId' : 'bson',
+ 'modules' : [],
+ 'parents' : parents
+ };
+
+})({ 'binary': function(module, exports, global, require, undefined){
+ /**
+ * Module dependencies.
+ */
+if(typeof window === 'undefined') {
+ var Buffer = require('buffer').Buffer; // TODO just use global Buffer
+}
+
+// Binary default subtype
+var BSON_BINARY_SUBTYPE_DEFAULT = 0;
+
+/**
+ * @ignore
+ * @api private
+ */
+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
+ * @api private
+ */
+var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) {
+ var result = "";
+ for(var i = startIndex; i < endIndex; i++) {
+ result = result + String.fromCharCode(byteArray[i]);
+ }
+ return result;
+};
+
+/**
+ * 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 Represents the Binary BSON type.
+ * @param {Buffer} buffer a buffer object containing the binary data.
+ * @param {Number} [subType] the option binary type.
+ * @return {Grid}
+ */
+function Binary(buffer, subType) {
+ if(!(this instanceof Binary)) return new Binary(buffer, subType);
+
+ 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.
+ *
+ * @param {Character} byte_value a single byte we wish to write.
+ * @api public
+ */
+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 {
+ var 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.
+ *
+ * @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.
+ * @api public
+ */
+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, 'binary', offset);
+ 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(var 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(var 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**.
+ *
+ * @param {Number} position read from the given position in the Binary.
+ * @param {Number} length the number of bytes to read.
+ * @return {Buffer}
+ * @api public
+ */
+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.
+ *
+ * @return {String}
+ * @api public
+ */
+Binary.prototype.value = function value(asRaw) {
+ asRaw = asRaw == null ? false : asRaw;
+
+ // 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.
+ *
+ * @return {Number} the length of the binary.
+ * @api public
+ */
+Binary.prototype.length = function length() {
+ return this.position;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+Binary.prototype.toJSON = function() {
+ return this.buffer != null ? this.buffer.toString('base64') : '';
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+Binary.prototype.toString = function(format) {
+ return this.buffer != null ? this.buffer.slice(0, this.position).toString(format) : '';
+}
+
+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.
+ */
+exports.Binary = Binary;
+
+
+},
+
+
+
+'binary_parser': function(module, exports, global, require, undefined){
+ /**
+ * Binary Parser.
+ * Jonas Raoni Soares Silva
+ * http://jsfromhell.com/classes/binary-parser [v1.0]
+ */
+var chr = String.fromCharCode;
+
+var maxBits = [];
+for (var i = 0; i < 64; i++) {
+ maxBits[i] = Math.pow(2, i);
+}
+
+function BinaryParser (bigEndian, allowExceptions) {
+ if(!(this instanceof BinaryParser)) return new BinaryParser(bigEndian, allowExceptions);
+
+ this.bigEndian = bigEndian;
+ this.allowExceptions = allowExceptions;
+};
+
+BinaryParser.warn = function warn (msg) {
+ if (this.allowExceptions) {
+ throw new Error(msg);
+ }
+
+ return 1;
+};
+
+BinaryParser.decodeFloat = function decodeFloat (data, precisionBits, exponentBits) {
+ var b = new this.Buffer(this.bigEndian, data);
+
+ b.checkBuffer(precisionBits + exponentBits + 1);
+
+ var bias = maxBits[exponentBits - 1] - 1
+ , signal = b.readBits(precisionBits + exponentBits, 1)
+ , exponent = b.readBits(precisionBits, exponentBits)
+ , significand = 0
+ , divisor = 2
+ , curByte = b.buffer.length + (-precisionBits >> 3) - 1;
+
+ do {
+ for (var byteValue = b.buffer[ ++curByte ], startBit = precisionBits % 8 || 8, mask = 1 << startBit; mask >>= 1; ( byteValue & mask ) && ( significand += 1 / divisor ), divisor *= 2 );
+ } while (precisionBits -= startBit);
+
+ return exponent == ( bias << 1 ) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity : ( 1 + signal * -2 ) * ( exponent || significand ? !exponent ? Math.pow( 2, -bias + 1 ) * significand : Math.pow( 2, exponent - bias ) * ( 1 + significand ) : 0 );
+};
+
+BinaryParser.decodeInt = function decodeInt (data, bits, signed, forceBigEndian) {
+ var b = new this.Buffer(this.bigEndian || forceBigEndian, data)
+ , x = b.readBits(0, bits)
+ , max = maxBits[bits]; //max = Math.pow( 2, bits );
+
+ return signed && x >= max / 2
+ ? x - max
+ : x;
+};
+
+BinaryParser.encodeFloat = function encodeFloat (data, precisionBits, exponentBits) {
+ var bias = maxBits[exponentBits - 1] - 1
+ , minExp = -bias + 1
+ , maxExp = bias
+ , minUnnormExp = minExp - precisionBits
+ , n = parseFloat(data)
+ , status = isNaN(n) || n == -Infinity || n == +Infinity ? n : 0
+ , exp = 0
+ , len = 2 * bias + 1 + precisionBits + 3
+ , bin = new Array(len)
+ , signal = (n = status !== 0 ? 0 : n) < 0
+ , intPart = Math.floor(n = Math.abs(n))
+ , floatPart = n - intPart
+ , lastBit
+ , rounded
+ , result
+ , i
+ , j;
+
+ for (i = len; i; bin[--i] = 0);
+
+ for (i = bias + 2; intPart && i; bin[--i] = intPart % 2, intPart = Math.floor(intPart / 2));
+
+ for (i = bias + 1; floatPart > 0 && i; (bin[++i] = ((floatPart *= 2) >= 1) - 0 ) && --floatPart);
+
+ for (i = -1; ++i < len && !bin[i];);
+
+ if (bin[(lastBit = precisionBits - 1 + (i = (exp = bias + 1 - i) >= minExp && exp <= maxExp ? i + 1 : bias + 1 - (exp = minExp - 1))) + 1]) {
+ if (!(rounded = bin[lastBit])) {
+ for (j = lastBit + 2; !rounded && j < len; rounded = bin[j++]);
+ }
+
+ for (j = lastBit + 1; rounded && --j >= 0; (bin[j] = !bin[j] - 0) && (rounded = 0));
+ }
+
+ for (i = i - 2 < 0 ? -1 : i - 3; ++i < len && !bin[i];);
+
+ if ((exp = bias + 1 - i) >= minExp && exp <= maxExp) {
+ ++i;
+ } else if (exp < minExp) {
+ exp != bias + 1 - len && exp < minUnnormExp && this.warn("encodeFloat::float underflow");
+ i = bias + 1 - (exp = minExp - 1);
+ }
+
+ if (intPart || status !== 0) {
+ this.warn(intPart ? "encodeFloat::float overflow" : "encodeFloat::" + status);
+ exp = maxExp + 1;
+ i = bias + 2;
+
+ if (status == -Infinity) {
+ signal = 1;
+ } else if (isNaN(status)) {
+ bin[i] = 1;
+ }
+ }
+
+ for (n = Math.abs(exp + bias), j = exponentBits + 1, result = ""; --j; result = (n % 2) + result, n = n >>= 1);
+
+ for (n = 0, j = 0, i = (result = (signal ? "1" : "0") + result + bin.slice(i, i + precisionBits).join("")).length, r = []; i; j = (j + 1) % 8) {
+ n += (1 << j) * result.charAt(--i);
+ if (j == 7) {
+ r[r.length] = String.fromCharCode(n);
+ n = 0;
+ }
+ }
+
+ r[r.length] = n
+ ? String.fromCharCode(n)
+ : "";
+
+ return (this.bigEndian ? r.reverse() : r).join("");
+};
+
+BinaryParser.encodeInt = function encodeInt (data, bits, signed, forceBigEndian) {
+ var max = maxBits[bits];
+
+ if (data >= max || data < -(max / 2)) {
+ this.warn("encodeInt::overflow");
+ data = 0;
+ }
+
+ if (data < 0) {
+ data += max;
+ }
+
+ for (var r = []; data; r[r.length] = String.fromCharCode(data % 256), data = Math.floor(data / 256));
+
+ for (bits = -(-bits >> 3) - r.length; bits--; r[r.length] = "\0");
+
+ return ((this.bigEndian || forceBigEndian) ? r.reverse() : r).join("");
+};
+
+BinaryParser.toSmall = function( data ){ return this.decodeInt( data, 8, true ); };
+BinaryParser.fromSmall = function( data ){ return this.encodeInt( data, 8, true ); };
+BinaryParser.toByte = function( data ){ return this.decodeInt( data, 8, false ); };
+BinaryParser.fromByte = function( data ){ return this.encodeInt( data, 8, false ); };
+BinaryParser.toShort = function( data ){ return this.decodeInt( data, 16, true ); };
+BinaryParser.fromShort = function( data ){ return this.encodeInt( data, 16, true ); };
+BinaryParser.toWord = function( data ){ return this.decodeInt( data, 16, false ); };
+BinaryParser.fromWord = function( data ){ return this.encodeInt( data, 16, false ); };
+BinaryParser.toInt = function( data ){ return this.decodeInt( data, 32, true ); };
+BinaryParser.fromInt = function( data ){ return this.encodeInt( data, 32, true ); };
+BinaryParser.toLong = function( data ){ return this.decodeInt( data, 64, true ); };
+BinaryParser.fromLong = function( data ){ return this.encodeInt( data, 64, true ); };
+BinaryParser.toDWord = function( data ){ return this.decodeInt( data, 32, false ); };
+BinaryParser.fromDWord = function( data ){ return this.encodeInt( data, 32, false ); };
+BinaryParser.toQWord = function( data ){ return this.decodeInt( data, 64, true ); };
+BinaryParser.fromQWord = function( data ){ return this.encodeInt( data, 64, true ); };
+BinaryParser.toFloat = function( data ){ return this.decodeFloat( data, 23, 8 ); };
+BinaryParser.fromFloat = function( data ){ return this.encodeFloat( data, 23, 8 ); };
+BinaryParser.toDouble = function( data ){ return this.decodeFloat( data, 52, 11 ); };
+BinaryParser.fromDouble = function( data ){ return this.encodeFloat( data, 52, 11 ); };
+
+// Factor out the encode so it can be shared by add_header and push_int32
+BinaryParser.encode_int32 = function encode_int32 (number, asArray) {
+ var a, b, c, d, unsigned;
+ unsigned = (number < 0) ? (number + 0x100000000) : number;
+ a = Math.floor(unsigned / 0xffffff);
+ unsigned &= 0xffffff;
+ b = Math.floor(unsigned / 0xffff);
+ unsigned &= 0xffff;
+ c = Math.floor(unsigned / 0xff);
+ unsigned &= 0xff;
+ d = Math.floor(unsigned);
+ return asArray ? [chr(a), chr(b), chr(c), chr(d)] : chr(a) + chr(b) + chr(c) + chr(d);
+};
+
+BinaryParser.encode_int64 = function encode_int64 (number) {
+ var a, b, c, d, e, f, g, h, unsigned;
+ unsigned = (number < 0) ? (number + 0x10000000000000000) : number;
+ a = Math.floor(unsigned / 0xffffffffffffff);
+ unsigned &= 0xffffffffffffff;
+ b = Math.floor(unsigned / 0xffffffffffff);
+ unsigned &= 0xffffffffffff;
+ c = Math.floor(unsigned / 0xffffffffff);
+ unsigned &= 0xffffffffff;
+ d = Math.floor(unsigned / 0xffffffff);
+ unsigned &= 0xffffffff;
+ e = Math.floor(unsigned / 0xffffff);
+ unsigned &= 0xffffff;
+ f = Math.floor(unsigned / 0xffff);
+ unsigned &= 0xffff;
+ g = Math.floor(unsigned / 0xff);
+ unsigned &= 0xff;
+ h = Math.floor(unsigned);
+ return chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g) + chr(h);
+};
+
+/**
+ * UTF8 methods
+ */
+
+// Take a raw binary string and return a utf8 string
+BinaryParser.decode_utf8 = function decode_utf8 (binaryStr) {
+ var len = binaryStr.length
+ , decoded = ''
+ , i = 0
+ , c = 0
+ , c1 = 0
+ , c2 = 0
+ , c3;
+
+ while (i < len) {
+ c = binaryStr.charCodeAt(i);
+ if (c < 128) {
+ decoded += String.fromCharCode(c);
+ i++;
+ } else if ((c > 191) && (c < 224)) {
+ c2 = binaryStr.charCodeAt(i+1);
+ decoded += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
+ i += 2;
+ } else {
+ c2 = binaryStr.charCodeAt(i+1);
+ c3 = binaryStr.charCodeAt(i+2);
+ decoded += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
+ i += 3;
+ }
+ }
+
+ return decoded;
+};
+
+// Encode a cstring
+BinaryParser.encode_cstring = function encode_cstring (s) {
+ return unescape(encodeURIComponent(s)) + BinaryParser.fromByte(0);
+};
+
+// Take a utf8 string and return a binary string
+BinaryParser.encode_utf8 = function encode_utf8 (s) {
+ var a = ""
+ , c;
+
+ for (var n = 0, len = s.length; n < len; n++) {
+ c = s.charCodeAt(n);
+
+ if (c < 128) {
+ a += String.fromCharCode(c);
+ } else if ((c > 127) && (c < 2048)) {
+ a += String.fromCharCode((c>>6) | 192) ;
+ a += String.fromCharCode((c&63) | 128);
+ } else {
+ a += String.fromCharCode((c>>12) | 224);
+ a += String.fromCharCode(((c>>6) & 63) | 128);
+ a += String.fromCharCode((c&63) | 128);
+ }
+ }
+
+ return a;
+};
+
+BinaryParser.hprint = function hprint (s) {
+ var number;
+
+ for (var i = 0, len = s.length; i < len; i++) {
+ if (s.charCodeAt(i) < 32) {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(16)
+ : s.charCodeAt(i).toString(16);
+ process.stdout.write(number + " ")
+ } else {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(16)
+ : s.charCodeAt(i).toString(16);
+ process.stdout.write(number + " ")
+ }
+ }
+
+ process.stdout.write("\n\n");
+};
+
+BinaryParser.ilprint = function hprint (s) {
+ var number;
+
+ for (var i = 0, len = s.length; i < len; i++) {
+ if (s.charCodeAt(i) < 32) {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(10)
+ : s.charCodeAt(i).toString(10);
+
+ require('util').debug(number+' : ');
+ } else {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(10)
+ : s.charCodeAt(i).toString(10);
+ require('util').debug(number+' : '+ s.charAt(i));
+ }
+ }
+};
+
+BinaryParser.hlprint = function hprint (s) {
+ var number;
+
+ for (var i = 0, len = s.length; i < len; i++) {
+ if (s.charCodeAt(i) < 32) {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(16)
+ : s.charCodeAt(i).toString(16);
+ require('util').debug(number+' : ');
+ } else {
+ number = s.charCodeAt(i) <= 15
+ ? "0" + s.charCodeAt(i).toString(16)
+ : s.charCodeAt(i).toString(16);
+ require('util').debug(number+' : '+ s.charAt(i));
+ }
+ }
+};
+
+/**
+ * BinaryParser buffer constructor.
+ */
+function BinaryParserBuffer (bigEndian, buffer) {
+ this.bigEndian = bigEndian || 0;
+ this.buffer = [];
+ this.setBuffer(buffer);
+};
+
+BinaryParserBuffer.prototype.setBuffer = function setBuffer (data) {
+ var l, i, b;
+
+ if (data) {
+ i = l = data.length;
+ b = this.buffer = new Array(l);
+ for (; i; b[l - i] = data.charCodeAt(--i));
+ this.bigEndian && b.reverse();
+ }
+};
+
+BinaryParserBuffer.prototype.hasNeededBits = function hasNeededBits (neededBits) {
+ return this.buffer.length >= -(-neededBits >> 3);
+};
+
+BinaryParserBuffer.prototype.checkBuffer = function checkBuffer (neededBits) {
+ if (!this.hasNeededBits(neededBits)) {
+ throw new Error("checkBuffer::missing bytes");
+ }
+};
+
+BinaryParserBuffer.prototype.readBits = function readBits (start, length) {
+ //shl fix: Henri Torgemane ~1996 (compressed by Jonas Raoni)
+
+ function shl (a, b) {
+ for (; b--; a = ((a %= 0x7fffffff + 1) & 0x40000000) == 0x40000000 ? a * 2 : (a - 0x40000000) * 2 + 0x7fffffff + 1);
+ return a;
+ }
+
+ if (start < 0 || length <= 0) {
+ return 0;
+ }
+
+ this.checkBuffer(start + length);
+
+ var offsetLeft
+ , offsetRight = start % 8
+ , curByte = this.buffer.length - ( start >> 3 ) - 1
+ , lastByte = this.buffer.length + ( -( start + length ) >> 3 )
+ , diff = curByte - lastByte
+ , sum = ((this.buffer[ curByte ] >> offsetRight) & ((1 << (diff ? 8 - offsetRight : length)) - 1)) + (diff && (offsetLeft = (start + length) % 8) ? (this.buffer[lastByte++] & ((1 << offsetLeft) - 1)) << (diff-- << 3) - offsetRight : 0);
+
+ for(; diff; sum += shl(this.buffer[lastByte++], (diff-- << 3) - offsetRight));
+
+ return sum;
+};
+
+/**
+ * Expose.
+ */
+BinaryParser.Buffer = BinaryParserBuffer;
+
+exports.BinaryParser = BinaryParser;
+
+},
+
+
+
+'bson': function(module, exports, global, require, undefined){
+ 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
+ , DBRef = require('./db_ref').DBRef
+ , Binary = require('./binary').Binary
+ , BinaryParser = require('./binary_parser').BinaryParser
+ , writeIEEE754 = require('./float_parser').writeIEEE754
+ , readIEEE754 = require('./float_parser').readIEEE754
+
+// 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]';
+}
+
+/**
+ * Create a new BSON instance
+ *
+ * @class Represents the BSON Parser
+ * @return {BSON} instance of BSON Parser.
+ */
+function BSON () {};
+
+/**
+ * @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;
+
+/**
+ * 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} [serializeFunctions] serialize all functions in the object **(default:false)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.calculateObjectSize = function calculateObjectSize(object, serializeFunctions) {
+ var totalLength = (4 + 1);
+
+ if(Array.isArray(object)) {
+ for(var i = 0; i < object.length; i++) {
+ totalLength += calculateElement(i.toString(), object[i], serializeFunctions)
+ }
+ } 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)
+ }
+ }
+
+ return totalLength;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+function calculateElement(name, value, serializeFunctions) {
+ var isBuffer = typeof Buffer !== 'undefined';
+
+ switch(typeof value) {
+ case 'string':
+ return 1 + (!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1 + 4 + (!isBuffer ? numberOfBytes(value) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (4 + 1);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ }
+ } else { // 64 bit
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ }
+ case 'undefined':
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (1);
+ case 'boolean':
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (1);
+ } else if(value instanceof ObjectID || value['_bsontype'] == 'ObjectID') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (12 + 1);
+ } else if(value instanceof Date || isDate(value)) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 1);
+ } else if(typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (8 + 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + 4 + (!isBuffer ? numberOfBytes(value.code.toString()) : Buffer.byteLength(value.code.toString(), 'utf8')) + 1 + BSON.calculateObjectSize(value.scope, serializeFunctions);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + (!isBuffer ? numberOfBytes(value.code.toString()) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (value.position + 1 + 4 + 1 + 4);
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + (value.position + 1 + 4 + 1);
+ }
+ } else if(value instanceof Symbol || value['_bsontype'] == 'Symbol') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + ((!isBuffer ? numberOfBytes(value.value) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + BSON.calculateObjectSize(ordered_values, serializeFunctions);
+ } else if(value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]') {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + (!isBuffer ? numberOfBytes(value.source) : Buffer.byteLength(value.source, 'utf8')) + 1
+ + (value.global ? 1 : 0) + (value.ignoreCase ? 1 : 0) + (value.multiline ? 1 : 0) + 1
+ } else {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + BSON.calculateObjectSize(value, serializeFunctions) + 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + (!isBuffer ? numberOfBytes(value.source) : 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 ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + 4 + (!isBuffer ? numberOfBytes(value.toString()) : Buffer.byteLength(value.toString(), 'utf8')) + 1 + BSON.calculateObjectSize(value.scope, serializeFunctions);
+ } else if(serializeFunctions) {
+ return (name != null ? ((!isBuffer ? numberOfBytes(name) : Buffer.byteLength(name, 'utf8')) + 1) : 0) + 1 + 4 + (!isBuffer ? numberOfBytes(value.toString()) : Buffer.byteLength(value.toString(), 'utf8')) + 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * 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 {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Number} index the index in the buffer where we wish to start serializing into.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Number} returns the new write index in the Buffer.
+ * @api public
+ */
+BSON.serializeWithBufferAndIndex = function serializeWithBufferAndIndex(object, checkKeys, buffer, index, serializeFunctions) {
+ // Default setting false
+ serializeFunctions = serializeFunctions == null ? false : serializeFunctions;
+ // Write end information (length of the object)
+ var size = buffer.length;
+ // Write the size of the object
+ buffer[index++] = size & 0xff;
+ buffer[index++] = (size >> 8) & 0xff;
+ buffer[index++] = (size >> 16) & 0xff;
+ buffer[index++] = (size >> 24) & 0xff;
+ return serializeObject(object, checkKeys, buffer, index, serializeFunctions) - 1;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var serializeObject = function(object, checkKeys, buffer, index, serializeFunctions) {
+ // Process the object
+ if(Array.isArray(object)) {
+ for(var i = 0; i < object.length; i++) {
+ index = packElement(i.toString(), object[i], checkKeys, buffer, index, serializeFunctions);
+ }
+ } else {
+ // If we have toBSON defined, override the current object
+ if(object.toBSON) {
+ object = object.toBSON();
+ }
+
+ // Serialize the object
+ for(var key in object) {
+ // Check the key and throw error if it's illegal
+ if (key != '$db' && key != '$ref' && key != '$id') {
+ // dollars and dots ok
+ BSON.checkKey(key, !checkKeys);
+ }
+
+ // Pack the element
+ index = packElement(key, object[key], checkKeys, buffer, index, serializeFunctions);
+ }
+ }
+
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+}
+
+var stringToBytes = function(str) {
+ var ch, st, re = [];
+ for (var i = 0; i < str.length; i++ ) {
+ ch = str.charCodeAt(i); // get char
+ st = []; // set up "stack"
+ do {
+ st.push( ch & 0xFF ); // push byte to stack
+ ch = ch >> 8; // shift value down by 1 byte
+ }
+ while ( ch );
+ // add stack contents to result
+ // done because chars have "wrong" endianness
+ re = re.concat( st.reverse() );
+ }
+ // return an array of bytes
+ return re;
+}
+
+var numberOfBytes = function(str) {
+ var ch, st, re = 0;
+ for (var i = 0; i < str.length; i++ ) {
+ ch = str.charCodeAt(i); // get char
+ st = []; // set up "stack"
+ do {
+ st.push( ch & 0xFF ); // push byte to stack
+ ch = ch >> 8; // shift value down by 1 byte
+ }
+ while ( ch );
+ // add stack contents to result
+ // done because chars have "wrong" endianness
+ re = re + st.length;
+ }
+ // return an array of bytes
+ return re;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var writeToTypedArray = function(buffer, string, index) {
+ var bytes = stringToBytes(string);
+ for(var i = 0; i < bytes.length; i++) {
+ buffer[index + i] = bytes[i];
+ }
+ return bytes.length;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+var supportsBuffer = typeof Buffer != 'undefined';
+
+/**
+ * @ignore
+ * @api private
+ */
+var packElement = function(name, value, checkKeys, buffer, index, serializeFunctions) {
+ var startIndex = index;
+
+ switch(typeof value) {
+ case 'string':
+ // Encode String type
+ buffer[index++] = BSON.BSON_DATA_STRING;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Calculate size
+ var size = supportsBuffer ? Buffer.byteLength(value) + 1 : numberOfBytes(value) + 1;
+ // Write the size of the string to buffer
+ buffer[index + 3] = (size >> 24) & 0xff;
+ buffer[index + 2] = (size >> 16) & 0xff;
+ buffer[index + 1] = (size >> 8) & 0xff;
+ buffer[index] = size & 0xff;
+ // Ajust the index
+ index = index + 4;
+ // Write the string
+ supportsBuffer ? buffer.write(value, index, 'utf8') : writeToTypedArray(buffer, value, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Return index
+ return index;
+ case 'number':
+ // 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 = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Write float
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
+ // Ajust index
+ index = index + 8;
+ }
+
+ return index;
+ case 'undefined':
+ // Set long type
+ buffer[index++] = BSON.BSON_DATA_NULL;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ return index;
+ case 'boolean':
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BOOLEAN;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Encode the boolean value
+ buffer[index++] = value ? 1 : 0;
+ return index;
+ case 'object':
+ if(value === null || value instanceof MinKey || value instanceof MaxKey
+ || value['_bsontype'] == 'MinKey' || value['_bsontype'] == 'MaxKey') {
+ // 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 = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ return index;
+ } else if(value instanceof ObjectID || value['_bsontype'] == 'ObjectID') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_OID;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write objectid
+ supportsBuffer ? buffer.write(value.id, index, 'binary') : writeToTypedArray(buffer, value.id, index);
+ // Ajust index
+ index = index + 12;
+ return index;
+ } else if(value instanceof Date || isDate(value)) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_DATE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BINARY;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(value instanceof Long || value instanceof Timestamp || value['_bsontype'] == 'Long' || value['_bsontype'] == 'Timestamp') {
+ // Write the type
+ buffer[index++] = value instanceof Long ? BSON.BSON_DATA_LONG : BSON.BSON_DATA_TIMESTAMP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 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;
+ } else if(value instanceof Double || value['_bsontype'] == 'Double') {
+ // Encode as double
+ buffer[index++] = BSON.BSON_DATA_NUMBER;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Write float
+ writeIEEE754(buffer, value, index, 'little', 52, 8);
+ // Ajust index
+ index = index + 8;
+ return index;
+ } else if(value instanceof Code || value['_bsontype'] == 'Code') {
+ if(value.scope != null && Object.keys(value.scope).length > 0) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate the scope size
+ var scopeSize = BSON.calculateObjectSize(value.scope, serializeFunctions);
+ // Function string
+ var functionString = value.code.toString();
+ // Function Size
+ var codeSize = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+
+ // Calculate full size of the object
+ var totalSize = 4 + codeSize + scopeSize + 4;
+
+ // Write the total size of the object
+ buffer[index++] = totalSize & 0xff;
+ buffer[index++] = (totalSize >> 8) & 0xff;
+ buffer[index++] = (totalSize >> 16) & 0xff;
+ buffer[index++] = (totalSize >> 24) & 0xff;
+
+ // Write the size of the string to buffer
+ buffer[index++] = codeSize & 0xff;
+ buffer[index++] = (codeSize >> 8) & 0xff;
+ buffer[index++] = (codeSize >> 16) & 0xff;
+ buffer[index++] = (codeSize >> 24) & 0xff;
+
+ // Write the string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + codeSize - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Serialize the scope object
+ var scopeObjectBuffer = supportsBuffer ? new Buffer(scopeSize) : new Uint8Array(new ArrayBuffer(scopeSize));
+ // Execute the serialization into a seperate buffer
+ serializeObject(value.scope, checkKeys, scopeObjectBuffer, 0, serializeFunctions);
+
+ // Adjusted scope Size (removing the header)
+ var scopeDocSize = scopeSize;
+ // Write scope object size
+ buffer[index++] = scopeDocSize & 0xff;
+ buffer[index++] = (scopeDocSize >> 8) & 0xff;
+ buffer[index++] = (scopeDocSize >> 16) & 0xff;
+ buffer[index++] = (scopeDocSize >> 24) & 0xff;
+
+ // Write the scopeObject into the buffer
+ supportsBuffer ? scopeObjectBuffer.copy(buffer, index, 0, scopeSize) : buffer.set(scopeObjectBuffer, index);
+ // Adjust index, removing the empty size of the doc (5 bytes 0000000005)
+ index = index + scopeDocSize - 5;
+ // Write trailing zero
+ buffer[index++] = 0;
+ return index
+ } else {
+ buffer[index++] = BSON.BSON_DATA_CODE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Function string
+ var functionString = value.code.toString();
+ // Function Size
+ var size = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+ // 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 string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+ }
+ } else if(value instanceof Binary || value['_bsontype'] == 'Binary') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_BINARY;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Extract the buffer
+ var data = value.value(true);
+ // Calculate size
+ var size = value.position;
+ // 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) {
+ 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
+ supportsBuffer ? data.copy(buffer, index, 0, value.position) : buffer.set(data, index);
+ // Ajust index
+ index = index + value.position;
+ return index;
+ } else if(value instanceof Symbol || value['_bsontype'] == 'Symbol') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_SYMBOL;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate size
+ var size = supportsBuffer ? Buffer.byteLength(value.value) + 1 : numberOfBytes(value.value) + 1;
+ // 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 string
+ buffer.write(value.value, index, 'utf8');
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0x00;
+ return index;
+ } else if(value instanceof DBRef || value['_bsontype'] == 'DBRef') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_OBJECT;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // 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;
+ }
+
+ // Message size
+ var size = BSON.calculateObjectSize(ordered_values, serializeFunctions);
+ // Serialize the object
+ var endIndex = BSON.serializeWithBufferAndIndex(ordered_values, checkKeys, buffer, index, serializeFunctions);
+ // 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 zero for object
+ buffer[endIndex++] = 0x00;
+ // Return the end index
+ return endIndex;
+ } else if(value instanceof RegExp || Object.prototype.toString.call(value) === '[object RegExp]') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_REGEXP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write the regular expression string
+ supportsBuffer ? buffer.write(value.source, index, 'utf8') : writeToTypedArray(buffer, value.source, index);
+ // Adjust the index
+ index = index + (supportsBuffer ? Buffer.byteLength(value.source) : numberOfBytes(value.source));
+ // 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;
+ } else {
+ // Write the type
+ buffer[index++] = Array.isArray(value) ? BSON.BSON_DATA_ARRAY : BSON.BSON_DATA_OBJECT;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Adjust the index
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ var endIndex = serializeObject(value, checkKeys, buffer, index + 4, serializeFunctions);
+ // Write size
+ var size = endIndex - index;
+ // 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;
+ return endIndex;
+ }
+ 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]') {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_REGEXP;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+
+ // Write the regular expression string
+ buffer.write(value.source, index, 'utf8');
+ // Adjust the index
+ index = index + (supportsBuffer ? Buffer.byteLength(value.source) : numberOfBytes(value.source));
+ // 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;
+ } else {
+ if(serializeFunctions && value.scope != null && Object.keys(value.scope).length > 0) {
+ // Write the type
+ buffer[index++] = BSON.BSON_DATA_CODE_W_SCOPE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Calculate the scope size
+ var scopeSize = BSON.calculateObjectSize(value.scope, serializeFunctions);
+ // Function string
+ var functionString = value.toString();
+ // Function Size
+ var codeSize = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+
+ // Calculate full size of the object
+ var totalSize = 4 + codeSize + scopeSize;
+
+ // Write the total size of the object
+ buffer[index++] = totalSize & 0xff;
+ buffer[index++] = (totalSize >> 8) & 0xff;
+ buffer[index++] = (totalSize >> 16) & 0xff;
+ buffer[index++] = (totalSize >> 24) & 0xff;
+
+ // Write the size of the string to buffer
+ buffer[index++] = codeSize & 0xff;
+ buffer[index++] = (codeSize >> 8) & 0xff;
+ buffer[index++] = (codeSize >> 16) & 0xff;
+ buffer[index++] = (codeSize >> 24) & 0xff;
+
+ // Write the string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + codeSize - 1;
+ // Write zero
+ buffer[index++] = 0;
+ // Serialize the scope object
+ var scopeObjectBuffer = new Buffer(scopeSize);
+ // Execute the serialization into a seperate buffer
+ serializeObject(value.scope, checkKeys, scopeObjectBuffer, 0, serializeFunctions);
+
+ // Adjusted scope Size (removing the header)
+ var scopeDocSize = scopeSize - 4;
+ // Write scope object size
+ buffer[index++] = scopeDocSize & 0xff;
+ buffer[index++] = (scopeDocSize >> 8) & 0xff;
+ buffer[index++] = (scopeDocSize >> 16) & 0xff;
+ buffer[index++] = (scopeDocSize >> 24) & 0xff;
+
+ // Write the scopeObject into the buffer
+ scopeObjectBuffer.copy(buffer, index, 0, scopeSize);
+
+ // Adjust index, removing the empty size of the doc (5 bytes 0000000005)
+ index = index + scopeDocSize - 5;
+ // Write trailing zero
+ buffer[index++] = 0;
+ return index
+ } else if(serializeFunctions) {
+ buffer[index++] = BSON.BSON_DATA_CODE;
+ // Number of written bytes
+ var numberOfWrittenBytes = supportsBuffer ? buffer.write(name, index, 'utf8') : writeToTypedArray(buffer, name, index);
+ // Encode the name
+ index = index + numberOfWrittenBytes + 1;
+ buffer[index - 1] = 0;
+ // Function string
+ var functionString = value.toString();
+ // Function Size
+ var size = supportsBuffer ? Buffer.byteLength(functionString) + 1 : numberOfBytes(functionString) + 1;
+ // 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 string
+ supportsBuffer ? buffer.write(functionString, index, 'utf8') : writeToTypedArray(buffer, functionString, index);
+ // Update index
+ index = index + size - 1;
+ // Write zero
+ buffer[index++] = 0;
+ return index;
+ }
+ }
+ }
+
+ // If no value to serialize
+ return index;
+}
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.serialize = function(object, checkKeys, asBuffer, serializeFunctions) {
+ // Throw error if we are trying serialize an illegal type
+ if(object == null || typeof object != 'object' || Array.isArray(object))
+ throw new Error("Only javascript objects supported");
+
+ // Emoty target buffer
+ var buffer = null;
+ // Calculate the size of the object
+ var size = BSON.calculateObjectSize(object, serializeFunctions);
+ // Fetch the best available type for storing the binary data
+ if(buffer = typeof Buffer != 'undefined') {
+ buffer = new Buffer(size);
+ asBuffer = true;
+ } else if(typeof Uint8Array != 'undefined') {
+ buffer = new Uint8Array(new ArrayBuffer(size));
+ } else {
+ buffer = new Array(size);
+ }
+
+ // If asBuffer is false use typed arrays
+ BSON.serializeWithBufferAndIndex(object, checkKeys, buffer, 0, serializeFunctions);
+ return buffer;
+}
+
+/**
+ * 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 = {};
+
+/**
+ * Crc state variables shared by function
+ *
+ * @ignore
+ * @api private
+ */
+var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D];
+
+/**
+ * CRC32 hash method, Fast and enough versitility for our usage
+ *
+ * @ignore
+ * @api private
+ */
+var crc32 = function(string, start, end) {
+ var crc = 0
+ var x = 0;
+ var y = 0;
+ crc = crc ^ (-1);
+
+ for(var i = start, iTop = end; i < iTop;i++) {
+ y = (crc ^ string[i]) & 0xFF;
+ x = table[y];
+ crc = (crc >>> 8) ^ x;
+ }
+
+ return crc ^ (-1);
+}
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @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.
+ * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
+ * @api public
+ */
+BSON.deserializeStream = function(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
+ // if(numberOfDocuments !== documents.length) throw new Error("Number of expected results back is less than the number of documents");
+ 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] = BSON.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;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Convert Uint8Array to String
+ *
+ * @ignore
+ * @api private
+ */
+var convertUint8ArrayToUtf8String = function(byteArray, startIndex, endIndex) {
+ return BinaryParser.decode_utf8(convertArraytoUtf8BinaryString(byteArray, startIndex, endIndex));
+}
+
+var convertArraytoUtf8BinaryString = function(byteArray, startIndex, endIndex) {
+ var result = "";
+ for(var i = startIndex; i < endIndex; i++) {
+ result = result + String.fromCharCode(byteArray[i]);
+ }
+
+ return result;
+};
+
+/**
+ * Deserialize data as BSON.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.deserialize = function(buffer, options, isArray) {
+ // Options
+ options = options == null ? {} : options;
+ var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
+ var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
+ var cacheFunctionsCrc32 = options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32'];
+ var promoteLongs = options['promoteLongs'] || true;
+
+ // Validate that we have at least 4 bytes of buffer
+ if(buffer.length < 5) throw new Error("corrupt bson message < 5 bytes long");
+
+ // Set up index
+ var index = typeof options['index'] == 'number' ? options['index'] : 0;
+ // Reads in a C style string
+ var readCStyleString = function() {
+ // Get the start search index
+ var i = index;
+ // Locate the end of the c string
+ while(buffer[i] !== 0x00) { i++ }
+ // Grab utf8 encoded string
+ var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i);
+ // Update index position
+ index = i + 1;
+ // Return string
+ return string;
+ }
+
+ // Create holding object
+ var object = isArray ? [] : {};
+
+ // 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");
+
+ // While we have more left data left keep parsing
+ while(true) {
+ // Read the type
+ var elementType = buffer[index++];
+ // If we get a zero it's the last byte, exit
+ if(elementType == 0) break;
+ // Read the name of the field
+ var name = readCStyleString();
+ // Switch on the type
+ switch(elementType) {
+ case BSON.BSON_DATA_OID:
+ var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('binary', index, index + 12) : convertArraytoUtf8BinaryString(buffer, index, index + 12);
+ // Decode the oid
+ object[name] = new ObjectID(string);
+ // Update index
+ index = index + 12;
+ break;
+ case BSON.BSON_DATA_STRING:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Add string to object
+ object[name] = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_INT:
+ // Decode the 32bit value
+ object[name] = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ break;
+ case BSON.BSON_DATA_NUMBER:
+ // Decode the double value
+ object[name] = readIEEE754(buffer, index, 'little', 52, 8);
+ // Update the index
+ index = index + 8;
+ break;
+ case BSON.BSON_DATA_DATE:
+ // Unpack the low and high bits
+ 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;
+ // Set date object
+ object[name] = new Date(new Long(lowBits, highBits).toNumber());
+ break;
+ case BSON.BSON_DATA_BOOLEAN:
+ // Parse the boolean value
+ object[name] = buffer[index++] == 1;
+ break;
+ case BSON.BSON_DATA_NULL:
+ // Parse the boolean value
+ object[name] = null;
+ break;
+ case BSON.BSON_DATA_BINARY:
+ // Decode the size of the binary blob
+ var binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Decode the subtype
+ var subType = buffer[index++];
+ // 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;
+ }
+ // Slice the data
+ 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;
+ }
+ // Copy the data
+ for(var i = 0; i < binarySize; i++) {
+ _buffer[i] = buffer[index + i];
+ }
+ // Create the binary object
+ object[name] = new Binary(_buffer, subType);
+ }
+ // Update the index
+ index = index + binarySize;
+ break;
+ case BSON.BSON_DATA_ARRAY:
+ options['index'] = index;
+ // Decode the size of the array document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Set the array to the object
+ object[name] = BSON.deserialize(buffer, options, true);
+ // Adjust the index
+ index = index + objectSize;
+ break;
+ case BSON.BSON_DATA_OBJECT:
+ options['index'] = index;
+ // Decode the size of the object document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Set the array to the object
+ object[name] = BSON.deserialize(buffer, options, false);
+ // Adjust the index
+ index = index + objectSize;
+ break;
+ case BSON.BSON_DATA_REGEXP:
+ // Create the regexp
+ var source = readCStyleString();
+ var regExpOptions = readCStyleString();
+ // For each option add the corresponding one for javascript
+ var optionsArray = new Array(regExpOptions.length);
+
+ // Parse options
+ for(var 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(''));
+ break;
+ case BSON.BSON_DATA_LONG:
+ // Unpack the low and high bits
+ 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;
+ // Create long object
+ var long = new Long(lowBits, highBits);
+ // Promote the long if possible
+ if(promoteLongs) {
+ object[name] = long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG) ? long.toNumber() : long;
+ } else {
+ object[name] = long;
+ }
+ break;
+ case BSON.BSON_DATA_SYMBOL:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Add string to object
+ object[name] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1));
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_TIMESTAMP:
+ // Unpack the low and high bits
+ 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;
+ // Set the object
+ object[name] = new Timestamp(lowBits, highBits);
+ break;
+ case BSON.BSON_DATA_MIN_KEY:
+ // Parse the object
+ object[name] = new MinKey();
+ break;
+ case BSON.BSON_DATA_MAX_KEY:
+ // Parse the object
+ object[name] = new MaxKey();
+ break;
+ case BSON.BSON_DATA_CODE:
+ // Read the content of the field
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Function string
+ var functionString = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+
+ // If we are evaluating the functions
+ if(evalFunctions) {
+ // Contains the value we are going to set
+ var value = null;
+ // 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 {
+ // Set directly
+ object[name] = isolateEval(functionString);
+ }
+ } else {
+ object[name] = new Code(functionString, {});
+ }
+
+ // Update parse index position
+ index = index + stringSize;
+ break;
+ case BSON.BSON_DATA_CODE_W_SCOPE:
+ // Read the content of the field
+ var totalSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;
+ // Javascript function
+ var functionString = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, index + stringSize - 1) : convertUint8ArrayToUtf8String(buffer, index, index + stringSize - 1);
+ // Update parse index position
+ index = index + stringSize;
+ // Parse the element
+ options['index'] = index;
+ // Decode the size of the object document
+ var objectSize = buffer[index] | buffer[index + 1] << 8 | buffer[index + 2] << 16 | buffer[index + 3] << 24;
+ // Decode the scope object
+ var scopeObject = BSON.deserialize(buffer, options, false);
+ // Adjust the index
+ index = index + objectSize;
+
+ // If we are evaluating the functions
+ if(evalFunctions) {
+ // Contains the value we are going to set
+ var value = null;
+ // 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 {
+ // Set directly
+ object[name] = isolateEval(functionString);
+ }
+
+ // Set the scope on the object
+ object[name].scope = scopeObject;
+ } else {
+ object[name] = new Code(functionString, scopeObject);
+ }
+
+ // Add string to object
+ break;
+ }
+ }
+
+ // Check if we have a db ref object
+ if(object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']);
+
+ // Return the final objects
+ return object;
+}
+
+/**
+ * Check if key name is valid.
+ *
+ * @ignore
+ * @api private
+ */
+BSON.checkKey = function checkKey (key, dollarsAndDotsOk) {
+ if (!key.length) return;
+ // Check if we have a legal key for the object
+ if (!!~key.indexOf("\x00")) {
+ // 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 (!dollarsAndDotsOk) {
+ if('$' == key[0]) {
+ throw Error("key " + key + " must not start with '$'");
+ } else if (!!~key.indexOf('.')) {
+ throw Error("key " + key + " must not contain '.'");
+ }
+ }
+};
+
+/**
+ * Deserialize data as BSON.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.prototype.deserialize = function(data, options) {
+ return BSON.deserialize(data, options);
+}
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ *
+ * @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.
+ * @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) {
+ return BSON.deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options);
+}
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.prototype.serialize = function(object, checkKeys, asBuffer, serializeFunctions) {
+ return BSON.serialize(object, checkKeys, asBuffer, serializeFunctions);
+}
+
+/**
+ * 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} [serializeFunctions] serialize all functions in the object **(default:false)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.prototype.calculateObjectSize = function(object, serializeFunctions) {
+ return BSON.calculateObjectSize(object, serializeFunctions);
+}
+
+/**
+ * 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 {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Number} index the index in the buffer where we wish to start serializing into.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Number} returns the new write index in the Buffer.
+ * @api public
+ */
+BSON.prototype.serializeWithBufferAndIndex = function(object, checkKeys, buffer, startIndex, serializeFunctions) {
+ return BSON.serializeWithBufferAndIndex(object, checkKeys, buffer, startIndex, serializeFunctions);
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+exports.Code = Code;
+exports.Symbol = Symbol;
+exports.BSON = BSON;
+exports.DBRef = DBRef;
+exports.Binary = Binary;
+exports.ObjectID = ObjectID;
+exports.Long = Long;
+exports.Timestamp = Timestamp;
+exports.Double = Double;
+exports.MinKey = MinKey;
+exports.MaxKey = MaxKey;
+
+},
+
+
+
+'code': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON Code type.
+ *
+ * @class Represents the BSON Code type.
+ * @param {String|Function} code a string or function.
+ * @param {Object} [scope] an optional scope for the function.
+ * @return {Code}
+ */
+function Code(code, scope) {
+ if(!(this instanceof Code)) return new Code(code, scope);
+
+ this._bsontype = 'Code';
+ this.code = code;
+ this.scope = scope == null ? {} : scope;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+Code.prototype.toJSON = function() {
+ return {scope:this.scope, code:this.code};
+}
+
+exports.Code = Code;
+},
+
+
+
+'db_ref': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON DBRef type.
+ *
+ * @class Represents the BSON DBRef type.
+ * @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
+ };
+}
+
+exports.DBRef = DBRef;
+},
+
+
+
+'double': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON Double type.
+ *
+ * @class Represents the BSON Double type.
+ * @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.
+ *
+ * @return {Number} returns the wrapped double number.
+ * @api public
+ */
+Double.prototype.valueOf = function() {
+ return this.value;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+Double.prototype.toJSON = function() {
+ return this.value;
+}
+
+exports.Double = Double;
+},
+
+
+
+'float_parser': function(module, exports, global, require, undefined){
+ // 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;
+},
+
+
+
+'index': function(module, exports, global, require, undefined){
+ try {
+ exports.BSONPure = require('./bson');
+ exports.BSONNative = require('../../ext');
+} catch(err) {
+ // do nothing
+}
+
+[ './binary_parser'
+ , './binary'
+ , './code'
+ , './db_ref'
+ , './double'
+ , './max_key'
+ , './min_key'
+ , './objectid'
+ , './symbol'
+ , './timestamp'
+ , './long'].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ exports[i] = module[i];
+ }
+});
+
+// Exports all the classes for the NATIVE JS BSON Parser
+exports.native = function() {
+ var classes = {};
+ // Map all the classes
+ [ './binary_parser'
+ , './binary'
+ , './code'
+ , './db_ref'
+ , './double'
+ , './max_key'
+ , './min_key'
+ , './objectid'
+ , './symbol'
+ , './timestamp'
+ , './long'
+ , '../../ext'
+].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ classes[i] = module[i];
+ }
+ });
+ // Return classes list
+ return classes;
+}
+
+// Exports all the classes for the PURE JS BSON Parser
+exports.pure = function() {
+ var classes = {};
+ // Map all the classes
+ [ './binary_parser'
+ , './binary'
+ , './code'
+ , './db_ref'
+ , './double'
+ , './max_key'
+ , './min_key'
+ , './objectid'
+ , './symbol'
+ , './timestamp'
+ , './long'
+ , '././bson'].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ classes[i] = module[i];
+ }
+ });
+ // Return classes list
+ return classes;
+}
+
+},
+
+
+
+'long': function(module, exports, global, require, undefined){
+ // 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 Represents the BSON Long type.
+ * @param {Number} low the low (signed) 32 bits of the Long.
+ * @param {Number} high the high (signed) 32 bits of the Long.
+ */
+function Long(low, high) {
+ if(!(this instanceof Long)) return new Long(low, high);
+
+ this._bsontype = 'Long';
+ /**
+ * @type {number}
+ * @api private
+ */
+ this.low_ = low | 0; // force into 32 signed bits.
+
+ /**
+ * @type {number}
+ * @api private
+ */
+ this.high_ = high | 0; // force into 32 signed bits.
+};
+
+/**
+ * Return the int value.
+ *
+ * @return {Number} the value, assuming it is a 32-bit integer.
+ * @api public
+ */
+Long.prototype.toInt = function() {
+ return this.low_;
+};
+
+/**
+ * Return the Number value.
+ *
+ * @return {Number} the closest floating-point representation to this value.
+ * @api public
+ */
+Long.prototype.toNumber = function() {
+ return this.high_ * Long.TWO_PWR_32_DBL_ +
+ this.getLowBitsUnsigned();
+};
+
+/**
+ * Return the JSON value.
+ *
+ * @return {String} the JSON representation.
+ * @api public
+ */
+Long.prototype.toJSON = function() {
+ return this.toString();
+}
+
+/**
+ * Return the String value.
+ *
+ * @param {Number} [opt_radix] the radix in which the text should be written.
+ * @return {String} the textual representation of this value.
+ * @api public
+ */
+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));
+
+ var rem = this;
+ var result = '';
+ while (true) {
+ 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.
+ *
+ * @return {Number} the high 32-bits as a signed value.
+ * @api public
+ */
+Long.prototype.getHighBits = function() {
+ return this.high_;
+};
+
+/**
+ * Return the low 32-bits value.
+ *
+ * @return {Number} the low 32-bits as a signed value.
+ * @api public
+ */
+Long.prototype.getLowBits = function() {
+ return this.low_;
+};
+
+/**
+ * Return the low unsigned 32-bits value.
+ *
+ * @return {Number} the low 32-bits as an unsigned value.
+ * @api public
+ */
+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.
+ *
+ * @return {Number} Returns the number of bits needed to represent the absolute value of this Long.
+ * @api public
+ */
+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.
+ *
+ * @return {Boolean} whether this value is zero.
+ * @api public
+ */
+Long.prototype.isZero = function() {
+ return this.high_ == 0 && this.low_ == 0;
+};
+
+/**
+ * Return whether this value is negative.
+ *
+ * @return {Boolean} whether this value is negative.
+ * @api public
+ */
+Long.prototype.isNegative = function() {
+ return this.high_ < 0;
+};
+
+/**
+ * Return whether this value is odd.
+ *
+ * @return {Boolean} whether this value is odd.
+ * @api public
+ */
+Long.prototype.isOdd = function() {
+ return (this.low_ & 1) == 1;
+};
+
+/**
+ * Return whether this Long equals the other
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long equals the other
+ * @api public
+ */
+Long.prototype.equals = function(other) {
+ return (this.high_ == other.high_) && (this.low_ == other.low_);
+};
+
+/**
+ * Return whether this Long does not equal the other.
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long does not equal the other.
+ * @api public
+ */
+Long.prototype.notEquals = function(other) {
+ return (this.high_ != other.high_) || (this.low_ != other.low_);
+};
+
+/**
+ * Return whether this Long is less than the other.
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long is less than the other.
+ * @api public
+ */
+Long.prototype.lessThan = function(other) {
+ return this.compare(other) < 0;
+};
+
+/**
+ * Return whether this Long is less than or equal to the other.
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long is less than or equal to the other.
+ * @api public
+ */
+Long.prototype.lessThanOrEqual = function(other) {
+ return this.compare(other) <= 0;
+};
+
+/**
+ * Return whether this Long is greater than the other.
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long is greater than the other.
+ * @api public
+ */
+Long.prototype.greaterThan = function(other) {
+ return this.compare(other) > 0;
+};
+
+/**
+ * Return whether this Long is greater than or equal to the other.
+ *
+ * @param {Long} other Long to compare against.
+ * @return {Boolean} whether this Long is greater than or equal to the other.
+ * @api public
+ */
+Long.prototype.greaterThanOrEqual = function(other) {
+ return this.compare(other) >= 0;
+};
+
+/**
+ * Compares this Long with the given one.
+ *
+ * @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.
+ * @api public
+ */
+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.
+ *
+ * @return {Long} the negation of this value.
+ * @api public
+ */
+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.
+ *
+ * @param {Long} other Long to add to this one.
+ * @return {Long} the sum of this and the given Long.
+ * @api public
+ */
+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.
+ *
+ * @param {Long} other Long to subtract from this.
+ * @return {Long} the difference of this and the given Long.
+ * @api public
+ */
+Long.prototype.subtract = function(other) {
+ return this.add(other.negate());
+};
+
+/**
+ * Returns the product of this and the given Long.
+ *
+ * @param {Long} other Long to multiply with this.
+ * @return {Long} the product of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Long} other Long by which to divide.
+ * @return {Long} this Long divided by the given one.
+ * @api public
+ */
+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;
+ var rem = this;
+ while (rem.greaterThanOrEqual(other)) {
+ // Approximate the result of division. This may be a little greater or
+ // smaller than the actual value.
+ var 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.
+ *
+ * @param {Long} other Long by which to mod.
+ * @return {Long} this Long modulo the given one.
+ * @api public
+ */
+Long.prototype.modulo = function(other) {
+ return this.subtract(this.div(other).multiply(other));
+};
+
+/**
+ * The bitwise-NOT of this value.
+ *
+ * @return {Long} the bitwise-NOT of this value.
+ * @api public
+ */
+Long.prototype.not = function() {
+ return Long.fromBits(~this.low_, ~this.high_);
+};
+
+/**
+ * Returns the bitwise-AND of this Long and the given one.
+ *
+ * @param {Long} other the Long with which to AND.
+ * @return {Long} the bitwise-AND of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Long} other the Long with which to OR.
+ * @return {Long} the bitwise-OR of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Long} other the Long with which to XOR.
+ * @return {Long} the bitwise-XOR of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} numBits the number of bits by which to shift.
+ * @return {Long} this shifted to the left by the given amount.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} numBits the number of bits by which to shift.
+ * @return {Long} this shifted to the right by the given amount.
+ * @api public
+ */
+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.
+ *
+ * @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.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} value the 32-bit integer in question.
+ * @return {Long} the corresponding Long value.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} value the number in question.
+ * @return {Long} the corresponding Long value.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} lowBits the low 32-bits.
+ * @param {Number} highBits the high 32-bits.
+ * @return {Long} the corresponding Long value.
+ * @api public
+ */
+Long.fromBits = function(lowBits, highBits) {
+ return new Long(lowBits, highBits);
+};
+
+/**
+ * Returns a Long representation of the given string, written using the given radix.
+ *
+ * @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.
+ * @api public
+ */
+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}
+ * @api private
+ */
+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}
+ * @api private
+ */
+Long.TWO_PWR_16_DBL_ = 1 << 16;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Long.TWO_PWR_24_DBL_ = 1 << 24;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Long.TWO_PWR_32_DBL_ = Long.TWO_PWR_16_DBL_ * Long.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Long.TWO_PWR_31_DBL_ = Long.TWO_PWR_32_DBL_ / 2;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Long.TWO_PWR_48_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Long.TWO_PWR_64_DBL_ = Long.TWO_PWR_32_DBL_ * Long.TWO_PWR_32_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+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}
+ * @api private
+ */
+Long.TWO_PWR_24_ = Long.fromInt(1 << 24);
+
+/**
+ * Expose.
+ */
+exports.Long = Long;
+},
+
+
+
+'max_key': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON MaxKey type.
+ *
+ * @class Represents the BSON MaxKey type.
+ * @return {MaxKey}
+ */
+function MaxKey() {
+ if(!(this instanceof MaxKey)) return new MaxKey();
+
+ this._bsontype = 'MaxKey';
+}
+
+exports.MaxKey = MaxKey;
+},
+
+
+
+'min_key': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON MinKey type.
+ *
+ * @class Represents the BSON MinKey type.
+ * @return {MinKey}
+ */
+function MinKey() {
+ if(!(this instanceof MinKey)) return new MinKey();
+
+ this._bsontype = 'MinKey';
+}
+
+exports.MinKey = MinKey;
+},
+
+
+
+'objectid': function(module, exports, global, require, undefined){
+ /**
+ * Module dependencies.
+ */
+var BinaryParser = require('./binary_parser').BinaryParser;
+
+/**
+ * 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.
+ */
+var MACHINE_ID = parseInt(Math.random() * 0xFFFFFF, 10);
+
+// Regular expression that checks for hex value
+var checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$");
+
+/**
+* Create a new ObjectID instance
+*
+* @class Represents the BSON ObjectID type
+* @param {String|Number} id Can be a 24 byte hex string, 12 byte binary string or a Number.
+* @return {Object} instance of ObjectID.
+*/
+var ObjectID = function ObjectID(id, _hex) {
+ if(!(this instanceof ObjectID)) return new ObjectID(id, _hex);
+
+ this._bsontype = 'ObjectID';
+ var __id = null;
+
+ // Throw an error if it's not a valid setup
+ if(id != null && 'number' != typeof id && (id.length != 12 && id.length != 24))
+ throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
+
+ // Generate id based on the input
+ if(id == null || typeof id == 'number') {
+ // convert to 12 byte binary string
+ this.id = this.generate(id);
+ } else if(id != null && id.length === 12) {
+ // assume 12 byte string
+ this.id = id;
+ } else if(checkForHexRegExp.test(id)) {
+ return ObjectID.createFromHexString(id);
+ } else {
+ throw new Error("Value passed in is not a valid 24 character hex string");
+ }
+
+ if(ObjectID.cacheHexString) this.__id = this.toHexString();
+};
+
+// 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
+*
+* @return {String} return the 24 byte hex string representation.
+* @api public
+*/
+ObjectID.prototype.toHexString = function() {
+ if(ObjectID.cacheHexString && this.__id) return this.__id;
+
+ var 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
+*
+* @return {Number} returns next index value.
+* @api private
+*/
+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
+*
+* @return {Number} returns next index value.
+* @api private
+*/
+ObjectID.prototype.getInc = function() {
+ return this.get_inc();
+};
+
+/**
+* Generate a 12 byte id string used in ObjectID's
+*
+* @param {Number} [time] optional parameter allowing to pass in a second based timestamp.
+* @return {String} return the 12 byte id binary string.
+* @api private
+*/
+ObjectID.prototype.generate = function(time) {
+ if ('number' == typeof time) {
+ var time4Bytes = BinaryParser.encodeInt(time, 32, true, true);
+ /* for time-based ObjectID the bytes following the time will be zeroed */
+ var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false);
+ var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid);
+ var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true);
+ } else {
+ var unixTime = parseInt(Date.now()/1000,10);
+ var time4Bytes = BinaryParser.encodeInt(unixTime, 32, true, true);
+ var machine3Bytes = BinaryParser.encodeInt(MACHINE_ID, 24, false);
+ var pid2Bytes = BinaryParser.fromShort(typeof process === 'undefined' ? Math.floor(Math.random() * 100000) : process.pid);
+ var index3Bytes = BinaryParser.encodeInt(this.get_inc(), 24, false, true);
+ }
+
+ return time4Bytes + machine3Bytes + pid2Bytes + index3Bytes;
+};
+
+/**
+* Converts the id into a 24 byte hex string for printing
+*
+* @return {String} return the 24 byte hex string representation.
+* @api private
+*/
+ObjectID.prototype.toString = function() {
+ return this.toHexString();
+};
+
+/**
+* Converts to a string representation of this Id.
+*
+* @return {String} return the 24 byte hex string representation.
+* @api private
+*/
+ObjectID.prototype.inspect = ObjectID.prototype.toString;
+
+/**
+* Converts to its JSON representation.
+*
+* @return {String} return the 24 byte hex string representation.
+* @api private
+*/
+ObjectID.prototype.toJSON = function() {
+ return this.toHexString();
+};
+
+/**
+* Compares the equality of this ObjectID with `otherID`.
+*
+* @param {Object} otherID ObjectID instance to compare against.
+* @return {Bool} the result of comparing two ObjectID's
+* @api public
+*/
+ObjectID.prototype.equals = function equals (otherID) {
+ var id = (otherID instanceof ObjectID || otherID.toHexString)
+ ? otherID.id
+ : ObjectID.createFromHexString(otherID).id;
+
+ return this.id === id;
+}
+
+/**
+* Returns the generation date (accurate up to the second) that this ID was generated.
+*
+* @return {Date} the generation date
+* @api public
+*/
+ObjectID.prototype.getTimestamp = function() {
+ var timestamp = new Date();
+ timestamp.setTime(Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true)) * 1000);
+ return timestamp;
+}
+
+/**
+* @ignore
+* @api private
+*/
+ObjectID.index = parseInt(Math.random() * 0xFFFFFF, 10);
+
+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.
+*
+* @param {Number} time an integer number representing a number of seconds.
+* @return {ObjectID} return the created ObjectID
+* @api public
+*/
+ObjectID.createFromTime = function createFromTime (time) {
+ var id = BinaryParser.encodeInt(time, 32, true, true) +
+ BinaryParser.encodeInt(0, 64, true, true);
+ return new ObjectID(id);
+};
+
+/**
+* Creates an ObjectID from a hex string representation of an ObjectID.
+*
+* @param {String} hexString create a ObjectID from a passed in 24 byte hexstring.
+* @return {ObjectID} return the created ObjectID
+* @api public
+*/
+ObjectID.createFromHexString = function createFromHexString (hexString) {
+ // Throw an error if it's not a valid setup
+ if(typeof hexString === 'undefined' || hexString != null && hexString.length != 24)
+ throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");
+
+ var len = hexString.length;
+
+ if(len > 12*2) {
+ throw new Error('Id cannot be longer than 12 bytes');
+ }
+
+ var result = ''
+ , string
+ , number;
+
+ for (var index = 0; index < len; index += 2) {
+ string = hexString.substr(index, 2);
+ number = parseInt(string, 16);
+ result += BinaryParser.fromByte(number);
+ }
+
+ return new ObjectID(result, hexString);
+};
+
+/**
+* @ignore
+*/
+Object.defineProperty(ObjectID.prototype, "generationTime", {
+ enumerable: true
+ , get: function () {
+ return Math.floor(BinaryParser.decodeInt(this.id.substring(0,4), 32, true, true));
+ }
+ , set: function (value) {
+ var value = BinaryParser.encodeInt(value, 32, true, true);
+ this.id = value + this.id.substr(4);
+ // delete this.__id;
+ this.toHexString();
+ }
+});
+
+/**
+ * Expose.
+ */
+exports.ObjectID = ObjectID;
+exports.ObjectId = ObjectID;
+
+},
+
+
+
+'symbol': function(module, exports, global, require, undefined){
+ /**
+ * A class representation of the BSON Symbol type.
+ *
+ * @class Represents the BSON Symbol type.
+ * @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.
+ *
+ * @return {String} returns the wrapped string.
+ * @api public
+ */
+Symbol.prototype.valueOf = function() {
+ return this.value;
+};
+
+/**
+ * @ignore
+ * @api private
+ */
+Symbol.prototype.toString = function() {
+ return this.value;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+Symbol.prototype.inspect = function() {
+ return this.value;
+}
+
+/**
+ * @ignore
+ * @api private
+ */
+Symbol.prototype.toJSON = function() {
+ return this.value;
+}
+
+exports.Symbol = Symbol;
+},
+
+
+
+'timestamp': function(module, exports, global, require, undefined){
+ // 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 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 Represents the BSON Timestamp type.
+ * @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}
+ * @api private
+ */
+ this.low_ = low | 0; // force into 32 signed bits.
+
+ /**
+ * @type {number}
+ * @api private
+ */
+ this.high_ = high | 0; // force into 32 signed bits.
+};
+
+/**
+ * Return the int value.
+ *
+ * @return {Number} the value, assuming it is a 32-bit integer.
+ * @api public
+ */
+Timestamp.prototype.toInt = function() {
+ return this.low_;
+};
+
+/**
+ * Return the Number value.
+ *
+ * @return {Number} the closest floating-point representation to this value.
+ * @api public
+ */
+Timestamp.prototype.toNumber = function() {
+ return this.high_ * Timestamp.TWO_PWR_32_DBL_ +
+ this.getLowBitsUnsigned();
+};
+
+/**
+ * Return the JSON value.
+ *
+ * @return {String} the JSON representation.
+ * @api public
+ */
+Timestamp.prototype.toJSON = function() {
+ return this.toString();
+}
+
+/**
+ * Return the String value.
+ *
+ * @param {Number} [opt_radix] the radix in which the text should be written.
+ * @return {String} the textual representation of this value.
+ * @api public
+ */
+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));
+
+ var rem = this;
+ var result = '';
+ while (true) {
+ 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.
+ *
+ * @return {Number} the high 32-bits as a signed value.
+ * @api public
+ */
+Timestamp.prototype.getHighBits = function() {
+ return this.high_;
+};
+
+/**
+ * Return the low 32-bits value.
+ *
+ * @return {Number} the low 32-bits as a signed value.
+ * @api public
+ */
+Timestamp.prototype.getLowBits = function() {
+ return this.low_;
+};
+
+/**
+ * Return the low unsigned 32-bits value.
+ *
+ * @return {Number} the low 32-bits as an unsigned value.
+ * @api public
+ */
+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.
+ *
+ * @return {Number} Returns the number of bits needed to represent the absolute value of this Timestamp.
+ * @api public
+ */
+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.
+ *
+ * @return {Boolean} whether this value is zero.
+ * @api public
+ */
+Timestamp.prototype.isZero = function() {
+ return this.high_ == 0 && this.low_ == 0;
+};
+
+/**
+ * Return whether this value is negative.
+ *
+ * @return {Boolean} whether this value is negative.
+ * @api public
+ */
+Timestamp.prototype.isNegative = function() {
+ return this.high_ < 0;
+};
+
+/**
+ * Return whether this value is odd.
+ *
+ * @return {Boolean} whether this value is odd.
+ * @api public
+ */
+Timestamp.prototype.isOdd = function() {
+ return (this.low_ & 1) == 1;
+};
+
+/**
+ * Return whether this Timestamp equals the other
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp equals the other
+ * @api public
+ */
+Timestamp.prototype.equals = function(other) {
+ return (this.high_ == other.high_) && (this.low_ == other.low_);
+};
+
+/**
+ * Return whether this Timestamp does not equal the other.
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp does not equal the other.
+ * @api public
+ */
+Timestamp.prototype.notEquals = function(other) {
+ return (this.high_ != other.high_) || (this.low_ != other.low_);
+};
+
+/**
+ * Return whether this Timestamp is less than the other.
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp is less than the other.
+ * @api public
+ */
+Timestamp.prototype.lessThan = function(other) {
+ return this.compare(other) < 0;
+};
+
+/**
+ * Return whether this Timestamp is less than or equal to the other.
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp is less than or equal to the other.
+ * @api public
+ */
+Timestamp.prototype.lessThanOrEqual = function(other) {
+ return this.compare(other) <= 0;
+};
+
+/**
+ * Return whether this Timestamp is greater than the other.
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp is greater than the other.
+ * @api public
+ */
+Timestamp.prototype.greaterThan = function(other) {
+ return this.compare(other) > 0;
+};
+
+/**
+ * Return whether this Timestamp is greater than or equal to the other.
+ *
+ * @param {Timestamp} other Timestamp to compare against.
+ * @return {Boolean} whether this Timestamp is greater than or equal to the other.
+ * @api public
+ */
+Timestamp.prototype.greaterThanOrEqual = function(other) {
+ return this.compare(other) >= 0;
+};
+
+/**
+ * Compares this Timestamp with the given one.
+ *
+ * @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.
+ * @api public
+ */
+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.
+ *
+ * @return {Timestamp} the negation of this value.
+ * @api public
+ */
+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.
+ *
+ * @param {Timestamp} other Timestamp to add to this one.
+ * @return {Timestamp} the sum of this and the given Timestamp.
+ * @api public
+ */
+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.
+ *
+ * @param {Timestamp} other Timestamp to subtract from this.
+ * @return {Timestamp} the difference of this and the given Timestamp.
+ * @api public
+ */
+Timestamp.prototype.subtract = function(other) {
+ return this.add(other.negate());
+};
+
+/**
+ * Returns the product of this and the given Timestamp.
+ *
+ * @param {Timestamp} other Timestamp to multiply with this.
+ * @return {Timestamp} the product of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Timestamp} other Timestamp by which to divide.
+ * @return {Timestamp} this Timestamp divided by the given one.
+ * @api public
+ */
+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;
+ var rem = this;
+ while (rem.greaterThanOrEqual(other)) {
+ // Approximate the result of division. This may be a little greater or
+ // smaller than the actual value.
+ var 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.
+ *
+ * @param {Timestamp} other Timestamp by which to mod.
+ * @return {Timestamp} this Timestamp modulo the given one.
+ * @api public
+ */
+Timestamp.prototype.modulo = function(other) {
+ return this.subtract(this.div(other).multiply(other));
+};
+
+/**
+ * The bitwise-NOT of this value.
+ *
+ * @return {Timestamp} the bitwise-NOT of this value.
+ * @api public
+ */
+Timestamp.prototype.not = function() {
+ return Timestamp.fromBits(~this.low_, ~this.high_);
+};
+
+/**
+ * Returns the bitwise-AND of this Timestamp and the given one.
+ *
+ * @param {Timestamp} other the Timestamp with which to AND.
+ * @return {Timestamp} the bitwise-AND of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Timestamp} other the Timestamp with which to OR.
+ * @return {Timestamp} the bitwise-OR of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Timestamp} other the Timestamp with which to XOR.
+ * @return {Timestamp} the bitwise-XOR of this and the other.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} numBits the number of bits by which to shift.
+ * @return {Timestamp} this shifted to the left by the given amount.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} numBits the number of bits by which to shift.
+ * @return {Timestamp} this shifted to the right by the given amount.
+ * @api public
+ */
+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.
+ *
+ * @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.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} value the 32-bit integer in question.
+ * @return {Timestamp} the corresponding Timestamp value.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} value the number in question.
+ * @return {Timestamp} the corresponding Timestamp value.
+ * @api public
+ */
+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.
+ *
+ * @param {Number} lowBits the low 32-bits.
+ * @param {Number} highBits the high 32-bits.
+ * @return {Timestamp} the corresponding Timestamp value.
+ * @api public
+ */
+Timestamp.fromBits = function(lowBits, highBits) {
+ return new Timestamp(lowBits, highBits);
+};
+
+/**
+ * Returns a Timestamp representation of the given string, written using the given radix.
+ *
+ * @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.
+ * @api public
+ */
+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}
+ * @api private
+ */
+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}
+ * @api private
+ */
+Timestamp.TWO_PWR_16_DBL_ = 1 << 16;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Timestamp.TWO_PWR_24_DBL_ = 1 << 24;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Timestamp.TWO_PWR_32_DBL_ = Timestamp.TWO_PWR_16_DBL_ * Timestamp.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Timestamp.TWO_PWR_31_DBL_ = Timestamp.TWO_PWR_32_DBL_ / 2;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Timestamp.TWO_PWR_48_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_16_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+Timestamp.TWO_PWR_64_DBL_ = Timestamp.TWO_PWR_32_DBL_ * Timestamp.TWO_PWR_32_DBL_;
+
+/**
+ * @type {number}
+ * @api private
+ */
+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}
+ * @api private
+ */
+Timestamp.TWO_PWR_24_ = Timestamp.fromInt(1 << 24);
+
+/**
+ * Expose.
+ */
+exports.Timestamp = Timestamp;
+},
+
+ });
+
+
+if(typeof module != 'undefined' && module.exports ){
+ module.exports = bson;
+
+ if( !module.parent ){
+ bson();
+ }
+}
+
+if(typeof window != 'undefined' && typeof require == 'undefined'){
+ window.require = bson.require;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/package.json
new file mode 100644
index 0000000..3ebb587
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/browser_build/package.json
@@ -0,0 +1,8 @@
+{ "name" : "bson"
+, "description" : "A bson parser for node.js and the browser"
+, "main": "../lib/bson/bson"
+, "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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/deserializer_bak.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/deserializer_bak.js
new file mode 100644
index 0000000..c879ad5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/deserializer_bak.js
@@ -0,0 +1,357 @@
+"use strict"
+
+var writeIEEE754 = require('../float_parser').writeIEEE754,
+ readIEEE754 = require('../float_parser').readIEEE754,
+ f = require('util').format,
+ 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,
+ DBRef = require('../db_ref').DBRef,
+ BSONRegExp = require('../regexp').BSONRegExp,
+ Binary = require('../binary').Binary;
+
+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
+ *
+ * @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;
+
+// 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.
+
+var deserialize = function(buffer, options, isArray) {
+ var index = 0;
+ // 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 || buffer.length < size) {
+ throw new Error("corrupt bson message");
+ }
+
+ // Illegal end value
+ if(buffer[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, options, isArray);
+}
+
+// // Reads in a C style string
+// var readCStyleStringSpecial = function(buffer, index) {
+// // 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")
+// // Grab utf8 encoded string
+// var string = buffer.toString('utf8', index, i);
+// // Update index position
+// index = i + 1;
+// // Return string
+// return {s: string, i: index};
+// }
+
+// Reads in a C style string
+var readCStyleStringSpecial = function(buffer, index) {
+ // 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")
+ // Grab utf8 encoded string
+ return buffer.toString('utf8', index, i);
+}
+
+var DeserializationMethods = {}
+DeserializationMethods[BSON.BSON_DATA_OID] = function(name, object, buffer, index) {
+ var string = buffer.toString('binary', index, index + 12);
+ object[name] = new ObjectID(string);
+ return index + 12;
+}
+
+DeserializationMethods[BSON.BSON_DATA_NUMBER] = function(name, object, buffer, index) {
+ object[name] = buffer.readDoubleLE(index);
+ return index + 8;
+}
+
+DeserializationMethods[BSON.BSON_DATA_INT] = function(name, object, buffer, index) {
+ object[name] = buffer.readInt32LE(index);
+ return index + 4;
+}
+
+DeserializationMethods[BSON.BSON_DATA_TIMESTAMP] = function(name, object, buffer, index) {
+ 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 Timestamp(lowBits, highBits);
+ return index;
+}
+
+DeserializationMethods[BSON.BSON_DATA_STRING] = function(name, object, buffer, index) {
+ 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);
+ return index + stringSize;
+}
+
+DeserializationMethods[BSON.BSON_DATA_BOOLEAN] = function(name, object, buffer, index) {
+ object[name] = buffer[index++] == 1;
+ return index;
+}
+
+var deserializeObject = function(buffer, options, isArray) {
+ // Options
+ options = options == null ? {} : options;
+ var evalFunctions = options['evalFunctions'] == null ? false : options['evalFunctions'];
+ var cacheFunctions = options['cacheFunctions'] == null ? false : options['cacheFunctions'];
+ var cacheFunctionsCrc32 = options['cacheFunctionsCrc32'] == null ? false : options['cacheFunctionsCrc32'];
+ var promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs'];
+ var fieldsAsRaw = options['fieldsAsRaw'] == null ? {} : options['fieldsAsRaw'];
+ // Return BSONRegExp objects instead of native regular expressions
+ var bsonRegExp = typeof options['bsonRegExp'] == 'boolean' ? options['bsonRegExp'] : false;
+ var promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers'];
+
+ // Validate that we have at least 4 bytes of buffer
+ if(buffer.length < 5) throw new Error("corrupt bson message < 5 bytes long");
+
+ // Set up index
+ var index = typeof options['index'] == 'number' ? options['index'] : 0;
+
+ // 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 ? [] : {};
+
+ // While we have more left data left keep parsing
+ while(true) {
+ // Read the type
+ var elementType = buffer[index++];
+ // If we get a zero it's the last byte, exit
+ if(elementType == 0) break;
+ var name = readCStyleStringSpecial(buffer, index);
+ index = index + name.length + 1;
+
+ // console.log("----------- 0 " + elementType + " :: " + name)
+ index = DeserializationMethods[elementType](name, object, buffer, index);
+ // console.log('--------------- 1')
+ }
+
+ // Check if we have a db ref object
+ if(object['$id'] != null) object = new DBRef(object['$ref'], object['$id'], object['$db']);
+
+ // Return the final objects
+ 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;
+}
+
+module.exports = deserialize
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/binary.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/binary.js
new file mode 100644
index 0000000..793b56f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/binary.js
@@ -0,0 +1,347 @@
+/**
+ * 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);
+
+ 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 {
+ var 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(var 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(var 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/bson.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/bson.js
new file mode 100644
index 0000000..bd2ee6c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/bson.js
@@ -0,0 +1,327 @@
+"use strict"
+
+var writeIEEE754 = require('./float_parser').writeIEEE754,
+ readIEEE754 = require('./float_parser').readIEEE754,
+ 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
+ */
+// Max Size
+var MAXSIZE = (1024*1024*17);
+// Max Document Buffer size
+var buffer = new Buffer(MAXSIZE);
+
+var BSON = function() {
+}
+
+/**
+ * Serialize a Javascript object.
+ *
+ * @param {Object} object the Javascript object to serialize.
+ * @param {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Buffer} returns the Buffer object containing the serialized object.
+ * @api public
+ */
+BSON.prototype.serialize = function serialize(object, checkKeys, asBuffer, serializeFunctions, index, ignoreUndefined) {
+ // Attempt to serialize
+ var serializationIndex = serializer(buffer, object, checkKeys, index || 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 {Boolean} checkKeys the serializer will check if keys are valid.
+ * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
+ * @param {Number} index the index in the buffer where we wish to start serializing into.
+ * @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**.
+ * @return {Number} returns the index pointing to the last written byte in the buffer.
+ * @api public
+ */
+BSON.prototype.serializeWithBufferAndIndex = function(object, checkKeys, finalBuffer, startIndex, serializeFunctions, ignoreUndefined) {
+ // Attempt to serialize
+ var serializationIndex = serializer(buffer, object, checkKeys, startIndex || 0, 0, serializeFunctions, ignoreUndefined);
+ buffer.copy(finalBuffer, startIndex, 0, serializationIndex);
+ // Return the index
+ return serializationIndex - 1;
+}
+
+/**
+ * Deserialize data as BSON.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
+ * @param {Object} [options] additional options used for the deserialization.
+ * @param {Boolean} [isArray] ignore used for recursive parsing.
+ * @return {Object} returns the deserialized Javascript Object.
+ * @api public
+ */
+BSON.prototype.deserialize = function(data, options) {
+ return deserialize(data, 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} [serializeFunctions] serialize all functions in the object **(default:false)**.
+ * @return {Number} returns the number of bytes the BSON object will take up.
+ * @api public
+ */
+BSON.prototype.calculateObjectSize = function(object, serializeFunctions, ignoreUndefined) {
+ return calculateObjectSize(object, serializeFunctions, ignoreUndefined);
+}
+
+/**
+ * Deserialize stream data as BSON documents.
+ *
+ * Options
+ * - **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
+ * - **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
+ * - **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
+ * - **promoteLongs** {Boolean, default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits
+ *
+ * @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.
+ * @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) {
+ // if(numberOfDocuments !== documents.length) throw new Error("Number of expected results back is less than the number of documents");
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/code.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/code.js
new file mode 100644
index 0000000..bc80ce5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/db_ref.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/db_ref.js
new file mode 100644
index 0000000..06789a6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/decimal128.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/decimal128.js
new file mode 100644
index 0000000..23ae082
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/decimal128.js
@@ -0,0 +1,728 @@
+"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(var 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');
+}
+
+var Decimal128 = function(bytes) {
+ this._bsontype = 'Decimal128';
+ this.bytes = bytes;
+}
+
+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();
+
+ // 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
+ 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))
+ }
+ }
+ }
+
+
+ // 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(var 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) {
+ var 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 {
+ var 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
+ var 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);
+ var 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
+var EXPONENT_BIAS = 6176;
+
+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
+ var i;
+ var j, k;
+
+ // Output string
+ var string = [];
+
+ // Unpack index
+ var 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
+ var 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(var 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(var 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;
+ var 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(var 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(var 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(var 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(var 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/double.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/double.js
new file mode 100644
index 0000000..82c5bd6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/float_parser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/float_parser.js
new file mode 100644
index 0000000..6fca392
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/float_parser.js
@@ -0,0 +1,121 @@
+// 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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/index.js
new file mode 100644
index 0000000..a11199a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/index.js
@@ -0,0 +1,90 @@
+try {
+ exports.BSONPure = require('./bson');
+ exports.BSONNative = require('./bson');
+} catch(err) {
+}
+
+[ 'binary'
+ , 'code'
+ , 'map'
+ , 'db_ref'
+ , 'double'
+ , 'int_32'
+ , 'max_key'
+ , 'min_key'
+ , 'objectid'
+ , 'regexp'
+ , 'symbol'
+ , 'decimal128'
+ , 'timestamp'
+ , 'long'
+ , 'bson'].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ exports[i] = module[i];
+ }
+});
+
+// Exports all the classes for the PURE JS BSON Parser
+exports.pure = function() {
+ var classes = {};
+ // Map all the classes
+ [ 'binary'
+ , 'code'
+ , 'map'
+ , 'db_ref'
+ , 'double'
+ , 'int_32'
+ , 'max_key'
+ , 'min_key'
+ , 'objectid'
+ , 'regexp'
+ , 'symbol'
+ , 'decimal128'
+ , 'timestamp'
+ , 'long'
+ , 'bson'].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ classes[i] = module[i];
+ }
+ });
+ // Return classes list
+ return classes;
+}
+
+// Exports all the classes for the NATIVE JS BSON Parser
+exports.native = function() {
+ var classes = {};
+ // Map all the classes
+ [ 'binary'
+ , 'code'
+ , 'map'
+ , 'db_ref'
+ , 'double'
+ , 'int_32'
+ , 'max_key'
+ , 'min_key'
+ , 'objectid'
+ , 'regexp'
+ , 'symbol'
+ , 'decimal128'
+ , 'timestamp'
+ , 'long'
+ , 'bson'].forEach(function (path) {
+ var module = require('./' + path);
+ for (var i in module) {
+ classes[i] = module[i];
+ }
+ });
+
+ // Catch error and return no classes found
+ try {
+ classes['BSON'] = require('./bson');
+ } catch(err) {
+ return exports.pure();
+ }
+
+ // Return classes list
+ return classes;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/int_32.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/int_32.js
new file mode 100644
index 0000000..6c729f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/int_32.js
@@ -0,0 +1,26 @@
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/long.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/long.js
new file mode 100644
index 0000000..6f18885
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/long.js
@@ -0,0 +1,856 @@
+// 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));
+
+ var rem = this;
+ var result = '';
+ while (true) {
+ 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;
+ var rem = this;
+ while (rem.greaterThanOrEqual(other)) {
+ // Approximate the result of division. This may be a little greater or
+ // smaller than the actual value.
+ var 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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/map.js
new file mode 100644
index 0000000..f53c8c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/map.js
@@ -0,0 +1,126 @@
+"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(key) {
+ 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(key, value) {
+ 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;
+} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/max_key.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/max_key.js
new file mode 100644
index 0000000..03ee9cd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/min_key.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/min_key.js
new file mode 100644
index 0000000..5e120fb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/objectid.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/objectid.js
new file mode 100644
index 0000000..83b85d7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/objectid.js
@@ -0,0 +1,343 @@
+/**
+ * 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}$");
+
+/**
+* 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';
+
+ var __id = null;
+ 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) {
+ return ObjectID.createFromHexString(id);
+ } else if(id == null || typeof id == 'number') {
+ // convert to 12 byte binary string
+ this.id = this.generate(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.toHexString();
+};
+
+// 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' ? 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
+*
+* @return {String} return the 24 byte hex string representation.
+* @ignore
+*/
+ObjectID.prototype.toString = function() {
+ 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 === 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 = []
+var 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");
+
+ var length = string.length;
+
+ if(length > 12*2) {
+ throw new Error('Id cannot be longer than 12 bytes');
+ }
+
+ // Calculate lengths
+ var sizeof = length >> 1;
+ var array = new _Buffer(sizeof);
+ var n = 0;
+ var i = 0;
+
+ while (i < length) {
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/calculate_size.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/calculate_size.js
new file mode 100644
index 0000000..53d338f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/calculate_size.js
@@ -0,0 +1,152 @@
+"use strict"
+
+var writeIEEE754 = require('../float_parser').writeIEEE754
+ , readIEEE754 = require('../float_parser').readIEEE754
+ , 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;
+
+// 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(value.toString(), 'utf8') + 1 + calculateObjectSize(value.scope, serializeFunctions, ignoreUndefined);
+ } else if(serializeFunctions) {
+ return (name != null ? (Buffer.byteLength(name, 'utf8') + 1) : 0) + 1 + 4 + Buffer.byteLength(value.toString(), '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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/deserializer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/deserializer.js
new file mode 100644
index 0000000..bb27cd4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/deserializer.js
@@ -0,0 +1,653 @@
+"use strict"
+
+var readIEEE754 = require('../float_parser').readIEEE754,
+ f = require('util').format,
+ 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'];
+ 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;
+
+ // While we have more left data left keep parsing
+ while(true) {
+ // 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) {
+ var _index = index;
+ var 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
+ 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;
+ 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(var 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
+ 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")
+ // Return the C string
+ var source = buffer.toString('utf8', index, i);
+ // Create the regexp
+ index = i + 1;
+
+ // 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")
+ // 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(var 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
+ 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")
+ // Return the C string
+ var source = buffer.toString('utf8', index, i);
+ index = i + 1;
+
+ // 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")
+ // Return the C string
+ var 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) {
+ 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] = new Symbol(buffer.toString('utf8', index, index + stringSize - 1));
+ index = index + stringSize;
+ } else if(elementType == BSON.BSON_DATA_TIMESTAMP) {
+ 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 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) {
+ 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");
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
+
+ // If we are evaluating the functions
+ if(evalFunctions) {
+ var value = null;
+ // 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
+ var 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
+ var functionString = buffer.toString('utf8', index, index + stringSize - 1);
+ // Update parse index position
+ index = index + stringSize;
+ // Parse the element
+ var _index = index;
+ // Decode the size of the object document
+ var 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) {
+ // Contains the value we are going to set
+ var value = null;
+ // 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);
+ }
+
+ object[name].scope = scopeObject;
+ } else {
+ object[name] = new Code(functionString, scopeObject);
+ }
+ } else if(elementType == BSON_DATA_DBPOINTER) {
+ // Get the code string size
+ var 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);
+ var 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/serializer.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/serializer.js
new file mode 100644
index 0000000..1b2f83f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/parser/serializer.js
@@ -0,0 +1,991 @@
+"use strict"
+
+var writeIEEE754 = require('../float_parser').writeIEEE754,
+ readIEEE754 = require('../float_parser').readIEEE754,
+ Long = require('../long').Long,
+ Map = require('../map'),
+ Double = require('../double').Double,
+ Timestamp = require('../timestamp').Timestamp,
+ ObjectID = require('../objectid').ObjectID,
+ Symbol = require('../symbol').Symbol,
+ Code = require('../code').Code,
+ BSONRegExp = require('../regexp').BSONRegExp,
+ Int32 = require('../int_32').Int32,
+ MinKey = require('../min_key').MinKey,
+ MaxKey = require('../max_key').MaxKey,
+ Decimal128 = require('../decimal128'),
+ DBRef = require('../db_ref').DBRef,
+ Binary = require('../binary').Binary;
+
+try {
+ var _Buffer = Uint8Array;
+} catch(e) {
+ var _Buffer = Buffer;
+}
+
+var regexp = /\x00/
+
+// 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
+ 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;
+ } else {
+ // Set long type
+ buffer[index++] = BSON.BSON_DATA_LONG;
+ // 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 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
+ 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 serializeUndefined = 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;
+ // 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
+ var size = endIndex - index;
+ 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 = value.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 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
+ 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 = 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(type == 'undefined' || value == null) {
+ index = serializeUndefined(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
+ var key = entry.value[0];
+ var value = entry.value[1];
+
+ // Check the type of the value
+ var 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) {
+ index = serializeUndefined(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(var key in object) {
+ var 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
+ var 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) {
+ index = serializeUndefined(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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/regexp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/regexp.js
new file mode 100644
index 0000000..6b148b2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/regexp.js
@@ -0,0 +1,30 @@
+/**
+ * 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 < 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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/symbol.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/symbol.js
new file mode 100644
index 0000000..7681a4d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/symbol.js
@@ -0,0 +1,47 @@
+/**
+ * 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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/timestamp.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/timestamp.js
new file mode 100644
index 0000000..7718caf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/lib/bson/timestamp.js
@@ -0,0 +1,856 @@
+// 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));
+
+ var rem = this;
+ var result = '';
+ while (true) {
+ 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;
+ var rem = this;
+ while (rem.greaterThanOrEqual(other)) {
+ // Approximate the result of division. This may be a little greater or
+ // smaller than the actual value.
+ var 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; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/package.json
new file mode 100644
index 0000000..85c3813
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "bson",
+ "description": "A bson parser for node.js and the browser",
+ "keywords": [
+ "mongodb",
+ "bson",
+ "parser"
+ ],
+ "files": [
+ "lib",
+ "browser_build",
+ "alternate_parsers",
+ "bower.json",
+ "tools",
+ "deserializer_bak.js"
+ ],
+ "version": "0.5.7",
+ "author": {
+ "name": "Christian Amor Kvalheim",
+ "email": "christkv@gmail.com"
+ },
+ "contributors": [],
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/mongodb/js-bson.git"
+ },
+ "bugs": {
+ "url": "https://github.com/mongodb/js-bson/issues"
+ },
+ "devDependencies": {
+ "benchmark": "1.0.0",
+ "colors": "1.1.0",
+ "gleak": "0.2.3",
+ "nodeunit": "0.9.0"
+ },
+ "config": {
+ "native": false
+ },
+ "main": "./lib/bson/index",
+ "directories": {
+ "lib": "./lib/bson"
+ },
+ "engines": {
+ "node": ">=0.6.19"
+ },
+ "scripts": {
+ "test": "nodeunit ./test/node"
+ },
+ "browser": "lib/bson/bson.js",
+ "license": "Apache-2.0",
+ "gitHead": "c3bc67c4e89e795beca2d6d309e7a840b740574d",
+ "homepage": "https://github.com/mongodb/js-bson#readme",
+ "_id": "bson@0.5.7",
+ "_shasum": "0d11fe0936c1fee029e11f7063f5d0ab2422ea3e",
+ "_from": "bson@>=0.5.4 <0.6.0",
+ "_npmVersion": "3.10.8",
+ "_nodeVersion": "6.9.1",
+ "_npmUser": {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ },
+ "dist": {
+ "shasum": "0d11fe0936c1fee029e11f7063f5d0ab2422ea3e",
+ "tarball": "https://registry.npmjs.org/bson/-/bson-0.5.7.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "octave",
+ "email": "chinsay@gmail.com"
+ },
+ {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-18-east.internal.npmjs.com",
+ "tmp": "tmp/bson-0.5.7.tgz_1479477418380_0.5046395626850426"
+ },
+ "_resolved": "https://registry.npmjs.org/bson/-/bson-0.5.7.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/tools/gleak.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/tools/gleak.js
new file mode 100644
index 0000000..c707cfc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/bson/tools/gleak.js
@@ -0,0 +1,21 @@
+
+var gleak = require('gleak')();
+gleak.ignore('AssertionError');
+gleak.ignore('testFullSpec_param_found');
+gleak.ignore('events');
+gleak.ignore('Uint8Array');
+gleak.ignore('Uint8ClampedArray');
+gleak.ignore('TAP_Global_Harness');
+gleak.ignore('setImmediate');
+gleak.ignore('clearImmediate');
+
+gleak.ignore('DTRACE_NET_SERVER_CONNECTION');
+gleak.ignore('DTRACE_NET_STREAM_END');
+gleak.ignore('DTRACE_NET_SOCKET_READ');
+gleak.ignore('DTRACE_NET_SOCKET_WRITE');
+gleak.ignore('DTRACE_HTTP_SERVER_REQUEST');
+gleak.ignore('DTRACE_HTTP_SERVER_RESPONSE');
+gleak.ignore('DTRACE_HTTP_CLIENT_REQUEST');
+gleak.ignore('DTRACE_HTTP_CLIENT_RESPONSE');
+
+module.exports = gleak;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/.npmignore
new file mode 100644
index 0000000..96e29a8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/.npmignore
@@ -0,0 +1,2 @@
+**.swp
+node_modules
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/Makefile
new file mode 100644
index 0000000..1db5d65
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/Makefile
@@ -0,0 +1,9 @@
+test:
+ @NODE_ENV=test ./node_modules/expresso/bin/expresso \
+ $(TESTFLAGS) \
+ ./test.js
+
+test-cov:
+ @TESTFLAGS=--cov $(MAKE) test
+
+.PHONY: test test-cov
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/README.md
new file mode 100644
index 0000000..98fe85b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/README.md
@@ -0,0 +1,369 @@
+hooks
+============
+
+Add pre and post middleware hooks to your JavaScript methods.
+
+## Installation
+ npm install hooks
+
+## Motivation
+Suppose you have a JavaScript object with a `save` method.
+
+It would be nice to be able to declare code that runs before `save` and after `save`.
+For example, you might want to run validation code before every `save`,
+and you might want to dispatch a job to a background job queue after `save`.
+
+One might have an urge to hard code this all into `save`, but that turns out to
+couple all these pieces of functionality (validation, save, and job creation) more
+tightly than is necessary. For example, what if someone does not want to do background
+job creation after the logical save?
+
+It is nicer to tack on functionality using what we call `pre` and `post` hooks. These
+are functions that you define and that you direct to execute before or after particular
+methods.
+
+## Example
+We can use `hooks` to add validation and background jobs in the following way:
+
+```javascript
+var hooks = require('hooks')
+ , Document = require('./path/to/some/document/constructor');
+
+// Add hooks' methods: `hook`, `pre`, and `post`
+for (var k in hooks) {
+ Document[k] = hooks[k];
+}
+
+// Define a new method that is able to invoke pre and post middleware
+Document.hook('save', Document.prototype.save);
+
+// Define a middleware function to be invoked before 'save'
+Document.pre('save', function validate (next) {
+ // The `this` context inside of `pre` and `post` functions
+ // is the Document instance
+ if (this.isValid()) next(); // next() passes control to the next middleware
+ // or to the target method itself
+ else next(new Error("Invalid")); // next(error) invokes an error callback
+});
+
+// Define a middleware function to be invoked after 'save'
+Document.post('save', function createJob (next) {
+ this.sendToBackgroundQueue();
+ next();
+});
+```
+
+If you already have defined `Document.prototype` methods for which you want pres and posts,
+then you do not need to explicitly invoke `Document.hook(...)`. Invoking `Document.pre(methodName, fn)`
+or `Document.post(methodName, fn)` will automatically and lazily change `Document.prototype[methodName]`
+so that it plays well with `hooks`. An equivalent way to implement the previous example is:
+
+```javascript
+var hooks = require('hooks')
+ , Document = require('./path/to/some/document/constructor');
+
+// Add hooks' methods: `hook`, `pre`, and `post`
+for (var k in hooks) {
+ Document[k] = hooks[k];
+}
+
+Document.prototype.save = function () {
+ // ...
+};
+
+// Define a middleware function to be invoked before 'save'
+Document.pre('save', function validate (next) {
+ // The `this` context inside of `pre` and `post` functions
+ // is the Document instance
+ if (this.isValid()) next(); // next() passes control to the next middleware
+ // or to the target method itself
+ else next(new Error("Invalid")); // next(error) invokes an error callback
+});
+
+// Define a middleware function to be invoked after 'save'
+Document.post('save', function createJob (next) {
+ this.sendToBackgroundQueue();
+ next();
+});
+```
+
+## Pres and Posts as Middleware
+We structure pres and posts as middleware to give you maximum flexibility:
+
+1. You can define **multiple** pres (or posts) for a single method.
+2. These pres (or posts) are then executed as a chain of methods.
+3. Any functions in this middleware chain can choose to halt the chain's execution by `next`ing an Error from that middleware function. If this occurs, then none of the other middleware in the chain will execute, and the main method (e.g., `save`) will not execute. This is nice, for example, when we don't want a document to save if it is invalid.
+
+## Defining multiple pres (or posts)
+`pre` and `post` are chainable, so you can define multiple via:
+```javascript
+Document.pre('save', function (next) {
+ console.log("hello");
+ next();
+}).pre('save', function (next) {
+ console.log("world");
+ next();
+});
+
+Document.post('save', function (next) {
+ console.log("hello");
+ next();
+}).post('save', function (next) {
+ console.log("world");
+ next();
+});
+```
+
+As soon as one pre finishes executing, the next one will be invoked, and so on.
+
+## Error Handling
+You can define a default error handler by passing a 2nd function as the 3rd argument to `hook`:
+```javascript
+Document.hook('set', function (path, val) {
+ this[path] = val;
+}, function (err) {
+ // Handler the error here
+ console.error(err);
+});
+```
+
+Then, we can pass errors to this handler from a pre or post middleware function:
+```javascript
+Document.pre('set', function (next, path, val) {
+ next(new Error());
+});
+```
+
+If you do not set up a default handler, then `hooks` makes the default handler that just throws the `Error`.
+
+The default error handler can be over-rided on a per method invocation basis.
+
+If the main method that you are surrounding with pre and post middleware expects its last argument to be a function
+with callback signature `function (error, ...)`, then that callback becomes the error handler, over-riding the default
+error handler you may have set up.
+
+```javascript
+Document.hook('save', function (callback) {
+ // Save logic goes here
+ ...
+});
+
+var doc = new Document();
+doc.save( function (err, saved) {
+ // We can pass err via `next` in any of our pre or post middleware functions
+ if (err) console.error(err);
+
+ // Rest of callback logic follows ...
+});
+```
+
+## Mutating Arguments via Middleware
+`pre` and `post` middleware can also accept the intended arguments for the method
+they augment. This is useful if you want to mutate the arguments before passing
+them along to the next middleware and eventually pass a mutated arguments list to
+the main method itself.
+
+As a simple example, let's define a method `set` that just sets a key, value pair.
+If we want to namespace the key, we can do so by adding a `pre` middleware hook
+that runs before `set`, alters the arguments by namespacing the `key` argument, and passes them onto `set`:
+
+```javascript
+Document.hook('set', function (key, val) {
+ this[key] = val;
+});
+Document.pre('set', function (next, key, val) {
+ next('namespace-' + key, val);
+});
+var doc = new Document();
+doc.set('hello', 'world');
+console.log(doc.hello); // undefined
+console.log(doc['namespace-hello']); // 'world'
+```
+
+As you can see above, we pass arguments via `next`.
+
+If you are not mutating the arguments, then you can pass zero arguments
+to `next`, and the next middleware function will still have access
+to the arguments.
+
+```javascript
+Document.hook('set', function (key, val) {
+ this[key] = val;
+});
+Document.pre('set', function (next, key, val) {
+ // I have access to key and val here
+ next(); // We don't need to pass anything to next
+});
+Document.pre('set', function (next, key, val) {
+ // And I still have access to the original key and val here
+ next();
+});
+```
+
+Finally, you can add arguments that downstream middleware can also see:
+
+```javascript
+// Note that in the definition of `set`, there is no 3rd argument, options
+Document.hook('set', function (key, val) {
+ // But...
+ var options = arguments[2]; // ...I have access to an options argument
+ // because of pre function pre2 (defined below)
+ console.log(options); // '{debug: true}'
+ this[key] = val;
+});
+Document.pre('set', function pre1 (next, key, val) {
+ // I only have access to key and val arguments
+ console.log(arguments.length); // 3
+ next(key, val, {debug: true});
+});
+Document.pre('set', function pre2 (next, key, val, options) {
+ console.log(arguments.length); // 4
+ console.log(options); // '{ debug: true}'
+ next();
+});
+Document.pre('set', function pre3 (next, key, val, options) {
+ // I still have access to key, val, AND the options argument introduced via the preceding middleware
+ console.log(arguments.length); // 4
+ console.log(options); // '{ debug: true}'
+ next();
+});
+
+var doc = new Document()
+doc.set('hey', 'there');
+```
+
+## Post middleware
+
+Post middleware intercepts the callback originally sent to the asynchronous function you have hooked to.
+
+This means that the following chain of execution will occur in a typical `save` operation:
+
+(1) doc.save -> (2) pre --(next)--> (3) save calls back -> (4) post --(next)--> (5) targetFn
+
+Illustrated below:
+
+```
+Document.pre('save', function (next) {
+ this.key = "value";
+ next();
+});
+// Post handler occurs before `set` calls back. This is useful if we need to grab something
+// async before `set` finishes.
+Document.post('set', function (next) {
+ var me = this;
+ getSomethingAsync(function(value){ // let's assume it returns "Hello Async"
+ me.key2 = value;
+ next();
+ });
+});
+
+var doc = new Document();
+doc.save(function(err){
+ console.log(this.key); // "value" - this value was saved
+ console.log(this.key2); // "Hello Async" - this value was *not* saved
+}
+
+```
+
+Post middleware must call `next()` or execution will stop.
+
+## Parallel `pre` middleware
+
+All middleware up to this point has been "serial" middleware -- i.e., middleware whose logic
+is executed as a serial chain.
+
+Some scenarios call for parallel middleware -- i.e., middleware that can wait for several
+asynchronous services at once to respond.
+
+For instance, you may only want to save a Document only after you have checked
+that the Document is valid according to two different remote services.
+
+We accomplish asynchronous middleware by adding a second kind of flow control callback
+(the only flow control callback so far has been `next`), called `done`.
+
+- `next` passes control to the next middleware in the chain
+- `done` keeps track of how many parallel middleware have invoked `done` and passes
+ control to the target method when ALL parallel middleware have invoked `done`. If
+ you pass an `Error` to `done`, then the error is handled, and the main method that is
+ wrapped by pres and posts will not get invoked.
+
+We declare pre middleware that is parallel by passing a 3rd boolean argument to our `pre`
+definition method.
+
+We illustrate via the parallel validation example mentioned above:
+
+```javascript
+Document.hook('save', function targetFn (callback) {
+ // Save logic goes here
+ // ...
+ // This only gets run once the two `done`s are both invoked via preOne and preTwo.
+});
+
+ // true marks this as parallel middleware
+Document.pre('save', true, function preOne (next, doneOne, callback) {
+ remoteServiceOne.validate(this.serialize(), function (err, isValid) {
+ // The code in here will probably be run after the `next` below this block
+ // and could possibly be run after the console.log("Hola") in `preTwo
+ if (err) return doneOne(err);
+ if (isValid) doneOne();
+ });
+ next(); // Pass control to the next middleware
+});
+
+// We will suppose that we need 2 different remote services to validate our document
+Document.pre('save', true, function preTwo (next, doneTwo, callback) {
+ remoteServiceTwo.validate(this.serialize(), function (err, isValid) {
+ if (err) return doneTwo(err);
+ if (isValid) doneTwo();
+ });
+ next();
+});
+
+// While preOne and preTwo are parallel, preThree is a serial pre middleware
+Document.pre('save', function preThree (next, callback) {
+ next();
+});
+
+var doc = new Document();
+doc.save( function (err, doc) {
+ // Do stuff with the saved doc here...
+});
+```
+
+In the above example, flow control may happen in the following way:
+
+(1) doc.save -> (2) preOne --(next)--> (3) preTwo --(next)--> (4) preThree --(next)--> (wait for dones to invoke) -> (5) doneTwo -> (6) doneOne -> (7) targetFn
+
+So what's happening is that:
+
+1. You call `doc.save(...)`
+2. First, your preOne middleware gets executed. It makes a remote call to the validation service and `next()`s to the preTwo middleware.
+3. Now, your preTwo middleware gets executed. It makes a remote call to another validation service and `next()`s to the preThree middleware.
+4. Your preThree middleware gets executed. It immediately `next()`s. But nothing else gets executing until both `doneOne` and `doneTwo` are invoked inside the callbacks handling the response from the two valiation services.
+5. We will suppose that validation remoteServiceTwo returns a response to us first. In this case, we call `doneTwo` inside the callback to remoteServiceTwo.
+6. Some fractions of a second later, remoteServiceOne returns a response to us. In this case, we call `doneOne` inside the callback to remoteServiceOne.
+7. `hooks` implementation keeps track of how many parallel middleware has been defined per target function. It detects that both asynchronous pre middlewares (`preOne` and `preTwo`) have finally called their `done` functions (`doneOne` and `doneTwo`), so the implementation finally invokes our `targetFn` (i.e., our core `save` business logic).
+
+## Removing Pres
+
+You can remove a particular pre associated with a hook:
+
+ Document.pre('set', someFn);
+ Document.removePre('set', someFn);
+
+And you can also remove all pres associated with a hook:
+ Document.removePre('set'); // Removes all declared `pre`s on the hook 'set'
+
+## Tests
+To run the tests:
+ make test
+
+### Contributors
+- [Brian Noguchi](https://github.com/bnoguchi)
+
+### License
+MIT License
+
+---
+### Author
+Brian Noguchi
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.alt.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.alt.js
new file mode 100644
index 0000000..6ced357
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.alt.js
@@ -0,0 +1,134 @@
+/**
+ * Hooks are useful if we want to add a method that automatically has `pre` and `post` hooks.
+ * For example, it would be convenient to have `pre` and `post` hooks for `save`.
+ * _.extend(Model, mixins.hooks);
+ * Model.hook('save', function () {
+ * console.log('saving');
+ * });
+ * Model.pre('save', function (next, done) {
+ * console.log('about to save');
+ * next();
+ * });
+ * Model.post('save', function (next, done) {
+ * console.log('saved');
+ * next();
+ * });
+ *
+ * var m = new Model();
+ * m.save();
+ * // about to save
+ * // saving
+ * // saved
+ */
+
+// TODO Add in pre and post skipping options
+module.exports = {
+ /**
+ * Declares a new hook to which you can add pres and posts
+ * @param {String} name of the function
+ * @param {Function} the method
+ * @param {Function} the error handler callback
+ */
+ hook: function (name, fn, err) {
+ if (arguments.length === 1 && typeof name === 'object') {
+ for (var k in name) { // `name` is a hash of hookName->hookFn
+ this.hook(k, name[k]);
+ }
+ return;
+ }
+
+ if (!err) err = fn;
+
+ var proto = this.prototype || this
+ , pres = proto._pres = proto._pres || {}
+ , posts = proto._posts = proto._posts || {};
+ pres[name] = pres[name] || [];
+ posts[name] = posts[name] || [];
+
+ function noop () {}
+
+ proto[name] = function () {
+ var self = this
+ , pres = this._pres[name]
+ , posts = this._posts[name]
+ , numAsyncPres = 0
+ , hookArgs = [].slice.call(arguments)
+ , preChain = pres.map( function (pre, i) {
+ var wrapper = function () {
+ if (arguments[0] instanceof Error)
+ return err(arguments[0]);
+ if (numAsyncPres) {
+ // arguments[1] === asyncComplete
+ if (arguments.length)
+ hookArgs = [].slice.call(arguments, 2);
+ pre.apply(self,
+ [ preChain[i+1] || allPresInvoked,
+ asyncComplete
+ ].concat(hookArgs)
+ );
+ } else {
+ if (arguments.length)
+ hookArgs = [].slice.call(arguments);
+ pre.apply(self,
+ [ preChain[i+1] || allPresDone ].concat(hookArgs));
+ }
+ }; // end wrapper = function () {...
+ if (wrapper.isAsync = pre.isAsync)
+ numAsyncPres++;
+ return wrapper;
+ }); // end posts.map(...)
+ function allPresInvoked () {
+ if (arguments[0] instanceof Error)
+ err(arguments[0]);
+ }
+
+ function allPresDone () {
+ if (arguments[0] instanceof Error)
+ return err(arguments[0]);
+ if (arguments.length)
+ hookArgs = [].slice.call(arguments);
+ fn.apply(self, hookArgs);
+ var postChain = posts.map( function (post, i) {
+ var wrapper = function () {
+ if (arguments[0] instanceof Error)
+ return err(arguments[0]);
+ if (arguments.length)
+ hookArgs = [].slice.call(arguments);
+ post.apply(self,
+ [ postChain[i+1] || noop].concat(hookArgs));
+ }; // end wrapper = function () {...
+ return wrapper;
+ }); // end posts.map(...)
+ if (postChain.length) postChain[0]();
+ }
+
+ if (numAsyncPres) {
+ complete = numAsyncPres;
+ function asyncComplete () {
+ if (arguments[0] instanceof Error)
+ return err(arguments[0]);
+ --complete || allPresDone.call(this);
+ }
+ }
+ (preChain[0] || allPresDone)();
+ };
+
+ return this;
+ },
+
+ pre: function (name, fn, isAsync) {
+ var proto = this.prototype
+ , pres = proto._pres = proto._pres || {};
+ if (fn.isAsync = isAsync) {
+ this.prototype[name].numAsyncPres++;
+ }
+ (pres[name] = pres[name] || []).push(fn);
+ return this;
+ },
+ post: function (name, fn, isAsync) {
+ var proto = this.prototype
+ , posts = proto._posts = proto._posts || {};
+ (posts[name] = posts[name] || []).push(fn);
+ return this;
+ }
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.js
new file mode 100644
index 0000000..b94d11e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/hooks.js
@@ -0,0 +1,188 @@
+// TODO Add in pre and post skipping options
+module.exports = {
+ /**
+ * Declares a new hook to which you can add pres and posts
+ * @param {String} name of the function
+ * @param {Function} the method
+ * @param {Function} the error handler callback
+ */
+ hook: function (name, fn, errorCb) {
+ if (arguments.length === 1 && typeof name === 'object') {
+ for (var k in name) { // `name` is a hash of hookName->hookFn
+ this.hook(k, name[k]);
+ }
+ return;
+ }
+
+ var proto = this.prototype || this
+ , pres = proto._pres = proto._pres || {}
+ , posts = proto._posts = proto._posts || {};
+ pres[name] = pres[name] || [];
+ posts[name] = posts[name] || [];
+
+ proto[name] = function () {
+ var self = this
+ , hookArgs // arguments eventually passed to the hook - are mutable
+ , lastArg = arguments[arguments.length-1]
+ , pres = this._pres[name]
+ , posts = this._posts[name]
+ , _total = pres.length
+ , _current = -1
+ , _asyncsLeft = proto[name].numAsyncPres
+ , _asyncsDone = function(err) {
+ if (err) {
+ return handleError(err);
+ }
+ --_asyncsLeft || _done.apply(self, hookArgs);
+ }
+ , handleError = function(err) {
+ if ('function' == typeof lastArg)
+ return lastArg(err);
+ if (errorCb) return errorCb.call(self, err);
+ throw err;
+ }
+ , _next = function () {
+ if (arguments[0] instanceof Error) {
+ return handleError(arguments[0]);
+ }
+ var _args = Array.prototype.slice.call(arguments)
+ , currPre
+ , preArgs;
+ if (_args.length && !(arguments[0] == null && typeof lastArg === 'function'))
+ hookArgs = _args;
+ if (++_current < _total) {
+ currPre = pres[_current]
+ if (currPre.isAsync && currPre.length < 2)
+ throw new Error("Your pre must have next and done arguments -- e.g., function (next, done, ...)");
+ if (currPre.length < 1)
+ throw new Error("Your pre must have a next argument -- e.g., function (next, ...)");
+ preArgs = (currPre.isAsync
+ ? [once(_next), once(_asyncsDone)]
+ : [once(_next)]).concat(hookArgs);
+ return currPre.apply(self, preArgs);
+ } else if (!_asyncsLeft) {
+ return _done.apply(self, hookArgs);
+ }
+ }
+ , _done = function () {
+ var args_ = Array.prototype.slice.call(arguments)
+ , ret, total_, current_, next_, done_, postArgs;
+
+ if (_current === _total) {
+
+ next_ = function () {
+ if (arguments[0] instanceof Error) {
+ return handleError(arguments[0]);
+ }
+ var args_ = Array.prototype.slice.call(arguments, 1)
+ , currPost
+ , postArgs;
+ if (args_.length) hookArgs = args_;
+ if (++current_ < total_) {
+ currPost = posts[current_]
+ if (currPost.length < 1)
+ throw new Error("Your post must have a next argument -- e.g., function (next, ...)");
+ postArgs = [once(next_)].concat(hookArgs);
+ return currPost.apply(self, postArgs);
+ } else if (typeof lastArg === 'function'){
+ // All post handlers are done, call original callback function
+ return lastArg.apply(self, arguments);
+ }
+ };
+
+ // We are assuming that if the last argument provided to the wrapped function is a function, it was expecting
+ // a callback. We trap that callback and wait to call it until all post handlers have finished.
+ if(typeof lastArg === 'function'){
+ args_[args_.length - 1] = once(next_);
+ }
+
+ total_ = posts.length;
+ current_ = -1;
+ ret = fn.apply(self, args_); // Execute wrapped function, post handlers come afterward
+
+ if (total_ && typeof lastArg !== 'function') return next_(); // no callback provided, execute next_() manually
+ return ret;
+ }
+ };
+
+ return _next.apply(this, arguments);
+ };
+
+ proto[name].numAsyncPres = 0;
+
+ return this;
+ },
+
+ pre: function (name, isAsync, fn, errorCb) {
+ if ('boolean' !== typeof arguments[1]) {
+ errorCb = fn;
+ fn = isAsync;
+ isAsync = false;
+ }
+ var proto = this.prototype || this
+ , pres = proto._pres = proto._pres || {};
+
+ this._lazySetupHooks(proto, name, errorCb);
+
+ if (fn.isAsync = isAsync) {
+ proto[name].numAsyncPres++;
+ }
+
+ (pres[name] = pres[name] || []).push(fn);
+ return this;
+ },
+ post: function (name, isAsync, fn) {
+ if (arguments.length === 2) {
+ fn = isAsync;
+ isAsync = false;
+ }
+ var proto = this.prototype || this
+ , posts = proto._posts = proto._posts || {};
+
+ this._lazySetupHooks(proto, name);
+ (posts[name] = posts[name] || []).push(fn);
+ return this;
+ },
+ removePre: function (name, fnToRemove) {
+ var proto = this.prototype || this
+ , pres = proto._pres || (proto._pres || {});
+ if (!pres[name]) return this;
+ if (arguments.length === 1) {
+ // Remove all pre callbacks for hook `name`
+ pres[name].length = 0;
+ } else {
+ pres[name] = pres[name].filter( function (currFn) {
+ return currFn !== fnToRemove;
+ });
+ }
+ return this;
+ },
+ removePost: function (name, fnToRemove) {
+ var proto = this.prototype || this
+ , posts = proto._posts || (proto._posts || {});
+ if (!posts[name]) return this;
+ if (arguments.length === 1) {
+ // Remove all post callbacks for hook `name`
+ posts[name].length = 0;
+ } else {
+ posts[name] = posts[name].filter( function (currFn) {
+ return currFn !== fnToRemove;
+ });
+ }
+ return this;
+ },
+
+ _lazySetupHooks: function (proto, methodName, errorCb) {
+ if ('undefined' === typeof proto[methodName].numAsyncPres) {
+ this.hook(methodName, proto[methodName], errorCb);
+ }
+ }
+};
+
+function once (fn, scope) {
+ return function fnWrapper () {
+ if (fnWrapper.hookCalled) return;
+ fnWrapper.hookCalled = true;
+ fn.apply(scope, arguments);
+ };
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/package.json
new file mode 100644
index 0000000..6c80085
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/package.json
@@ -0,0 +1,70 @@
+{
+ "name": "hooks-fixed",
+ "description": "Adds pre and post hook functionality to your JavaScript methods.",
+ "version": "1.2.0",
+ "keywords": [
+ "node",
+ "hooks",
+ "middleware",
+ "pre",
+ "post"
+ ],
+ "homepage": "https://github.com/vkarpov15/hooks-fixed/",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/vkarpov15/hooks-fixed.git"
+ },
+ "author": {
+ "name": "Brian Noguchi",
+ "email": "brian.noguchi@gmail.com",
+ "url": "https://github.com/bnoguchi/"
+ },
+ "main": "./hooks.js",
+ "directories": {
+ "lib": "."
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "expresso": ">=0.7.6",
+ "should": ">=0.2.1",
+ "underscore": ">=1.1.4"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ },
+ "licenses": [
+ "MIT"
+ ],
+ "optionalDependencies": {},
+ "gitHead": "db6db04cb1e9e8d549d5a48eb33b42513e89d036",
+ "bugs": {
+ "url": "https://github.com/vkarpov15/hooks-fixed/issues"
+ },
+ "_id": "hooks-fixed@1.2.0",
+ "_shasum": "0d2772d4d7d685ff9244724a9f0b5b2559aac96b",
+ "_from": "hooks-fixed@1.2.0",
+ "_npmVersion": "3.9.5",
+ "_nodeVersion": "6.2.2",
+ "_npmUser": {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ "dist": {
+ "shasum": "0d2772d4d7d685ff9244724a9f0b5b2559aac96b",
+ "tarball": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-1.2.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "vkarpov15",
+ "email": "valkar207@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/hooks-fixed-1.2.0.tgz_1469112529130_0.3766456232406199"
+ },
+ "_resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-1.2.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/test.js
new file mode 100644
index 0000000..81ad79e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/hooks-fixed/test.js
@@ -0,0 +1,786 @@
+var hooks = require('./hooks')
+ , should = require('should')
+ , assert = require('assert')
+ , _ = require('underscore');
+
+// TODO Add in test for making sure all pres get called if pre is defined directly on an instance.
+// TODO Test for calling `done` twice or `next` twice in the same function counts only once
+module.exports = {
+ 'should be able to assign multiple hooks at once': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook({
+ hook1: function (a) {},
+ hook2: function (b) {}
+ });
+ var a = new A();
+ assert.equal(typeof a.hook1, 'function');
+ assert.equal(typeof a.hook2, 'function');
+ },
+ 'should run without pres and posts when not present': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ },
+ 'should run with pres when present': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.preValue = 2;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ a.preValue.should.equal(2);
+ },
+ 'should run with posts when present': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.post('save', function (next) {
+ this.value = 2;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(2);
+ },
+ 'should run pres and posts when present': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.preValue = 2;
+ next();
+ });
+ A.post('save', function (next) {
+ this.value = 3;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(3);
+ a.preValue.should.equal(2);
+ },
+ 'should run posts after pres': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.override = 100;
+ next();
+ });
+ A.post('save', function (next) {
+ this.override = 200;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ a.override.should.equal(200);
+ },
+ 'should not run a hook if a pre fails': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ var counter = 0;
+ A.hook('save', function () {
+ this.value = 1;
+ }, function (err) {
+ counter++;
+ });
+ A.pre('save', true, function (next, done) {
+ next(new Error());
+ });
+ var a = new A();
+ a.save();
+ counter.should.equal(1);
+ assert.equal(typeof a.value, 'undefined');
+ },
+ 'should be able to run multiple pres': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.v1 = 1;
+ next();
+ }).pre('save', function (next) {
+ this.v2 = 2;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.v1.should.equal(1);
+ a.v2.should.equal(2);
+ },
+ 'should run multiple pres until a pre fails and not call the hook': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ }, function (err) {});
+ A.pre('save', function (next) {
+ this.v1 = 1;
+ next();
+ }).pre('save', function (next) {
+ next(new Error());
+ }).pre('save', function (next) {
+ this.v3 = 3;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.v1.should.equal(1);
+ assert.equal(typeof a.v3, 'undefined');
+ assert.equal(typeof a.value, 'undefined');
+ },
+ 'should be able to run multiple posts': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.post('save', function (next) {
+ this.value = 2;
+ next();
+ }).post('save', function (next) {
+ this.value = 3.14;
+ next();
+ }).post('save', function (next) {
+ this.v3 = 3;
+ next();
+ });
+ var a = new A();
+ a.save();
+ assert.equal(a.value, 3.14);
+ assert.equal(a.v3, 3);
+ },
+ 'should run only posts up until an error': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ }, function (err) {});
+ A.post('save', function (next) {
+ this.value = 2;
+ next();
+ }).post('save', function (next) {
+ this.value = 3;
+ next(new Error());
+ }).post('save', function (next) {
+ this.value = 4;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(3);
+ },
+ "should fall back first to the hook method's last argument as the error handler if it is a function of arity 1 or 2": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ var counter = 0;
+ A.hook('save', function (callback) {
+ this.value = 1;
+ });
+ A.pre('save', true, function (next, done) {
+ next(new Error());
+ });
+ var a = new A();
+ a.save( function (err) {
+ if (err instanceof Error) counter++;
+ });
+ counter.should.equal(1);
+ should.deepEqual(undefined, a.value);
+ },
+ 'should fall back second to the default error handler if specified': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ var counter = 0;
+ A.hook('save', function (callback) {
+ this.value = 1;
+ }, function (err) {
+ if (err instanceof Error) counter++;
+ });
+ A.pre('save', true, function (next, done) {
+ next(new Error());
+ });
+ var a = new A();
+ a.save();
+ counter.should.equal(1);
+ should.deepEqual(undefined, a.value);
+ },
+ 'fallback default error handler should scope to the object': function () {
+ var A = function () {
+ this.counter = 0;
+ };
+ _.extend(A, hooks);
+ var counter = 0;
+ A.hook('save', function (callback) {
+ this.value = 1;
+ }, function (err) {
+ if (err instanceof Error) this.counter++;
+ });
+ A.pre('save', true, function (next, done) {
+ next(new Error());
+ });
+ var a = new A();
+ a.save();
+ a.counter.should.equal(1);
+ should.deepEqual(undefined, a.value);
+ },
+ 'should fall back last to throwing the error': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ var counter = 0;
+ A.hook('save', function (err) {
+ if (err instanceof Error) return counter++;
+ this.value = 1;
+ });
+ A.pre('save', true, function (next, done) {
+ next(new Error());
+ });
+ var a = new A();
+ var didCatch = false;
+ try {
+ a.save();
+ } catch (e) {
+ didCatch = true;
+ e.should.be.an.instanceof(Error);
+ counter.should.equal(0);
+ assert.equal(typeof a.value, 'undefined');
+ }
+ didCatch.should.be.true;
+ },
+ "should proceed without mutating arguments if `next(null|undefined)` is called in a serial pre, and the last argument of the target method is a callback with node-like signature function (err, obj) {...} or function (err) {...}": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ var counter = 0;
+ A.prototype.save = function (callback) {
+ this.value = 1;
+ callback();
+ };
+ A.pre('save', function (next) {
+ next(null);
+ });
+ A.pre('save', function (next) {
+ next(undefined);
+ });
+ var a = new A();
+ a.save( function (err) {
+ if (err instanceof Error) counter++;
+ else counter--;
+ });
+ counter.should.equal(-1);
+ a.value.should.eql(1);
+ },
+ "should proceed with mutating arguments if `next(null|undefined)` is callback in a serial pre, and the last argument of the target method is not a function": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.prototype.set = function (v) {
+ this.value = v;
+ };
+ A.pre('set', function (next) {
+ next(undefined);
+ });
+ A.pre('set', function (next) {
+ next(null);
+ });
+ var a = new A();
+ a.set(1);
+ should.strictEqual(null, a.value);
+ },
+ 'should not run any posts if a pre fails': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 2;
+ }, function (err) {});
+ A.pre('save', function (next) {
+ this.value = 1;
+ next(new Error());
+ }).post('save', function (next) {
+ this.value = 3;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ },
+
+ "can pass the hook's arguments verbatim to pres": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ this[path] = val;
+ });
+ A.pre('set', function (next, path, val) {
+ path.should.equal('hello');
+ val.should.equal('world');
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ a.hello.should.equal('world');
+ },
+// "can pass the hook's arguments as an array to pres": function () {
+// // Great for dynamic arity - e.g., slice(...)
+// var A = function () {};
+// _.extend(A, hooks);
+// A.hook('set', function (path, val) {
+// this[path] = val;
+// });
+// A.pre('set', function (next, hello, world) {
+// hello.should.equal('hello');
+// world.should.equal('world');
+// next();
+// });
+// var a = new A();
+// a.set('hello', 'world');
+// assert.equal(a.hello, 'world');
+// },
+ "can pass the hook's arguments verbatim to posts": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ this[path] = val;
+ });
+ A.post('set', function (next, path, val) {
+ path.should.equal('hello');
+ val.should.equal('world');
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ assert.equal(a.hello, 'world');
+ },
+// "can pass the hook's arguments as an array to posts": function () {
+// var A = function () {};
+// _.extend(A, hooks);
+// A.hook('set', function (path, val) {
+// this[path] = val;
+// });
+// A.post('set', function (next, halt, args) {
+// assert.equal(args[0], 'hello');
+// assert.equal(args[1], 'world');
+// next();
+// });
+// var a = new A();
+// a.set('hello', 'world');
+// assert.equal(a.hello, 'world');
+// },
+ "pres should be able to modify and pass on a modified version of the hook's arguments": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ this[path] = val;
+ assert.equal(arguments[2], 'optional');
+ });
+ A.pre('set', function (next, path, val) {
+ next('foo', 'bar');
+ });
+ A.pre('set', function (next, path, val) {
+ assert.equal(path, 'foo');
+ assert.equal(val, 'bar');
+ next('rock', 'says', 'optional');
+ });
+ A.pre('set', function (next, path, val, opt) {
+ assert.equal(path, 'rock');
+ assert.equal(val, 'says');
+ assert.equal(opt, 'optional');
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ assert.equal(typeof a.hello, 'undefined');
+ a.rock.should.equal('says');
+ },
+ 'posts should see the modified version of arguments if the pres modified them': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ this[path] = val;
+ });
+ A.pre('set', function (next, path, val) {
+ next('foo', 'bar');
+ });
+ A.post('set', function (next, path, val) {
+ path.should.equal('foo');
+ val.should.equal('bar');
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ assert.equal(typeof a.hello, 'undefined');
+ a.foo.should.equal('bar');
+ },
+ 'should pad missing arguments (relative to expected arguments of the hook) with null': function () {
+ // Otherwise, with hookFn = function (a, b, next, ),
+ // if we use hookFn(a), then because the pre functions are of the form
+ // preFn = function (a, b, next, ), then it actually gets executed with
+ // preFn(a, next, ), so when we call next() from within preFn, we are actually
+ // calling ()
+
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val, opts) {
+ this[path] = val;
+ });
+ A.pre('set', function (next, path, val, opts) {
+ next('foo', 'bar');
+ assert.equal(typeof opts, 'undefined');
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ },
+
+ 'should not invoke the target method until all asynchronous middleware have invoked dones': function () {
+ var counter = 0;
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ counter++;
+ this[path] = val;
+ counter.should.equal(7);
+ });
+ A.pre('set', function (next, path, val) {
+ counter++;
+ next();
+ });
+ A.pre('set', true, function (next, done, path, val) {
+ counter++;
+ setTimeout(function () {
+ counter++;
+ done();
+ }, 1000);
+ next();
+ });
+ A.pre('set', function (next, path, val) {
+ counter++;
+ next();
+ });
+ A.pre('set', true, function (next, done, path, val) {
+ counter++;
+ setTimeout(function () {
+ counter++;
+ done();
+ }, 500);
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ },
+
+ 'invoking a method twice should run its async middleware twice': function () {
+ var counter = 0;
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val) {
+ this[path] = val;
+ if (path === 'hello') counter.should.equal(1);
+ if (path === 'foo') counter.should.equal(2);
+ });
+ A.pre('set', true, function (next, done, path, val) {
+ setTimeout(function () {
+ counter++;
+ done();
+ }, 1000);
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world');
+ a.set('foo', 'bar');
+ },
+
+ 'calling the same done multiple times should have the effect of only calling it once': function () {
+ var A = function () {
+ this.acked = false;
+ };
+ _.extend(A, hooks);
+ A.hook('ack', function () {
+ console.log("UH OH, YOU SHOULD NOT BE SEEING THIS");
+ this.acked = true;
+ });
+ A.pre('ack', true, function (next, done) {
+ next();
+ done();
+ done();
+ });
+ A.pre('ack', true, function (next, done) {
+ next();
+ // Notice that done() is not invoked here
+ });
+ var a = new A();
+ a.ack();
+ setTimeout( function () {
+ a.acked.should.be.false;
+ }, 1000);
+ },
+
+ 'calling the same next multiple times should have the effect of only calling it once': function (beforeExit) {
+ var A = function () {
+ this.acked = false;
+ };
+ _.extend(A, hooks);
+ A.hook('ack', function () {
+ console.log("UH OH, YOU SHOULD NOT BE SEEING THIS");
+ this.acked = true;
+ });
+ A.pre('ack', function (next) {
+ // force a throw to re-exec next()
+ try {
+ next(new Error('bam'));
+ } catch (err) {
+ next();
+ }
+ });
+ A.pre('ack', function (next) {
+ next();
+ });
+ var a = new A();
+ a.ack();
+ beforeExit( function () {
+ a.acked.should.be.false;
+ });
+ },
+
+ 'asynchronous middleware should be able to pass an error via `done`, stopping the middleware chain': function () {
+ var counter = 0;
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('set', function (path, val, fn) {
+ counter++;
+ this[path] = val;
+ fn(null);
+ });
+ A.pre('set', true, function (next, done, path, val, fn) {
+ setTimeout(function () {
+ counter++;
+ done(new Error);
+ }, 1000);
+ next();
+ });
+ var a = new A();
+ a.set('hello', 'world', function (err) {
+ err.should.be.an.instanceof(Error);
+ should.strictEqual(undefined, a['hello']);
+ counter.should.eql(1);
+ });
+ },
+
+ 'should be able to remove a particular pre': function () {
+ var A = function () {}
+ , preTwo;
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.preValueOne = 2;
+ next();
+ });
+ A.pre('save', preTwo = function (next) {
+ this.preValueTwo = 4;
+ next();
+ });
+ A.removePre('save', preTwo);
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ a.preValueOne.should.equal(2);
+ should.strictEqual(undefined, a.preValueTwo);
+ },
+
+ 'should be able to remove all pres associated with a hook': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.pre('save', function (next) {
+ this.preValueOne = 2;
+ next();
+ });
+ A.pre('save', function (next) {
+ this.preValueTwo = 4;
+ next();
+ });
+ A.removePre('save');
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ should.strictEqual(undefined, a.preValueOne);
+ should.strictEqual(undefined, a.preValueTwo);
+ },
+
+ 'should be able to remove a particular post': function () {
+ var A = function () {}
+ , postTwo;
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.post('save', function (next) {
+ this.postValueOne = 2;
+ next();
+ });
+ A.post('save', postTwo = function (next) {
+ this.postValueTwo = 4;
+ next();
+ });
+ A.removePost('save', postTwo);
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ a.postValueOne.should.equal(2);
+ should.strictEqual(undefined, a.postValueTwo);
+ },
+
+ 'should be able to remove all posts associated with a hook': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function () {
+ this.value = 1;
+ });
+ A.post('save', function (next) {
+ this.postValueOne = 2;
+ next();
+ });
+ A.post('save', function (next) {
+ this.postValueTwo = 4;
+ next();
+ });
+ A.removePost('save');
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ should.strictEqual(undefined, a.postValueOne);
+ should.strictEqual(undefined, a.postValueTwo);
+ },
+
+ '#pre should lazily make a method hookable': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.prototype.save = function () {
+ this.value = 1;
+ };
+ A.pre('save', function (next) {
+ this.preValue = 2;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(1);
+ a.preValue.should.equal(2);
+ },
+
+ '#pre lazily making a method hookable should be able to provide a default errorHandler as the last argument': function () {
+ var A = function () {};
+ var preValue = "";
+ _.extend(A, hooks);
+ A.prototype.save = function () {
+ this.value = 1;
+ };
+ A.pre('save', function (next) {
+ next(new Error);
+ }, function (err) {
+ preValue = 'ERROR';
+ });
+ var a = new A();
+ a.save();
+ should.strictEqual(undefined, a.value);
+ preValue.should.equal('ERROR');
+ },
+
+ '#post should lazily make a method hookable': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.prototype.save = function () {
+ this.value = 1;
+ };
+ A.post('save', function (next) {
+ this.value = 2;
+ next();
+ });
+ var a = new A();
+ a.save();
+ a.value.should.equal(2);
+ },
+
+ "a lazy hooks setup should handle errors via a method's last argument, if it's a callback": function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.prototype.save = function (fn) {};
+ A.pre('save', function (next) {
+ next(new Error("hi there"));
+ });
+ var a = new A();
+ a.save( function (err) {
+ err.should.be.an.instanceof(Error);
+ });
+ },
+
+ 'should intercept method callbacks for post handlers': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function (val, callback) {
+ this.value = val;
+ callback();
+ });
+ A.post('save', function (next) {
+ assert.equal(a.value, 2);
+ this.value += 2;
+ setTimeout(next, 10);
+ }).post('save', function (next) {
+ assert.equal(a.value, 4);
+ this.value += 3;
+ setTimeout(next, 10);
+ }).post('save', function (next) {
+ assert.equal(a.value, 7);
+ this.value2 = 3;
+ setTimeout(next, 10);
+ });
+ var a = new A();
+ a.save(2, function(){
+ assert.equal(a.value, 7);
+ assert.equal(a.value2, 3);
+ });
+ },
+
+ 'should handle parallel followed by serial': function () {
+ var A = function () {};
+ _.extend(A, hooks);
+ A.hook('save', function (val, callback) {
+ this.value = val;
+ callback();
+ });
+ A.pre('save', true, function(next, done) {
+ process.nextTick(function() {
+ done();
+ });
+ next();
+ }).pre('save', function(done) {
+ process.nextTick(function() {
+ done();
+ });
+ });
+ var a = new A();
+ a.save(2, function(){
+ assert.ok(true);
+ });
+ }
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.npmignore
new file mode 100644
index 0000000..59d842b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.npmignore
@@ -0,0 +1,28 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# Commenting this out is preferred by some people, see
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
+node_modules
+
+# Users Environment Variables
+.lock-wscript
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.travis.yml
new file mode 100644
index 0000000..117c2b6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/.travis.yml
@@ -0,0 +1,9 @@
+language: node_js
+node_js:
+ - "5"
+ - "4"
+ - "0.12"
+ - "0.10"
+ - "iojs"
+script: "npm run-script test-travis"
+after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/LICENSE
new file mode 100644
index 0000000..e06d208
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/LICENSE
@@ -0,0 +1,202 @@
+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.
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/Makefile
new file mode 100644
index 0000000..f71ba90
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/Makefile
@@ -0,0 +1,5 @@
+docs:
+ node ./docs.js
+
+coverage:
+ ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/README.md
new file mode 100644
index 0000000..7d2dc84
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/README.md
@@ -0,0 +1,379 @@
+# kareem
+
+ [![Build Status](https://travis-ci.org/vkarpov15/kareem.svg?branch=master)](https://travis-ci.org/vkarpov15/kareem)
+ [![Coverage Status](https://img.shields.io/coveralls/vkarpov15/kareem.svg)](https://coveralls.io/r/vkarpov15/kareem)
+
+Re-imagined take on the [hooks](http://npmjs.org/package/hooks) module, meant to offer additional flexibility in allowing you to execute hooks whenever necessary, as opposed to simply wrapping a single function.
+
+Named for the NBA's all-time leading scorer Kareem Abdul-Jabbar, known for his mastery of the [hook shot](http://en.wikipedia.org/wiki/Kareem_Abdul-Jabbar#Skyhook)
+
+<img src="http://upload.wikimedia.org/wikipedia/commons/0/00/Kareem-Abdul-Jabbar_Lipofsky.jpg" width="220">
+
+# API
+
+## pre hooks
+
+Much like [hooks](https://npmjs.org/package/hooks), kareem lets you define
+pre and post hooks: pre hooks are called before a given function executes.
+Unlike hooks, kareem stores hooks and other internal state in a separate
+object, rather than relying on inheritance. Furthermore, kareem exposes
+an `execPre()` function that allows you to execute your pre hooks when
+appropriate, giving you more fine-grained control over your function hooks.
+
+
+#### It runs without any hooks specified
+
+```javascript
+
+ hooks.execPre('cook', null, function() {
+ done();
+ });
+
+```
+
+#### It runs basic serial pre hooks
+
+pre hook functions take one parameter, a "done" function that you execute
+when your pre hook is finished.
+
+
+```javascript
+
+ var count = 0;
+
+ hooks.pre('cook', function(done) {
+ ++count;
+ done();
+ });
+
+ hooks.execPre('cook', null, function() {
+ assert.equal(1, count);
+ done();
+ });
+
+```
+
+#### It can run multipe pre hooks
+
+```javascript
+
+ var count1 = 0;
+ var count2 = 0;
+
+ hooks.pre('cook', function(done) {
+ ++count1;
+ done();
+ });
+
+ hooks.pre('cook', function(done) {
+ ++count2;
+ done();
+ });
+
+ hooks.execPre('cook', null, function() {
+ assert.equal(1, count1);
+ assert.equal(1, count2);
+ done();
+ });
+
+```
+
+#### It can run fully synchronous pre hooks
+
+If your pre hook function takes no parameters, its assumed to be
+fully synchronous.
+
+
+```javascript
+
+ var count1 = 0;
+ var count2 = 0;
+
+ hooks.pre('cook', function() {
+ ++count1;
+ });
+
+ hooks.pre('cook', function() {
+ ++count2;
+ });
+
+ hooks.execPre('cook', null, function(error) {
+ assert.equal(null, error);
+ assert.equal(1, count1);
+ assert.equal(1, count2);
+ done();
+ });
+
+```
+
+#### It properly attaches context to pre hooks
+
+Pre save hook functions are bound to the second parameter to `execPre()`
+
+
+```javascript
+
+ hooks.pre('cook', function(done) {
+ this.bacon = 3;
+ done();
+ });
+
+ hooks.pre('cook', function(done) {
+ this.eggs = 4;
+ done();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ // In the pre hooks, `this` will refer to `obj`
+ hooks.execPre('cook', obj, function(error) {
+ assert.equal(null, error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ done();
+ });
+
+```
+
+#### It can execute parallel (async) pre hooks
+
+Like the hooks module, you can declare "async" pre hooks - these take two
+parameters, the functions `next()` and `done()`. `next()` passes control to
+the next pre hook, but the underlying function won't be called until all
+async pre hooks have called `done()`.
+
+
+```javascript
+
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ hooks.execPre('cook', obj, function() {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ done();
+ });
+
+```
+
+## post hooks
+
+#### It runs without any hooks specified
+
+```javascript
+
+ hooks.execPost('cook', null, [1], function(error, eggs) {
+ assert.ifError(error);
+ assert.equal(1, eggs);
+ done();
+ });
+
+```
+
+#### It executes with parameters passed in
+
+```javascript
+
+ hooks.post('cook', function(eggs, bacon, callback) {
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ callback();
+ });
+
+ hooks.execPost('cook', null, [1, 2], function(error, eggs, bacon) {
+ assert.ifError(error);
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ done();
+ });
+
+```
+
+#### It can use synchronous post hooks
+
+```javascript
+
+ var execed = {};
+
+ hooks.post('cook', function(eggs, bacon) {
+ execed.first = true;
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ });
+
+ hooks.post('cook', function(eggs, bacon, callback) {
+ execed.second = true;
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ callback();
+ });
+
+ hooks.execPost('cook', null, [1, 2], function(error, eggs, bacon) {
+ assert.ifError(error);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ done();
+ });
+
+```
+
+## wrap()
+
+#### It wraps pre and post calls into one call
+
+```javascript
+
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+ args.push(function(error, result) {
+ assert.ifError(error);
+ assert.equal(null, error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal('no', obj.tofu);
+
+ assert.equal(obj, result);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal(undefined, obj.tofu);
+ callback(null, o);
+ },
+ obj,
+ args);
+
+```
+
+## createWrapper()
+
+#### It wraps wrap() into a callable function
+
+```javascript
+
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var cook = hooks.createWrapper(
+ 'cook',
+ function(o, callback) {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal(undefined, obj.tofu);
+ callback(null, o);
+ },
+ obj);
+
+ cook(obj, function(error, result) {
+ assert.ifError(error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal('no', obj.tofu);
+
+ assert.equal(obj, result);
+ done();
+ });
+
+```
+
+## clone()
+
+#### It clones a Kareem object
+
+```javascript
+
+ var k1 = new Kareem();
+ k1.pre('cook', function() {});
+ k1.post('cook', function() {});
+
+ var k2 = k1.clone();
+ assert.deepEqual(['cook'], Object.keys(k2._pres));
+ assert.deepEqual(['cook'], Object.keys(k2._posts));
+
+```
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/docs.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/docs.js
new file mode 100644
index 0000000..4a8d4c8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/docs.js
@@ -0,0 +1,37 @@
+var acquit = require('acquit');
+
+var content = require('fs').readFileSync('./test/examples.test.js').toString();
+var blocks = acquit.parse(content);
+
+var mdOutput =
+ '# kareem\n\n' +
+ ' [![Build Status](https://travis-ci.org/vkarpov15/kareem.svg?branch=master)](https://travis-ci.org/vkarpov15/kareem)\n' +
+ ' [![Coverage Status](https://img.shields.io/coveralls/vkarpov15/kareem.svg)](https://coveralls.io/r/vkarpov15/kareem)\n\n' +
+ 'Re-imagined take on the [hooks](http://npmjs.org/package/hooks) module, ' +
+ 'meant to offer additional flexibility in allowing you to execute hooks ' +
+ 'whenever necessary, as opposed to simply wrapping a single function.\n\n' +
+ 'Named for the NBA\'s all-time leading scorer Kareem Abdul-Jabbar, known ' +
+ 'for his mastery of the [hook shot](http://en.wikipedia.org/wiki/Kareem_Abdul-Jabbar#Skyhook)\n\n' +
+ '<img src="http://upload.wikimedia.org/wikipedia/commons/0/00/Kareem-Abdul-Jabbar_Lipofsky.jpg" width="220">\n\n' +
+ '# API\n\n';
+
+for (var i = 0; i < blocks.length; ++i) {
+ var describe = blocks[i];
+ mdOutput += '## ' + describe.contents + '\n\n';
+ mdOutput += describe.comments[0] ?
+ acquit.trimEachLine(describe.comments[0]) + '\n\n' :
+ '';
+
+ for (var j = 0; j < describe.blocks.length; ++j) {
+ var it = describe.blocks[j];
+ mdOutput += '#### It ' + it.contents + '\n\n';
+ mdOutput += it.comments[0] ?
+ acquit.trimEachLine(it.comments[0]) + '\n\n' :
+ '';
+ mdOutput += '```javascript\n';
+ mdOutput += ' ' + it.code + '\n';
+ mdOutput += '```\n\n';
+ }
+}
+
+require('fs').writeFileSync('README.md', mdOutput);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/gulpfile.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/gulpfile.js
new file mode 100644
index 0000000..635bfc7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/gulpfile.js
@@ -0,0 +1,18 @@
+var gulp = require('gulp');
+var mocha = require('gulp-mocha');
+var config = require('./package.json');
+var jscs = require('gulp-jscs');
+
+gulp.task('mocha', function() {
+ return gulp.src('./test/*').
+ pipe(mocha({ reporter: 'dot' }));
+});
+
+gulp.task('jscs', function() {
+ return gulp.src('./index.js').
+ pipe(jscs(config.jscsConfig));
+});
+
+gulp.task('watch', function() {
+ gulp.watch('./index.js', ['jscs', 'mocha']);
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/index.js
new file mode 100644
index 0000000..ccc266c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/index.js
@@ -0,0 +1,312 @@
+'use strict';
+
+function Kareem() {
+ this._pres = {};
+ this._posts = {};
+}
+
+Kareem.prototype.execPre = function(name, context, callback) {
+ var pres = this._pres[name] || [];
+ var numPres = pres.length;
+ var numAsyncPres = pres.numAsync || 0;
+ var currentPre = 0;
+ var asyncPresLeft = numAsyncPres;
+ var done = false;
+
+ if (!numPres) {
+ return process.nextTick(function() {
+ callback(null);
+ });
+ }
+
+ var next = function() {
+ if (currentPre >= numPres) {
+ return;
+ }
+ var pre = pres[currentPre];
+
+ if (pre.isAsync) {
+ pre.fn.call(
+ context,
+ function(error) {
+ if (error) {
+ if (done) {
+ return;
+ }
+ done = true;
+ return callback(error);
+ }
+
+ ++currentPre;
+ next.apply(context, arguments);
+ },
+ function(error) {
+ if (error) {
+ if (done) {
+ return;
+ }
+ done = true;
+ return callback(error);
+ }
+
+ if (--numAsyncPres === 0) {
+ return callback(null);
+ }
+ });
+ } else if (pre.fn.length > 0) {
+ var args = [function(error) {
+ if (error) {
+ if (done) {
+ return;
+ }
+ done = true;
+ return callback(error);
+ }
+
+ if (++currentPre >= numPres) {
+ if (asyncPresLeft > 0) {
+ // Leave parallel hooks to run
+ return;
+ } else {
+ return callback(null);
+ }
+ }
+
+ next.apply(context, arguments);
+ }];
+ if (arguments.length >= 2) {
+ for (var i = 1; i < arguments.length; ++i) {
+ args.push(arguments[i]);
+ }
+ }
+ pre.fn.apply(context, args);
+ } else {
+ pre.fn.call(context);
+ if (++currentPre >= numPres) {
+ if (asyncPresLeft > 0) {
+ // Leave parallel hooks to run
+ return;
+ } else {
+ return process.nextTick(function() {
+ callback(null);
+ });
+ }
+ }
+ next();
+ }
+ };
+
+ next();
+};
+
+Kareem.prototype.execPreSync = function(name, context) {
+ var pres = this._pres[name] || [];
+ var numPres = pres.length;
+
+ for (var i = 0; i < numPres; ++i) {
+ pres[i].fn.call(context);
+ }
+};
+
+Kareem.prototype.execPost = function(name, context, args, options, callback) {
+ if (arguments.length < 5) {
+ callback = options;
+ options = null;
+ }
+ var posts = this._posts[name] || [];
+ var numPosts = posts.length;
+ var currentPost = 0;
+
+ var firstError = null;
+ if (options && options.error) {
+ firstError = options.error;
+ }
+
+ if (!numPosts) {
+ return process.nextTick(function() {
+ callback.apply(null, [firstError].concat(args));
+ });
+ }
+
+ var next = function() {
+ var post = posts[currentPost];
+
+ if (firstError) {
+ if (post.length === args.length + 2) {
+ post.apply(context, [firstError].concat(args).concat(function(error) {
+ if (error) {
+ firstError = error;
+ }
+ if (++currentPost >= numPosts) {
+ return callback.call(null, firstError);
+ }
+ next();
+ }));
+ } else {
+ if (++currentPost >= numPosts) {
+ return callback.call(null, firstError);
+ }
+ next();
+ }
+ } else {
+ if (post.length === args.length + 2) {
+ // Skip error handlers if no error
+ if (++currentPost >= numPosts) {
+ return callback.apply(null, [null].concat(args));
+ }
+ return next();
+ }
+ if (post.length === args.length + 1) {
+ post.apply(context, args.concat(function(error) {
+ if (error) {
+ firstError = error;
+ return next();
+ }
+
+ if (++currentPost >= numPosts) {
+ return callback.apply(null, [null].concat(args));
+ }
+
+ next();
+ }));
+ } else {
+ post.apply(context, args);
+
+ if (++currentPost >= numPosts) {
+ return callback.apply(null, [null].concat(args));
+ }
+
+ next();
+ }
+ }
+ };
+
+ next();
+};
+
+Kareem.prototype.execPostSync = function(name, context) {
+ var posts = this._posts[name] || [];
+ var numPosts = posts.length;
+
+ for (var i = 0; i < numPosts; ++i) {
+ posts[i].call(context);
+ }
+};
+
+function _handleWrapError(instance, error, name, context, args, options, callback) {
+ if (options.useErrorHandlers) {
+ var _options = { error: error };
+ var newArgs = [];
+ // Filter out trailing undefineds
+ for (var i = args.length; i >= 0; --i) {
+ if (newArgs.length > 0 || args[i] !== void 0) {
+ newArgs.unshift(args[i]);
+ }
+ }
+ return instance.execPost(name, context, newArgs, _options, function(error) {
+ return typeof callback === 'function' && callback(error);
+ });
+ } else {
+ return typeof callback === 'function' ?
+ callback(error) :
+ undefined;
+ }
+}
+
+Kareem.prototype.wrap = function(name, fn, context, args, options) {
+ var lastArg = (args.length > 0 ? args[args.length - 1] : null);
+ var argsWithoutCb = typeof lastArg === 'function' ?
+ args.slice(0, args.length - 1) :
+ args;
+ var _this = this;
+
+ var useLegacyPost;
+ if (typeof options === 'object') {
+ useLegacyPost = options && options.useLegacyPost;
+ } else {
+ useLegacyPost = options;
+ }
+ options = options || {};
+
+ this.execPre(name, context, function(error) {
+ if (error) {
+ return _handleWrapError(_this, error, name, context, argsWithoutCb,
+ options, lastArg)
+ }
+
+ var end = (typeof lastArg === 'function' ? args.length - 1 : args.length);
+
+ fn.apply(context, args.slice(0, end).concat(function() {
+ var args = arguments;
+ var argsWithoutError = Array.prototype.slice.call(arguments, 1);
+ if (arguments[0]) {
+ // Assume error
+ return _handleWrapError(_this, arguments[0], name, context,
+ args, options, lastArg);
+ } else {
+ if (useLegacyPost && typeof lastArg === 'function') {
+ lastArg.apply(context, arguments);
+ }
+
+ _this.execPost(name, context, argsWithoutError, function() {
+ if (arguments[0]) {
+ return typeof lastArg === 'function' ?
+ lastArg(arguments[0]) :
+ undefined;
+ }
+
+ return typeof lastArg === 'function' && !useLegacyPost ?
+ lastArg.apply(context, arguments) :
+ undefined;
+ });
+ }
+ }));
+ });
+};
+
+Kareem.prototype.createWrapper = function(name, fn, context, options) {
+ var _this = this;
+ return function() {
+ var args = Array.prototype.slice.call(arguments);
+ _this.wrap(name, fn, context, args, options);
+ };
+};
+
+Kareem.prototype.pre = function(name, isAsync, fn, error) {
+ if (typeof arguments[1] !== 'boolean') {
+ error = fn;
+ fn = isAsync;
+ isAsync = false;
+ }
+
+ this._pres[name] = this._pres[name] || [];
+ var pres = this._pres[name];
+
+ if (isAsync) {
+ pres.numAsync = pres.numAsync || 0;
+ ++pres.numAsync;
+ }
+
+ pres.push({ fn: fn, isAsync: isAsync });
+
+ return this;
+};
+
+Kareem.prototype.post = function(name, fn) {
+ (this._posts[name] = this._posts[name] || []).push(fn);
+ return this;
+};
+
+Kareem.prototype.clone = function() {
+ var n = new Kareem();
+ for (var key in this._pres) {
+ n._pres[key] = this._pres[key].slice();
+ }
+ for (var key in this._posts) {
+ n._posts[key] = this._posts[key].slice();
+ }
+
+ return n;
+};
+
+module.exports = Kareem;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/package.json
new file mode 100644
index 0000000..45e4a65
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "kareem",
+ "version": "1.1.3",
+ "description": "Next-generation take on pre/post function hooks",
+ "main": "index.js",
+ "scripts": {
+ "test": "./node_modules/mocha/bin/mocha ./test/*",
+ "test-travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec ./test/*"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/vkarpov15/kareem.git"
+ },
+ "devDependencies": {
+ "acquit": "0.0.3",
+ "gulp": "3.8.10",
+ "gulp-mocha": "2.0.0",
+ "gulp-jscs": "1.4.0",
+ "istanbul": "0.3.5",
+ "jscs": "1.9.0",
+ "mocha": "2.0.0"
+ },
+ "jscsConfig": {
+ "preset": "airbnb",
+ "requireMultipleVarDecl": null,
+ "disallowMultipleVarDecl": true
+ },
+ "author": {
+ "name": "Valeri Karpov",
+ "email": "val@karpov.io"
+ },
+ "license": "Apache 2.0",
+ "gitHead": "87171c8d0d3743d7f3a5dce2e540314b32980920",
+ "bugs": {
+ "url": "https://github.com/vkarpov15/kareem/issues"
+ },
+ "homepage": "https://github.com/vkarpov15/kareem#readme",
+ "_id": "kareem@1.1.3",
+ "_shasum": "0877610d8879c38da62d1dbafde4e17f2692f041",
+ "_from": "kareem@1.1.3",
+ "_npmVersion": "3.8.6",
+ "_nodeVersion": "6.0.0",
+ "_npmUser": {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ "dist": {
+ "shasum": "0877610d8879c38da62d1dbafde4e17f2692f041",
+ "tarball": "https://registry.npmjs.org/kareem/-/kareem-1.1.3.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "vkarpov15",
+ "email": "valkar207@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/kareem-1.1.3.tgz_1467040511533_0.5054662451148033"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/kareem/-/kareem-1.1.3.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/examples.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/examples.test.js
new file mode 100644
index 0000000..96d2fb8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/examples.test.js
@@ -0,0 +1,339 @@
+var assert = require('assert');
+var Kareem = require('../');
+
+/* Much like [hooks](https://npmjs.org/package/hooks), kareem lets you define
+ * pre and post hooks: pre hooks are called before a given function executes.
+ * Unlike hooks, kareem stores hooks and other internal state in a separate
+ * object, rather than relying on inheritance. Furthermore, kareem exposes
+ * an `execPre()` function that allows you to execute your pre hooks when
+ * appropriate, giving you more fine-grained control over your function hooks.
+ */
+describe('pre hooks', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('runs without any hooks specified', function(done) {
+ hooks.execPre('cook', null, function() {
+ done();
+ });
+ });
+
+ /* pre hook functions take one parameter, a "done" function that you execute
+ * when your pre hook is finished.
+ */
+ it('runs basic serial pre hooks', function(done) {
+ var count = 0;
+
+ hooks.pre('cook', function(done) {
+ ++count;
+ done();
+ });
+
+ hooks.execPre('cook', null, function() {
+ assert.equal(1, count);
+ done();
+ });
+ });
+
+ it('can run multipe pre hooks', function(done) {
+ var count1 = 0;
+ var count2 = 0;
+
+ hooks.pre('cook', function(done) {
+ ++count1;
+ done();
+ });
+
+ hooks.pre('cook', function(done) {
+ ++count2;
+ done();
+ });
+
+ hooks.execPre('cook', null, function() {
+ assert.equal(1, count1);
+ assert.equal(1, count2);
+ done();
+ });
+ });
+
+ /* If your pre hook function takes no parameters, its assumed to be
+ * fully synchronous.
+ */
+ it('can run fully synchronous pre hooks', function(done) {
+ var count1 = 0;
+ var count2 = 0;
+
+ hooks.pre('cook', function() {
+ ++count1;
+ });
+
+ hooks.pre('cook', function() {
+ ++count2;
+ });
+
+ hooks.execPre('cook', null, function(error) {
+ assert.equal(null, error);
+ assert.equal(1, count1);
+ assert.equal(1, count2);
+ done();
+ });
+ });
+
+ /* Pre save hook functions are bound to the second parameter to `execPre()`
+ */
+ it('properly attaches context to pre hooks', function(done) {
+ hooks.pre('cook', function(done) {
+ this.bacon = 3;
+ done();
+ });
+
+ hooks.pre('cook', function(done) {
+ this.eggs = 4;
+ done();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ // In the pre hooks, `this` will refer to `obj`
+ hooks.execPre('cook', obj, function(error) {
+ assert.equal(null, error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ done();
+ });
+ });
+
+ /* Like the hooks module, you can declare "async" pre hooks - these take two
+ * parameters, the functions `next()` and `done()`. `next()` passes control to
+ * the next pre hook, but the underlying function won't be called until all
+ * async pre hooks have called `done()`.
+ */
+ it('can execute parallel (async) pre hooks', function(done) {
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ hooks.execPre('cook', obj, function() {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ done();
+ });
+ });
+});
+
+describe('post hooks', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('runs without any hooks specified', function(done) {
+ hooks.execPost('cook', null, [1], function(error, eggs) {
+ assert.ifError(error);
+ assert.equal(1, eggs);
+ done();
+ });
+ });
+
+ it('executes with parameters passed in', function(done) {
+ hooks.post('cook', function(eggs, bacon, callback) {
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ callback();
+ });
+
+ hooks.execPost('cook', null, [1, 2], function(error, eggs, bacon) {
+ assert.ifError(error);
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ done();
+ });
+ });
+
+ it('can use synchronous post hooks', function(done) {
+ var execed = {};
+
+ hooks.post('cook', function(eggs, bacon) {
+ execed.first = true;
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ });
+
+ hooks.post('cook', function(eggs, bacon, callback) {
+ execed.second = true;
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ callback();
+ });
+
+ hooks.execPost('cook', null, [1, 2], function(error, eggs, bacon) {
+ assert.ifError(error);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ assert.equal(1, eggs);
+ assert.equal(2, bacon);
+ done();
+ });
+ });
+});
+
+describe('wrap()', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('wraps pre and post calls into one call', function(done) {
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+ args.push(function(error, result) {
+ assert.ifError(error);
+ assert.equal(null, error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal('no', obj.tofu);
+
+ assert.equal(obj, result);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal(undefined, obj.tofu);
+ callback(null, o);
+ },
+ obj,
+ args);
+ });
+});
+
+describe('createWrapper()', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('wraps wrap() into a callable function', function(done) {
+ hooks.pre('cook', true, function(next, done) {
+ this.bacon = 3;
+ next();
+ setTimeout(function() {
+ done();
+ }, 5);
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ next();
+ var _this = this;
+ setTimeout(function() {
+ _this.eggs = 4;
+ done();
+ }, 10);
+ });
+
+ hooks.pre('cook', function(next) {
+ this.waffles = false;
+ next();
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var cook = hooks.createWrapper(
+ 'cook',
+ function(o, callback) {
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal(undefined, obj.tofu);
+ callback(null, o);
+ },
+ obj);
+
+ cook(obj, function(error, result) {
+ assert.ifError(error);
+ assert.equal(3, obj.bacon);
+ assert.equal(4, obj.eggs);
+ assert.equal(false, obj.waffles);
+ assert.equal('no', obj.tofu);
+
+ assert.equal(obj, result);
+ done();
+ });
+ });
+});
+
+describe('clone()', function() {
+ it('clones a Kareem object', function() {
+ var k1 = new Kareem();
+ k1.pre('cook', function() {});
+ k1.post('cook', function() {});
+
+ var k2 = k1.clone();
+ assert.deepEqual(['cook'], Object.keys(k2._pres));
+ assert.deepEqual(['cook'], Object.keys(k2._posts));
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/post.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/post.test.js
new file mode 100644
index 0000000..9fcbb0e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/post.test.js
@@ -0,0 +1,155 @@
+var assert = require('assert');
+var Kareem = require('../');
+
+describe('execPost', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('handles errors', function(done) {
+ hooks.post('cook', function(eggs, callback) {
+ callback('error!');
+ });
+
+ hooks.execPost('cook', null, [4], function(error, eggs) {
+ assert.equal('error!', error);
+ assert.ok(!eggs);
+ done();
+ });
+ });
+
+ it('multiple posts', function(done) {
+ hooks.post('cook', function(eggs, callback) {
+ setTimeout(
+ function() {
+ callback();
+ },
+ 5);
+ });
+
+ hooks.post('cook', function(eggs, callback) {
+ setTimeout(
+ function() {
+ callback();
+ },
+ 5);
+ });
+
+ hooks.execPost('cook', null, [4], function(error, eggs) {
+ assert.ifError(error);
+ assert.equal(4, eggs);
+ done();
+ });
+ });
+
+ it('error posts', function(done) {
+ var called = {};
+ hooks.post('cook', function(eggs, callback) {
+ called.first = true;
+ callback();
+ });
+
+ hooks.post('cook', function(eggs, callback) {
+ called.second = true;
+ callback(new Error('fail'));
+ });
+
+ hooks.post('cook', function(eggs, callback) {
+ assert.ok(false);
+ });
+
+ hooks.post('cook', function(error, eggs, callback) {
+ called.fourth = true;
+ assert.equal(error.message, 'fail');
+ callback(new Error('fourth'));
+ });
+
+ hooks.post('cook', function(error, eggs, callback) {
+ called.fifth = true;
+ assert.equal(error.message, 'fourth');
+ callback(new Error('fifth'));
+ });
+
+ hooks.execPost('cook', null, [4], function(error, eggs) {
+ assert.ok(error);
+ assert.equal(error.message, 'fifth');
+ assert.deepEqual(called, {
+ first: true,
+ second: true,
+ fourth: true,
+ fifth: true
+ });
+ done();
+ });
+ });
+
+ it('error posts with initial error', function(done) {
+ var called = {};
+
+ hooks.post('cook', function(eggs, callback) {
+ assert.ok(false);
+ });
+
+ hooks.post('cook', function(error, eggs, callback) {
+ called.second = true;
+ assert.equal(error.message, 'fail');
+ callback(new Error('second'));
+ });
+
+ hooks.post('cook', function(error, eggs, callback) {
+ called.third = true;
+ assert.equal(error.message, 'second');
+ callback(new Error('third'));
+ });
+
+ hooks.post('cook', function(error, eggs, callback) {
+ called.fourth = true;
+ assert.equal(error.message, 'third');
+ callback();
+ });
+
+ var options = { error: new Error('fail') };
+ hooks.execPost('cook', null, [4], options, function(error, eggs) {
+ assert.ok(error);
+ assert.equal(error.message, 'third');
+ assert.deepEqual(called, {
+ second: true,
+ third: true,
+ fourth: true
+ });
+ done();
+ });
+ });
+});
+
+describe('execPostSync', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('executes hooks synchronously', function() {
+ var execed = {};
+
+ hooks.post('cook', function() {
+ execed.first = true;
+ });
+
+ hooks.post('cook', function() {
+ execed.second = true;
+ });
+
+ hooks.execPostSync('cook', null);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ });
+
+ it('works with no hooks specified', function() {
+ assert.doesNotThrow(function() {
+ hooks.execPostSync('cook', null);
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/pre.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/pre.test.js
new file mode 100644
index 0000000..adbbc39
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/pre.test.js
@@ -0,0 +1,256 @@
+var assert = require('assert');
+var Kareem = require('../');
+
+describe('execPre', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('handles errors with multiple pres', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', function(done) {
+ execed.first = true;
+ done();
+ });
+
+ hooks.pre('cook', function(done) {
+ execed.second = true;
+ done('error!');
+ });
+
+ hooks.pre('cook', function(done) {
+ execed.third = true;
+ done();
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.equal('error!', err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('handles async errors', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.first = true;
+ setTimeout(
+ function() {
+ done('error!');
+ },
+ 5);
+
+ next();
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.second = true;
+ setTimeout(
+ function() {
+ done('other error!');
+ },
+ 10);
+
+ next();
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.equal('error!', err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('handles async errors in next()', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.first = true;
+ setTimeout(
+ function() {
+ done('other error!');
+ },
+ 15);
+
+ next();
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.second = true;
+ setTimeout(
+ function() {
+ next('error!');
+ done('another error!');
+ },
+ 5);
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.equal('error!', err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('handles async errors in next() when already done', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.first = true;
+ setTimeout(
+ function() {
+ done('other error!');
+ },
+ 5);
+
+ next();
+ });
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.second = true;
+ setTimeout(
+ function() {
+ next('error!');
+ done('another error!');
+ },
+ 25);
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.equal('other error!', err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('returns correct error when async pre errors', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.first = true;
+ setTimeout(
+ function() {
+ done('other error!');
+ },
+ 5);
+
+ next();
+ });
+
+ hooks.pre('cook', function(next) {
+ execed.second = true;
+ setTimeout(
+ function() {
+ next('error!');
+ },
+ 15);
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.equal('other error!', err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('lets async pres run when fully sync pres are done', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', true, function(next, done) {
+ execed.first = true;
+ setTimeout(
+ function() {
+ done();
+ },
+ 5);
+
+ next();
+ });
+
+ hooks.pre('cook', function() {
+ execed.second = true;
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.ifError(err);
+ assert.equal(2, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ done();
+ });
+ });
+
+ it('allows passing arguments to the next pre', function(done) {
+ var execed = {};
+
+ hooks.pre('cook', function(next) {
+ execed.first = true;
+ next(null, 'test');
+ });
+
+ hooks.pre('cook', function(next, p) {
+ execed.second = true;
+ assert.equal(p, 'test');
+ next();
+ });
+
+ hooks.pre('cook', function(next, p) {
+ execed.third = true;
+ assert.ok(!p);
+ next();
+ });
+
+ hooks.execPre('cook', null, function(err) {
+ assert.ifError(err);
+ assert.equal(3, Object.keys(execed).length);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ assert.ok(execed.third);
+ done();
+ });
+ });
+});
+
+describe('execPreSync', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('executes hooks synchronously', function() {
+ var execed = {};
+
+ hooks.pre('cook', function() {
+ execed.first = true;
+ });
+
+ hooks.pre('cook', function() {
+ execed.second = true;
+ });
+
+ hooks.execPreSync('cook', null);
+ assert.ok(execed.first);
+ assert.ok(execed.second);
+ });
+
+ it('works with no hooks specified', function() {
+ assert.doesNotThrow(function() {
+ hooks.execPreSync('cook', null);
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/wrap.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/wrap.test.js
new file mode 100644
index 0000000..b3fe7d0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/kareem/test/wrap.test.js
@@ -0,0 +1,347 @@
+var assert = require('assert');
+var Kareem = require('../');
+
+describe('wrap()', function() {
+ var hooks;
+
+ beforeEach(function() {
+ hooks = new Kareem();
+ });
+
+ it('handles pre errors', function(done) {
+ hooks.pre('cook', function(done) {
+ done('error!');
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+ args.push(function(error, result) {
+ assert.equal('error!', error);
+ assert.ok(!result);
+ assert.equal(undefined, obj.tofu);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ // Should never get called
+ assert.ok(false);
+ callback(null, o);
+ },
+ obj,
+ args);
+ });
+
+ it('handles pre errors when no callback defined', function(done) {
+ hooks.pre('cook', function(done) {
+ done('error!');
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ // Should never get called
+ assert.ok(false);
+ callback(null, o);
+ },
+ obj,
+ args);
+
+ setTimeout(
+ function() {
+ done();
+ },
+ 25);
+ });
+
+ it('handles errors in wrapped function', function(done) {
+ hooks.pre('cook', function(done) {
+ done();
+ });
+
+ hooks.post('cook', function(obj) {
+ obj.tofu = 'no';
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+ args.push(function(error, result) {
+ assert.equal('error!', error);
+ assert.ok(!result);
+ assert.equal(undefined, obj.tofu);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ callback('error!');
+ },
+ obj,
+ args);
+ });
+
+ it('handles errors in post', function(done) {
+ hooks.pre('cook', function(done) {
+ done();
+ });
+
+ hooks.post('cook', function(obj, callback) {
+ obj.tofu = 'no';
+ callback('error!');
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [obj];
+ args.push(function(error, result) {
+ assert.equal('error!', error);
+ assert.ok(!result);
+ assert.equal('no', obj.tofu);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(o, callback) {
+ callback(null, o);
+ },
+ obj,
+ args);
+ });
+
+ it('defers errors to post hooks if enabled', function(done) {
+ hooks.pre('cook', function(done) {
+ done(new Error('fail'));
+ });
+
+ hooks.post('cook', function(error, callback) {
+ callback(new Error('another error occurred'));
+ });
+
+ var args = [];
+ args.push(function(error) {
+ assert.equal(error.message, 'another error occurred');
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ assert.ok(false);
+ callback();
+ },
+ null,
+ args,
+ { useErrorHandlers: true });
+ });
+
+ it('error handlers with no callback', function(done) {
+ hooks.pre('cook', function(done) {
+ done(new Error('fail'));
+ });
+
+ hooks.post('cook', function(error, callback) {
+ assert.equal(error.message, 'fail');
+ done();
+ });
+
+ var args = [];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ assert.ok(false);
+ callback();
+ },
+ null,
+ args,
+ { useErrorHandlers: true });
+ });
+
+ it('error handlers with no error', function(done) {
+ hooks.post('cook', function(error, callback) {
+ callback(new Error('another error occurred'));
+ });
+
+ var args = [];
+ args.push(function(error) {
+ assert.ifError(error);
+ done();
+ });
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback();
+ },
+ null,
+ args,
+ { useErrorHandlers: true });
+ });
+
+ it('works with no args', function(done) {
+ hooks.pre('cook', function(done) {
+ done();
+ });
+
+ hooks.post('cook', function(callback) {
+ obj.tofu = 'no';
+ callback();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback(null);
+ },
+ obj,
+ args);
+
+ setTimeout(
+ function() {
+ assert.equal('no', obj.tofu);
+ done();
+ },
+ 25);
+ });
+
+ it('handles pre errors with no args', function(done) {
+ hooks.pre('cook', function(done) {
+ done('error!');
+ });
+
+ hooks.post('cook', function(callback) {
+ obj.tofu = 'no';
+ callback();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback(null);
+ },
+ obj,
+ args);
+
+ setTimeout(
+ function() {
+ assert.equal(undefined, obj.tofu);
+ done();
+ },
+ 25);
+ });
+
+ it('handles wrapped function errors with no args', function(done) {
+ hooks.pre('cook', function(done) {
+ obj.waffles = false;
+ done();
+ });
+
+ hooks.post('cook', function(callback) {
+ obj.tofu = 'no';
+ callback();
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback('error!');
+ },
+ obj,
+ args);
+
+ setTimeout(
+ function() {
+ assert.equal(false, obj.waffles);
+ assert.equal(undefined, obj.tofu);
+ done();
+ },
+ 25);
+ });
+
+ it('handles post errors with no args', function(done) {
+ hooks.pre('cook', function(done) {
+ obj.waffles = false;
+ done();
+ });
+
+ hooks.post('cook', function(callback) {
+ obj.tofu = 'no';
+ callback('error!');
+ });
+
+ var obj = { bacon: 0, eggs: 0 };
+
+ var args = [];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback();
+ },
+ obj,
+ args);
+
+ setTimeout(
+ function() {
+ assert.equal(false, obj.waffles);
+ assert.equal('no', obj.tofu);
+ done();
+ },
+ 25);
+ });
+
+ it('can use legacy post behavior', function(done) {
+ var called = 0;
+ hooks.post('cook', function(callback) {
+ ++called;
+ callback();
+ });
+
+ var args = [function(error) {
+ assert.equal(called, 0);
+
+ setTimeout(function() {
+ assert.equal(called, 1);
+ done();
+ }, 0);
+ }];
+
+ hooks.wrap(
+ 'cook',
+ function(callback) {
+ callback();
+ },
+ null,
+ args,
+ true);
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/.coveralls.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/.coveralls.yml
new file mode 100644
index 0000000..ad1e93c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/.coveralls.yml
@@ -0,0 +1 @@
+repo_token: GZFmqKPy7XEX0uOl9TDZFUoOQ5AHADMkU
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/HISTORY.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/HISTORY.md
new file mode 100644
index 0000000..0c03f52
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/HISTORY.md
@@ -0,0 +1,1547 @@
+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 <db>.fs.chunks or <db>.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 '\<Object\>' 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/LICENSE
new file mode 100644
index 0000000..ad410e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/Makefile
new file mode 100644
index 0000000..36e1202
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/README.md
new file mode 100644
index 0000000..73f2785
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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 Chat.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) <http://christiankvalheim.com>
+
+### 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 <https://jira.mongodb.org>.
+- Navigate to the NODE project <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
+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');
+ // Insert some documents
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/boot_auth.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/boot_auth.js
new file mode 100644
index 0000000..95956c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/conf.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/conf.json
new file mode 100644
index 0000000..aba0b7a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/conf.json
@@ -0,0 +1,73 @@
+{
+ "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"
+ ]
+ },
+ "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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/index.js
new file mode 100644
index 0000000..5808750
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/index.js
@@ -0,0 +1,55 @@
+// 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.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/insert_bench.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/insert_bench.js
new file mode 100644
index 0000000..5c4d0b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/admin.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/admin.js
new file mode 100644
index 0000000..528d582
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/admin.js
@@ -0,0 +1,581 @@
+"use strict";
+
+var toError = require('./utils').toError,
+ Define = require('./metadata'),
+ shallowClone = require('./utils').shallowClone;
+
+/**
+ * @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);
+ var self = this;
+
+ // 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) {
+ doc = 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
+ */
+Admin.prototype.authenticate = function(username, password, options, callback) {
+ var self = this;
+ if(typeof options == 'function') callback = options, options = {};
+ options = shallowClone(options);
+ options.authdb = 'admin';
+
+ // Execute using callback
+ if(typeof callback == 'function') return this.s.db.authenticate(username, password, options, callback);
+
+ // Return a Promise
+ return new this.s.promiseLibrary(function(resolve, reject) {
+ self.s.db.authenticate(username, password, options, function(err, r) {
+ if(err) return reject(err);
+ resolve(r);
+ });
+ });
+}
+
+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, r) {
+ 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) {
+ doc = 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});
+
+/**
+ * Retrive the current profiling information for MongoDB
+ *
+ * @param {Admin~resultCallback} [callback] The command result callback.
+ * @return {Promise} returns Promise if no callback passed
+ */
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js
new file mode 100644
index 0000000..7546ee3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/aggregation_cursor.js
@@ -0,0 +1,444 @@
+"use strict";
+
+var inherits = require('util').inherits
+ , f = require('util').format
+ , toError = require('./utils').toError
+ , getSingleProperty = require('./utils').getSingleProperty
+ , formattedOrderClause = require('./utils').formattedOrderClause
+ , handleCallback = require('./utils').handleCallback
+ , Logger = require('mongodb-core').Logger
+ , EventEmitter = require('events').EventEmitter
+ , ReadPreference = require('./read_preference')
+ , MongoError = require('mongodb-core').MongoError
+ , Readable = require('stream').Readable || require('readable-stream').Readable
+ , Define = require('./metadata')
+ , CoreCursor = require('./cursor')
+ , Query = require('mongodb-core').Query;
+
+/**
+ * @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 self = this;
+ 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
+ // Namespae
+ , 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);
+
+// Set the methods to inherit from prototype
+var methodsToInherit = ['_next', 'next', 'each', 'forEach', 'toArray'
+ , 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill'
+ , '_find', '_getmore', '_killcursor', 'isDead', 'explain', 'isNotified'];
+
+// 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", 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
+ * @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('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
+ */
+
+/**
+ * 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 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.
+ * @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 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
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/apm.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/apm.js
new file mode 100644
index 0000000..3810c3f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/apm.js
@@ -0,0 +1,613 @@
+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'),
+ Server = require('./server'),
+ ReplSet = require('./replset'),
+ Mongos = require('./mongos'),
+ Cursor = require('./cursor'),
+ Collection = require('./collection'),
+ Db = require('./db'),
+ Admin = require('./admin');
+
+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 aruments
+ 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];
+
+ // Do we have a legacy insert/update/remove command
+ if(x == 'insert') { //} && !this.lastIsMaster().maxWireVersion) {
+ commandName = 'insert';
+ // Get the collection
+ var col = ns.split('.');
+ col.shift();
+ col = col.join('.');
+
+ // 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';
+
+ // Get the collection
+ var col = ns.split('.');
+ col.shift();
+ col = col.join('.');
+
+ // 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';
+
+ // Get the collection
+ var col = ns.split('.');
+ col.shift();
+ col = col.join('.');
+
+ // 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;
+ // } else if(x == 'insert' || x == 'update' || x == 'remove' && this.lastIsMaster().maxWireVersion >= 2) {
+ // // Skip the insert/update/remove commands as they are executed as actual write commands in 2.6 or higher
+ // return func.apply(this, args);
+ }
+
+ // console.log("=== APM 0")
+
+ // 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();
+ // console.log("=== APM 1")
+
+ // Get a connection reference for this server instance
+ var connection = this.s.pool.get()
+
+ // console.log("=== APM 2")
+ // 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
+ };
+
+ // console.log("=== APM 3")
+
+ // Filter out any sensitive commands
+ if(senstiveCommands.indexOf(commandName.toLowerCase())) {
+ 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())) {
+ 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
+ var 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() {
+ var bulk = this;
+ // Get the aruments
+ 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
+ var methods = ['_find', '_getmore', '_killcursor'];
+ var 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 == '_killcursors') {
+ 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
+ var 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 aruments
+ 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
+ var command = {
+ duration: timestampGenerator.duration(startTime, timestampGenerator.current()),
+ commandName: commandName,
+ requestId: requestId,
+ operationId: cursor.operationId,
+ connectionId: cursor.server.getConnection(),
+ reply: [{ok:1}]
+ };
+
+ // 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' && 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
+ var 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(r) {
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js
new file mode 100644
index 0000000..ff723bb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/common.js
@@ -0,0 +1,440 @@
+"use strict";
+
+var utils = require('../utils'),
+ 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
+ *
+ * @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 instanceof 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(var i = 0; i < result.writeErrors.length; i++) {
+
+ var 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/ordered.js
new file mode 100644
index 0000000..b6c183d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/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
+ , f = require('util').format
+ , handleCallback = require('../utils').handleCallback
+ , shallowClone = utils.shallowClone
+ , WriteError = common.WriteError
+ , BulkWriteResult = common.BulkWriteResult
+ , LegacyOp = common.LegacyOp
+ , ObjectID = require('mongodb-core').BSON.ObjectID
+ , Define = require('../metadata')
+ , BSON = require('mongodb-core').BSON
+ , Batch = common.Batch
+ , mergeBatchResults = common.mergeBatchResults;
+
+var bson = new BSON.BSONPure();
+
+/**
+ * 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, 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 self = this;
+ 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;
+ }
+
+ // Current batch
+ var currentBatch = null;
+ var currentIndex = 0;
+ var currentBatchSize = 0;
+ var currentBatchSizeBytes = 0;
+ var batches = [];
+
+ // 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;
+ var 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) throw new toError("batch cannot be re-executed");
+ if(typeof _writeConcern == 'function') {
+ callback = _writeConcern;
+ } else {
+ 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) {
+ throw toError("Invalid Operation, No operations in bulk");
+ }
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js
new file mode 100644
index 0000000..ecb91db
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/bulk/unordered.js
@@ -0,0 +1,542 @@
+"use strict";
+
+var common = require('./common')
+ , utils = require('../utils')
+ , toError = require('../utils').toError
+ , f = require('util').format
+ , handleCallback = require('../utils').handleCallback
+ , shallowClone = utils.shallowClone
+ , WriteError = common.WriteError
+ , BulkWriteResult = common.BulkWriteResult
+ , LegacyOp = common.LegacyOp
+ , ObjectID = require('mongodb-core').BSON.ObjectID
+ , BSON = require('mongodb-core').BSON
+ , Define = require('../metadata')
+ , Batch = common.Batch
+ , mergeBatchResults = common.mergeBatchResults;
+
+var bson = new BSON.BSONPure();
+
+/**
+ * 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 {UnorderedBulkOperation}
+ */
+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, 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.currentIndex, _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
+ * @return {UnorderedBulkOperation} a UnorderedBulkOperation instance.
+ */
+var UnorderedBulkOperation = function(topology, collection, options) {
+ options = options == null ? {} : options;
+
+ // Contains reference to self
+ var self = this;
+ // Get the namesspace 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;
+ var currentIndex = 0;
+ var batches = [];
+
+ // The current Batches for the different operations
+ var currentInsertBatch = null;
+ var currentUpdateBatch = null;
+ var currentRemoveBatch = 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;
+ var 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;
+ var error = null;
+ // Execute over all the batches
+ for(var i = 0; i < self.s.batches.length; i++) {
+ executeBatch(self, self.s.batches[i], function(err, result) {
+ // 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) throw toError("batch cannot be re-executed");
+ if(typeof _writeConcern == 'function') {
+ callback = _writeConcern;
+ } else {
+ 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) {
+ throw toError("Invalid Operation, No operations in bulk");
+ }
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/collection.js
new file mode 100644
index 0000000..bae5d5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/collection.js
@@ -0,0 +1,3360 @@
+"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();
+ * });
+ * });
+ */
+
+/**
+ * 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);
+ var self = this;
+ // Unpack variables
+ var internalHint = null;
+ var opts = options != null && ('object' === typeof options) ? options : {};
+ 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(var 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
+ var object = fields;
+ 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 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 instanceof ObjectID || (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 {
+ for (var i = 0, l = options.fields.length; i < l; i++) {
+ fields[options.fields[i]] = 1;
+ }
+ }
+ } else {
+ fields = options.fields;
+ }
+ }
+
+ if (!options) options = {};
+
+ var newOptions = {};
+ // 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 ignoreUndfined
+ 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 mapInserManyResults = 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 {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 || {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, mapInserManyResults(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(mapInserManyResults(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 ignoreUndfined
+ 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(var 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 == null) 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) {
+ var self = this;
+ 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 ignoreUndfined
+ 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.matchedCount = r.result.n;
+ 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;
+ 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, update, options, callback) {
+ var self = this;
+ if(typeof options == 'function') callback = options, options = {};
+ options = shallowClone(options)
+
+ // Add ignoreUndfined
+ 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, update, options, callback);
+
+ // Return a Promise
+ return new this.s.promiseLibrary(function(resolve, reject) {
+ replaceOne(self, filter, update, options, function(err, r) {
+ if(err) return reject(err);
+ resolve(r);
+ });
+ });
+}
+
+var replaceOne = 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.matchedCount = r.result.n;
+ 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.ops = [update];
+ 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 ignoreUndfined
+ 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.matchedCount = r.result.n;
+ 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;
+ 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 = typeof options.upsert == 'boolean' ? options.upsert : false;
+ op.multi = typeof options.multi == 'boolean' ? 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 ignoreUndfined
+ 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 = {};
+ var options = shallowClone(options);
+
+ // Add ignoreUndfined
+ 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 = {};
+ var options = shallowClone(options);
+
+ // Add ignoreUndfined
+ 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 ignoreUndfined
+ 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 ignoreUndfined
+ 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 miliseconds 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 {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.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, result) {
+ 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};
+
+ // Decorate command with writeConcern if supported
+ decorateWithWriteConcern(cmd, self, options);
+
+ // 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
+ var 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
+ var 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 miliseconds 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) options.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 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.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'] = typeof options.returnOriginal == 'boolean' ? !options.returnOriginal : false;
+ finalOptions['upsert'] = typeof options.upsert == 'boolean' ? 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
+ var 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');
+ }
+
+ // 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');
+ }
+
+ if(this.s.topology.capabilities().hasAggregationCursor) {
+ options.cursor = options.cursor || { batchSize : 1000 };
+ command.cursor = options.cursor;
+ }
+
+ // 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);
+ }
+
+ var cursor = null;
+ // We do not allow cursor
+ if(options.cursor) {
+ return this.s.topology.cursor(this.s.namespace, command, options);
+ }
+
+ // Execute the command
+ 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;
+
+ // Command cursor options
+ var cmd = {
+ batchSize: options.batchSize
+ , cursorId: cursorId
+ , items: result.cursors[i].cursor.firstBatch
+ }
+
+ // 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, utils.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
+ */
+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 instanceof 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 instanceof 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 instanceof Code) {
+ selector.group.$keyf = keys instanceof 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 instanceof 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 instanceof 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
+ };
+
+ // Add any other options passed in
+ for(var n in options) {
+ if('scope' == n) {
+ mapCommandHash[n] = processScope(options[n]);
+ } else {
+ 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, coll) {
+ 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, {maxStalenessMS: r.maxStalenessMS});
+ } 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, {maxStalenessMS: r.maxStalenessMS});
+ }
+ }
+
+ 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
+}
+
+module.exports = Collection;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js
new file mode 100644
index 0000000..c0d86ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/command_cursor.js
@@ -0,0 +1,320 @@
+"use strict";
+
+var inherits = require('util').inherits
+ , f = require('util').format
+ , toError = require('./utils').toError
+ , getSingleProperty = require('./utils').getSingleProperty
+ , formattedOrderClause = require('./utils').formattedOrderClause
+ , handleCallback = require('./utils').handleCallback
+ , Logger = require('mongodb-core').Logger
+ , EventEmitter = require('events').EventEmitter
+ , ReadPreference = require('./read_preference')
+ , MongoError = require('mongodb-core').MongoError
+ , Readable = require('stream').Readable || require('readable-stream').Readable
+ , Define = require('./metadata')
+ , CoreCursor = require('./cursor')
+ , Query = require('mongodb-core').Query
+ , 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 self = this;
+ 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
+ // Namespae
+ , 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', 'each', 'forEach', 'toArray'
+ , 'rewind', 'bufferedCount', 'readBufferedDocuments', 'close', 'isClosed', 'kill'
+ , '_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, {maxStalenessMS: r.maxStalenessMS});
+ } 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('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
+ */
+
+/**
+ * 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 previouly 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 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
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/cursor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/cursor.js
new file mode 100644
index 0000000..44431c1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/cursor.js
@@ -0,0 +1,1182 @@
+"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
+ , Query = require('mongodb-core').Query
+ , 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;
+}
+
+/**
+ * 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(!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 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
+ * 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, {maxStalenessMS: r.maxStalenessMS});
+ } 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 previouly 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 miliseconds 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
+ }
+
+ 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;
+
+ // 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)
+ });
+}
+
+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, reject) {
+ resolve();
+ });
+}
+
+define.classMethod('close', {callback: true, promise:true});
+
+/**
+ * Map all documents using the provided function
+ * @method
+ * @param {function} [transform] The mapping transformation method.
+ * @return {null}
+ */
+Cursor.prototype.map = function(transform) {
+ 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(n) {
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/db.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/db.js
new file mode 100644
index 0000000..ca7c486
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/db.js
@@ -0,0 +1,1886 @@
+"use strict";
+
+var EventEmitter = require('events').EventEmitter
+ , 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')
+ , 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'];
+
+/**
+ * @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));
+}
+
+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, topology) {
+ 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, {maxStalenessMS: readPreference.maxStalenessMS});
+ } else if(readPreference && typeof readPreference == 'object') {
+ var mode = readPreference.mode || readPreference.preference;
+ if (mode && typeof mode == 'string') {
+ readPreference = new CoreReadPreference(mode, readPreference.tags, {maxStalenessMS: readPreference.maxStalenessMS});
+ }
+ }
+ 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, reject) {
+ 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.
+ */
+
+/**
+ * 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;
+ }
+
+ // 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(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}).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')
+ cmd[n] = options[n];
+ }
+
+ // Force a primary read Preference
+ finalOptions.readPreference = ReadPreference.PRIMARY;
+
+ // Execute command
+ self.command(cmd, finalOptions, function(err, result) {
+ 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.
+ *
+ * @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 {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 {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 {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);
+ }
+
+ // 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
+ var 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
+ var 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 instanceof 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 evaulation 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
+ var 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
+ var 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.replace(self.s.databaseName + ".", ''), 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);
+ // Run only against primary
+ options.readPreference = ReadPreference.PRIMARY;
+
+ // 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);
+ // 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(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)
+ // 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) {
+ 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'));
+
+ // Default command options
+ var commandOptions = {};
+ // Check if the index allready 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, documents) {
+ // 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, results, full) {
+ 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, result) {
+ 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);
+ });
+ });
+};
+
+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 authententicate is called from a retry context, it may be another one, like admin
+ var authdb = options.authdb ? options.authdb : options.dbName;
+ authdb = options.authSource ? options.authSource : authdb;
+ authdb = authdb ? authdb : self.databaseName;
+
+ // 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, result) {
+ if(err) return handleCallback(callback, err, false);
+ _callback(null, true);
+ });
+ } else if(authMechanism == 'PLAIN') {
+ self.s.topology.auth('plain', authdb, username, password, function(err, result) {
+ 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, result) {
+ 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, result) {
+ 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, result) {
+ if(err) return handleCallback(callback, err, false);
+ _callback(null, true);
+ });
+ } else {
+ self.s.topology.auth('gssapi', authdb, username, password, options, function(err, result) {
+ if(err) return handleCallback(callback, err, false);
+ _callback(null, true);
+ });
+ }
+ } else if(authMechanism == 'DEFAULT') {
+ self.s.topology.auth('default', authdb, username, password, function(err, result) {
+ 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}));
+ }
+}
+
+/**
+ * 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
+ */
+Db.prototype.authenticate = function(username, password, options, callback) {
+ if(typeof options == 'function') callback = options, options = {};
+ var self = this;
+ // 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 this.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);
+ });
+ });
+};
+
+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, r) {
+ 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, r) {
+ if(err) return reject(err);
+ resolve(true);
+ });
+ });
+}
+
+define.classMethod('logout', {callback: true, promise:true});
+
+// Figure out the read preference
+var getReadPreference = function(options, db) {
+ if(options.readPreference) return options;
+ if(db.readPreference) options.readPreference = db.readPreference;
+ return options;
+}
+
+/**
+ * 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().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;
+ var keys = indexParameters.keys;
+
+ // 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(options, callback) {
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js
new file mode 100644
index 0000000..494c34a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/download.js
@@ -0,0 +1,399 @@
+var shallowClone = require('../utils').shallowClone;
+var stream = require('stream');
+var 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) {
+ var _this = this;
+ 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) {
+ var errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n +
+ ', expected: ' + expectedN;
+ return __handleError(_this, new Error(errmsg));
+ }
+
+ if (doc.data.length() !== expectedLength) {
+ if (bytesRemaining <= 0) {
+ var errmsg = 'ExtraChunk: Got unexpected n: ' + doc.n;
+ return __handleError(_this, new Error(errmsg));
+ }
+ var errmsg = 'ChunkIsWrongSize: Got unexpected length: ' +
+ doc.data.length() + ', expected: ' + expectedLength;
+ return __handleError(_this, new Error(errmsg));
+ }
+
+ _this.s.bytesRead += doc.data.length();
+
+ if (doc.data.buffer.length === 0) {
+ return _this.push(null);
+ }
+
+ var sliceStart = null;
+ var sliceEnd = null;
+ var buf = doc.data.buffer;
+
+ 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) < doc.data.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.cursor = self.s.chunks.find({ files_id: doc._id }).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.bytesToSkip = handleStartOption(self, doc, self.s.cursor,
+ self.s.options);
+ 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, cursor, 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 + ')');
+ }
+
+ cursor.skip(Math.floor(options.start / 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;
+ }
+}
+
+/**
+ * @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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js
new file mode 100644
index 0000000..fc388b9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/index.js
@@ -0,0 +1,366 @@
+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 };
+ var 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 };
+ var 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js
new file mode 100644
index 0000000..7625345
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs-stream/upload.js
@@ -0,0 +1,525 @@
+var core = require('mongodb-core');
+var crypto = require('crypto');
+var shallowClone = require('../utils').shallowClone;
+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;
+
+ 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) {
+ var 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) {
+ if(typeof chunk == 'function') {
+ callback = chunk, chunk = null, encoding = null;
+ } else if(typeof encoding == 'function') {
+ callback = encoding, encoding = null;
+ }
+
+ if (checkAborted(this, callback)) {
+ return;
+ }
+ var _this = this;
+ this.state.streamEnd = true;
+
+ if (callback) {
+ this.once('finish', function(result) {
+ callback(null, result);
+ });
+ }
+
+ if (!chunk) {
+ waitForIndexes(this, function() {
+ writeRemnant(_this);
+ });
+ return;
+ }
+
+ var _this = this;
+ var inputBuf = (Buffer.isBuffer(chunk)) ?
+ chunk : new Buffer(chunk, encoding);
+
+ 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 {
+ var 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.state.streamEnd &&
+ _this.state.outstandingRequests === 0 &&
+ !_this.state.errored) {
+ 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 {
+ var 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 = concern.w;
+ obj.wtimeout = concern.wtimeout;
+ obj.j = concern.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js
new file mode 100644
index 0000000..cbd3ee8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/chunk.js
@@ -0,0 +1,233 @@
+"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 self = this;
+ 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(mongoObjectFinal.data == null) {
+ } else 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)) {
+ var 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._bsontype === 'Binary') {
+ this.data = mongoObjectFinal.data;
+ } else if(Buffer.isBuffer(mongoObjectFinal.data)) {
+ } else {
+ 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(var 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, collection) {
+ 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:
+ *
+ * <pre><code>
+ * {
+ * '_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
+ * }
+ * </code></pre>
+ *
+ * @see <a href="http://www.mongodb.org/display/DOCS/GridFS+Specification#GridFSSpecification-{{chunks}}">MongoDB GridFS Chunk Object Structure</a>
+ */
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js
new file mode 100644
index 0000000..93afa50
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/gridfs/grid_store.js
@@ -0,0 +1,1956 @@
+"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 <a href="http://www.mongodb.org/display/DOCS/GridFS">here</a>.
+ *
+ * @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'),
+ timers = require('timers'),
+ 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 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 {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);
+ var self = this;
+ 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 instanceof 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(err, index) {
+ // 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(err, index) {
+ // 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;
+ var numberOfChunksLeft = Math.min(stats.size / self.chunkSize);
+
+ // Write a chunk
+ var writeChunk = function() {
+ fs.read(file, self.chunkSize, offset, 'binary', function(err, data, bytesRead) {
+ 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, function(err, chunk) {
+ if(err) return callback(err, self);
+
+ chunk.save({}, function(err, result) {
+ if(err) return callback(err, self);
+
+ self.position = self.position + data.length;
+
+ // Point to current chunk
+ self.currentChunk = chunk;
+
+ if(offset >= stats.size) {
+ fs.close(file);
+ self.close(function(err, result) {
+ 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, chunk) {
+ 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, gridStore) {
+ 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
+ var 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, reject) {
+ 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 instanceof 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, result) {
+ 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;
+
+ var collection2 = self.chunkCollection();
+ // No file exists set up write mode
+ if(self.mode == "w") {
+ // Delete any existing chunks
+ deleteChunks(self, options, function(err, result) {
+ 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);
+ var 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, result) {
+ 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, result) {
+ 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, result) {
+ callback(err, self);
+ });
+ }
+ // Return normally
+ return callback(null, self);
+ }
+ }
+};
+
+/**
+ * Creates a mongoDB object representation of this object.
+ *
+ * <pre><code>
+ * {
+ * '_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}
+ * }
+ * </code></pre>
+ *
+ * @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, result) {
+ 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(result) {
+ 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, result) {
+ if(err) return callback(err);
+ gridStore.collection(function(err, collection) {
+ if(err) return callback(err);
+ collection.remove({'_id':gridStore.fileId}, writeConcern, function(err, result) {
+ 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) {
+ var self = this;
+ // 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(n) {
+ 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, gs) {
+ 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, encoding, callback) {
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/metadata.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/metadata.js
new file mode 100644
index 0000000..7dae562
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/metadata.js
@@ -0,0 +1,64 @@
+var f = require('util').format;
+
+var Define = function(name, object, stream) {
+ this.name = name;
+ this.object = object;
+ this.stream = typeof stream == 'boolean' ? stream : false;
+ this.instrumentations = {};
+}
+
+Define.prototype.classMethod = function(name, options) {
+ var keys = Object.keys(options).sort();
+ var key = generateKey(keys, options);
+
+ // Add a list of instrumentations
+ if(this.instrumentations[key] == null) {
+ this.instrumentations[key] = {
+ methods: [], options: options
+ }
+ }
+
+ // Push to list of method for this instrumentation
+ this.instrumentations[key].methods.push(name);
+}
+
+var generateKey = function(keys, options) {
+ var parts = [];
+ for(var i = 0; i < keys.length; i++) {
+ parts.push(f('%s=%s', keys[i], options[keys[i]]));
+ }
+
+ return parts.join();
+}
+
+Define.prototype.staticMethod = function(name, options) {
+ options.static = true;
+ var keys = Object.keys(options).sort();
+ var key = generateKey(keys, options);
+
+ // Add a list of instrumentations
+ if(this.instrumentations[key] == null) {
+ this.instrumentations[key] = {
+ methods: [], options: options
+ }
+ }
+
+ // Push to list of method for this instrumentation
+ this.instrumentations[key].methods.push(name);
+}
+
+Define.prototype.generate = function(keys, options) {
+ // Generate the return object
+ var object = {
+ name: this.name, obj: this.object, stream: this.stream,
+ instrumentations: []
+ }
+
+ for(var name in this.instrumentations) {
+ object.instrumentations.push(this.instrumentations[name]);
+ }
+
+ return object;
+}
+
+module.exports = Define; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js
new file mode 100644
index 0000000..deb1940
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongo_client.js
@@ -0,0 +1,328 @@
+"use strict";
+
+var parse = require('./url_parser')
+ , Server = require('./server')
+ , Mongos = require('./mongos')
+ , ReplSet = require('./replset')
+ , Define = require('./metadata')
+ , ReadPreference = require('./read_preference')
+ , Logger = require('mongodb-core').Logger
+ , MongoError = require('mongodb-core').MongoError
+ , Db = require('./db')
+ , dns = require('dns')
+ , f = require('util').format
+ , shallowClone = require('./utils').shallowClone;
+
+/**
+ * @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();
+ * });
+ */
+
+/**
+ * Creates a new MongoClient instance
+ * @class
+ * @return {MongoClient} a MongoClient instance.
+ */
+function MongoClient() {
+ /**
+ * 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=null] Optional settings.
+ * @param {boolean} [options.uri_decode_auth=false] Uri decode the user name and password for authentication
+ * @param {object} [options.db=null] A hash of options to set on the db object, see **Db constructor**
+ * @param {object} [options.server=null] A hash of options to set on the server objects, see **Server** constructor**
+ * @param {object} [options.replSet=null] A hash of options to set on the replSet object, see **ReplSet** constructor**
+ * @param {object} [options.mongos=null] A hash of options to set on the mongos object, see **Mongos** constructor**
+ * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
+ * @param {MongoClient~connectCallback} [callback] The command result callback
+ * @return {Promise} returns Promise if no callback passed
+ */
+ this.connect = MongoClient.connect;
+}
+
+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=null] Optional settings.
+ * @param {boolean} [options.uri_decode_auth=false] Uri decode the user name and password for authentication
+ * @param {object} [options.db=null] A hash of options to set on the db object, see **Db constructor**
+ * @param {object} [options.server=null] A hash of options to set on the server objects, see **Server** constructor**
+ * @param {object} [options.replSet=null] A hash of options to set on the replSet object, see **ReplSet** constructor**
+ * @param {object} [options.mongos=null] A hash of options to set on the mongos object, see **Mongos** constructor**
+ * @param {object} [options.promiseLibrary=null] A Promise library class the application wishes to use such as Bluebird, must be ES6 compatible
+ * @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 || {};
+
+ // 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) {
+ connect(url, options, function(err, db) {
+ if(err) return reject(err);
+ resolve(db);
+ });
+ });
+ }
+
+ // Fallback to callback based connect
+ connect(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 = [];
+
+ 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 maxStalenessMS
+ if(options.maxStalenessMS) {
+ options.readPreference.maxStalenessMS = options.maxStalenessMS;
+ }
+
+ // Set the socket and connection timeouts
+ if(!options.socketTimeoutMS == null) options.socketTimeoutMS = 30000;
+ 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);
+ });
+}
+
+function createReplicaset(options, callback) {
+ // Set default options
+ var servers = translateOptions(options);
+ // Create Db instance
+ new Db(options.dbName, new ReplSet(servers, options), options).open(callback);
+}
+
+function createMongos(options, callback) {
+ // Set default options
+ var servers = translateOptions(options);
+ // Create Db instance
+ new Db(options.dbName, new Mongos(servers, options), options).open(callback);
+}
+
+function createServer(options, callback) {
+ // Set default options
+ var servers = translateOptions(options);
+ // Create Db instance
+ new Db(options.dbName, servers[0], options).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(options, callback);
+ }
+
+ // 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
+ authentication_db.authenticate(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(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 the string
+ var object = parse(url, options);
+ 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 = 120000;
+ if(!_finalOptions.connectTimeoutMS == null) _finalOptions.connectTimeoutMS = 120000;
+
+ // Failure modes
+ if(object.servers.length == 0) {
+ throw new Error("connection string must contain at least one seed host");
+ }
+
+ 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);
+ }
+
+ // Do we have a replicaset then skip discovery and go straight to connectivity
+ if(_finalOptions.replicaSet || _finalOptions.rs_name) {
+ return createReplicaset(_finalOptions, connectHandler(_finalOptions, connectCallback));
+ } else if(object.servers.length > 1) {
+ return createMongos(_finalOptions, connectHandler(_finalOptions, connectCallback));
+ } else {
+ return createServer(_finalOptions, connectHandler(_finalOptions, connectCallback));
+ }
+}
+
+module.exports = MongoClient
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongos.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongos.js
new file mode 100644
index 0000000..a630b6a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/mongos.js
@@ -0,0 +1,509 @@
+"use strict";
+
+var EventEmitter = require('events').EventEmitter
+ , inherits = require('util').inherits
+ , f = require('util').format
+ , ServerCapabilities = require('./topology_base').ServerCapabilities
+ , MongoCR = require('mongodb-core').MongoCR
+ , MongoError = require('mongodb-core').MongoError
+ , CMongos = require('mongodb-core').Mongos
+ , Cursor = require('./cursor')
+ , AggregationCursor = require('./aggregation_cursor')
+ , CommandCursor = require('./command_cursor')
+ , Define = require('./metadata')
+ , Server = require('./server')
+ , Store = require('./topology_base').Store
+ , shallowClone = require('./utils').shallowClone
+ , MAX_JS_INT = require('./utils').MAX_JS_INT
+ , translateOptions = require('./utils').translateOptions
+ , filterOptions = require('./utils').filterOptions
+ , mergeOptions = require('./utils').mergeOptions
+ , os = require('os');
+
+// Get package.json variable
+var driverVersion = require(__dirname + '/../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();
+
+/**
+ * @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**
+ * @example
+ * var Db = require('mongodb').Db,
+ * Mongos = require('mongodb').Mongos,
+ * Server = require('mongodb').Server,
+ * test = require('assert');
+ * // Connect using Mongos
+ * var server = new Server('localhost', 27017);
+ * var db = new Db('test', new Mongos([server]));
+ * db.open(function(err, db) {
+ * // Get an additional db
+ * db.close();
+ * });
+ */
+
+ // Allowed parameters
+ var legalOptionNames = ['ha', 'haInterval', 'acceptableLatencyMS'
+ , 'poolSize', 'ssl', 'checkServerIdentity', 'sslValidate'
+ , 'sslCA', 'sslCert', 'sslKey', 'sslPass', 'socketOptions', 'bufferMaxEntries'
+ , 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
+ , 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS'
+ , 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
+ , 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
+
+/**
+ * Creates a new Mongos instance
+ * @class
+ * @deprecated
+ * @param {Server[]} servers A seedlist of servers participating in the replicaset.
+ * @param {object} [options=null] 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 {object} [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=null] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {(Buffer|string)} [options.sslCert=null] 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=null] 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=null] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {string} [options.servername=null] String containing the server name requested via TLS SNI.
+ * @param {object} [options.socketOptions=null] Socket options
+ * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option.
+ * @param {number} [options.socketOptions.keepAlive=0] TCP KeepAlive on the socket with a X ms delay before start.
+ * @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.
+ * @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
+ * @return {Mongos} a Mongos instance.
+ */
+var Mongos = function(servers, options) {
+ if(!(this instanceof Mongos)) return new Mongos(servers, options);
+ 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);
+
+ // Set up event emitter
+ EventEmitter.call(this);
+
+ // 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
+ });
+
+ // 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);
+ if(typeof clonedOptions.keepAlive == 'number') {
+ clonedOptions.keepAliveInitialDelay = clonedOptions.keepAlive;
+ clonedOptions.keepAlive = clonedOptions.keepAlive > 0;
+ }
+
+ // Build default client information
+ this.clientInfo = {
+ driver: {
+ name: "nodejs",
+ version: driverVersion
+ },
+ os: {
+ type: type,
+ name: name,
+ architecture: architecture,
+ version: release
+ },
+ platform: nodejsversion
+ }
+
+ // 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 Mongos
+ var mongos = new CMongos(seedlist, clonedOptions)
+ // Server capabilities
+ var sCapabilities = null;
+
+ // Internal state
+ this.s = {
+ // Create the Mongos
+ mongos: mongos
+ // Server capabilities
+ , sCapabilities: sCapabilities
+ // Debug turned on
+ , debug: clonedOptions.debug
+ // Store option defaults
+ , storeOptions: storeOptions
+ // Cloned options
+ , clonedOptions: clonedOptions
+ // Actual store of callbacks
+ , store: store
+ // Options
+ , options: options
+ }
+}
+
+var define = Mongos.define = new Define('Mongos', Mongos, false);
+
+/**
+ * @ignore
+ */
+inherits(Mongos, EventEmitter);
+
+// Last ismaster
+Object.defineProperty(Mongos.prototype, 'isMasterDoc', {
+ enumerable:true, get: function() { return this.s.mongos.lastIsMaster(); }
+});
+
+// BSON property
+Object.defineProperty(Mongos.prototype, 'bson', {
+ enumerable: true, get: function() {
+ return this.s.mongos.s.bson;
+ }
+});
+
+Object.defineProperty(Mongos.prototype, 'haInterval', {
+ enumerable:true, get: function() { return this.s.mongos.s.haInterval; }
+});
+
+// Connect
+Mongos.prototype.connect = function(db, _options, callback) {
+ var self = this;
+ if('function' === typeof _options) callback = _options, _options = {};
+ if(_options == null) _options = {};
+ if(!('function' === typeof callback)) callback = null;
+ self.s.options = _options;
+
+ // Update bufferMaxEntries
+ self.s.storeOptions.bufferMaxEntries = db.bufferMaxEntries;
+
+ // Error handler
+ var connectErrorHandler = function(event) {
+ return function(err) {
+ // Remove all event handlers
+ var events = ['timeout', 'error', 'close'];
+ events.forEach(function(e) {
+ self.removeListener(e, connectErrorHandler);
+ });
+
+ self.s.mongos.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(err) {
+ 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
+ ["timeout", "error", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted',
+ 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening',
+ 'topologyClosed', 'topologyDescriptionChanged'].forEach(function(e) {
+ self.s.mongos.removeAllListeners(e);
+ });
+
+ // Set up listeners
+ self.s.mongos.once('timeout', errorHandler('timeout'));
+ self.s.mongos.once('error', errorHandler('error'));
+ self.s.mongos.once('close', errorHandler('close'));
+
+ // Set up SDAM listeners
+ self.s.mongos.on('serverDescriptionChanged', relay('serverDescriptionChanged'));
+ self.s.mongos.on('serverHeartbeatStarted', relay('serverHeartbeatStarted'));
+ self.s.mongos.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded'));
+ self.s.mongos.on('serverHeartbeatFailed', relay('serverHeartbeatFailed'));
+ self.s.mongos.on('serverOpening', relay('serverOpening'));
+ self.s.mongos.on('serverClosed', relay('serverClosed'));
+ self.s.mongos.on('topologyOpening', relay('topologyOpening'));
+ self.s.mongos.on('topologyClosed', relay('topologyClosed'));
+ self.s.mongos.on('topologyDescriptionChanged', relay('topologyDescriptionChanged'));
+
+ // Set up serverConfig listeners
+ self.s.mongos.on('fullsetup', relay('fullsetup'));
+
+ // Emit open event
+ self.emit('open', null, self);
+
+ // Return correctly
+ try {
+ callback(null, self);
+ } catch(err) {
+ process.nextTick(function() { throw err; })
+ }
+ }
+
+ // Set up listeners
+ self.s.mongos.once('timeout', connectErrorHandler('timeout'));
+ self.s.mongos.once('error', connectErrorHandler('error'));
+ self.s.mongos.once('close', connectErrorHandler('close'));
+ self.s.mongos.once('connect', connectHandler);
+ // Join and leave events
+ self.s.mongos.on('joined', relay('joined'));
+ self.s.mongos.on('left', relay('left'));
+
+ // Reconnect server
+ self.s.mongos.on('reconnect', reconnectHandler);
+
+ // Start connection
+ self.s.mongos.connect(_options);
+}
+
+// Server capabilities
+Mongos.prototype.capabilities = function() {
+ if(this.s.sCapabilities) return this.s.sCapabilities;
+ if(this.s.mongos.lastIsMaster() == null) return null;
+ this.s.sCapabilities = new ServerCapabilities(this.s.mongos.lastIsMaster());
+ return this.s.sCapabilities;
+}
+
+define.classMethod('capabilities', {callback: false, promise:false, returns: [ServerCapabilities]});
+
+// Command
+Mongos.prototype.command = function(ns, cmd, options, callback) {
+ this.s.mongos.command(ns, cmd, options, callback);
+}
+
+define.classMethod('command', {callback: true, promise:false});
+
+// Insert
+Mongos.prototype.insert = function(ns, ops, options, callback) {
+ this.s.mongos.insert(ns, ops, options, function(e, m) {
+ callback(e, m)
+ });
+}
+
+define.classMethod('insert', {callback: true, promise:false});
+
+// Update
+Mongos.prototype.update = function(ns, ops, options, callback) {
+ this.s.mongos.update(ns, ops, options, callback);
+}
+
+define.classMethod('update', {callback: true, promise:false});
+
+// Remove
+Mongos.prototype.remove = function(ns, ops, options, callback) {
+ this.s.mongos.remove(ns, ops, options, callback);
+}
+
+define.classMethod('remove', {callback: true, promise:false});
+
+// Destroyed
+Mongos.prototype.isDestroyed = function() {
+ return this.s.mongos.isDestroyed();
+}
+
+// IsConnected
+Mongos.prototype.isConnected = function() {
+ return this.s.mongos.isConnected();
+}
+
+define.classMethod('isConnected', {callback: false, promise:false, returns: [Boolean]});
+
+// Insert
+Mongos.prototype.cursor = function(ns, cmd, options) {
+ options.disconnectHandler = this.s.store;
+ return this.s.mongos.cursor(ns, cmd, options);
+}
+
+define.classMethod('cursor', {callback: false, promise:false, returns: [Cursor, AggregationCursor, CommandCursor]});
+
+Mongos.prototype.lastIsMaster = function() {
+ return this.s.mongos.lastIsMaster();
+}
+
+Mongos.prototype.close = function(forceClosed) {
+ this.s.mongos.destroy();
+ // We need to wash out all stored processes
+ if(forceClosed == true) {
+ this.s.storeOptions.force = forceClosed;
+ this.s.store.flush();
+ }
+}
+
+define.classMethod('close', {callback: false, promise:false});
+
+Mongos.prototype.auth = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.mongos.auth.apply(this.s.mongos, args);
+}
+
+define.classMethod('auth', {callback: true, promise:false});
+
+Mongos.prototype.logout = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.mongos.logout.apply(this.s.mongos, args);
+}
+
+define.classMethod('logout', {callback: true, promise:false});
+
+/**
+ * All raw connections
+ * @method
+ * @return {array}
+ */
+Mongos.prototype.connections = function() {
+ return this.s.mongos.connections();
+}
+
+define.classMethod('connections', {callback: false, promise:false, returns:[Array]});
+
+/**
+ * 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}
+ */
+
+module.exports = Mongos;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/read_preference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/read_preference.js
new file mode 100644
index 0000000..1763b2c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/read_preference.js
@@ -0,0 +1,131 @@
+"use strict";
+
+/**
+ * @fileOverview The **ReadPreference** class is a class that represents a MongoDB ReadPreference and is
+ * used to construct connections.
+ *
+ * @example
+ * var Db = require('mongodb').Db,
+ * ReplSet = require('mongodb').ReplSet,
+ * Server = require('mongodb').Server,
+ * ReadPreference = require('mongodb').ReadPreference,
+ * test = require('assert');
+ * // Connect using ReplSet
+ * var server = new Server('localhost', 27017);
+ * var db = new Db('test', new ReplSet([server]));
+ * db.open(function(err, db) {
+ * test.equal(null, err);
+ * // Perform a read
+ * var cursor = db.collection('t').find({});
+ * cursor.setReadPreference(ReadPreference.PRIMARY);
+ * cursor.toArray(function(err, docs) {
+ * test.equal(null, err);
+ * db.close();
+ * });
+ * });
+ */
+
+/**
+ * Creates a new ReadPreference instance
+ *
+ * Read Preferences
+ * - **ReadPreference.PRIMARY**, Read from primary only. All operations produce an error (throw an exception where applicable) if primary is unavailable. Cannot be combined with tags (This is the default.).
+ * - **ReadPreference.PRIMARY_PREFERRED**, Read from primary if available, otherwise a secondary.
+ * - **ReadPreference.SECONDARY**, Read from secondary if available, otherwise error.
+ * - **ReadPreference.SECONDARY_PREFERRED**, Read from a secondary if available, otherwise read from the primary.
+ * - **ReadPreference.NEAREST**, All modes read from among the nearest candidates, but unlike other modes, NEAREST will include both the primary and all secondaries in the random selection.
+ *
+ * @class
+ * @param {string} mode The ReadPreference mode as listed above.
+ * @param {array|object} tags An object representing read preference tags.
+ * @param {object} [options] Additional read preference options
+ * @param {number} [options.maxStalenessMS] Max Secondary Read Stalleness in Miliseconds
+ * @return {ReadPreference} a ReadPreference instance.
+ */
+var ReadPreference = function(mode, tags, options) {
+ if(!(this instanceof ReadPreference)) {
+ return new ReadPreference(mode, tags, options);
+ }
+
+ this._type = 'ReadPreference';
+ this.mode = mode;
+ this.tags = tags;
+ this.options = options;
+
+ // If no tags were passed in
+ if(tags && typeof tags == 'object' && !Array.isArray(tags)) {
+ if(tags.maxStalenessMS) {
+ this.options = tags;
+ this.tags = null;
+ }
+ }
+
+ // Add the maxStalenessMS value to the read Preference
+ if(this.options && this.options.maxStalenessMS) {
+ this.maxStalenessMS = this.options.maxStalenessMS;
+ }
+}
+
+/**
+ * Validate if a mode is legal
+ *
+ * @method
+ * @param {string} mode The string representing the read preference mode.
+ * @return {boolean}
+ */
+ReadPreference.isValid = function(_mode) {
+ return (_mode == ReadPreference.PRIMARY || _mode == ReadPreference.PRIMARY_PREFERRED
+ || _mode == ReadPreference.SECONDARY || _mode == ReadPreference.SECONDARY_PREFERRED
+ || _mode == ReadPreference.NEAREST
+ || _mode == true || _mode == false || _mode == null);
+}
+
+/**
+ * Validate if a mode is legal
+ *
+ * @method
+ * @param {string} mode The string representing the read preference mode.
+ * @return {boolean}
+ */
+ReadPreference.prototype.isValid = function(mode) {
+ var _mode = typeof mode == 'string' ? mode : this.mode;
+ return ReadPreference.isValid(_mode);
+}
+
+/**
+ * @ignore
+ */
+ReadPreference.prototype.toObject = function() {
+ var object = {mode:this.mode};
+
+ if(this.tags != null) {
+ object['tags'] = this.tags;
+ }
+
+ if(this.maxStalenessMS) {
+ object['maxStalenessMS'] = this.maxStalenessMS;
+ }
+
+ return object;
+}
+
+/**
+ * @ignore
+ */
+ReadPreference.prototype.toJSON = function() {
+ return this.toObject();
+}
+
+/**
+ * @ignore
+ */
+ReadPreference.PRIMARY = 'primary';
+ReadPreference.PRIMARY_PREFERRED = 'primaryPreferred';
+ReadPreference.SECONDARY = 'secondary';
+ReadPreference.SECONDARY_PREFERRED = 'secondaryPreferred';
+ReadPreference.NEAREST = 'nearest'
+
+/**
+ * @ignore
+ */
+module.exports = ReadPreference;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/replset.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/replset.js
new file mode 100644
index 0000000..97791bf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/replset.js
@@ -0,0 +1,559 @@
+"use strict";
+
+var EventEmitter = require('events').EventEmitter
+ , inherits = require('util').inherits
+ , f = require('util').format
+ , Server = require('./server')
+ , Mongos = require('./mongos')
+ , Cursor = require('./cursor')
+ , AggregationCursor = require('./aggregation_cursor')
+ , CommandCursor = require('./command_cursor')
+ , ReadPreference = require('./read_preference')
+ , MongoCR = require('mongodb-core').MongoCR
+ , MongoError = require('mongodb-core').MongoError
+ , ServerCapabilities = require('./topology_base').ServerCapabilities
+ , Store = require('./topology_base').Store
+ , Define = require('./metadata')
+ , CServer = require('mongodb-core').Server
+ , CReplSet = require('mongodb-core').ReplSet
+ , CoreReadPreference = require('mongodb-core').ReadPreference
+ , shallowClone = require('./utils').shallowClone
+ , MAX_JS_INT = require('./utils').MAX_JS_INT
+ , translateOptions = require('./utils').translateOptions
+ , filterOptions = require('./utils').filterOptions
+ , mergeOptions = require('./utils').mergeOptions
+ , os = require('os');
+/**
+ * @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**
+ * @example
+ * var Db = require('mongodb').Db,
+ * ReplSet = require('mongodb').ReplSet,
+ * Server = require('mongodb').Server,
+ * test = require('assert');
+ * // Connect using ReplSet
+ * var server = new Server('localhost', 27017);
+ * var db = new Db('test', new ReplSet([server]));
+ * db.open(function(err, db) {
+ * // Get an additional db
+ * db.close();
+ * });
+ */
+
+// Allowed parameters
+var legalOptionNames = ['ha', 'haInterval', 'replicaSet', 'rs_name', 'secondaryAcceptableLatencyMS'
+ , 'connectWithNoPrimary', 'poolSize', 'ssl', 'checkServerIdentity', 'sslValidate'
+ , 'sslCA', 'sslCert', 'sslKey', 'sslPass', 'socketOptions', 'bufferMaxEntries'
+ , 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
+ , 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS', 'strategy', 'debug'
+ , 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
+ , 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
+
+// Get package.json variable
+var driverVersion = require(__dirname + '/../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();
+
+/**
+ * Creates a new ReplSet instance
+ * @class
+ * @deprecated
+ * @param {Server[]} servers A seedlist of servers participating in the replicaset.
+ * @param {object} [options=null] Optional settings.
+ * @param {booelan} [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 {object} [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=null] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {(Buffer|string)} [options.sslCert=null] 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=null] 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=null] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {string} [options.servername=null] String containing the server name requested via TLS SNI.
+ * @param {object} [options.socketOptions=null] Socket options
+ * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option.
+ * @param {number} [options.socketOptions.keepAlive=0] TCP KeepAlive on the socket with a X ms delay before start.
+ * @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.
+ * @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
+ * @return {ReplSet} a ReplSet instance.
+ */
+var ReplSet = function(servers, options) {
+ if(!(this instanceof ReplSet)) return new ReplSet(servers, options);
+ options = options || {};
+ var self = this;
+ // Set up event emitter
+ EventEmitter.call(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
+ });
+
+ // 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);
+ if(typeof clonedOptions.keepAlive == 'number') {
+ clonedOptions.keepAliveInitialDelay = clonedOptions.keepAlive;
+ clonedOptions.keepAlive = clonedOptions.keepAlive > 0;
+ }
+
+ // Client info
+ this.clientInfo = {
+ driver: {
+ name: "nodejs",
+ version: driverVersion
+ },
+ os: {
+ type: type,
+ name: name,
+ architecture: architecture,
+ version: release
+ },
+ platform: nodejsversion
+ }
+
+ // 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 replset = new CReplSet(seedlist, clonedOptions);
+ // Server capabilities
+ var sCapabilities = null;
+
+ // Listen to reconnect event
+ replset.on('reconnect', function() {
+ self.emit('reconnect');
+ store.execute();
+ });
+
+ // Internal state
+ this.s = {
+ // Replicaset
+ replset: replset
+ // Server capabilities
+ , sCapabilities: null
+ // Debug tag
+ , tag: options.tag
+ // Store options
+ , storeOptions: storeOptions
+ // Cloned options
+ , clonedOptions: clonedOptions
+ // Store
+ , store: store
+ // Options
+ , options: options
+ }
+
+ // Debug
+ if(clonedOptions.debug) {
+ // Last ismaster
+ Object.defineProperty(this, 'replset', {
+ enumerable:true, get: function() { return replset; }
+ });
+ }
+}
+
+/**
+ * @ignore
+ */
+inherits(ReplSet, EventEmitter);
+
+// Last ismaster
+Object.defineProperty(ReplSet.prototype, 'isMasterDoc', {
+ enumerable:true, get: function() { return this.s.replset.lastIsMaster(); }
+});
+
+// BSON property
+Object.defineProperty(ReplSet.prototype, 'bson', {
+ enumerable: true, get: function() {
+ return this.s.replset.s.bson;
+ }
+});
+
+Object.defineProperty(ReplSet.prototype, 'haInterval', {
+ enumerable:true, get: function() { return this.s.replset.s.haInterval; }
+});
+
+var define = ReplSet.define = new Define('ReplSet', ReplSet, false);
+
+// Ensure the right read Preference object
+var translateReadPreference = function(options) {
+ if(typeof options.readPreference == 'string') {
+ options.readPreference = new CoreReadPreference(options.readPreference);
+ } else if(options.readPreference instanceof ReadPreference) {
+ options.readPreference = new CoreReadPreference(options.readPreference.mode
+ , options.readPreference.tags, {maxStalenessMS: options.readPreference.maxStalenessMS});
+ }
+
+ return options;
+}
+
+// Connect method
+ReplSet.prototype.connect = function(db, _options, callback) {
+ var self = this;
+ if('function' === typeof _options) callback = _options, _options = {};
+ if(_options == null) _options = {};
+ if(!('function' === typeof callback)) callback = null;
+ self.s.options = _options;
+
+ // Update bufferMaxEntries
+ self.s.storeOptions.bufferMaxEntries = db.bufferMaxEntries;
+
+ // Actual handler
+ var errorHandler = function(event) {
+ return function(err) {
+ if(event != 'error') {
+ self.emit(event, err);
+ }
+ }
+ }
+
+ // Connect handler
+ var connectHandler = function() {
+ // Clear out all the current handlers left over
+ ["timeout", "error", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted',
+ 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening',
+ 'topologyClosed', 'topologyDescriptionChanged'].forEach(function(e) {
+ self.s.replset.removeAllListeners(e);
+ });
+
+ // Set up listeners
+ self.s.replset.once('timeout', errorHandler('timeout'));
+ self.s.replset.once('error', errorHandler('error'));
+ self.s.replset.once('close', errorHandler('close'));
+
+ // 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.replset.on('joined', replsetRelay('joined'));
+ self.s.replset.on('left', relay('left'));
+ self.s.replset.on('ping', relay('ping'));
+ self.s.replset.on('ha', relayHa);
+
+ // Set up SDAM listeners
+ self.s.replset.on('serverDescriptionChanged', relay('serverDescriptionChanged'));
+ self.s.replset.on('serverHeartbeatStarted', relay('serverHeartbeatStarted'));
+ self.s.replset.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded'));
+ self.s.replset.on('serverHeartbeatFailed', relay('serverHeartbeatFailed'));
+ self.s.replset.on('serverOpening', relay('serverOpening'));
+ self.s.replset.on('serverClosed', relay('serverClosed'));
+ self.s.replset.on('topologyOpening', relay('topologyOpening'));
+ self.s.replset.on('topologyClosed', relay('topologyClosed'));
+ self.s.replset.on('topologyDescriptionChanged', relay('topologyDescriptionChanged'));
+
+ self.s.replset.on('fullsetup', function(topology) {
+ self.emit('fullsetup', null, self);
+ });
+
+ self.s.replset.on('all', function(topology) {
+ self.emit('all', null, self);
+ });
+
+ // 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(event) {
+ return function(err) {
+ ['timeout', 'error', 'close'].forEach(function(e) {
+ self.s.replset.removeListener(e, connectErrorHandler);
+ });
+
+ self.s.replset.removeListener('connect', connectErrorHandler);
+ // Destroy the replset
+ self.s.replset.destroy();
+
+ // Try to callback
+ try {
+ callback(err);
+ } catch(err) {
+ if(!self.s.replset.isConnected())
+ process.nextTick(function() { throw err; })
+ }
+ }
+ }
+
+ // Set up listeners
+ self.s.replset.once('timeout', connectErrorHandler('timeout'));
+ self.s.replset.once('error', connectErrorHandler('error'));
+ self.s.replset.once('close', connectErrorHandler('close'));
+ self.s.replset.once('connect', connectHandler);
+
+ // Start connection
+ self.s.replset.connect(_options);
+}
+
+// Server capabilities
+ReplSet.prototype.capabilities = function() {
+ if(this.s.sCapabilities) return this.s.sCapabilities;
+ if(this.s.replset.lastIsMaster() == null) return null;
+ this.s.sCapabilities = new ServerCapabilities(this.s.replset.lastIsMaster());
+ return this.s.sCapabilities;
+}
+
+define.classMethod('capabilities', {callback: false, promise:false, returns: [ServerCapabilities]});
+
+// Command
+ReplSet.prototype.command = function(ns, cmd, options, callback) {
+ options = translateReadPreference(options);
+ this.s.replset.command(ns, cmd, options, callback);
+}
+
+define.classMethod('command', {callback: true, promise:false});
+
+// Insert
+ReplSet.prototype.insert = function(ns, ops, options, callback) {
+ this.s.replset.insert(ns, ops, options, callback);
+}
+
+define.classMethod('insert', {callback: true, promise:false});
+
+// Update
+ReplSet.prototype.update = function(ns, ops, options, callback) {
+ this.s.replset.update(ns, ops, options, callback);
+}
+
+define.classMethod('update', {callback: true, promise:false});
+
+// Remove
+ReplSet.prototype.remove = function(ns, ops, options, callback) {
+ this.s.replset.remove(ns, ops, options, callback);
+}
+
+define.classMethod('remove', {callback: true, promise:false});
+
+// Destroyed
+ReplSet.prototype.isDestroyed = function() {
+ return this.s.replset.isDestroyed();
+}
+
+// IsConnected
+ReplSet.prototype.isConnected = function() {
+ return this.s.replset.isConnected();
+}
+
+define.classMethod('isConnected', {callback: false, promise:false, returns: [Boolean]});
+
+// Insert
+ReplSet.prototype.cursor = function(ns, cmd, options) {
+ options = translateReadPreference(options);
+ options.disconnectHandler = this.s.store;
+ return this.s.replset.cursor(ns, cmd, options);
+}
+
+define.classMethod('cursor', {callback: false, promise:false, returns: [Cursor, AggregationCursor, CommandCursor]});
+
+ReplSet.prototype.lastIsMaster = function() {
+ return this.s.replset.lastIsMaster();
+}
+
+ReplSet.prototype.close = function(forceClosed) {
+ var self = this;
+ this.s.replset.destroy();
+ // We need to wash out all stored processes
+ if(forceClosed == true) {
+ this.s.storeOptions.force = forceClosed;
+ this.s.store.flush();
+ }
+
+ var events = ['timeout', 'error', 'close', 'joined', 'left'];
+ events.forEach(function(e) {
+ self.removeAllListeners(e);
+ });
+}
+
+define.classMethod('close', {callback: false, promise:false});
+
+ReplSet.prototype.auth = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.replset.auth.apply(this.s.replset, args);
+}
+
+define.classMethod('auth', {callback: true, promise:false});
+
+ReplSet.prototype.logout = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.replset.logout.apply(this.s.replset, args);
+}
+
+define.classMethod('logout', {callback: true, promise:false});
+
+/**
+ * All raw connections
+ * @method
+ * @return {array}
+ */
+ReplSet.prototype.connections = function() {
+ return this.s.replset.connections();
+}
+
+define.classMethod('connections', {callback: false, promise:false, returns:[Array]});
+
+/**
+ * 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}
+ */
+
+module.exports = ReplSet;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/server.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/server.js
new file mode 100644
index 0000000..127675d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/server.js
@@ -0,0 +1,507 @@
+"use strict";
+
+var EventEmitter = require('events').EventEmitter
+ , inherits = require('util').inherits
+ , CServer = require('mongodb-core').Server
+ , Cursor = require('./cursor')
+ , AggregationCursor = require('./aggregation_cursor')
+ , CommandCursor = require('./command_cursor')
+ , f = require('util').format
+ , ServerCapabilities = require('./topology_base').ServerCapabilities
+ , Store = require('./topology_base').Store
+ , Define = require('./metadata')
+ , MongoError = require('mongodb-core').MongoError
+ , shallowClone = require('./utils').shallowClone
+ , MAX_JS_INT = require('./utils').MAX_JS_INT
+ , translateOptions = require('./utils').translateOptions
+ , filterOptions = require('./utils').filterOptions
+ , mergeOptions = require('./utils').mergeOptions
+ , os = require('os');
+
+// Get package.json variable
+var driverVersion = require(__dirname + '/../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();
+
+/**
+ * @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**
+ * @example
+ * var Db = require('mongodb').Db,
+ * Server = require('mongodb').Server,
+ * test = require('assert');
+ * // Connect using single Server
+ * var db = new Db('test', new Server('localhost', 27017););
+ * db.open(function(err, db) {
+ * // Get an additional db
+ * db.close();
+ * });
+ */
+
+ // Allowed parameters
+ var legalOptionNames = ['ha', 'haInterval', 'acceptableLatencyMS'
+ , 'poolSize', 'ssl', 'checkServerIdentity', 'sslValidate'
+ , 'sslCA', 'sslCert', 'sslKey', 'sslPass', 'socketOptions', 'bufferMaxEntries'
+ , 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
+ , 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS'
+ , 'loggerLevel', 'logger', 'reconnectTries', 'reconnectInterval', 'monitoring'
+ , 'appname', 'domainsEnabled'
+ , 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
+
+/**
+ * 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=null] 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 {object} [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=null] Array of valid certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {(Buffer|string)} [options.sslCert=null] 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=null] 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=null] String or buffer containing the certificate password (needs to have a mongod server with ssl support, 2.4 or higher)
+ * @param {string} [options.servername=null] String containing the server name requested via TLS SNI.
+ * @param {object} [options.socketOptions=null] Socket options
+ * @param {boolean} [options.socketOptions.autoReconnect=true] Reconnect on error.
+ * @param {boolean} [options.socketOptions.noDelay=true] TCP Socket NoDelay option.
+ * @param {number} [options.socketOptions.keepAlive=0] TCP KeepAlive on the socket with a X ms delay before start.
+ * @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.
+ * @fires Server#connect
+ * @fires Server#close
+ * @fires Server#error
+ * @fires Server#timeout
+ * @fires Server#parseError
+ * @fires Server#reconnect
+ * @return {Server} a Server instance.
+ */
+var Server = function(host, port, options) {
+ options = options || {};
+ if(!(this instanceof Server)) return new Server(host, port, options);
+ EventEmitter.call(this);
+ var self = this;
+
+ // Filter the options
+ options = filterOptions(options, legalOptionNames);
+
+ // 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
+ });
+
+ // 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);
+ if(typeof clonedOptions.keepAlive == 'number') {
+ clonedOptions.keepAliveInitialDelay = clonedOptions.keepAlive;
+ clonedOptions.keepAlive = clonedOptions.keepAlive > 0;
+ }
+
+ // Build default client information
+ this.clientInfo = {
+ driver: {
+ name: "nodejs",
+ version: driverVersion
+ },
+ os: {
+ type: type,
+ name: name,
+ architecture: architecture,
+ version: release
+ },
+ platform: nodejsversion
+ }
+
+ // 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 an instance of a server instance from mongodb-core
+ var server = new CServer(clonedOptions);
+ // Server capabilities
+ var sCapabilities = null;
+
+ // Define the internal properties
+ this.s = {
+ // Create an instance of a server instance from mongodb-core
+ server: server
+ // 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
+ }
+}
+
+inherits(Server, EventEmitter);
+
+var define = Server.define = new Define('Server', Server, false);
+
+// BSON property
+Object.defineProperty(Server.prototype, 'bson', {
+ enumerable: true, get: function() {
+ return this.s.server.s.bson;
+ }
+});
+
+// Last ismaster
+Object.defineProperty(Server.prototype, 'isMasterDoc', {
+ enumerable:true, get: function() {
+ return this.s.server.lastIsMaster();
+ }
+});
+
+// Last ismaster
+Object.defineProperty(Server.prototype, 'poolSize', {
+ enumerable:true, get: function() { return this.s.server.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; }
+});
+
+// Connect
+Server.prototype.connect = function(db, _options, callback) {
+ var self = this;
+ if('function' === typeof _options) callback = _options, _options = {};
+ if(_options == null) _options = {};
+ if(!('function' === typeof callback)) callback = null;
+ self.s.options = _options;
+
+ // Update bufferMaxEntries
+ self.s.storeOptions.bufferMaxEntries = db.bufferMaxEntries;
+
+ // Error handler
+ var connectErrorHandler = function(event) {
+ return function(err) {
+ // Remove all event handlers
+ var events = ['timeout', 'error', 'close'];
+ events.forEach(function(e) {
+ self.s.server.removeListener(e, connectHandlers[e]);
+ });
+
+ self.s.server.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(err) {
+ 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();
+ }
+
+ // Connect handler
+ var connectHandler = function() {
+ // Clear out all the current handlers left over
+ ["timeout", "error", "close", 'serverOpening', 'serverDescriptionChanged', 'serverHeartbeatStarted',
+ 'serverHeartbeatSucceeded', 'serverHeartbeatFailed', 'serverClosed', 'topologyOpening',
+ 'topologyClosed', 'topologyDescriptionChanged'].forEach(function(e) {
+ self.s.server.removeAllListeners(e);
+ });
+
+ // Set up listeners
+ self.s.server.once('timeout', errorHandler('timeout'));
+ self.s.server.once('error', errorHandler('error'));
+ self.s.server.on('close', errorHandler('close'));
+ // Only called on destroy
+ self.s.server.once('destroy', destroyHandler);
+
+ // relay the event
+ var relay = function(event) {
+ return function(t, server) {
+ self.emit(event, t, server);
+ }
+ }
+
+ // Set up SDAM listeners
+ self.s.server.on('serverDescriptionChanged', relay('serverDescriptionChanged'));
+ self.s.server.on('serverHeartbeatStarted', relay('serverHeartbeatStarted'));
+ self.s.server.on('serverHeartbeatSucceeded', relay('serverHeartbeatSucceeded'));
+ self.s.server.on('serverHeartbeatFailed', relay('serverHeartbeatFailed'));
+ self.s.server.on('serverOpening', relay('serverOpening'));
+ self.s.server.on('serverClosed', relay('serverClosed'));
+ self.s.server.on('topologyOpening', relay('topologyOpening'));
+ self.s.server.on('topologyClosed', relay('topologyClosed'));
+ self.s.server.on('topologyDescriptionChanged', relay('topologyDescriptionChanged'));
+ self.s.server.on('attemptReconnect', relay('attemptReconnect'));
+ self.s.server.on('monitoring', relay('monitoring'));
+
+ // Emit open event
+ self.emit('open', null, self);
+
+ // Return correctly
+ try {
+ callback(null, self);
+ } catch(err) {
+ console.log(err.stack)
+ process.nextTick(function() { throw err; })
+ }
+ }
+
+ // Set up listeners
+ var connectHandlers = {
+ timeout: connectErrorHandler('timeout'),
+ error: connectErrorHandler('error'),
+ close: connectErrorHandler('close')
+ };
+
+ // Add the event handlers
+ self.s.server.once('timeout', connectHandlers.timeout);
+ self.s.server.once('error', connectHandlers.error);
+ self.s.server.once('close', connectHandlers.close);
+ self.s.server.once('connect', connectHandler);
+ // Reconnect server
+ self.s.server.on('reconnect', reconnectHandler);
+ self.s.server.on('reconnectFailed', reconnectFailedHandler);
+
+ // Start connection
+ self.s.server.connect(_options);
+}
+
+// Server capabilities
+Server.prototype.capabilities = function() {
+ if(this.s.sCapabilities) return this.s.sCapabilities;
+ if(this.s.server.lastIsMaster() == null) return null;
+ this.s.sCapabilities = new ServerCapabilities(this.s.server.lastIsMaster());
+ return this.s.sCapabilities;
+}
+
+define.classMethod('capabilities', {callback: false, promise:false, returns: [ServerCapabilities]});
+
+// Command
+Server.prototype.command = function(ns, cmd, options, callback) {
+ this.s.server.command(ns, cmd, options, callback);
+}
+
+define.classMethod('command', {callback: true, promise:false});
+
+// Insert
+Server.prototype.insert = function(ns, ops, options, callback) {
+ this.s.server.insert(ns, ops, options, callback);
+}
+
+define.classMethod('insert', {callback: true, promise:false});
+
+// Update
+Server.prototype.update = function(ns, ops, options, callback) {
+ this.s.server.update(ns, ops, options, callback);
+}
+
+define.classMethod('update', {callback: true, promise:false});
+
+// Remove
+Server.prototype.remove = function(ns, ops, options, callback) {
+ this.s.server.remove(ns, ops, options, callback);
+}
+
+define.classMethod('remove', {callback: true, promise:false});
+
+// IsConnected
+Server.prototype.isConnected = function() {
+ return this.s.server.isConnected();
+}
+
+Server.prototype.isDestroyed = function() {
+ return this.s.server.isDestroyed();
+}
+
+define.classMethod('isConnected', {callback: false, promise:false, returns: [Boolean]});
+
+// Insert
+Server.prototype.cursor = function(ns, cmd, options) {
+ options.disconnectHandler = this.s.store;
+ return this.s.server.cursor(ns, cmd, options);
+}
+
+define.classMethod('cursor', {callback: false, promise:false, returns: [Cursor, AggregationCursor, CommandCursor]});
+
+Server.prototype.lastIsMaster = function() {
+ return this.s.server.lastIsMaster();
+}
+
+/**
+ * Unref all sockets
+ * @method
+ */
+Server.prototype.unref = function() {
+ this.s.server.unref();
+}
+
+Server.prototype.close = function(forceClosed) {
+ this.s.server.destroy();
+ // We need to wash out all stored processes
+ if(forceClosed == true) {
+ this.s.storeOptions.force = forceClosed;
+ this.s.store.flush();
+ }
+}
+
+define.classMethod('close', {callback: false, promise:false});
+
+Server.prototype.auth = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.server.auth.apply(this.s.server, args);
+}
+
+define.classMethod('auth', {callback: true, promise:false});
+
+Server.prototype.logout = function() {
+ var args = Array.prototype.slice.call(arguments, 0);
+ this.s.server.logout.apply(this.s.server, args);
+}
+
+define.classMethod('logout', {callback: true, promise:false});
+
+/**
+ * All raw connections
+ * @method
+ * @return {array}
+ */
+Server.prototype.connections = function() {
+ return this.s.server.connections();
+}
+
+define.classMethod('connections', {callback: false, promise:false, returns:[Array]});
+
+/**
+ * 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}
+ */
+
+module.exports = Server;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js
new file mode 100644
index 0000000..ebfd616
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js
@@ -0,0 +1,191 @@
+"use strict";
+
+var MongoError = require('mongodb-core').MongoError
+ , f = require('util').format;
+
+// 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);
+}
+
+exports.Store = Store;
+exports.ServerCapabilities = ServerCapabilities;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js
new file mode 100644
index 0000000..663e5dc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/url_parser.js
@@ -0,0 +1,406 @@
+"use strict";
+
+var ReadPreference = require('./read_preference'),
+ parser = require('url'),
+ f = require('util').format;
+
+module.exports = function(url, options) {
+ // Ensure we have a default options object if none set
+ options = 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.protocol != 'mongodb:') {
+ throw new Error('invalid schema, expected mongodb');
+ }
+
+ 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(var i = 0; i < hosts.length; i++) {
+ var r = parser.parse(f('mongodb://%s', hosts[i].trim()));
+ if(r.path && r.path.indexOf(':') != -1) {
+ 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]};
+
+ // 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 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;
+ });
+ }
+
+ // 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);
+ 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 'maxStalenessMS':
+ dbOptions.maxStalenessMS = 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';
+ }
+
+ // Add servers to result
+ object.servers = servers;
+ // Returned parsed object
+ return object;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/utils.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/utils.js
new file mode 100644
index 0000000..fcadf8f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/lib/utils.js
@@ -0,0 +1,313 @@
+"use strict";
+
+var MongoError = require('mongodb-core').MongoError,
+ f = require('util').format;
+
+var shallowClone = function(obj) {
+ var copy = {};
+ for(var name in obj) copy[name] = obj[name];
+ return copy;
+}
+
+// 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 Error("collection name must be a String");
+ }
+
+ if(!collectionName || collectionName.indexOf('..') != -1) {
+ throw Error("collection names cannot be empty");
+ }
+
+ if(collectionName.indexOf('$') != -1 &&
+ collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null) {
+ throw Error("collection names must not contain '$'");
+ }
+
+ if(collectionName.match(/^\.|\.$/) != null) {
+ throw Error("collection names must not start or end with '.'");
+ }
+
+ // Validate that we are not passing 0x00 in the colletion name
+ if(!!~collectionName.indexOf("\x00")) {
+ throw new Error("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]' == 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', '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 polyfille
+var assign = Object.assign ? Object.assign : function assign(target, firstSource) {
+ 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;
+}
+
+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;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/CHANGELOG.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/CHANGELOG.md
new file mode 100644
index 0000000..cc8aa10
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/CHANGELOG.md
@@ -0,0 +1,65 @@
+# Master
+
+# 3.2.0
+
+* improve tamper resistence of Promise.all Promise.race and
+ Promise.prototype.then (note, this isn't complete, but addresses an exception
+ when used \w core-js, follow up work will address entirely)
+* remove spec incompatible then chaining fast-path
+* add eslint
+* update build deps
+
+# 3.1.2
+
+* fix node detection issues with NWJS/electron
+
+# 3.1.0
+
+* improve performance of Promise.all when it encounters a non-promise input object input
+* then/resolve tamper protection
+* reduce AST size of promise constructor, to facilitate more inlining
+* Update README.md with details about PhantomJS requirement for running tests
+* Mangle and compress the minified version
+
+# 3.0.1
+
+* no longer include dist/test in npm releases
+
+# 3.0.0
+
+* use nextTick() instead of setImmediate() to schedule microtasks with node 0.10. Later versions of
+ nodes are not affected as they were already using nextTick(). Note that using nextTick() might
+ trigger a depreciation warning on 0.10 as described at https://github.com/cujojs/when/issues/410.
+ The reason why nextTick() is preferred is that is setImmediate() would schedule a macrotask
+ instead of a microtask and might result in a different scheduling.
+ If needed you can revert to the former behavior as follow:
+
+ var Promise = require('es6-promise').Promise;
+ Promise._setScheduler(setImmediate);
+
+# 2.3.0
+
+* #121: Ability to override the internal asap implementation
+* #120: Use an ascii character for an apostrophe, for source maps
+
+# 2.2.0
+
+* #116: Expose asap() and a way to override the scheduling mechanism on Promise
+* Lock to v0.2.3 of ember-cli
+
+# 2.1.1
+
+* Fix #100 via #105: tell browserify to ignore vertx require
+* Fix #101 via #102: "follow thenable state, not own state"
+
+# 2.1.0
+
+* ? (see the commit log)
+
+# 2.0.0
+
+* re-sync with RSVP. Many large performance improvements and bugfixes.
+
+# 1.0.0
+
+* first subset of RSVP
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/LICENSE
new file mode 100644
index 0000000..954ec59
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and 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.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/README.md
new file mode 100644
index 0000000..16739ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/README.md
@@ -0,0 +1,74 @@
+# ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js))
+
+This is a polyfill of the [ES6 Promise](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js) extracted by @jakearchibald, if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
+
+For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
+
+## Downloads
+
+* [es6-promise](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.js)
+* [es6-promise-min](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.min.js)
+
+## Node.js
+
+To install:
+
+```sh
+npm install es6-promise
+```
+
+To use:
+
+```js
+var Promise = require('es6-promise').Promise;
+```
+
+## Bower
+
+To install:
+
+```sh
+bower install es6-promise --save
+```
+
+
+## Usage in IE<9
+
+`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, you can use a string to access the property as shown in the following example.
+
+However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:
+
+```js
+promise['catch'](function(err) {
+ // ...
+});
+```
+
+Or use `.then` instead:
+
+```js
+promise.then(undefined, function(err) {
+ // ...
+});
+```
+
+## Auto-polyfill
+
+To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
+
+```js
+require('es6-promise').polyfill();
+```
+
+Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.
+
+## Building & Testing
+
+You will need to have PhantomJS installed globally in order to run the tests.
+
+`npm install -g phantomjs`
+
+* `npm run build` to build
+* `npm test` to run tests
+* `npm start` to run a build watcher, and webserver to test
+* `npm run test:server` for a testem test runner and watching builder
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.js
new file mode 100644
index 0000000..0755e9b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.js
@@ -0,0 +1,959 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 3.2.1
+ */
+
+(function() {
+ "use strict";
+ function lib$es6$promise$utils$$objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+ }
+
+ function lib$es6$promise$utils$$isFunction(x) {
+ return typeof x === 'function';
+ }
+
+ function lib$es6$promise$utils$$isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+ }
+
+ var lib$es6$promise$utils$$_isArray;
+ if (!Array.isArray) {
+ lib$es6$promise$utils$$_isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ lib$es6$promise$utils$$_isArray = Array.isArray;
+ }
+
+ var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
+ var lib$es6$promise$asap$$len = 0;
+ var lib$es6$promise$asap$$vertxNext;
+ var lib$es6$promise$asap$$customSchedulerFn;
+
+ var lib$es6$promise$asap$$asap = function asap(callback, arg) {
+ lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
+ lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
+ lib$es6$promise$asap$$len += 2;
+ if (lib$es6$promise$asap$$len === 2) {
+ // If len is 2, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ if (lib$es6$promise$asap$$customSchedulerFn) {
+ lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
+ } else {
+ lib$es6$promise$asap$$scheduleFlush();
+ }
+ }
+ }
+
+ function lib$es6$promise$asap$$setScheduler(scheduleFn) {
+ lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
+ }
+
+ function lib$es6$promise$asap$$setAsap(asapFn) {
+ lib$es6$promise$asap$$asap = asapFn;
+ }
+
+ var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
+ var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
+ var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
+ var lib$es6$promise$asap$$isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
+
+ // test for web worker but not in IE10
+ var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+ // node
+ function lib$es6$promise$asap$$useNextTick() {
+ // node version 0.10.x displays a deprecation warning when nextTick is used recursively
+ // see https://github.com/cujojs/when/issues/410 for details
+ return function() {
+ process.nextTick(lib$es6$promise$asap$$flush);
+ };
+ }
+
+ // vertx
+ function lib$es6$promise$asap$$useVertxTimer() {
+ return function() {
+ lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
+ };
+ }
+
+ function lib$es6$promise$asap$$useMutationObserver() {
+ var iterations = 0;
+ var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+ }
+
+ // web worker
+ function lib$es6$promise$asap$$useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = lib$es6$promise$asap$$flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+ }
+
+ function lib$es6$promise$asap$$useSetTimeout() {
+ return function() {
+ setTimeout(lib$es6$promise$asap$$flush, 1);
+ };
+ }
+
+ var lib$es6$promise$asap$$queue = new Array(1000);
+ function lib$es6$promise$asap$$flush() {
+ for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
+ var callback = lib$es6$promise$asap$$queue[i];
+ var arg = lib$es6$promise$asap$$queue[i+1];
+
+ callback(arg);
+
+ lib$es6$promise$asap$$queue[i] = undefined;
+ lib$es6$promise$asap$$queue[i+1] = undefined;
+ }
+
+ lib$es6$promise$asap$$len = 0;
+ }
+
+ function lib$es6$promise$asap$$attemptVertx() {
+ try {
+ var r = require;
+ var vertx = r('vertx');
+ lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
+ return lib$es6$promise$asap$$useVertxTimer();
+ } catch(e) {
+ return lib$es6$promise$asap$$useSetTimeout();
+ }
+ }
+
+ var lib$es6$promise$asap$$scheduleFlush;
+ // Decide what async method to use to triggering processing of queued callbacks:
+ if (lib$es6$promise$asap$$isNode) {
+ lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
+ } else if (lib$es6$promise$asap$$BrowserMutationObserver) {
+ lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
+ } else if (lib$es6$promise$asap$$isWorker) {
+ lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
+ } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
+ lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
+ } else {
+ lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
+ }
+ function lib$es6$promise$then$$then(onFulfillment, onRejection) {
+ var parent = this;
+
+ var child = new this.constructor(lib$es6$promise$$internal$$noop);
+
+ if (child[lib$es6$promise$$internal$$PROMISE_ID] === undefined) {
+ lib$es6$promise$$internal$$makePromise(child);
+ }
+
+ var state = parent._state;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ lib$es6$promise$asap$$asap(function(){
+ lib$es6$promise$$internal$$invokeCallback(state, child, callback, parent._result);
+ });
+ } else {
+ lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+ }
+ var lib$es6$promise$then$$default = lib$es6$promise$then$$then;
+ function lib$es6$promise$promise$resolve$$resolve(object) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor(lib$es6$promise$$internal$$noop);
+ lib$es6$promise$$internal$$resolve(promise, object);
+ return promise;
+ }
+ var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
+ var lib$es6$promise$$internal$$PROMISE_ID = Math.random().toString(36).substring(16);
+
+ function lib$es6$promise$$internal$$noop() {}
+
+ var lib$es6$promise$$internal$$PENDING = void 0;
+ var lib$es6$promise$$internal$$FULFILLED = 1;
+ var lib$es6$promise$$internal$$REJECTED = 2;
+
+ var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
+
+ function lib$es6$promise$$internal$$selfFulfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+ }
+
+ function lib$es6$promise$$internal$$cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.');
+ }
+
+ function lib$es6$promise$$internal$$getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
+ return lib$es6$promise$$internal$$GET_THEN_ERROR;
+ }
+ }
+
+ function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+ }
+
+ function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
+ lib$es6$promise$asap$$asap(function(promise) {
+ var sealed = false;
+ var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ lib$es6$promise$$internal$$resolve(promise, value);
+ } else {
+ lib$es6$promise$$internal$$fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ lib$es6$promise$$internal$$reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ lib$es6$promise$$internal$$reject(promise, error);
+ }
+ }, promise);
+ }
+
+ function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
+ if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
+ lib$es6$promise$$internal$$fulfill(promise, thenable._result);
+ } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
+ lib$es6$promise$$internal$$reject(promise, thenable._result);
+ } else {
+ lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
+ lib$es6$promise$$internal$$resolve(promise, value);
+ }, function(reason) {
+ lib$es6$promise$$internal$$reject(promise, reason);
+ });
+ }
+ }
+
+ function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) {
+ if (maybeThenable.constructor === promise.constructor &&
+ then === lib$es6$promise$then$$default &&
+ constructor.resolve === lib$es6$promise$promise$resolve$$default) {
+ lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
+ } else {
+ if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
+ lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
+ } else if (lib$es6$promise$utils$$isFunction(then)) {
+ lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
+ }
+ }
+ }
+
+ function lib$es6$promise$$internal$$resolve(promise, value) {
+ if (promise === value) {
+ lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
+ } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
+ lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value));
+ } else {
+ lib$es6$promise$$internal$$fulfill(promise, value);
+ }
+ }
+
+ function lib$es6$promise$$internal$$publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ lib$es6$promise$$internal$$publish(promise);
+ }
+
+ function lib$es6$promise$$internal$$fulfill(promise, value) {
+ if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
+
+ promise._result = value;
+ promise._state = lib$es6$promise$$internal$$FULFILLED;
+
+ if (promise._subscribers.length !== 0) {
+ lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
+ }
+ }
+
+ function lib$es6$promise$$internal$$reject(promise, reason) {
+ if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
+ promise._state = lib$es6$promise$$internal$$REJECTED;
+ promise._result = reason;
+
+ lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
+ }
+
+ function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
+ subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
+ }
+ }
+
+ function lib$es6$promise$$internal$$publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+ }
+
+ function lib$es6$promise$$internal$$ErrorObject() {
+ this.error = null;
+ }
+
+ var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
+
+ function lib$es6$promise$$internal$$tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
+ return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
+ }
+ }
+
+ function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = lib$es6$promise$utils$$isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = lib$es6$promise$$internal$$tryCatch(callback, detail);
+
+ if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== lib$es6$promise$$internal$$PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ lib$es6$promise$$internal$$resolve(promise, value);
+ } else if (failed) {
+ lib$es6$promise$$internal$$reject(promise, error);
+ } else if (settled === lib$es6$promise$$internal$$FULFILLED) {
+ lib$es6$promise$$internal$$fulfill(promise, value);
+ } else if (settled === lib$es6$promise$$internal$$REJECTED) {
+ lib$es6$promise$$internal$$reject(promise, value);
+ }
+ }
+
+ function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ lib$es6$promise$$internal$$resolve(promise, value);
+ }, function rejectPromise(reason) {
+ lib$es6$promise$$internal$$reject(promise, reason);
+ });
+ } catch(e) {
+ lib$es6$promise$$internal$$reject(promise, e);
+ }
+ }
+
+ var lib$es6$promise$$internal$$id = 0;
+ function lib$es6$promise$$internal$$nextId() {
+ return lib$es6$promise$$internal$$id++;
+ }
+
+ function lib$es6$promise$$internal$$makePromise(promise) {
+ promise[lib$es6$promise$$internal$$PROMISE_ID] = lib$es6$promise$$internal$$id++;
+ promise._state = undefined;
+ promise._result = undefined;
+ promise._subscribers = [];
+ }
+
+ function lib$es6$promise$promise$all$$all(entries) {
+ return new lib$es6$promise$enumerator$$default(this, entries).promise;
+ }
+ var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
+ function lib$es6$promise$promise$race$$race(entries) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (!lib$es6$promise$utils$$isArray(entries)) {
+ return new Constructor(function(resolve, reject) {
+ reject(new TypeError('You must pass an array to race.'));
+ });
+ } else {
+ return new Constructor(function(resolve, reject) {
+ var length = entries.length;
+ for (var i = 0; i < length; i++) {
+ Constructor.resolve(entries[i]).then(resolve, reject);
+ }
+ });
+ }
+ }
+ var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
+ function lib$es6$promise$promise$reject$$reject(reason) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(lib$es6$promise$$internal$$noop);
+ lib$es6$promise$$internal$$reject(promise, reason);
+ return promise;
+ }
+ var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
+
+
+ function lib$es6$promise$promise$$needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
+
+ function lib$es6$promise$promise$$needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+ }
+
+ var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise's eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+ */
+ function lib$es6$promise$promise$$Promise(resolver) {
+ this[lib$es6$promise$$internal$$PROMISE_ID] = lib$es6$promise$$internal$$nextId();
+ this._result = this._state = undefined;
+ this._subscribers = [];
+
+ if (lib$es6$promise$$internal$$noop !== resolver) {
+ typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver();
+ this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew();
+ }
+ }
+
+ lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
+ lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
+ lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
+ lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
+ lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
+ lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
+ lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
+
+ lib$es6$promise$promise$$Promise.prototype = {
+ constructor: lib$es6$promise$promise$$Promise,
+
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: lib$es6$promise$then$$default,
+
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+ };
+ var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
+ function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(lib$es6$promise$$internal$$noop);
+
+ if (!this.promise[lib$es6$promise$$internal$$PROMISE_ID]) {
+ lib$es6$promise$$internal$$makePromise(this.promise);
+ }
+
+ if (lib$es6$promise$utils$$isArray(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._result = new Array(this.length);
+
+ if (this.length === 0) {
+ lib$es6$promise$$internal$$fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ lib$es6$promise$$internal$$fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ lib$es6$promise$$internal$$reject(this.promise, lib$es6$promise$enumerator$$validationError());
+ }
+ }
+
+ function lib$es6$promise$enumerator$$validationError() {
+ return new Error('Array Methods must be provided an Array');
+ }
+
+ lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var input = this._input;
+
+ for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+ };
+
+ lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ var resolve = c.resolve;
+
+ if (resolve === lib$es6$promise$promise$resolve$$default) {
+ var then = lib$es6$promise$$internal$$getThen(entry);
+
+ if (then === lib$es6$promise$then$$default &&
+ entry._state !== lib$es6$promise$$internal$$PENDING) {
+ this._settledAt(entry._state, i, entry._result);
+ } else if (typeof then !== 'function') {
+ this._remaining--;
+ this._result[i] = entry;
+ } else if (c === lib$es6$promise$promise$$default) {
+ var promise = new c(lib$es6$promise$$internal$$noop);
+ lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then);
+ this._willSettleAt(promise, i);
+ } else {
+ this._willSettleAt(new c(function(resolve) { resolve(entry); }), i);
+ }
+ } else {
+ this._willSettleAt(resolve(entry), i);
+ }
+ };
+
+ lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === lib$es6$promise$$internal$$PENDING) {
+ this._remaining--;
+
+ if (state === lib$es6$promise$$internal$$REJECTED) {
+ lib$es6$promise$$internal$$reject(promise, value);
+ } else {
+ this._result[i] = value;
+ }
+ }
+
+ if (this._remaining === 0) {
+ lib$es6$promise$$internal$$fulfill(promise, this._result);
+ }
+ };
+
+ lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
+ enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
+ });
+ };
+ function lib$es6$promise$polyfill$$polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof self !== 'undefined') {
+ local = self;
+ } else {
+ try {
+ local = Function('return this')();
+ } catch (e) {
+ throw new Error('polyfill failed because global object is unavailable in this environment');
+ }
+ }
+
+ var P = local.Promise;
+
+ if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
+ return;
+ }
+
+ local.Promise = lib$es6$promise$promise$$default;
+ }
+ var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
+
+ var lib$es6$promise$umd$$ES6Promise = {
+ 'Promise': lib$es6$promise$promise$$default,
+ 'polyfill': lib$es6$promise$polyfill$$default
+ };
+
+ /* global define:true module:true window: true */
+ if (typeof define === 'function' && define['amd']) {
+ define(function() { return lib$es6$promise$umd$$ES6Promise; });
+ } else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = lib$es6$promise$umd$$ES6Promise;
+ } else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
+ }
+
+ lib$es6$promise$polyfill$$default();
+}).call(this);
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.min.js
new file mode 100644
index 0000000..13151c2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/dist/es6-promise.min.js
@@ -0,0 +1,9 @@
+/*!
+ * @overview es6-promise - a tiny implementation of Promises/A+.
+ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
+ * @license Licensed under MIT license
+ * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
+ * @version 3.2.1
+ */
+
+(function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){G=t}function r(t){Q=t}function o(){return function(){process.nextTick(a)}}function i(){return function(){B(a)}}function s(){var t=0,e=new X(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){t.port2.postMessage(0)}}function c(){return function(){setTimeout(a,1)}}function a(){for(var t=0;J>t;t+=2){var e=tt[t],n=tt[t+1];e(n),tt[t]=void 0,tt[t+1]=void 0}J=0}function f(){try{var t=require,e=t("vertx");return B=e.runOnLoop||e.runOnContext,i()}catch(n){return c()}}function l(t,e){var n=this,r=new this.constructor(p);void 0===r[rt]&&k(r);var o=n._state;if(o){var i=arguments[o-1];Q(function(){x(o,r,i,n._result)})}else E(n,r,t,e);return r}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(p);return g(n,t),n}function p(){}function _(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function v(t){try{return t.then}catch(e){return ut.error=e,ut}}function y(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function m(t,e,n){Q(function(t){var r=!1,o=y(n,e,function(n){r||(r=!0,e!==n?g(t,n):S(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function b(t,e){e._state===it?S(t,e._result):e._state===st?j(t,e._result):E(e,void 0,function(e){g(t,e)},function(e){j(t,e)})}function w(t,n,r){n.constructor===t.constructor&&r===et&&constructor.resolve===nt?b(t,n):r===ut?j(t,ut.error):void 0===r?S(t,n):e(r)?m(t,n,r):S(t,n)}function g(e,n){e===n?j(e,_()):t(n)?w(e,n,v(n)):S(e,n)}function A(t){t._onerror&&t._onerror(t._result),T(t)}function S(t,e){t._state===ot&&(t._result=e,t._state=it,0!==t._subscribers.length&&Q(T,t))}function j(t,e){t._state===ot&&(t._state=st,t._result=e,Q(A,t))}function E(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+it]=n,o[i+st]=r,0===i&&t._state&&Q(T,t)}function T(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,o,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?x(n,r,o,i):o(i);t._subscribers.length=0}}function M(){this.error=null}function P(t,e){try{return t(e)}catch(n){return ct.error=n,ct}}function x(t,n,r,o){var i,s,u,c,a=e(r);if(a){if(i=P(r,o),i===ct?(c=!0,s=i.error,i=null):u=!0,n===i)return void j(n,d())}else i=o,u=!0;n._state!==ot||(a&&u?g(n,i):c?j(n,s):t===it?S(n,i):t===st&&j(n,i))}function C(t,e){try{e(function(e){g(t,e)},function(e){j(t,e)})}catch(n){j(t,n)}}function O(){return at++}function k(t){t[rt]=at++,t._state=void 0,t._result=void 0,t._subscribers=[]}function Y(t){return new _t(this,t).promise}function q(t){var e=this;return new e(I(t)?function(n,r){for(var o=t.length,i=0;o>i;i++)e.resolve(t[i]).then(n,r)}:function(t,e){e(new TypeError("You must pass an array to race."))})}function F(t){var e=this,n=new e(p);return j(n,t),n}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function K(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function L(t){this[rt]=O(),this._result=this._state=void 0,this._subscribers=[],p!==t&&("function"!=typeof t&&D(),this instanceof L?C(this,t):K())}function N(t,e){this._instanceConstructor=t,this.promise=new t(p),this.promise[rt]||k(this.promise),I(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?S(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&S(this.promise,this._result))):j(this.promise,U())}function U(){return new Error("Array Methods must be provided an Array")}function W(){var t;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;(!n||"[object Promise]"!==Object.prototype.toString.call(n.resolve())||n.cast)&&(t.Promise=pt)}var z;z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B,G,H,I=z,J=0,Q=function(t,e){tt[J]=t,tt[J+1]=e,J+=2,2===J&&(G?G(a):H())},R="undefined"!=typeof window?window:void 0,V=R||{},X=V.MutationObserver||V.WebKitMutationObserver,Z="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),$="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,tt=new Array(1e3);H=Z?o():X?s():$?u():void 0===R&&"function"==typeof require?f():c();var et=l,nt=h,rt=Math.random().toString(36).substring(16),ot=void 0,it=1,st=2,ut=new M,ct=new M,at=0,ft=Y,lt=q,ht=F,pt=L;L.all=ft,L.race=lt,L.resolve=nt,L.reject=ht,L._setScheduler=n,L._setAsap=r,L._asap=Q,L.prototype={constructor:L,then:et,"catch":function(t){return this.then(null,t)}};var _t=N;N.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ot&&t>n;n++)this._eachEntry(e[n],n)},N.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===nt){var o=v(t);if(o===et&&t._state!==ot)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===pt){var i=new n(p);w(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},N.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ot&&(this._remaining--,t===st?j(r,n):this._result[e]=n),0===this._remaining&&S(r,this._result)},N.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){n._settledAt(it,e,t)},function(t){n._settledAt(st,e,t)})};var dt=W,vt={Promise:pt,polyfill:dt};"function"==typeof define&&define.amd?define(function(){return vt}):"undefined"!=typeof module&&module.exports?module.exports=vt:"undefined"!=typeof this&&(this.ES6Promise=vt),dt()}).call(this); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise.umd.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise.umd.js
new file mode 100644
index 0000000..5984f70
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise.umd.js
@@ -0,0 +1,18 @@
+import Promise from './es6-promise/promise';
+import polyfill from './es6-promise/polyfill';
+
+var ES6Promise = {
+ 'Promise': Promise,
+ 'polyfill': polyfill
+};
+
+/* global define:true module:true window: true */
+if (typeof define === 'function' && define['amd']) {
+ define(function() { return ES6Promise; });
+} else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = ES6Promise;
+} else if (typeof this !== 'undefined') {
+ this['ES6Promise'] = ES6Promise;
+}
+
+polyfill();
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/-internal.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/-internal.js
new file mode 100644
index 0000000..aeebf57
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/-internal.js
@@ -0,0 +1,273 @@
+import {
+ objectOrFunction,
+ isFunction
+} from './utils';
+
+import {
+ asap
+} from './asap';
+
+import originalThen from './then';
+import originalResolve from './promise/resolve';
+
+export var PROMISE_ID = Math.random().toString(36).substring(16);
+
+function noop() {}
+
+var PENDING = void 0;
+var FULFILLED = 1;
+var REJECTED = 2;
+
+var GET_THEN_ERROR = new ErrorObject();
+
+function selfFulfillment() {
+ return new TypeError("You cannot resolve a promise with itself");
+}
+
+function cannotReturnOwn() {
+ return new TypeError('A promises callback cannot return that same promise.');
+}
+
+function getThen(promise) {
+ try {
+ return promise.then;
+ } catch(error) {
+ GET_THEN_ERROR.error = error;
+ return GET_THEN_ERROR;
+ }
+}
+
+function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch(e) {
+ return e;
+ }
+}
+
+function handleForeignThenable(promise, thenable, then) {
+ asap(function(promise) {
+ var sealed = false;
+ var error = tryThen(then, thenable, function(value) {
+ if (sealed) { return; }
+ sealed = true;
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function(reason) {
+ if (sealed) { return; }
+ sealed = true;
+
+ reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
+
+ if (!sealed && error) {
+ sealed = true;
+ reject(promise, error);
+ }
+ }, promise);
+}
+
+function handleOwnThenable(promise, thenable) {
+ if (thenable._state === FULFILLED) {
+ fulfill(promise, thenable._result);
+ } else if (thenable._state === REJECTED) {
+ reject(promise, thenable._result);
+ } else {
+ subscribe(thenable, undefined, function(value) {
+ resolve(promise, value);
+ }, function(reason) {
+ reject(promise, reason);
+ });
+ }
+}
+
+function handleMaybeThenable(promise, maybeThenable, then) {
+ if (maybeThenable.constructor === promise.constructor &&
+ then === originalThen &&
+ constructor.resolve === originalResolve) {
+ handleOwnThenable(promise, maybeThenable);
+ } else {
+ if (then === GET_THEN_ERROR) {
+ reject(promise, GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ fulfill(promise, maybeThenable);
+ } else if (isFunction(then)) {
+ handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ fulfill(promise, maybeThenable);
+ }
+ }
+}
+
+function resolve(promise, value) {
+ if (promise === value) {
+ reject(promise, selfFulfillment());
+ } else if (objectOrFunction(value)) {
+ handleMaybeThenable(promise, value, getThen(value));
+ } else {
+ fulfill(promise, value);
+ }
+}
+
+function publishRejection(promise) {
+ if (promise._onerror) {
+ promise._onerror(promise._result);
+ }
+
+ publish(promise);
+}
+
+function fulfill(promise, value) {
+ if (promise._state !== PENDING) { return; }
+
+ promise._result = value;
+ promise._state = FULFILLED;
+
+ if (promise._subscribers.length !== 0) {
+ asap(publish, promise);
+ }
+}
+
+function reject(promise, reason) {
+ if (promise._state !== PENDING) { return; }
+ promise._state = REJECTED;
+ promise._result = reason;
+
+ asap(publishRejection, promise);
+}
+
+function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
+
+ parent._onerror = null;
+
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
+
+ if (length === 0 && parent._state) {
+ asap(publish, parent);
+ }
+}
+
+function publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
+
+ if (subscribers.length === 0) { return; }
+
+ var child, callback, detail = promise._result;
+
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
+
+ if (child) {
+ invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
+ }
+ }
+
+ promise._subscribers.length = 0;
+}
+
+function ErrorObject() {
+ this.error = null;
+}
+
+var TRY_CATCH_ERROR = new ErrorObject();
+
+function tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch(e) {
+ TRY_CATCH_ERROR.error = e;
+ return TRY_CATCH_ERROR;
+ }
+}
+
+function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = isFunction(callback),
+ value, error, succeeded, failed;
+
+ if (hasCallback) {
+ value = tryCatch(callback, detail);
+
+ if (value === TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
+ } else {
+ succeeded = true;
+ }
+
+ if (promise === value) {
+ reject(promise, cannotReturnOwn());
+ return;
+ }
+
+ } else {
+ value = detail;
+ succeeded = true;
+ }
+
+ if (promise._state !== PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
+ fulfill(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
+ }
+}
+
+function initializePromise(promise, resolver) {
+ try {
+ resolver(function resolvePromise(value){
+ resolve(promise, value);
+ }, function rejectPromise(reason) {
+ reject(promise, reason);
+ });
+ } catch(e) {
+ reject(promise, e);
+ }
+}
+
+var id = 0;
+function nextId() {
+ return id++;
+}
+
+function makePromise(promise) {
+ promise[PROMISE_ID] = id++;
+ promise._state = undefined;
+ promise._result = undefined;
+ promise._subscribers = [];
+}
+
+export {
+ nextId,
+ makePromise,
+ getThen,
+ noop,
+ resolve,
+ reject,
+ fulfill,
+ subscribe,
+ publish,
+ publishRejection,
+ initializePromise,
+ invokeCallback,
+ FULFILLED,
+ REJECTED,
+ PENDING,
+ handleMaybeThenable
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/asap.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/asap.js
new file mode 100644
index 0000000..40f1d25
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/asap.js
@@ -0,0 +1,119 @@
+var len = 0;
+var vertxNext;
+var customSchedulerFn;
+
+export var asap = function asap(callback, arg) {
+ queue[len] = callback;
+ queue[len + 1] = arg;
+ len += 2;
+ if (len === 2) {
+ // If len is 2, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ if (customSchedulerFn) {
+ customSchedulerFn(flush);
+ } else {
+ scheduleFlush();
+ }
+ }
+}
+
+export function setScheduler(scheduleFn) {
+ customSchedulerFn = scheduleFn;
+}
+
+export function setAsap(asapFn) {
+ asap = asapFn;
+}
+
+var browserWindow = (typeof window !== 'undefined') ? window : undefined;
+var browserGlobal = browserWindow || {};
+var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
+
+// test for web worker but not in IE10
+var isWorker = typeof Uint8ClampedArray !== 'undefined' &&
+ typeof importScripts !== 'undefined' &&
+ typeof MessageChannel !== 'undefined';
+
+// node
+function useNextTick() {
+ // node version 0.10.x displays a deprecation warning when nextTick is used recursively
+ // see https://github.com/cujojs/when/issues/410 for details
+ return function() {
+ process.nextTick(flush);
+ };
+}
+
+// vertx
+function useVertxTimer() {
+ return function() {
+ vertxNext(flush);
+ };
+}
+
+function useMutationObserver() {
+ var iterations = 0;
+ var observer = new BrowserMutationObserver(flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
+
+ return function() {
+ node.data = (iterations = ++iterations % 2);
+ };
+}
+
+// web worker
+function useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
+}
+
+function useSetTimeout() {
+ return function() {
+ setTimeout(flush, 1);
+ };
+}
+
+var queue = new Array(1000);
+function flush() {
+ for (var i = 0; i < len; i+=2) {
+ var callback = queue[i];
+ var arg = queue[i+1];
+
+ callback(arg);
+
+ queue[i] = undefined;
+ queue[i+1] = undefined;
+ }
+
+ len = 0;
+}
+
+function attemptVertx() {
+ try {
+ var r = require;
+ var vertx = r('vertx');
+ vertxNext = vertx.runOnLoop || vertx.runOnContext;
+ return useVertxTimer();
+ } catch(e) {
+ return useSetTimeout();
+ }
+}
+
+var scheduleFlush;
+// Decide what async method to use to triggering processing of queued callbacks:
+if (isNode) {
+ scheduleFlush = useNextTick();
+} else if (BrowserMutationObserver) {
+ scheduleFlush = useMutationObserver();
+} else if (isWorker) {
+ scheduleFlush = useMessageChannel();
+} else if (browserWindow === undefined && typeof require === 'function') {
+ scheduleFlush = attemptVertx();
+} else {
+ scheduleFlush = useSetTimeout();
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/enumerator.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/enumerator.js
new file mode 100644
index 0000000..2a7a28f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/enumerator.js
@@ -0,0 +1,118 @@
+import {
+ isArray,
+ isMaybeThenable
+} from './utils';
+
+import {
+ noop,
+ reject,
+ fulfill,
+ subscribe,
+ FULFILLED,
+ REJECTED,
+ PENDING,
+ getThen,
+ handleMaybeThenable
+} from './-internal';
+
+import then from './then';
+import Promise from './promise';
+import originalResolve from './promise/resolve';
+import originalThen from './then';
+import { makePromise, PROMISE_ID } from './-internal';
+
+export default Enumerator;
+function Enumerator(Constructor, input) {
+ this._instanceConstructor = Constructor;
+ this.promise = new Constructor(noop);
+
+ if (!this.promise[PROMISE_ID]) {
+ makePromise(this.promise);
+ }
+
+ if (isArray(input)) {
+ this._input = input;
+ this.length = input.length;
+ this._remaining = input.length;
+
+ this._result = new Array(this.length);
+
+ if (this.length === 0) {
+ fulfill(this.promise, this._result);
+ } else {
+ this.length = this.length || 0;
+ this._enumerate();
+ if (this._remaining === 0) {
+ fulfill(this.promise, this._result);
+ }
+ }
+ } else {
+ reject(this.promise, validationError());
+ }
+}
+
+function validationError() {
+ return new Error('Array Methods must be provided an Array');
+};
+
+Enumerator.prototype._enumerate = function() {
+ var length = this.length;
+ var input = this._input;
+
+ for (var i = 0; this._state === PENDING && i < length; i++) {
+ this._eachEntry(input[i], i);
+ }
+};
+
+Enumerator.prototype._eachEntry = function(entry, i) {
+ var c = this._instanceConstructor;
+ var resolve = c.resolve;
+
+ if (resolve === originalResolve) {
+ var then = getThen(entry);
+
+ if (then === originalThen &&
+ entry._state !== PENDING) {
+ this._settledAt(entry._state, i, entry._result);
+ } else if (typeof then !== 'function') {
+ this._remaining--;
+ this._result[i] = entry;
+ } else if (c === Promise) {
+ var promise = new c(noop);
+ handleMaybeThenable(promise, entry, then);
+ this._willSettleAt(promise, i);
+ } else {
+ this._willSettleAt(new c(function(resolve) { resolve(entry); }), i);
+ }
+ } else {
+ this._willSettleAt(resolve(entry), i);
+ }
+};
+
+Enumerator.prototype._settledAt = function(state, i, value) {
+ var promise = this.promise;
+
+ if (promise._state === PENDING) {
+ this._remaining--;
+
+ if (state === REJECTED) {
+ reject(promise, value);
+ } else {
+ this._result[i] = value;
+ }
+ }
+
+ if (this._remaining === 0) {
+ fulfill(promise, this._result);
+ }
+};
+
+Enumerator.prototype._willSettleAt = function(promise, i) {
+ var enumerator = this;
+
+ subscribe(promise, undefined, function(value) {
+ enumerator._settledAt(FULFILLED, i, value);
+ }, function(reason) {
+ enumerator._settledAt(REJECTED, i, reason);
+ });
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/polyfill.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/polyfill.js
new file mode 100644
index 0000000..6696dfc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/polyfill.js
@@ -0,0 +1,26 @@
+/*global self*/
+import Promise from './promise';
+
+export default function polyfill() {
+ var local;
+
+ if (typeof global !== 'undefined') {
+ local = global;
+ } else if (typeof self !== 'undefined') {
+ local = self;
+ } else {
+ try {
+ local = Function('return this')();
+ } catch (e) {
+ throw new Error('polyfill failed because global object is unavailable in this environment');
+ }
+ }
+
+ var P = local.Promise;
+
+ if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
+ return;
+ }
+
+ local.Promise = Promise;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise.js
new file mode 100644
index 0000000..d95951e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise.js
@@ -0,0 +1,384 @@
+import {
+ isFunction
+} from './utils';
+
+import {
+ noop,
+ nextId,
+ PROMISE_ID,
+ initializePromise
+} from './-internal';
+
+import {
+ asap,
+ setAsap,
+ setScheduler
+} from './asap';
+
+import all from './promise/all';
+import race from './promise/race';
+import Resolve from './promise/resolve';
+import Reject from './promise/reject';
+import then from './then';
+
+
+function needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+}
+
+function needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
+}
+
+export default Promise;
+/**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise's eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class Promise
+ @param {function} resolver
+ Useful for tooling.
+ @constructor
+*/
+function Promise(resolver) {
+ this[PROMISE_ID] = nextId();
+ this._result = this._state = undefined;
+ this._subscribers = [];
+
+ if (noop !== resolver) {
+ typeof resolver !== 'function' && needsResolver();
+ this instanceof Promise ? initializePromise(this, resolver) : needsNew();
+ }
+}
+
+Promise.all = all;
+Promise.race = race;
+Promise.resolve = Resolve;
+Promise.reject = Reject;
+Promise._setScheduler = setScheduler;
+Promise._setAsap = setAsap;
+Promise._asap = asap;
+
+Promise.prototype = {
+ constructor: Promise,
+
+/**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfilled
+ @param {Function} onRejected
+ Useful for tooling.
+ @return {Promise}
+*/
+ then: then,
+
+/**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ Useful for tooling.
+ @return {Promise}
+*/
+ 'catch': function(onRejection) {
+ return this.then(null, onRejection);
+ }
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/all.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/all.js
new file mode 100644
index 0000000..03033f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/all.js
@@ -0,0 +1,52 @@
+import Enumerator from '../enumerator';
+
+/**
+ `Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = resolve(2);
+ var promise3 = resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+ Example:
+
+ ```javascript
+ var promise1 = resolve(1);
+ var promise2 = reject(new Error("2"));
+ var promise3 = reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+ @method all
+ @static
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+*/
+export default function all(entries) {
+ return new Enumerator(this, entries).promise;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/race.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/race.js
new file mode 100644
index 0000000..8c922e3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/race.js
@@ -0,0 +1,86 @@
+import {
+ isArray
+} from "../utils";
+
+/**
+ `Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 2');
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // result === 'promise 2' because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error('promise 2'));
+ }, 100);
+ });
+
+ Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === 'promise 2' because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @static
+ @param {Array} promises array of promises to observe
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+*/
+export default function race(entries) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (!isArray(entries)) {
+ return new Constructor(function(resolve, reject) {
+ reject(new TypeError('You must pass an array to race.'));
+ });
+ } else {
+ return new Constructor(function(resolve, reject) {
+ var length = entries.length;
+ for (var i = 0; i < length; i++) {
+ Constructor.resolve(entries[i]).then(resolve, reject);
+ }
+ });
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/reject.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/reject.js
new file mode 100644
index 0000000..63b86cb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/reject.js
@@ -0,0 +1,46 @@
+import {
+ noop,
+ reject as _reject
+} from '../-internal';
+
+/**
+ `Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @static
+ @param {Any} reason value that the returned promise will be rejected with.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+*/
+export default function reject(reason) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(noop);
+ _reject(promise, reason);
+ return promise;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/resolve.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
new file mode 100644
index 0000000..201a545
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
@@ -0,0 +1,48 @@
+import {
+ noop,
+ resolve as _resolve
+} from '../-internal';
+
+/**
+ `Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ @method resolve
+ @static
+ @param {Any} value value that the returned promise will be resolved with
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+*/
+export default function resolve(object) {
+ /*jshint validthis:true */
+ var Constructor = this;
+
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
+
+ var promise = new Constructor(noop);
+ _resolve(promise, object);
+ return promise;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/then.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/then.js
new file mode 100644
index 0000000..f97e946
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/then.js
@@ -0,0 +1,34 @@
+import {
+ invokeCallback,
+ subscribe,
+ FULFILLED,
+ REJECTED,
+ noop,
+ makePromise,
+ PROMISE_ID
+} from './-internal';
+
+import { asap } from './asap';
+
+export default function then(onFulfillment, onRejection) {
+ var parent = this;
+
+ var child = new this.constructor(noop);
+
+ if (child[PROMISE_ID] === undefined) {
+ makePromise(child);
+ }
+
+ var state = parent._state;
+
+ if (state) {
+ var callback = arguments[state - 1];
+ asap(function(){
+ invokeCallback(state, child, callback, parent._result);
+ });
+ } else {
+ subscribe(parent, child, onFulfillment, onRejection);
+ }
+
+ return child;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/utils.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/utils.js
new file mode 100644
index 0000000..31ec6f9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/lib/es6-promise/utils.js
@@ -0,0 +1,22 @@
+export function objectOrFunction(x) {
+ return typeof x === 'function' || (typeof x === 'object' && x !== null);
+}
+
+export function isFunction(x) {
+ return typeof x === 'function';
+}
+
+export function isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
+}
+
+var _isArray;
+if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+} else {
+ _isArray = Array.isArray;
+}
+
+export var isArray = _isArray;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/package.json
new file mode 100644
index 0000000..e3ee168
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/es6-promise/package.json
@@ -0,0 +1,95 @@
+{
+ "name": "es6-promise",
+ "namespace": "es6-promise",
+ "version": "3.2.1",
+ "description": "A lightweight library that provides tools for organizing asynchronous code",
+ "main": "dist/es6-promise.js",
+ "directories": {
+ "lib": "lib"
+ },
+ "files": [
+ "dist",
+ "lib",
+ "!dist/test"
+ ],
+ "devDependencies": {
+ "babel-eslint": "^6.0.0",
+ "broccoli-es6-module-transpiler": "^0.5.0",
+ "broccoli-jshint": "^2.1.0",
+ "broccoli-merge-trees": "^1.1.1",
+ "broccoli-replace": "^0.12.0",
+ "broccoli-stew": "^1.2.0",
+ "broccoli-uglify-js": "^0.1.3",
+ "broccoli-watchify": "^0.2.0",
+ "ember-cli": "2.5.0",
+ "ember-publisher": "0.0.7",
+ "git-repo-version": "0.0.3",
+ "json3": "^3.3.2",
+ "mocha": "^1.20.1",
+ "promises-aplus-tests-phantom": "^2.1.0-revise",
+ "release-it": "0.0.10"
+ },
+ "scripts": {
+ "build": "ember build",
+ "build:production": "ember build --environment production",
+ "start": "ember s",
+ "test": "ember test",
+ "test:server": "ember test --server",
+ "test:node": "ember build && mocha ./dist/test/browserify",
+ "lint": "jshint lib",
+ "prepublish": "ember build --environment production",
+ "dry-run-release": "ember build --environment production && release-it --dry-run --non-interactive"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jakearchibald/ES6-Promises.git"
+ },
+ "bugs": {
+ "url": "https://github.com/jakearchibald/ES6-Promises/issues"
+ },
+ "browser": {
+ "vertx": false
+ },
+ "keywords": [
+ "promises",
+ "futures"
+ ],
+ "author": {
+ "name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors",
+ "url": "Conversion to ES6 API by Jake Archibald"
+ },
+ "license": "MIT",
+ "spm": {
+ "main": "dist/es6-promise.js"
+ },
+ "gitHead": "5df472ec56d5b9fbc76589383852008d46055c61",
+ "homepage": "https://github.com/jakearchibald/ES6-Promises#readme",
+ "_id": "es6-promise@3.2.1",
+ "_shasum": "ec56233868032909207170c39448e24449dd1fc4",
+ "_from": "es6-promise@3.2.1",
+ "_npmVersion": "3.8.8",
+ "_nodeVersion": "5.10.1",
+ "_npmUser": {
+ "name": "stefanpenner",
+ "email": "stefan.penner@gmail.com"
+ },
+ "dist": {
+ "shasum": "ec56233868032909207170c39448e24449dd1fc4",
+ "tarball": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "jaffathecake",
+ "email": "jaffathecake@gmail.com"
+ },
+ {
+ "name": "stefanpenner",
+ "email": "stefan.penner@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/es6-promise-3.2.1.tgz_1463027774105_0.6333294357173145"
+ },
+ "_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/.coveralls.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/.coveralls.yml
new file mode 100644
index 0000000..a0b4fb6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/.coveralls.yml
@@ -0,0 +1 @@
+repo_token: 47iIZ0B3llo2Wc4dxWRltvgdImqcrVDTi
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/HISTORY.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/HISTORY.md
new file mode 100644
index 0000000..28bd789
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/HISTORY.md
@@ -0,0 +1,559 @@
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/LICENSE
new file mode 100644
index 0000000..ad410e1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/Makefile
new file mode 100644
index 0000000..36e1202
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/README.md
new file mode 100644
index 0000000..433dd88
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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) <http://christiankvalheim.com>
+
+### 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 <https://jira.mongodb.org>.
+- Navigate to the NODE project <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
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/TESTING.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/TESTING.md
new file mode 100644
index 0000000..fe03ea0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/TESTING.md
@@ -0,0 +1,18 @@
+Testing setup
+=============
+
+Single Server
+-------------
+mongod --dbpath=./db
+
+Replicaset
+----------
+mongo --nodb
+var x = new ReplSetTest({"useHostName":"false", "nodes" : {node0 : {}, node1 : {}, node2 : {}}})
+x.startSet();
+var config = x.getReplSetConfig()
+x.initiate(config);
+
+Mongos
+------
+var s = new ShardingTest( "auth1", 1 , 0 , 2 , {rs: true, noChunkSize : true}); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/conf.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/conf.json
new file mode 100644
index 0000000..12ce4c7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/connect_test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/connect_test.js
new file mode 100644
index 0000000..47ee71e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/connect_test.js
@@ -0,0 +1,72 @@
+var Server = require('./lib/topologies/server');
+
+// Attempt to connect
+var server = new Server({
+ host: 'localhost', port: 27017, socketTimeout: 500
+});
+
+// function executeCursors(_server, cb) {
+// var count = 100;
+//
+// for(var i = 0; i < 100; i++) {
+// // Execute the write
+// var cursor = _server.cursor('test.test', {
+// find: 'test.test'
+// , query: {a:1}
+// }, {readPreference: new ReadPreference('secondary')});
+//
+// // Get the first document
+// cursor.next(function(err, doc) {
+// count = count - 1;
+// if(err) console.dir(err)
+// if(count == 0) return cb();
+// });
+// }
+// }
+
+server.on('connect', function(_server) {
+ // console.log("===== connect")
+ setInterval(function() {
+ _server.insert('test.test', [{a:1}], function(err, r) {
+ console.log("insert")
+ });
+ }, 1000)
+ // console.log("---------------------------------- 0")
+ // // Attempt authentication
+ // _server.auth('scram-sha-1', 'admin', 'root', 'root', function(err, r) {
+ // console.log("---------------------------------- 1")
+ // // console.dir(err)
+ // // console.dir(r)
+ //
+ // _server.insert('test.test', [{a:1}], function(err, r) {
+ // console.log("---------------------------------- 2")
+ // console.dir(err)
+ // if(r)console.dir(r.result)
+ // var name = null;
+ //
+ // _server.on('joined', function(_t, _server) {
+ // if(name == _server.name) {
+ // console.log("=========== joined :: " + _t + " :: " + _server.name)
+ // executeCursors(_server, function() {
+ // });
+ // }
+ // })
+ //
+ // // var s = _server.s.replicaSetState.secondaries[0];
+ // // s.destroy({emitClose:true});
+ // executeCursors(_server, function() {
+ // console.log("============== 0")
+ // // Attempt to force a server reconnect
+ // var s = _server.s.replicaSetState.secondaries[0];
+ // name = s.name;
+ // s.destroy({emitClose:true});
+ // // console.log("============== 1")
+ //
+ // // _server.destroy();
+ // // test.done();
+ // });
+ // });
+ // });
+});
+
+server.connect();
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js
new file mode 100644
index 0000000..5011f4a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js
@@ -0,0 +1,38 @@
+// module.exports = {
+// MongoError: require('./lib/error')
+// , 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: require('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')
+// }
+
+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: require('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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/gssapi.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/gssapi.js
new file mode 100644
index 0000000..e06ce72
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/gssapi.js
@@ -0,0 +1,266 @@
+"use strict";
+
+var f = require('util').format
+ , crypto = require('crypto')
+ , 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 credentialsValid = false;
+ 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 {
+ credentialsValid = true;
+ 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, context) {
+ 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, payload) {
+ 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 err = null;
+ 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, r) {
+ if(err) err = 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js
new file mode 100644
index 0000000..0df70a0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js
@@ -0,0 +1,185 @@
+"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 credentialsValid = false;
+ 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 {
+ credentialsValid = true;
+ 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 err = null;
+ 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, r) {
+ if(err) err = 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/plain.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/plain.js
new file mode 100644
index 0000000..37bac30
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/plain.js
@@ -0,0 +1,170 @@
+"use strict";
+
+var f = require('util').format
+ , crypto = require('crypto')
+ , Binary = require('bson').Binary
+ , 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 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 credentialsValid = false;
+ 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 {
+ credentialsValid = true;
+ 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 err = null;
+ 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, r) {
+ if(err) err = 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js
new file mode 100644
index 0000000..0a620b3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js
@@ -0,0 +1,345 @@
+"use strict";
+
+var f = require('util').format
+ , crypto = require('crypto')
+ , Query = require('../connection/commands').Query
+ , Binary = require('bson').Binary
+ , 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;
+}
+
+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 (var i = 0; i < a.length; i++) {
+ res.push(a[i] ^ b[i])
+ }
+ }
+ return new Buffer(res);
+}
+
+// Create a final digest
+var hi = function(data, salt, iterations) {
+ // Create digest
+ var digest = function(msg) {
+ var hmac = crypto.createHmac('sha1', data);
+ hmac.update(msg);
+ return new Buffer(hmac.digest('base64'), 'base64');
+ }
+
+ // Create variables
+ salt = Buffer.concat([salt, new Buffer('\x00\x00\x00\x01')])
+ var ui = digest(salt);
+ var u1 = ui;
+
+ for(var i = 0; i < iterations - 1; i++) {
+ u1 = digest(u1);
+ ui = xor(ui, u1);
+ }
+
+ return ui;
+}
+
+/**
+ * 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 credentialsValid = false;
+ 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 {
+ credentialsValid = true;
+ 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
+ var 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(',');
+
+ // Generate server key
+ var hmac = crypto.createHmac('sha1', saltedPassword);
+ hmac.update(new Buffer('Server Key'))
+ var serverKey = new Buffer(hmac.digest('base64'), 'base64');
+
+ // Generate server signature
+ var hmac = crypto.createHmac('sha1', serverKey);
+ hmac.update(new Buffer(authMsg))
+ var serverSig = new Buffer(hmac.digest('base64'), 'base64');
+
+ //
+ // 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;
+ var err = null;
+ // 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, r) {
+ if(err) err = err;
+ count = count - 1;
+ // Done re-authenticating
+ if(count == 0) {
+ callback(err, null);
+ }
+ });
+ }
+}
+
+
+module.exports = ScramSHA1;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/sspi.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/sspi.js
new file mode 100644
index 0000000..01be1bf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/sspi.js
@@ -0,0 +1,255 @@
+"use strict";
+
+var f = require('util').format
+ , crypto = require('crypto')
+ , 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 credentialsValid = false;
+ 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 {
+ credentialsValid = true;
+ 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 err = null;
+ 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, r) {
+ if(err) err = 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/x509.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/x509.js
new file mode 100644
index 0000000..e3117c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/auth/x509.js
@@ -0,0 +1,165 @@
+"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 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 credentialsValid = false;
+ 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'
+ , 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 {
+ credentialsValid = true;
+ 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 err = null;
+ 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, r) {
+ if(err) err = 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/command_result.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/command_result.js
new file mode 100644
index 0000000..eb7b27a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/command_result.js
@@ -0,0 +1,38 @@
+"use strict";
+
+var setProperty = require('../connection/utils').setProperty
+ , getProperty = require('../connection/utils').getProperty
+ , getSingleProperty = require('../connection/utils').getSingleProperty;
+
+/**
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/commands.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/commands.js
new file mode 100644
index 0000000..7999e59
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/commands.js
@@ -0,0 +1,555 @@
+"use strict";
+
+var f = require('util').format
+ , Long = require('bson').Long
+ , setProperty = require('./utils').setProperty
+ , getProperty = require('./utils').getProperty
+ , getSingleProperty = require('./utils').getSingleProperty;
+
+// 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_NONE = 0;
+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 colletion 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
+ , this.checkKeys
+ , true
+ , this.serializeFunctions
+ , 0, 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, this.checkKeys, true, this.serializeFunctions, 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;
+}
+
+// Validation buffers
+var firstBatch = new Buffer('firstBatch', 'utf8');
+var nextBatch = new Buffer('nextBatch', 'utf8');
+var cursorId = new Buffer('id', 'utf8').toString('hex');
+
+var documentBuffers = {
+ firstBatch: firstBatch.toString('hex'),
+ nextBatch: nextBatch.toString('hex')
+};
+
+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
+
+ //
+ // Single document and documentsReturnedIn set
+ //
+ if(this.numberReturned == 1 && documentsReturnedIn != null && raw) {
+ // Calculate the bson size
+ var 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;
+ // Set up the options
+ var _options = {
+ promoteLongs: promoteLongs,
+ promoteValues: promoteValues,
+ promoteBuffers: promoteBuffers,
+ 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++) {
+ var bsonSize = this.data[this.index] | this.data[this.index + 1] << 8 | this.data[this.index + 2] << 16 | this.data[this.index + 3] << 24;
+ // Parse options
+ var _options = {promoteLongs: promoteLongs, promoteValues: promoteValues, promoteBuffers: promoteBuffers};
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js
new file mode 100644
index 0000000..261fd77
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js
@@ -0,0 +1,568 @@
+"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', '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 {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=0] 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.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.keepAlive = typeof options.keepAlive == 'boolean' ? options.keepAlive : true;
+ this.keepAliveInitialDelay = options.keepAliveInitialDelay || 0;
+ this.noDelay = typeof options.noDelay == 'boolean' ? options.noDelay : true;
+ this.connectionTimeout = options.connectionTimeout || 0;
+ this.socketTimeout = options.socketTimeout || 0;
+
+ // 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.cert = options.cert || null;
+ this.key = options.key || null;
+ this.passphrase = options.passphrase || 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(value) {
+ if(this.connection) {
+ this.connection.setTimeout(this.socketTimeout);;
+ }
+}
+
+Connection.enableConnectionAccounting = function() {
+ connectionAccounting = true;
+ connections = {};
+}
+
+Connection.disableConnectionAccounting = function() {
+ connectionAccounting = false;
+}
+
+Connection.connections = function() {
+ return connections;
+}
+
+//
+// Connection handlers
+var errorHandler = function(self) {
+ return function(err) {
+ if(connectionAccounting) delete connections[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(err) {
+ if(connectionAccounting) delete connections[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) delete connections[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) {
+ var 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 {
+ var 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) {
+ var 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 {
+ var 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'
+ , '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) connections[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
+ self.connection = self.domainSocket
+ ? net.createConnection(self.host)
+ : net.createConnection(self.port, self.host);
+
+ // 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.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(servername, cert) {
+ return undefined;
+ }
+ } else if(typeof self.checkServerIdentity == 'function') {
+ sslOptions.checkServerIdentity = self.checkServerIdentity;
+ }
+
+ // 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.on('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) delete connections[this.id];
+ if(this.connection) {
+ this.connection.end();
+ 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) {
+ // 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(var i = 0; i < buffer.length; i++)
+ this.logger.debug(f('writing buffer [%s] to %s:%s', buffer[i].toString('hex'), this.host, this.port));
+ }
+ }
+
+ // Write out the command
+ if(!Array.isArray(buffer)) return this.connection.write(buffer, 'binary');
+ // Iterate over all buffers and write them in order to the socket
+ for(var i = 0; i < buffer.length; i++) this.connection.write(buffer[i], 'binary');
+}
+
+/**
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/logger.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/logger.js
new file mode 100644
index 0000000..cba8954
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/logger.js
@@ -0,0 +1,229 @@
+"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
+ var self = this;
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js
new file mode 100644
index 0000000..4e3ad83
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js
@@ -0,0 +1,1220 @@
+"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('../topologies/shared').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=0] Initial delay before TCP keep alive enabled
+ * @param {boolean} [options.noDelay=true] TCP Connection no delay
+ * @param {number} [options.connectionTimeout=0] TCP Connection timeout setting
+ * @param {number} [options.socketTimeout=0] 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.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) {
+ var self = this;
+ // 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: 30000,
+ keepAlive: true,
+ keepAliveInitialDelay: 0,
+ noDelay: true,
+ // SSL Settings
+ ssl: false, checkServerIdentity: true,
+ ca: 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);
+
+ // 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)
+ }
+
+ // 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, r) {
+ // 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) {
+ 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() {
+ 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() {
+ 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(err) {
+ // Reset retries
+ self.retriesLeft = self.options.reconnectTries;
+ // Push to available connections
+ self.availableConnections.push(connection);
+ // Emit reconnect event
+ self.emit('reconnect', self);
+ // Trigger execute to start everything up again
+ _execute(self)();
+ });
+ }
+ }
+
+ // Create a connection
+ var connection = new Connection(messageHandler(self), self.options);
+ // Add handlers
+ connection.on('close', _connectionFailureHandler(self, 'close'));
+ connection.on('error', _connectionFailureHandler(self, 'error'));
+ connection.on('timeout', _connectionFailureHandler(self, 'timeout'));
+ connection.on('parseError', _connectionFailureHandler(self, 'parseError'));
+ // On connection
+ connection.on('connect', _connectHandler(self));
+ // Attempt connection
+ connection.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
+ var 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(err) {
+ 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(err) {
+ // 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 {Connectio[]} 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);
+
+ 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(auth) {
+ 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();
+
+ // 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
+ 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, db) {
+ 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.availableConnections;
+ // Allow nothing else to use the connections while we authenticate them
+ self.availableConnections = [];
+
+ var connectionsCount = connections.length;
+ var error = null;
+ // No connections available, return
+ if(connectionsCount == 0) 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, r) {
+ 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);
+ return destroy(self, connections);
+ }
+
+ // Wait for the operations to drain before we close the pool
+ function checkStatus() {
+ 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 {
+ 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.requestId = options.requestId;
+
+ // Optional per operation socketTimeout
+ operation.socketTimeout = options.socketTimeout;
+ operation.monitoring = options.monitoring;
+
+ // 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) {
+ var connection = new Connection(messageHandler(self), self.options);
+
+ // Push the connection
+ self.connectingConnections.push(connection);
+
+ // Handle any errors
+ var tempErrorHandler = function(_connection) {
+ return function(err) {
+ // 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 authenticating 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() {
+ // 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 = self.availableConnections.pop();
+ var connection = self.availableConnections[self.connectionIndex++ % self.availableConnections.length];
+ // Is the connection connected
+ if(connection.isConnected()) {
+ // Get the next work item
+ var workItem = self.queue.shift();
+
+ // Get actual binary commands
+ var buffer = workItem.buffer;
+
+ // Set current status of authentication process
+ workItem.authenticating = self.authenticating;
+ workItem.authenticatingTimestamp = self.authenticatingTimestamp;
+
+ // Add current associated callback to the connection
+ // connection.workItem = workItem
+ connection.workItems.push(workItem);
+
+ // We have a custom socketTimeout
+ if(!workItem.immediateRelease && typeof workItem.socketTimeout == 'number') {
+ connection.setSocketTimeout(workItem.socketTimeout);
+ }
+
+ // Put operation on the wire
+ if(Array.isArray(buffer)) {
+ for(var i = 0; i < buffer.length; i++) {
+ connection.write(buffer[i])
+ }
+ } else {
+ connection.write(buffer);
+ }
+
+ if(workItem.immediateRelease && self.authenticating) {
+ self.nonAuthenticatedConnections.push(connection);
+ }
+
+ // Have we not reached the max connection size yet
+ if(totalConnections < self.options.size
+ && self.queue.length > 0) {
+ // Create a new connection
+ _createConnection(self);
+ }
+ } else {
+ flushMonitoringOperations(self.queue);
+ }
+ }
+ });
+
+ self.executing = false;
+ }
+}
+
+var connectionId = 0
+/**
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/utils.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/utils.js
new file mode 100644
index 0000000..019ef19
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/utils.js
@@ -0,0 +1,67 @@
+"use strict";
+
+// 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;
+}
+
+exports.setProperty = setProperty;
+exports.getProperty = getProperty;
+exports.getSingleProperty = getSingleProperty;
+exports.copy = copy;
+exports.debugOptions = debugOptions;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js
new file mode 100644
index 0000000..12c9c27
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js
@@ -0,0 +1,699 @@
+"use strict";
+
+var Long = require('bson').Long
+ , Logger = require('./connection/logger')
+ , MongoError = require('./error')
+ , f = require('util').format;
+
+/**
+ * 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 reference
+ var self = this;
+ // Initial query
+ var query = null;
+
+ // 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 push = Array.prototype.push;
+
+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) && 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(f('connection destroyed, not possible to instantiate cursor')));
+
+ // query, cmd, options, cursorState, callback
+ self._find(function(err, r) {
+ 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(f('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.$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.$err));
+ });
+ }
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js
new file mode 100644
index 0000000..31ede94
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/tools/smoke_plugin.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/tools/smoke_plugin.js
new file mode 100644
index 0000000..dcceda4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/mongos.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/mongos.js
new file mode 100644
index 0000000..7ba6220
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/mongos.js
@@ -0,0 +1,1112 @@
+"use strict"
+
+var inherits = require('util').inherits,
+ f = require('util').format,
+ EventEmitter = require('events').EventEmitter,
+ BSON = require('bson').native().BSON,
+ ReadPreference = require('./read_preference'),
+ BasicCursor = require('../cursor'),
+ Logger = require('../connection/logger'),
+ debugOptions = require('../connection/utils').debugOptions,
+ MongoError = require('../error'),
+ Server = require('./server'),
+ ReplSetState = require('./replset_state'),
+ assign = require('./shared').assign,
+ clone = require('./shared').clone,
+ createClientInfo = require('./shared').createClientInfo;
+
+/**
+ * @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 DESTROYED = 'destroyed';
+
+function stateTransition(self, newState) {
+ var legalTransitions = {
+ 'disconnected': [CONNECTING, DESTROYED, DISCONNECTED],
+ 'connecting': [CONNECTING, DESTROYED, CONNECTED, DISCONNECTED],
+ 'connected': [CONNECTED, DISCONNECTED, 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.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
+ */
+var Mongos = function(seedlist, options) {
+ var self = this;
+ options = options || {};
+
+ // Get replSet Id
+ this.id = id++;
+
+ // Internal state
+ this.s = {
+ options: assign({}, options),
+ // BSON instance
+ bson: options.bson || new BSON(),
+ // 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)
+ }
+
+ // 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;
+
+ // Add event listener
+ EventEmitter.call(this);
+}
+
+inherits(Mongos, EventEmitter);
+
+Object.defineProperty(Mongos.prototype, 'type', {
+ enumerable:true, get: function() { return 'mongos'; }
+});
+
+/**
+ * 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)
+ }));
+ });
+
+ // Emit the topology opening event
+ emitSDAMEvent(this, 'topologyOpening', { topologyId: this.id });
+
+ // Start all server connections
+ connectProxies(self, servers);
+}
+
+function handleEvent(self, event) {
+ return function(err) {
+ if(self.state == DESTROYED) return;
+ // Move to list of disconnectedProxies
+ moveServerFrom(self.connectedProxies, self.disconnectedProxies, this);
+ // Emit the left signal
+ self.emit('left', 'mongos', this);
+ }
+}
+
+function handleInitialConnectEvent(self, event) {
+ return function(err) {
+ // Destroy the instance
+ if(self.state == DESTROYED) {
+ // Move from connectingProxies
+ moveServerFrom(self.connectingProxies, self.disconnectedProxies, this);
+ return this.destroy();
+ }
+
+ // Check the type of server
+ if(event == 'connect') {
+ // 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);
+ this.destroy();
+ return self.emit('failed', this);
+ }
+ }
+
+ // 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'));
+
+ // 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);
+ }
+
+ // 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() {
+ // 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++);
+ }
+}
+
+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(var 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(err, r) {
+ var _self = this;
+ count = count - 1;
+
+ // Destroyed
+ if(self.state == DESTROYED) {
+ moveServerFrom(self.connectingProxies, self.disconnectedProxies, _self);
+ return this.destroy();
+ }
+
+ if(event == 'connect' && !self.authenticating) {
+ // Destroyed
+ if(self.state == DESTROYED) {
+ 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 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) {
+ 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)
+ }));
+
+ // 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 < proxies.length; i++) {
+ execute(proxies[i], i);
+ }
+}
+
+function topologyMonitor(self, options) {
+ options = options || {};
+
+ // Set momitoring timeout
+ self.haTimeoutId = setTimeout(function() {
+ if(self.state == DESTROYED) 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}, function(err, r) {
+ if(self.state == DESTROYED) {
+ // 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 });
+ } 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.emit('close', self);
+ }
+
+ // Attempt to connect to any unknown servers
+ return reconnectProxies(self, self.disconnectedProxies, function(err, cb) {
+ if(self.state == DESTROYED) 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(err, r) {
+ count = count - 1;
+
+ if(count == 0) {
+ if(self.state == DESTROYED) return;
+
+ // Attempt to connect to any unknown servers
+ reconnectProxies(self, self.disconnectedProxies, function(err, cb) {
+ if(self.state == DESTROYED) 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(emitClose) {
+ // Transition state
+ stateTransition(this, DISCONNECTED);
+ // Get all proxies
+ var proxies = self.connectedProxies.concat(self.connectingProxies);
+ proxies.forEach(function(x) {
+ x.unref();
+ });
+
+ clearTimeout(this.haTimeoutId);
+}
+
+/**
+ * Destroy the server connection
+ * @method
+ */
+Mongos.prototype.destroy = function(emitClose) {
+ // 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);
+
+ // Destroy all connecting servers
+ proxies.forEach(function(x) {
+ x.destroy();
+ });
+
+ // Emit toplogy closing event
+ emitSDAMEvent(this, 'topologyClosed', { topologyId: this.id });
+}
+
+/**
+ * Figure out if the server is connected
+ * @method
+ * @return {boolean}
+ */
+Mongos.prototype.isConnected = function(options) {
+ 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;
+
+ // Establish readPreference
+ var readPreference = options.readPreference ? options.readPreference : ReadPreference.primary;
+
+ // 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'));
+ }
+
+ // Execute the command
+ server.command(ns, cmd, options, 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();
+
+ // 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, r) {
+ 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) 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);
+ }
+ }
+
+ // 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 = [];
+
+ // Execute logout on all server instances
+ for(var i = 0; i < servers.length; i++) {
+ servers[i].logout(dbName, function(err) {
+ count = count - 1;
+ if(err) errors.push({name: server.name, err: err});
+
+ 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
+ * @param {ReadPreference} [options.readPreference] Specify read preference if command supports it
+ * @return {Server}
+ */
+Mongos.prototype.getServer = function() {
+ var server = pickProxy(this);
+ if(this.s.debug) this.emit('pickedServer', null, server);
+ return server;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/read_preference.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/read_preference.js
new file mode 100644
index 0000000..a801fbe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/read_preference.js
@@ -0,0 +1,119 @@
+"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.maxStalenessMS] Max Secondary Read Stalleness in Miliseconds
+ * @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} maxStalenessMS MaxStalenessMS value for the read preference
+ * @return {ReadPreference}
+ */
+var ReadPreference = function(preference, tags, options) {
+ this.preference = preference;
+ this.tags = tags;
+ this.options = options;
+
+ // If no tags were passed in
+ if(tags && typeof tags == 'object') {
+ this.options = tags, tags = null;
+ }
+
+ // Add the maxStalenessMS value to the read Preference
+ if(this.options && this.options.maxStalenessMS) {
+ this.maxStalenessMS = this.options.maxStalenessMS;
+ }
+}
+
+/**
+ * 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.maxStalenessMS) readPreference.maxStalenessMS = this.maxStalenessMS;
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js
new file mode 100644
index 0000000..90a6862
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js
@@ -0,0 +1,1365 @@
+"use strict"
+
+var inherits = require('util').inherits,
+ f = require('util').format,
+ EventEmitter = require('events').EventEmitter,
+ BSON = require('bson').native().BSON,
+ ReadPreference = require('./read_preference'),
+ BasicCursor = require('../cursor'),
+ Logger = require('../connection/logger'),
+ debugOptions = require('../connection/utils').debugOptions,
+ MongoError = require('../error'),
+ Server = require('./server'),
+ ReplSetState = require('./replset_state'),
+ assign = require('./shared').assign,
+ clone = require('./shared').clone,
+ 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');
+
+//
+// States
+var DISCONNECTED = 'disconnected';
+var CONNECTING = 'connecting';
+var CONNECTED = 'connected';
+var DESTROYED = 'destroyed';
+
+function stateTransition(self, newState) {
+ var legalTransitions = {
+ 'disconnected': [CONNECTING, DESTROYED, DISCONNECTED],
+ 'connecting': [CONNECTING, DESTROYED, CONNECTED, DISCONNECTED],
+ 'connected': [CONNECTED, DISCONNECTED, 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 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.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 MongoS proxy 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
+ */
+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(),
+ // 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)
+ }
+
+ // 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;
+}
+
+inherits(ReplSet, EventEmitter);
+
+Object.defineProperty(ReplSet.prototype, 'type', {
+ enumerable:true, get: function() { return 'replset'; }
+});
+
+function attemptReconnect(self) {
+ if(self.runningAttempReconnect) return;
+ // Set as running
+ self.runningAttempReconnect = true;
+ // Wait before execute
+ self.haTimeoutId = setTimeout(function() {
+ if(self.state == DESTROYED) return;
+
+ // Debug log
+ if(self.s.logger.isDebug()) {
+ self.s.logger.debug(f('attemptReconnect for replset with id %s', self.id));
+ }
+
+ // Get all known hosts
+ var keys = Object.keys(self.s.replicaSetState.set);
+ var servers = keys.map(function(x) {
+ return new Server(assign({}, self.s.options, {
+ host: x.split(':')[0], port: parseInt(x.split(':')[1], 10)
+ }, {
+ authProviders: self.authProviders, reconnect:false, monitoring: false, inTopology: true
+ }, {
+ clientInfo: clone(self.s.clientInfo)
+ }));
+ });
+
+ // Create the list of servers
+ self.s.connectingServers = servers.slice(0);
+
+ // Handle all events coming from servers
+ function _handleEvent(self, event) {
+ return function(err) {
+ // Destroy the instance
+ if(self.state == DESTROYED) {
+ return this.destroy();
+ }
+
+ // Debug log
+ if(self.s.logger.isDebug()) {
+ self.s.logger.debug(f('attemptReconnect for replset with id %s using server %s ended with event %s', self.id, this.name, event));
+ }
+
+ // Check if we are done
+ function done() {
+ // Done with the reconnection attempt
+ if(self.s.connectingServers.length == 0) {
+ if(self.state == DESTROYED) return;
+
+ // 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 });
+ }
+
+ // Do we have a primary
+ if(self.s.replicaSetState.hasPrimary()) {
+ // Connect any missing servers
+ connectNewServers(self, self.s.replicaSetState.unknownServers, function(err, cb) {
+ // Debug log
+ if(self.s.logger.isDebug()) {
+ self.s.logger.debug(f('attemptReconnect for replset with id successful resuming topologyMonitor', self.id));
+ }
+
+ // Reset the running
+ self.runningAttempReconnect = false;
+ // Go back to normal topology monitoring
+ topologyMonitor(self);
+ });
+ } else {
+ if(self.listeners("close").length > 0) {
+ self.emit('close', self);
+ }
+
+ // Reset the running
+ self.runningAttempReconnect = false;
+ // Attempt a new reconnect
+ attemptReconnect(self);
+ }
+ }
+ }
+
+ // Remove the server from our list
+ for(var i = 0; i < self.s.connectingServers.length; i++) {
+ if(self.s.connectingServers[i].equals(this)) {
+ self.s.connectingServers.splice(i, 1);
+ }
+ }
+
+ // Keep reference to server
+ var _self = this;
+
+ // Debug log
+ if(self.s.logger.isDebug()) {
+ self.s.logger.debug(f('attemptReconnect in replset with id %s for', self.id));
+ }
+
+ // Connect and not authenticating
+ if(event == 'connect' && !self.authenticating) {
+ if(self.state == DESTROYED) {
+ return _self.destroy();
+ }
+
+ // Update the replicaset state
+ if(self.s.replicaSetState.update(_self)) {
+ // 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'));
+ } else {
+ _self.destroy();
+ }
+ } else if(event == 'connect' && self.authenticating) {
+ this.destroy();
+ }
+
+ done();
+ }
+ }
+
+ // Index used to interleaf the server connects, avoiding
+ // runtime issues on io constrained vm's
+ var timeoutInterval = 0;
+
+ function connect(server, timeoutInterval) {
+ setTimeout(function() {
+ 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);
+ }, timeoutInterval);
+ }
+
+ // Connect all servers
+ while(servers.length > 0) {
+ connect(servers.shift(), timeoutInterval++);
+ }
+ }, self.s.minHeartbeatFrequencyMS);
+}
+
+function connectNewServers(self, servers, callback) {
+ // Count lefts
+ var count = servers.length;
+
+ // Handle events
+ var _handleEvent = function(self, event) {
+ return function(err, r) {
+ var _self = this;
+ count = count - 1;
+
+ // Destroyed
+ if(self.state == DESTROYED) {
+ return this.destroy();
+ }
+
+ if(event == 'connect' && !self.authenticating) {
+ // Destroyed
+ if(self.state == DESTROYED) {
+ return _self.destroy();
+ }
+
+ 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'));
+ } else {
+ _self.destroy();
+ }
+ } else if(event == 'connect' && self.authenticating) {
+ 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) {
+ 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);
+ }
+}
+
+function topologyMonitor(self, options) {
+ options = options || {};
+
+ // Set momitoring timeout
+ self.haTimeoutId = setTimeout(function() {
+ if(self.state == DESTROYED) return;
+
+ // Is this a on connect topology discovery
+ // Schedule a proper topology monitoring to happen
+ // To ensure any discovered servers do not timeout
+ // while waiting for the initial discovery to happen.
+ if(options.haInterval) {
+ topologyMonitor(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 });
+ }
+
+ // Get the connectingServers
+ var connectingServers = self.s.replicaSetState.allServers();
+ // Debug log
+ if(self.s.logger.isDebug()) {
+ self.s.logger.debug(f('topologyMonitor in replset with id %s connected servers [%s]'
+ , self.id
+ , connectingServers.map(function(x) {
+ return x.name;
+ })));
+ }
+ // Get the count
+ var count = connectingServers.length;
+
+ // If we have no servers connected
+ if(count == 0 && !options.haInterval) {
+ if(self.listeners("close").length > 0) {
+ self.emit('close', self);
+ }
+
+ return attemptReconnect(self);
+ }
+
+ // 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}, function(err, r) {
+ if(self.state == DESTROYED) {
+ _server.destroy();
+ 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 });
+ } 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 stalness for this server
+ self.s.replicaSetState.updateServerMaxStaleness(_server, self.s.haInterval);
+
+ // Callback
+ cb(err, r);
+ });
+ }
+
+ // Connect any missing servers
+ function connectMissingServers() {
+ if(self.state == DESTROYED) return;
+
+ // Attempt to connect to any unknown servers
+ connectNewServers(self, self.s.replicaSetState.unknownServers, function(err, cb) {
+ if(self.state == DESTROYED) return;
+
+ // Check if we have an options.haInterval (meaning it was triggered from connect)
+ if(options.haInterval) {
+ // Do we have a primary and secondary
+ if(self.state == CONNECTING
+ && self.s.replicaSetState.hasPrimaryAndSecondary()) {
+ // Transition to connected
+ stateTransition(self, CONNECTED);
+ // Update initial state
+ self.initialConnectState.connect = true;
+ self.initialConnectState.fullsetup = true;
+ self.initialConnectState.all = true;
+ // Emit fullsetup and all events
+ process.nextTick(function() {
+ self.emit('connect', self);
+ self.emit('fullsetup', self);
+ self.emit('all', self);
+ });
+ } else if(self.state == CONNECTING
+ && self.s.replicaSetState.hasPrimary()) {
+ // Transition to connected
+ stateTransition(self, CONNECTED);
+ // Update initial state
+ self.initialConnectState.connect = true;
+ // Emit connected sign
+ process.nextTick(function() {
+ self.emit('connect', self);
+ });
+ } else if(self.state == CONNECTING
+ && self.s.replicaSetState.hasSecondary()
+ && self.s.options.secondaryOnlyConnectionAllowed) {
+ // Transition to connected
+ stateTransition(self, CONNECTED);
+ // Update initial state
+ self.initialConnectState.connect = true;
+ // Emit connected sign
+ process.nextTick(function() {
+ self.emit('connect', self);
+ });
+ } else if(self.state == CONNECTING) {
+ self.emit('error', new MongoError('no primary found in replicaset'));
+ // Destroy the topology
+ return self.destroy();
+ } else if(self.state == CONNECTED
+ && self.s.replicaSetState.hasPrimaryAndSecondary()
+ && !self.initialConnectState.fullsetup) {
+ self.initialConnectState.fullsetup = true;
+ // Emit fullsetup and all events
+ process.nextTick(function() {
+ self.emit('fullsetup', self);
+ self.emit('all', self);
+ });
+ }
+ }
+
+ if(!options.haInterval) topologyMonitor(self);
+ });
+ }
+
+ // No connectingServers but unknown servers
+ if(connectingServers.length == 0
+ && self.s.replicaSetState.unknownServers.length > 0 && options.haInterval) {
+ return connectMissingServers();
+ } else if(connectingServers.length == 0 && options.haInterval) {
+ self.destroy();
+ return self.emit('error', new MongoError('no valid replicaset members found'));
+ }
+
+ // Ping all servers
+ for(var i = 0; i < connectingServers.length; i++) {
+ pingServer(self, connectingServers[i], function(err, r) {
+ count = count - 1;
+
+ if(count == 0) {
+ connectMissingServers();
+ }
+ });
+ }
+ }, options.haInterval || self.s.haInterval)
+}
+
+function handleEvent(self, event) {
+ return function(err) {
+ if(self.state == DESTROYED) 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));
+ }
+
+ self.s.replicaSetState.remove(this);
+ }
+}
+
+function handleInitialConnectEvent(self, event) {
+ return function(err) {
+ // 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) {
+ return this.destroy();
+ }
+
+ // Check the type of server
+ if(event == 'connect') {
+ // 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'));
+ } else if(result instanceof MongoError) {
+ this.destroy();
+ self.destroy();
+ return self.emit('error', result);
+ } else {
+ this.destroy();
+ }
+ } else {
+ // Emit failure to connect
+ self.emit('failed', this);
+ // Remove from the state
+ self.s.replicaSetState.remove(this);
+ }
+
+ // 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) {
+ 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)
+ }));
+ });
+
+ // Emit the topology opening event
+ emitSDAMEvent(this, 'topologyOpening', { topologyId: this.id });
+
+ // Start all server connections
+ connectServers(self, servers);
+}
+
+/**
+ * Destroy the server connection
+ * @method
+ */
+ReplSet.prototype.destroy = function() {
+ // Transition state
+ stateTransition(this, DESTROYED);
+ // Clear out any monitoring process
+ if(this.haTimeoutId) clearTimeout(this.haTimeoutId);
+ // Destroy the replicaset
+ this.s.replicaSetState.destroy();
+
+ // Destroy all connecting servers
+ this.s.connectingServers.forEach(function(x) {
+ x.destroy();
+ });
+
+ // 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, DISCONNECTED);
+
+ 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() {
+ 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.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 all connected servers
+ * @method
+ * @return {Server[]}
+ */
+ReplSet.prototype.getServers = function() {
+ return this.s.replicaSetState.allServers();
+}
+
+function basicReadPreferenceValidation(self, options) {
+ if(options.readPreference && !(options.readPreference instanceof ReadPreference)) {
+ throw new Error("readPreference must be an instance of ReadPreference");
+ }
+}
+
+//
+// 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();
+
+ // 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.replicaSetState.hasPrimary() && 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.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, r) {
+ 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) 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;
+ // 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);
+ }
+
+ // Now logout all the servers
+ var servers = this.s.replicaSetState.allServers();
+ var count = servers.length;
+ if(count == 0) return callback();
+ var errors = [];
+
+ // Execute logout on all server instances
+ for(var i = 0; i < servers.length; i++) {
+ servers[i].logout(dbName, function(err) {
+ count = count - 1;
+ if(err) errors.push({name: server.name, err: err});
+
+ 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset_state.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset_state.js
new file mode 100644
index 0000000..600e554
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset_state.js
@@ -0,0 +1,948 @@
+"use strict"
+
+var inherits = require('util').inherits,
+ f = require('util').format,
+ EventEmitter = require('events').EventEmitter,
+ Logger = require('../connection/logger'),
+ ObjectId = require('bson').ObjectId,
+ 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(server) {
+ return this.primary != null && this.secondaries.length > 0;
+}
+
+ReplSetState.prototype.hasPrimary = function(server) {
+ return this.primary != null;
+}
+
+ReplSetState.prototype.hasSecondary = function(server) {
+ return this.secondaries.length > 0;
+}
+
+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() {
+ // Destroy all sockets
+ if(this.primary) this.primary.destroy();
+ this.secondaries.forEach(function(x) { x.destroy(); });
+ this.arbiters.forEach(function(x) { x.destroy(); });
+ this.passives.forEach(function(x) { x.destroy(); });
+ this.ghosts.forEach(function(x) { x.destroy(); });
+ // Clear out the complete state
+ this.secondaries = [];
+ this.arbiters = [];
+ this.passives = [];
+ this.ghosts = [];
+ this.unknownServers = [];
+ this.set = {};
+}
+
+ReplSetState.prototype.remove = function(server, options) {
+ options = options || {};
+
+ // 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[server.name]) {
+ this.set[server.name].type = ServerType.Unknown;
+ this.set[server.name].electionId = null;
+ this.set[server.name].setName = null;
+ this.set[server.name].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);
+
+ // 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();
+
+ //
+ // 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 : []);
+
+ // 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]);
+ }
+
+ 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[server.name] = {
+ type: ServerType.Unknown, setVersion: null, electionId: null, setName: null
+ }
+ // Update set information about the server instance
+ self.set[server.name].type = ServerType.Unknown;
+ self.set[server.name].electionId = ismaster ? ismaster.electionId : ismaster;
+ self.set[server.name].setName = ismaster ? ismaster.setName : ismaster;
+ self.set[server.name].setVersion = ismaster ? ismaster.setVersion : ismaster;
+
+ if(self.unknownServers.indexOf(server.name) == -1) {
+ self.unknownServers.push(server.name);
+ }
+
+ // 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[server.name] = {
+ 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[server.name] = {
+ 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 != server.name) {
+ 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));
+ }
+
+ // Set the type of topology we have
+ if(this.primary && !this.primary.equals(server)) {
+ this.topologyType = TopologyType.ReplicaSetWithPrimary;
+ } else {
+ this.topologyType = TopologyType.ReplicaSetNoPrimary;
+ }
+
+ 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 || result == 0) {
+ 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;
+ }
+
+ self.primary = server;
+ self.set[server.name] = {
+ 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;
+ } else if(ismaster.ismaster && ismaster.setName) {
+ // Get the electionIds
+ var currentElectionId = self.set[self.primary.name].electionId;
+ var currentSetVersion = self.set[self.primary.name].setVersion;
+ var currentSetName = self.set[self.primary.name].setName;
+ var ismasterElectionId = server.lastIsMaster().electionId;
+ var 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) {
+ var 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) {
+ var 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] = {
+ 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[server.name] = {
+ 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] = {
+ 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 == server.name) {
+ server.destroy();
+ this.primary = null;
+ self.emit('left', 'primary', server);
+ }
+
+ 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 == server.name) {
+ 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[server.name] && this.set[server.name].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 stalness 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;
+
+ // maxStalenessMS is not allowed with a primary read
+ if(readPreference.preference == 'primary' && readPreference.maxStalenessMS) {
+ return new MongoError('primary readPreference incompatible with maxStalenessMS');
+ }
+
+ // Check if we have any non compatible servers for maxStalenessMS
+ var allservers = this.primary ? [this.primary] : [];
+ allservers = allservers.concat(this.secondaries);
+
+ // Does any of the servers not support the right wire protocol version
+ // for maxStalenessMS when maxStalenessMS specified on readPreference. Then error out
+ if(readPreference.maxStalenessMS) {
+ for(var i = 0; i < allservers.length; i++) {
+ if(allservers[i].ismaster.maxWireVersion < 5) {
+ return new MongoError('maxStalenessMS not supported by at least one of the replicaset members');
+ }
+ }
+ }
+
+ // Do we have the nearest readPreference
+ if(readPreference.preference == 'nearest' && !readPreference.maxStalenessMS) {
+ return pickNearest(this, readPreference);
+ } else if(readPreference.preference == 'nearest' && readPreference.maxStalenessMS) {
+ return pickNearestMaxStalenessMS(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.maxStalenessMS) {
+ // 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.maxStalenessMS) {
+ // Pick nearest of any other servers available
+ var server = pickNearestMaxStalenessMS(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)) {
+ var server = null;
+
+ // We prefer the primary if it's available
+ if(this.primary) {
+ return this.primary;
+ }
+
+ // Pick a secondary
+ if(secondaries.length > 0 && !readPreference.maxStalenessMS) {
+ server = pickNearest(this, readPreference);
+ } else if(secondaries.length > 0 && readPreference.maxStalenessMS) {
+ server = pickNearestMaxStalenessMS(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]);
+ }
+ }
+
+ // We found servers by the highest priority
+ if(found) break;
+ }
+
+ // Returned filtered servers
+ return filteredServers;
+}
+
+function pickNearestMaxStalenessMS(self, readPreference) {
+ // Only get primary and secondaries as seeds
+ var seeds = {};
+ var servers = [];
+ var heartbeatFrequencyMS = self.heartbeatFrequencyMS;
+
+ // Check if the maxStalenessMS > heartbeatFrequencyMS * 2
+ if(readPreference.maxStalenessMS < (heartbeatFrequencyMS * 2)) {
+ return new MongoError('maxStalenessMS must be at least twice the haInterval');
+ }
+
+ // Add primary to list if not a secondary read preference
+ if(self.primary && readPreference.preference != 'secondary') {
+ servers.push(self.primary);
+ }
+
+ // Add all the secondaries
+ for(var i = 0; i < self.secondaries.length; i++) {
+ servers.push(self.secondaries[i]);
+ }
+
+ // 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 <= readPreference.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 seeds = {};
+ var servers = [];
+
+ // Add primary to list if not a secondary read preference
+ if(self.primary && readPreference.preference != 'secondary') {
+ servers.push(self.primary);
+ }
+
+ // Add all the secondaries
+ for(var i = 0; i < self.secondaries.length; i++) {
+ servers.push(self.secondaries[i]);
+ }
+
+ // 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].name == server.name) return true;
+ }
+
+ return false;
+}
+
+function addToList(self, type, ismaster, server, list) {
+ // Update set information about the server instance
+ self.set[server.name].type = type;
+ self.set[server.name].electionId = ismaster ? ismaster.electionId : ismaster;
+ self.set[server.name].setName = ismaster ? ismaster.setName : ismaster;
+ self.set[server.name].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] == server.name) {
+ 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;
+ }));
+
+ // Create the result
+ var result = {
+ topologyId: self.id,
+ previousDescription: self.replicasetDescription,
+ newDescription: description,
+ diff: diff(self.replicasetDescription, description)
+ };
+
+ // Emit the topologyDescription change
+ self.emit('topologyDescriptionChanged', result);
+
+ // Set the new description
+ self.replicasetDescription = description;
+ }
+}
+
+function diff(previous, current) {
+ // Difference document
+ var diff = {
+ servers: []
+ }
+
+ // Previous entry
+ if(!previous) {
+ previous = { servers: [] };
+ }
+
+ // 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 === currServer.address) {
+ // 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 = ReplSetState;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js
new file mode 100644
index 0000000..266b02f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js
@@ -0,0 +1,842 @@
+"use strict"
+
+var inherits = require('util').inherits,
+ f = require('util').format,
+ EventEmitter = require('events').EventEmitter,
+ BSON = require('bson').native().BSON,
+ ReadPreference = require('./read_preference'),
+ Logger = require('../connection/logger'),
+ debugOptions = require('../connection/utils').debugOptions,
+ 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('./shared').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', 'cert', 'key', 'rejectUnauthorized', 'promoteLongs', 'promoteValues'
+ , 'promoteBuffers', 'servername'];
+
+// Server instance id
+var id = 0;
+var serverAccounting = false;
+var servers = {};
+
+/**
+ * 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=0] Initial delay before TCP keep alive enabled
+ * @param {boolean} [options.noDelay=true] TCP Connection no delay
+ * @param {number} [options.connectionTimeout=0] TCP Connection timeout setting
+ * @param {number} [options.socketTimeout=0] 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.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
+ */
+var Server = function(options) {
+ options = options || {};
+
+ // Add event listener
+ EventEmitter.call(this);
+
+ // Server instance id
+ this.id = id++;
+
+ // Reconnect retries
+ var reconnectTries = options.reconnectTries || 30;
+
+ // 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(),
+ // 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; }
+});
+
+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.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, 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, 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: !self.s.inTopology ? 'Standalone' : sdam.getTopologyType(self)
+ });
+
+ // Emit topology description changed if something listening
+ sdam.emitTopologyDescriptionChanged(self, {
+ topologyType: 'Single', servers: [{address: self.name, arbiters: [], hosts: [], passives: [], type: 'Standalone'}]
+ });
+
+ // 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];
+ }
+
+ // 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', self.name)));
+ }
+
+ // Reconnect event, emit the server
+ if(event == 'reconnect') {
+ 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.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, options) {
+ 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.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);
+
+ // 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
+ };
+
+ // Create a query instance
+ var query = new Query(self.s.bson, ns, cmd, queryOptions);
+ // 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
+ };
+
+ // 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 == server;
+ if(server.name) return this.name == server.name;
+ 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);
+ }
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/shared.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/shared.js
new file mode 100644
index 0000000..8506255
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/shared.js
@@ -0,0 +1,225 @@
+"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(__dirname + '/../../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.hosts) return 'Standalone';
+ if(ismaster.ismaster && ismaster.msg == 'isdbgrid') return 'Mongos';
+ 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);
+ });
+ };
+}
+
+// Object.assign method or polyfille
+var assign = Object.assign ? Object.assign : function assign(target, firstSource) {
+ 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;
+}
+
+//
+// Clone the options
+var cloneOptions = function(options) {
+ var opts = {};
+ for(var name in options) {
+ opts[name] = options[name];
+ }
+ return opts;
+}
+
+module.exports.inquireServerState = inquireServerState
+module.exports.getTopologyType = getTopologyType;
+module.exports.emitServerDescriptionChanged = emitServerDescriptionChanged;
+module.exports.emitTopologyDescriptionChanged = emitTopologyDescriptionChanged;
+module.exports.cloneOptions = cloneOptions;
+module.exports.assign = assign;
+module.exports.createClientInfo = createClientInfo;
+module.exports.clone = clone;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js
new file mode 100644
index 0000000..abfeb97
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js
@@ -0,0 +1,569 @@
+"use strict";
+
+var Insert = require('./commands').Insert
+ , Update = require('./commands').Update
+ , Remove = require('./commands').Remove
+ , Query = require('../connection/commands').Query
+ , copy = require('../connection/utils').copy
+ , KillCursor = require('../connection/commands').KillCursor
+ , GetMore = require('../connection/commands').GetMore
+ , Query = require('../connection/commands').Query
+ , ReadPreference = require('../topologies/read_preference')
+ , f = require('util').format
+ , CommandResult = require('../connection/command_result')
+ , MongoError = require('../error')
+ , Long = require('bson').Long
+ , getReadPreference = require('./shared').getReadPreference;
+
+// Write concern fields
+var writeConcernFields = ['w', 'wtimeout', 'j', 'fsync'];
+
+var WireProtocol = function() {}
+
+//
+// Needs to support legacy mass insert as well as ordered/unordered legacy
+// emulation
+//
+WireProtocol.prototype.insert = function(pool, ismaster, ns, bson, ops, options, callback) {
+ options = options || {};
+ // Default is ordered execution
+ var ordered = typeof options.ordered == 'boolean' ? options.ordered : true;
+ var legacy = typeof options.legacy == 'boolean' ? options.legacy : false;
+ ops = Array.isArray(ops) ? ops :[ops];
+
+ // If we have more than a 1000 ops fails
+ if(ops.length > 1000) return callback(new MongoError("exceeded maximum write batch size of 1000"));
+
+ // Write concern
+ var writeConcern = options.writeConcern || {w:1};
+
+ // We are unordered
+ if(!ordered || writeConcern.w == 0) {
+ return executeUnordered('insert', Insert, ismaster, ns, bson, pool, ops, options, callback);
+ }
+
+ return executeOrdered('insert', Insert, ismaster, ns, bson, pool, ops, options, callback);
+}
+
+WireProtocol.prototype.update = function(pool, ismaster, ns, bson, ops, options, callback) {
+ options = options || {};
+ // Default is ordered execution
+ var ordered = typeof options.ordered == 'boolean' ? options.ordered : true;
+ ops = Array.isArray(ops) ? ops :[ops];
+
+ // Write concern
+ var writeConcern = options.writeConcern || {w:1};
+
+ // We are unordered
+ if(!ordered || writeConcern.w == 0) {
+ return executeUnordered('update', Update, ismaster, ns, bson, pool, ops, options, callback);
+ }
+
+ return executeOrdered('update', Update, ismaster, ns, bson, pool, ops, options, callback);
+}
+
+WireProtocol.prototype.remove = function(pool, ismaster, ns, bson, ops, options, callback) {
+ options = options || {};
+ // Default is ordered execution
+ var ordered = typeof options.ordered == 'boolean' ? options.ordered : true;
+ ops = Array.isArray(ops) ? ops :[ops];
+
+ // Write concern
+ var writeConcern = options.writeConcern || {w:1};
+
+ // We are unordered
+ if(!ordered || writeConcern.w == 0) {
+ return executeUnordered('remove', Remove, ismaster, ns, bson, pool, ops, options, callback);
+ }
+
+ return executeOrdered('remove', Remove, ismaster, ns, bson, pool, 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);
+ }
+
+ // If we have a raw query decorate the function
+ if(raw) {
+ queryCallback.raw = raw;
+ }
+
+ // Check if we need to promote longs
+ if(typeof cursorState.promoteLongs == 'boolean') {
+ queryCallback.promoteLongs = cursorState.promoteLongs;
+ }
+
+ if(typeof cursorState.promoteValues == 'boolean') {
+ queryCallback.promoteValues = cursorState.promoteValues;
+ }
+
+ if(typeof cursorState.promoteBuffers == 'boolean') {
+ queryCallback.promoteBuffers = cursorState.promoteBuffers;
+ }
+
+ // Write out the getMore command
+ connection.write(getMore, 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) {
+ } 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'];
+ }
+
+ // 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;
+
+ // 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(/\./);
+
+ // 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'];
+
+ // 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;
+}
+
+var hasWriteConcern = function(writeConcern) {
+ if(writeConcern.w
+ || writeConcern.wtimeout
+ || writeConcern.j == true
+ || writeConcern.fsync == true
+ || Object.keys(writeConcern).length == 0) {
+ return true;
+ }
+ return false;
+}
+
+var cloneWriteConcern = function(writeConcern) {
+ var wc = {};
+ if(writeConcern.w != null) wc.w = writeConcern.w;
+ if(writeConcern.wtimeout != null) wc.wtimeout = writeConcern.wtimeout;
+ if(writeConcern.j != null) wc.j = writeConcern.j;
+ if(writeConcern.fsync != null) wc.fsync = writeConcern.fsync;
+ return wc;
+}
+
+//
+// Aggregate up all the results
+//
+var aggregateWriteOperationResults = function(opType, ops, results, connection) {
+ var finalResult = { ok: 1, n: 0 }
+ if(opType == 'update') {
+ finalResult.nModified = 0;
+ n: 0;
+ };
+
+ // Map all the results coming back
+ for(var i = 0; i < results.length; i++) {
+ var result = results[i];
+ var op = ops[i];
+
+ if((result.upserted || (result.updatedExisting == false)) && finalResult.upserted == null) {
+ finalResult.upserted = [];
+ }
+
+ // Push the upserted document to the list of upserted values
+ if(result.upserted) {
+ finalResult.upserted.push({index: i, _id: result.upserted});
+ }
+
+ // We have an upsert where we passed in a _id
+ if(result.updatedExisting == false && result.n == 1 && result.upserted == null) {
+ finalResult.upserted.push({index: i, _id: op.q._id});
+ } else if(result.updatedExisting == true) {
+ finalResult.nModified += result.n;
+ }
+
+ // We have an insert command
+ if(result.ok == 1 && opType == 'insert' && result.err == null) {
+ finalResult.n = finalResult.n + 1;
+ }
+
+ // We have a command error
+ if(result != null && result.ok == 0 || result.err || result.errmsg) {
+ if(result.ok == 0) finalResult.ok = 0;
+ finalResult.code = result.code;
+ finalResult.errmsg = result.errmsg || result.err || result.errMsg;
+
+ // Check if we have a write error
+ if(result.code == 11000
+ || result.code == 11001
+ || result.code == 12582
+ || result.code == 16544
+ || result.code == 16538
+ || result.code == 16542
+ || result.code == 14
+ || result.code == 13511) {
+ if(finalResult.writeErrors == null) finalResult.writeErrors = [];
+ finalResult.writeErrors.push({
+ index: i
+ , code: result.code
+ , errmsg: result.errmsg || result.err || result.errMsg
+ });
+ } else {
+ finalResult.writeConcernError = {
+ code: result.code
+ , errmsg: result.errmsg || result.err || result.errMsg
+ }
+ }
+ } else if(typeof result.n == 'number') {
+ finalResult.n += result.n;
+ } else {
+ finalResult.n += 1;
+ }
+
+ // Result as expected
+ if(result != null && result.lastOp) finalResult.lastOp = result.lastOp;
+ }
+
+ // Return finalResult aggregated results
+ return new CommandResult(finalResult, connection);
+}
+
+//
+// Execute all inserts in an ordered manner
+//
+var executeOrdered = function(opType ,command, ismaster, ns, bson, pool, ops, options, callback) {
+ var _ops = ops.slice(0);
+ // Collect all the getLastErrors
+ var getLastErrors = [];
+ // Execute an operation
+ var executeOp = function(list, _callback) {
+ // No more items in the list
+ if(list.length == 0) {
+ return process.nextTick(function() {
+ _callback(null, aggregateWriteOperationResults(opType, ops, getLastErrors, null));
+ });
+ }
+
+ // Get the first operation
+ var doc = list.shift();
+ // Create an insert command
+ var op = new command(Query.getRequestId(), ismaster, bson, ns, [doc], options);
+ // Write concern
+ var optionWriteConcern = options.writeConcern || {w:1};
+ // Final write concern
+ var writeConcern = cloneWriteConcern(optionWriteConcern);
+
+ // Get the db name
+ var db = ns.split('.').shift();
+
+ try {
+ // Add binary message to list of commands to execute
+ var commands = [op];
+
+ // Add getLastOrdered
+ var getLastErrorCmd = {getlasterror: 1};
+ // Merge all the fields
+ for(var i = 0; i < writeConcernFields.length; i++) {
+ if(writeConcern[writeConcernFields[i]] != null) {
+ getLastErrorCmd[writeConcernFields[i]] = writeConcern[writeConcernFields[i]];
+ }
+ }
+
+ // Create a getLastError command
+ var getLastErrorOp = new Query(bson, f("%s.$cmd", db), getLastErrorCmd, {numberToReturn: -1});
+ // Add getLastError command to list of ops to execute
+ commands.push(getLastErrorOp);
+
+ // getLastError callback
+ var getLastErrorCallback = function(err, result) {
+ if(err) return callback(err);
+ // Get the document
+ var doc = result.result;
+ // Save the getLastError document
+ getLastErrors.push(doc);
+
+ // If we have an error terminate
+ if(doc.ok == 0 || doc.err || doc.errmsg) {
+ return callback(null, aggregateWriteOperationResults(opType, ops, getLastErrors, result.connection));
+ }
+
+ // Execute the next op in the list
+ executeOp(list, callback);
+ }
+
+ // Write both commands out at the same time
+ pool.write(commands, getLastErrorCallback);
+ } catch(err) {
+ if(typeof err == 'string') err = new MongoError(err);
+ // We have a serialization error, rewrite as a write error to have same behavior as modern
+ // write commands
+ getLastErrors.push({ ok: 1, errmsg: err.message, code: 14 });
+ // Return due to an error
+ process.nextTick(function() {
+ _callback(null, aggregateWriteOperationResults(opType, ops, getLastErrors, null));
+ });
+ }
+ }
+
+ // Execute the operations
+ executeOp(_ops, callback);
+}
+
+var executeUnordered = function(opType, command, ismaster, ns, bson, pool, ops, options, callback) {
+ // Total operations to write
+ var totalOps = ops.length;
+ // Collect all the getLastErrors
+ var getLastErrors = [];
+ // Write concern
+ var optionWriteConcern = options.writeConcern || {w:1};
+ // Final write concern
+ var writeConcern = cloneWriteConcern(optionWriteConcern);
+ // Driver level error
+ var error;
+
+ // Execute all the operations
+ for(var i = 0; i < ops.length; i++) {
+ // Create an insert command
+ var op = new command(Query.getRequestId(), ismaster, bson, ns, [ops[i]], options);
+ // Get db name
+ var db = ns.split('.').shift();
+
+ try {
+ // Add binary message to list of commands to execute
+ var commands = [op];
+
+ // If write concern 0 don't fire getLastError
+ if(hasWriteConcern(writeConcern)) {
+ var getLastErrorCmd = {getlasterror: 1};
+ // Merge all the fields
+ for(var j = 0; j < writeConcernFields.length; j++) {
+ if(writeConcern[writeConcernFields[j]] != null)
+ getLastErrorCmd[writeConcernFields[j]] = writeConcern[writeConcernFields[j]];
+ }
+
+ // Create a getLastError command
+ var getLastErrorOp = new Query(bson, f("%s.$cmd", db), getLastErrorCmd, {numberToReturn: -1});
+ // Add getLastError command to list of ops to execute
+ commands.push(getLastErrorOp);
+
+ // Give the result from getLastError the right index
+ var callbackOp = function(_index) {
+ return function(err, result) {
+ if(err) error = err;
+ // Update the number of operations executed
+ totalOps = totalOps - 1;
+ // Save the getLastError document
+ if(!err) getLastErrors[_index] = result.result;
+ // Check if we are done
+ if(totalOps == 0) {
+ process.nextTick(function() {
+ if(error) return callback(error);
+ callback(null, aggregateWriteOperationResults(opType, ops, getLastErrors, result.connection));
+ });
+ }
+ }
+ }
+
+ // Write both commands out at the same time
+ pool.write(commands, callbackOp(i));
+ } else {
+ pool.write(commands, {immediateRelease:true, noResponse:true});
+ }
+ } catch(err) {
+ if(typeof err == 'string') err = new MongoError(err);
+ // Update the number of operations executed
+ totalOps = totalOps - 1;
+ // We have a serialization error, rewrite as a write error to have same behavior as modern
+ // write commands
+ getLastErrors[i] = { ok: 1, errmsg: err.message, code: 14 };
+ // Check if we are done
+ if(totalOps == 0) {
+ callback(null, aggregateWriteOperationResults(opType, ops, getLastErrors, null));
+ }
+ }
+ }
+
+ // Empty w:0 return
+ if(writeConcern
+ && writeConcern.w == 0 && callback) {
+ callback(null, new CommandResult({ok:1}, null));
+ }
+}
+
+module.exports = WireProtocol;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js
new file mode 100644
index 0000000..8e83eb4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/2_6_support.js
@@ -0,0 +1,332 @@
+"use strict";
+
+var Insert = require('./commands').Insert
+ , Update = require('./commands').Update
+ , Remove = require('./commands').Remove
+ , Query = require('../connection/commands').Query
+ , copy = require('../connection/utils').copy
+ , KillCursor = require('../connection/commands').KillCursor
+ , GetMore = require('../connection/commands').GetMore
+ , Query = require('../connection/commands').Query
+ , ReadPreference = require('../topologies/read_preference')
+ , f = require('util').format
+ , CommandResult = require('../connection/command_result')
+ , MongoError = require('../error')
+ , Long = require('bson').Long
+ , getReadPreference = require('./shared').getReadPreference;
+
+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;
+ // 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);
+ }
+
+ // If we have a raw query decorate the function
+ if(raw) {
+ queryCallback.raw = raw;
+ }
+
+ // Check if we need to promote longs
+ if(typeof cursorState.promoteLongs == 'boolean') {
+ queryCallback.promoteLongs = cursorState.promoteLongs;
+ }
+
+ if(typeof cursorState.promoteValues == 'boolean') {
+ queryCallback.promoteValues = cursorState.promoteValues;
+ }
+
+ if(typeof cursorState.promoteBuffers == 'boolean') {
+ queryCallback.promoteBuffers = cursorState.promoteBuffers;
+ }
+
+ // Write out the getMore command
+ connection.write(getMore, 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) {
+ } 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js
new file mode 100644
index 0000000..b57048d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js
@@ -0,0 +1,541 @@
+"use strict";
+
+var Insert = require('./commands').Insert
+ , Update = require('./commands').Update
+ , Remove = require('./commands').Remove
+ , Query = require('../connection/commands').Query
+ , copy = require('../connection/utils').copy
+ , KillCursor = require('../connection/commands').KillCursor
+ , GetMore = require('../connection/commands').GetMore
+ , Query = require('../connection/commands').Query
+ , ReadPreference = require('../topologies/read_preference')
+ , f = require('util').format
+ , CommandResult = require('../connection/command_result')
+ , MongoError = require('../error')
+ , Long = require('bson').Long
+ , getReadPreference = require('./shared').getReadPreference;
+
+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;
+
+ // 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', cursorState.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());
+
+ // Check if we have an maxTimeMS set
+ var maxTimeMS = typeof cursorState.cmd.maxTimeMS == 'number' ? cursorState.cmd.maxTimeMS : 3000;
+
+ // 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') {
+ queryCallback.promoteValues = cursorState.promoteValues;
+ }
+
+ if(typeof cursorState.promoteBuffers == 'boolean') {
+ queryCallback.promoteBuffers = cursorState.promoteBuffers;
+ }
+
+ // Write out the getMore command
+ connection.write(query, queryOptions, queryCallback);
+}
+
+WireProtocol.prototype.command = function(bson, ns, cmd, cursorState, topology, options) {
+ // Establish type of command
+ if(cmd.find) {
+ // 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) {
+ } 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: <object>
+// , limit: <n>
+// , fields: <object>
+// , skip: <n>
+// , hint: <string>
+// , explain: <boolean>
+// , snapshot: <boolean>
+// , batchSize: <n>
+// , returnKey: <boolean>
+// , maxScan: <n>
+// , min: <n>
+// , max: <n>
+// , showDiskLoc: <boolean>
+// , comment: <string>
+// , maxTimeMS: <n>
+// , raw: <boolean>
+// , readPreference: <ReadPreference>
+// , tailable: <boolean>
+// , oplogReplay: <boolean>
+// , noCursorTimeout: <boolean>
+// , awaitdata: <boolean>
+// , exhaust: <boolean>
+// , partial: <boolean>
+// }
+
+// FIND/GETMORE SPEC
+// {
+// “find”: <string>,
+// “filter”: { ... },
+// “sort”: { ... },
+// “projection”: { ... },
+// “hint”: { ... },
+// “skip”: <int>,
+// “limit”: <int>,
+// “batchSize”: <int>,
+// “singleBatch”: <bool>,
+// “comment”: <string>,
+// “maxScan”: <int>,
+// “maxTimeMS”: <int>,
+// “max”: { ... },
+// “min”: { ... },
+// “returnKey”: <bool>,
+// “showRecordId”: <bool>,
+// “snapshot”: <bool>,
+// “tailable”: <bool>,
+// “oplogReplay”: <bool>,
+// “noCursorTimeout”: <bool>,
+// “awaitData”: <bool>,
+// “partial”: <bool>,
+// “$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++) {
+ var 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;
+ // Add a batchSize
+ if(typeof cmd.batchSize == 'number') findCmd.batchSize = Math.abs(cmd.batchSize);
+
+ // Check if we wish to have a singleBatch
+ if(cmd.limit < 0) {
+ findCmd.limit = Math.abs(cmd.limit);
+ findCmd.singleBatch = true;
+ }
+
+ // 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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/commands.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/commands.js
new file mode 100644
index 0000000..9c665ee
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/commands.js
@@ -0,0 +1,357 @@
+"use strict";
+
+var MongoError = require('../error');
+
+// Wire command operation ids
+var OP_UPDATE = 2001;
+var OP_INSERT = 2002;
+var OP_DELETE = 2006;
+
+var Insert = function(requestId, ismaster, bson, ns, documents, options) {
+ // Basic options needed to be passed in
+ if(ns == null) throw new MongoError("ns must be specified for query");
+ if(!Array.isArray(documents) || documents.length == 0) throw new MongoError("documents array must contain at least one document to insert");
+
+ // Validate that we are not passing 0x00 in the colletion name
+ if(!!~ns.indexOf("\x00")) {
+ throw new MongoError("namespace cannot contain a null character");
+ }
+
+ // Set internal
+ this.requestId = requestId;
+ this.bson = bson;
+ this.ns = ns;
+ this.documents = documents;
+ this.ismaster = ismaster;
+
+ // Ensure empty options
+ options = options || {};
+
+ // Unpack options
+ this.serializeFunctions = typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false;
+ this.ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : false;
+ this.checkKeys = typeof options.checkKeys == 'boolean' ? options.checkKeys : true;
+ this.continueOnError = typeof options.continueOnError == 'boolean' ? options.continueOnError : false;
+ // Set flags
+ this.flags = this.continueOnError ? 1 : 0;
+}
+
+// To Binary
+Insert.prototype.toBin = function() {
+ // Contains all the buffers to be written
+ var buffers = [];
+
+ // Header buffer
+ var header = new Buffer(
+ 4 * 4 // Header
+ + 4 // Flags
+ + Buffer.byteLength(this.ns) + 1 // namespace
+ );
+
+ // Add header to buffers
+ buffers.push(header);
+
+ // Total length of the message
+ var totalLength = header.length;
+
+ // Serialize all the documents
+ for(var i = 0; i < this.documents.length; i++) {
+ var buffer = this.bson.serialize(this.documents[i]
+ , this.checkKeys
+ , true
+ , this.serializeFunctions
+ , 0, this.ignoreUndefined);
+
+ // Document is larger than maxBsonObjectSize, terminate serialization
+ if(buffer.length > this.ismaster.maxBsonObjectSize) {
+ throw new MongoError("Document exceeds maximum allowed bson size of " + this.ismaster.maxBsonObjectSize + " bytes");
+ }
+
+ // Add to total length of wire protocol message
+ totalLength = totalLength + buffer.length;
+ // Add to buffer
+ buffers.push(buffer);
+ }
+
+ // Command is larger than maxMessageSizeBytes terminate serialization
+ if(totalLength > this.ismaster.maxMessageSizeBytes) {
+ throw new MongoError("Command exceeds maximum message size of " + this.ismaster.maxMessageSizeBytes + " bytes");
+ }
+
+ // Add all the metadata
+ var index = 0;
+
+ // Write header length
+ header[index + 3] = (totalLength >> 24) & 0xff;
+ header[index + 2] = (totalLength >> 16) & 0xff;
+ header[index + 1] = (totalLength >> 8) & 0xff;
+ header[index] = (totalLength) & 0xff;
+ index = index + 4;
+
+ // Write header 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;
+
+ // No flags
+ 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;
+
+ // Operation
+ header[index + 3] = (OP_INSERT >> 24) & 0xff;
+ header[index + 2] = (OP_INSERT >> 16) & 0xff;
+ header[index + 1] = (OP_INSERT >> 8) & 0xff;
+ header[index] = (OP_INSERT) & 0xff;
+ index = index + 4;
+
+ // Flags
+ header[index + 3] = (this.flags >> 24) & 0xff;
+ header[index + 2] = (this.flags >> 16) & 0xff;
+ header[index + 1] = (this.flags >> 8) & 0xff;
+ header[index] = (this.flags) & 0xff;
+ index = index + 4;
+
+ // Write collection name
+ index = index + header.write(this.ns, index, 'utf8') + 1;
+ header[index - 1] = 0;
+
+ // Return the buffers
+ return buffers;
+}
+
+var Update = function(requestId, ismaster, bson, ns, update, options) {
+ // Basic options needed to be passed in
+ if(ns == null) throw new MongoError("ns must be specified for query");
+
+ // Ensure empty options
+ options = options || {};
+
+ // Set internal
+ this.requestId = requestId;
+ this.bson = bson;
+ this.ns = ns;
+ this.ismaster = ismaster;
+
+ // Unpack options
+ this.serializeFunctions = typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false;
+ this.ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : false;
+ this.checkKeys = typeof options.checkKeys == 'boolean' ? options.checkKeys : false;
+
+ // Unpack the update document
+ this.upsert = typeof update[0].upsert == 'boolean' ? update[0].upsert : false;
+ this.multi = typeof update[0].multi == 'boolean' ? update[0].multi : false;
+ this.q = update[0].q;
+ this.u = update[0].u;
+
+ // Create flag value
+ this.flags = this.upsert ? 1 : 0;
+ this.flags = this.multi ? this.flags | 2 : this.flags;
+}
+
+// To Binary
+Update.prototype.toBin = function() {
+ // Contains all the buffers to be written
+ var buffers = [];
+
+ // Header buffer
+ var header = new Buffer(
+ 4 * 4 // Header
+ + 4 // ZERO
+ + Buffer.byteLength(this.ns) + 1 // namespace
+ + 4 // Flags
+ );
+
+ // Add header to buffers
+ buffers.push(header);
+
+ // Total length of the message
+ var totalLength = header.length;
+
+ // Serialize the selector
+ var selector = this.bson.serialize(this.q
+ , this.checkKeys
+ , true
+ , this.serializeFunctions
+ , 0, this.ignoreUndefined);
+ buffers.push(selector);
+ totalLength = totalLength + selector.length;
+
+ // Serialize the update
+ var update = this.bson.serialize(this.u
+ , this.checkKeys
+ , true
+ , this.serializeFunctions
+ , 0, this.ignoreUndefined);
+ buffers.push(update);
+ totalLength = totalLength + update.length;
+
+ // Index in header buffer
+ var index = 0;
+
+ // Write header length
+ header[index + 3] = (totalLength >> 24) & 0xff;
+ header[index + 2] = (totalLength >> 16) & 0xff;
+ header[index + 1] = (totalLength >> 8) & 0xff;
+ header[index] = (totalLength) & 0xff;
+ index = index + 4;
+
+ // Write header 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;
+
+ // No flags
+ 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;
+
+ // Operation
+ header[index + 3] = (OP_UPDATE >> 24) & 0xff;
+ header[index + 2] = (OP_UPDATE >> 16) & 0xff;
+ header[index + 1] = (OP_UPDATE >> 8) & 0xff;
+ header[index] = (OP_UPDATE) & 0xff;
+ index = index + 4;
+
+ // Write ZERO
+ 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 collection name
+ index = index + header.write(this.ns, index, 'utf8') + 1;
+ header[index - 1] = 0;
+
+ // Flags
+ header[index + 3] = (this.flags >> 24) & 0xff;
+ header[index + 2] = (this.flags >> 16) & 0xff;
+ header[index + 1] = (this.flags >> 8) & 0xff;
+ header[index] = (this.flags) & 0xff;
+ index = index + 4;
+
+ // Return the buffers
+ return buffers;
+}
+
+var Remove = function(requestId, ismaster, bson, ns, remove, options) {
+ // Basic options needed to be passed in
+ if(ns == null) throw new MongoError("ns must be specified for query");
+
+ // Ensure empty options
+ options = options || {};
+
+ // Set internal
+ this.requestId = requestId;
+ this.bson = bson;
+ this.ns = ns;
+ this.ismaster = ismaster;
+
+ // Unpack options
+ this.serializeFunctions = typeof options.serializeFunctions == 'boolean' ? options.serializeFunctions : false;
+ this.ignoreUndefined = typeof options.ignoreUndefined == 'boolean' ? options.ignoreUndefined : false;
+ this.checkKeys = typeof options.checkKeys == 'boolean' ? options.checkKeys : false;
+
+ // Unpack the update document
+ this.limit = typeof remove[0].limit == 'number' ? remove[0].limit : 1;
+ this.q = remove[0].q;
+
+ // Create flag value
+ this.flags = this.limit == 1 ? 1 : 0;
+}
+
+// To Binary
+Remove.prototype.toBin = function() {
+ // Contains all the buffers to be written
+ var buffers = [];
+
+ // Header buffer
+ var header = new Buffer(
+ 4 * 4 // Header
+ + 4 // ZERO
+ + Buffer.byteLength(this.ns) + 1 // namespace
+ + 4 // Flags
+ );
+
+ // Add header to buffers
+ buffers.push(header);
+
+ // Total length of the message
+ var totalLength = header.length;
+
+ // Serialize the selector
+ var selector = this.bson.serialize(this.q
+ , this.checkKeys
+ , true
+ , this.serializeFunctions
+ , 0, this.ignoreUndefined);
+ buffers.push(selector);
+ totalLength = totalLength + selector.length;
+
+ // Index in header buffer
+ var index = 0;
+
+ // Write header length
+ header[index + 3] = (totalLength >> 24) & 0xff;
+ header[index + 2] = (totalLength >> 16) & 0xff;
+ header[index + 1] = (totalLength >> 8) & 0xff;
+ header[index] = (totalLength) & 0xff;
+ index = index + 4;
+
+ // Write header 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;
+
+ // No flags
+ 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;
+
+ // Operation
+ header[index + 3] = (OP_DELETE >> 24) & 0xff;
+ header[index + 2] = (OP_DELETE >> 16) & 0xff;
+ header[index + 1] = (OP_DELETE >> 8) & 0xff;
+ header[index] = (OP_DELETE) & 0xff;
+ index = index + 4;
+
+ // Write ZERO
+ 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 collection name
+ index = index + header.write(this.ns, index, 'utf8') + 1;
+ header[index - 1] = 0;
+
+ // Write ZERO
+ header[index + 3] = (this.flags >> 24) & 0xff;
+ header[index + 2] = (this.flags >> 16) & 0xff;
+ header[index + 1] = (this.flags >> 8) & 0xff;
+ header[index] = (this.flags) & 0xff;
+ index = index + 4;
+
+ // Return the buffers
+ return buffers;
+}
+
+module.exports = {
+ Insert: Insert
+ , Update: Update
+ , Remove: Remove
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/shared.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/shared.js
new file mode 100644
index 0000000..3a20f51
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/shared.js
@@ -0,0 +1,26 @@
+"use strict"
+
+var ReadPreference = require('../topologies/read_preference');
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.npmignore
new file mode 100644
index 0000000..e920c16
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.npmignore
@@ -0,0 +1,33 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+node_modules
+
+# Optional npm cache directory
+.npm
+
+# Optional REPL history
+.node_repl_history
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.travis.yml
new file mode 100644
index 0000000..38de5c6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.12"
+ - "4.2.1"
+sudo: false
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/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.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/README.md
new file mode 100644
index 0000000..c0323f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/README.md
@@ -0,0 +1,2 @@
+# require_optional
+Work around the problem that we do not have a optionalPeerDependencies concept in node.js making it a hassle to optionally include native modules
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/index.js
new file mode 100644
index 0000000..9754581
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/index.js
@@ -0,0 +1,109 @@
+var path = require('path'),
+ fs = require('fs'),
+ f = require('util').format,
+ resolveFrom = require('resolve-from'),
+ semver = require('semver');
+
+var exists = fs.existsSync || path.existsSync;
+
+var find_package_json = function(location) {
+ var found = false;
+
+ while(!found) {
+ if (exists(location + '/package.json')) {
+ found = location;
+ } else if (location !== '/') {
+ location = path.dirname(location);
+ } else {
+ return false;
+ }
+ }
+
+ return location;
+}
+
+var require_optional = function(name, options) {
+ options = options || {};
+ options.strict = typeof options.strict == 'boolean' ? options.strict : true;
+
+ // Current location
+ var location = __dirname;
+ // Check if we have a parent
+ if(module.parent) {
+ location = module.parent.filename;
+ }
+
+ // Locate this module's package.json file
+ var location = find_package_json(location);
+ if(!location) {
+ throw new Error('package.json can not be located');
+ }
+
+ // Read the package.json file
+ var object = JSON.parse(fs.readFileSync(f('%s/package.json', location)));
+ // Is the name defined by interal file references
+ var parts = name.split(/\//);
+
+ // Optional dependencies exist
+ if(!object.peerOptionalDependencies) {
+ throw new Error(f('no optional dependency [%s] defined in peerOptionalDependencies in package.json', parts[0]));
+ } else if(object.peerOptionalDependencies && !object.peerOptionalDependencies[parts[0]]) {
+ throw new Error(f('no optional dependency [%s] defined in peerOptionalDependencies in package.json', parts[0]));
+ }
+
+ // Unpack the expected version
+ var expectedVersions = object.peerOptionalDependencies[parts[0]];
+ // The resolved package
+ var moduleEntry = undefined;
+ // Module file
+ var moduleEntryFile = name;
+
+ try {
+ // Validate if it's possible to read the module
+ moduleEntry = require(moduleEntryFile);
+ } catch(err) {
+ // Attempt to resolve in top level package
+ try {
+ // Get the module entry file
+ moduleEntryFile = resolveFrom(process.cwd(), name);
+ if(moduleEntryFile == null) return undefined;
+ // Attempt to resolve the module
+ moduleEntry = require(moduleEntryFile);
+ } catch(err) {
+ if(err.code === 'MODULE_NOT_FOUND') return undefined;
+ }
+ }
+
+ // Resolve the location of the module's package.json file
+ var location = find_package_json(require.resolve(moduleEntryFile));
+ if(!location) {
+ throw new Error('package.json can not be located');
+ }
+
+ // Read the module file
+ var dependentOnModule = JSON.parse(fs.readFileSync(f('%s/package.json', location)));
+ // Get the version
+ var version = dependentOnModule.version;
+ // Validate if the found module satisfies the version id
+ if(semver.satisfies(version, expectedVersions) == false
+ && options.strict) {
+ var error = new Error(f('optional dependency [%s] found but version [%s] did not satisfy constraint [%s]', parts[0], version, expectedVersions));
+ error.code = 'OPTIONAL_MODULE_NOT_FOUND';
+ throw error;
+ }
+
+ // Satifies the module requirement
+ return moduleEntry;
+}
+
+require_optional.exists = function(name) {
+ try {
+ var m = require_optional(name);
+ if(m === undefined) return false;
+ return true;
+ } catch(err) {
+ return false;
+ }
+}
+
+module.exports = require_optional;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver
new file mode 100644
index 0000000..d592e69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver
@@ -0,0 +1,15 @@
+#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
+
+case `uname` in
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+esac
+
+if [ -x "$basedir/node" ]; then
+ "$basedir/node" "$basedir/../semver/bin/semver" "$@"
+ ret=$?
+else
+ node "$basedir/../semver/bin/semver" "$@"
+ ret=$?
+fi
+exit $ret
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver.cmd b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver.cmd
new file mode 100644
index 0000000..eabc737
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/.bin/semver.cmd
@@ -0,0 +1,7 @@
+@IF EXIST "%~dp0\node.exe" (
+ "%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
+) ELSE (
+ @SETLOCAL
+ @SET PATHEXT=%PATHEXT:;.JS;=;%
+ node "%~dp0\..\semver\bin\semver" %*
+) \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/index.js
new file mode 100644
index 0000000..434159f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/index.js
@@ -0,0 +1,23 @@
+'use strict';
+var path = require('path');
+var Module = require('module');
+
+module.exports = function (fromDir, moduleId) {
+ if (typeof fromDir !== 'string' || typeof moduleId !== 'string') {
+ throw new TypeError('Expected `fromDir` and `moduleId` to be a string');
+ }
+
+ fromDir = path.resolve(fromDir);
+
+ var fromFile = path.join(fromDir, 'noop.js');
+
+ try {
+ return Module._resolveFilename(moduleId, {
+ id: fromFile,
+ filename: fromFile,
+ paths: Module._nodeModulePaths(fromDir)
+ });
+ } catch (err) {
+ return null;
+ }
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/license b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/package.json
new file mode 100644
index 0000000..c7a957b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "resolve-from",
+ "version": "2.0.0",
+ "description": "Resolve the path of a module like require.resolve() but from a given path",
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/sindresorhus/resolve-from"
+ },
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "require",
+ "resolve",
+ "path",
+ "module",
+ "from",
+ "like",
+ "path"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ },
+ "gitHead": "583e0f8df06e1bc4d1c96d8d4f2484c745f522c3",
+ "bugs": {
+ "url": "https://github.com/sindresorhus/resolve-from/issues"
+ },
+ "homepage": "https://github.com/sindresorhus/resolve-from",
+ "_id": "resolve-from@2.0.0",
+ "_shasum": "9480ab20e94ffa1d9e80a804c7ea147611966b57",
+ "_from": "resolve-from@>=2.0.0 <3.0.0",
+ "_npmVersion": "2.14.7",
+ "_nodeVersion": "4.2.1",
+ "_npmUser": {
+ "name": "sindresorhus",
+ "email": "sindresorhus@gmail.com"
+ },
+ "dist": {
+ "shasum": "9480ab20e94ffa1d9e80a804c7ea147611966b57",
+ "tarball": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "sindresorhus",
+ "email": "sindresorhus@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/readme.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/readme.md
new file mode 100644
index 0000000..bb4ca91
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/resolve-from/readme.md
@@ -0,0 +1,58 @@
+# resolve-from [![Build Status](https://travis-ci.org/sindresorhus/resolve-from.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-from)
+
+> Resolve the path of a module like [`require.resolve()`](http://nodejs.org/api/globals.html#globals_require_resolve) but from a given path
+
+Unlike `require.resolve()` it returns `null` instead of throwing when the module can't be found.
+
+
+## Install
+
+```
+$ npm install --save resolve-from
+```
+
+
+## Usage
+
+```js
+const resolveFrom = require('resolve-from');
+
+// there's a file at `./foo/bar.js`
+
+resolveFrom('foo', './bar');
+//=> '/Users/sindresorhus/dev/test/foo/bar.js'
+```
+
+
+## API
+
+### resolveFrom(fromDir, moduleId)
+
+#### fromDir
+
+Type: `string`
+
+Directory to resolve from.
+
+#### moduleId
+
+Type: `string`
+
+What you would use in `require()`.
+
+
+## Tip
+
+Create a partial using a bound function if you want to require from the same `fromDir` multiple times:
+
+```js
+const resolveFromFoo = resolveFrom.bind(null, 'foo');
+
+resolveFromFoo('./bar');
+resolveFromFoo('./baz');
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/LICENSE
new file mode 100644
index 0000000..19129e3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/README.md
new file mode 100644
index 0000000..cbd9565
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/README.md
@@ -0,0 +1,350 @@
+semver(1) -- The semantic versioner for npm
+===========================================
+
+## Usage
+
+ $ npm install semver
+ $ node
+ var semver = require('semver')
+
+ semver.valid('1.2.3') // '1.2.3'
+ semver.valid('a.b.c') // null
+ semver.clean(' =v1.2.3 ') // '1.2.3'
+ semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
+ semver.gt('1.2.3', '9.8.7') // false
+ semver.lt('1.2.3', '9.8.7') // true
+
+As a command-line utility:
+
+ $ semver -h
+
+ SemVer 5.1.0
+
+ A JavaScript implementation of the http://semver.org/ specification
+ Copyright Isaac Z. Schlueter
+
+ Usage: semver [options] <version> [<version> [...]]
+ Prints valid versions sorted by SemVer precedence
+
+ Options:
+ -r --range <range>
+ Print versions that match the specified range.
+
+ -i --increment [<level>]
+ Increment a version by the specified level. Level can
+ be one of: major, minor, patch, premajor, preminor,
+ prepatch, or prerelease. Default level is 'patch'.
+ Only one version may be specified.
+
+ --preid <identifier>
+ Identifier to be used to prefix premajor, preminor,
+ prepatch or prerelease version increments.
+
+ -l --loose
+ Interpret versions and ranges loosely
+
+ Program exits successfully if any valid version satisfies
+ all supplied ranges, and prints all satisfying versions.
+
+ If no satisfying versions are found, then exits failure.
+
+ Versions are printed in ascending order, so supplying
+ multiple versions to the utility will just sort them.
+
+## Versions
+
+A "version" is described by the `v2.0.0` specification found at
+<http://semver.org/>.
+
+A leading `"="` or `"v"` character is stripped off and ignored.
+
+## Ranges
+
+A `version range` is a set of `comparators` which specify versions
+that satisfy the range.
+
+A `comparator` is composed of an `operator` and a `version`. The set
+of primitive `operators` is:
+
+* `<` Less than
+* `<=` Less than or equal to
+* `>` Greater than
+* `>=` Greater than or equal to
+* `=` Equal. If no operator is specified, then equality is assumed,
+ so this operator is optional, but MAY be included.
+
+For example, the comparator `>=1.2.7` would match the versions
+`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
+or `1.1.0`.
+
+Comparators can be joined by whitespace to form a `comparator set`,
+which is satisfied by the **intersection** of all of the comparators
+it includes.
+
+A range is composed of one or more comparator sets, joined by `||`. A
+version matches a range if and only if every comparator in at least
+one of the `||`-separated comparator sets is satisfied by the version.
+
+For example, the range `>=1.2.7 <1.3.0` would match the versions
+`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
+or `1.1.0`.
+
+The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
+`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
+
+### Prerelease Tags
+
+If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
+it will only be allowed to satisfy comparator sets if at least one
+comparator with the same `[major, minor, patch]` tuple also has a
+prerelease tag.
+
+For example, the range `>1.2.3-alpha.3` would be allowed to match the
+version `1.2.3-alpha.7`, but it would *not* be satisfied by
+`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
+than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
+range only accepts prerelease tags on the `1.2.3` version. The
+version `3.4.5` *would* satisfy the range, because it does not have a
+prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
+
+The purpose for this behavior is twofold. First, prerelease versions
+frequently are updated very quickly, and contain many breaking changes
+that are (by the author's design) not yet fit for public consumption.
+Therefore, by default, they are excluded from range matching
+semantics.
+
+Second, a user who has opted into using a prerelease version has
+clearly indicated the intent to use *that specific* set of
+alpha/beta/rc versions. By including a prerelease tag in the range,
+the user is indicating that they are aware of the risk. However, it
+is still not appropriate to assume that they have opted into taking a
+similar risk on the *next* set of prerelease versions.
+
+#### Prerelease Identifiers
+
+The method `.inc` takes an additional `identifier` string argument that
+will append the value of the string as a prerelease identifier:
+
+```javascript
+> semver.inc('1.2.3', 'prerelease', 'beta')
+'1.2.4-beta.0'
+```
+
+command-line example:
+
+```shell
+$ semver 1.2.3 -i prerelease --preid beta
+1.2.4-beta.0
+```
+
+Which then can be used to increment further:
+
+```shell
+$ semver 1.2.4-beta.0 -i prerelease
+1.2.4-beta.1
+```
+
+### Advanced Range Syntax
+
+Advanced range syntax desugars to primitive comparators in
+deterministic ways.
+
+Advanced ranges may be combined in the same way as primitive
+comparators using white space or `||`.
+
+#### Hyphen Ranges `X.Y.Z - A.B.C`
+
+Specifies an inclusive set.
+
+* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
+
+If a partial version is provided as the first version in the inclusive
+range, then the missing pieces are replaced with zeroes.
+
+* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
+
+If a partial version is provided as the second version in the
+inclusive range, then all versions that start with the supplied parts
+of the tuple are accepted, but nothing that would be greater than the
+provided tuple parts.
+
+* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
+* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
+
+#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
+
+Any of `X`, `x`, or `*` may be used to "stand in" for one of the
+numeric values in the `[major, minor, patch]` tuple.
+
+* `*` := `>=0.0.0` (Any version satisfies)
+* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
+* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
+
+A partial version range is treated as an X-Range, so the special
+character is in fact optional.
+
+* `""` (empty string) := `*` := `>=0.0.0`
+* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
+* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
+
+#### Tilde Ranges `~1.2.3` `~1.2` `~1`
+
+Allows patch-level changes if a minor version is specified on the
+comparator. Allows minor-level changes if not.
+
+* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
+* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
+* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
+* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
+* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
+* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
+* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
+ the `1.2.3` version will be allowed, if they are greater than or
+ equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
+ `1.2.4-beta.2` would not, because it is a prerelease of a
+ different `[major, minor, patch]` tuple.
+
+#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
+
+Allows changes that do not modify the left-most non-zero digit in the
+`[major, minor, patch]` tuple. In other words, this allows patch and
+minor updates for versions `1.0.0` and above, patch updates for
+versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
+
+Many authors treat a `0.x` version as if the `x` were the major
+"breaking-change" indicator.
+
+Caret ranges are ideal when an author may make breaking changes
+between `0.2.4` and `0.3.0` releases, which is a common practice.
+However, it presumes that there will *not* be breaking changes between
+`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
+additive (but non-breaking), according to commonly observed practices.
+
+* `^1.2.3` := `>=1.2.3 <2.0.0`
+* `^0.2.3` := `>=0.2.3 <0.3.0`
+* `^0.0.3` := `>=0.0.3 <0.0.4`
+* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
+ the `1.2.3` version will be allowed, if they are greater than or
+ equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
+ `1.2.4-beta.2` would not, because it is a prerelease of a
+ different `[major, minor, patch]` tuple.
+* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
+ `0.0.3` version *only* will be allowed, if they are greater than or
+ equal to `beta`. So, `0.0.3-pr.2` would be allowed.
+
+When parsing caret ranges, a missing `patch` value desugars to the
+number `0`, but will allow flexibility within that value, even if the
+major and minor versions are both `0`.
+
+* `^1.2.x` := `>=1.2.0 <2.0.0`
+* `^0.0.x` := `>=0.0.0 <0.1.0`
+* `^0.0` := `>=0.0.0 <0.1.0`
+
+A missing `minor` and `patch` values will desugar to zero, but also
+allow flexibility within those values, even if the major version is
+zero.
+
+* `^1.x` := `>=1.0.0 <2.0.0`
+* `^0.x` := `>=0.0.0 <1.0.0`
+
+### Range Grammar
+
+Putting all this together, here is a Backus-Naur grammar for ranges,
+for the benefit of parser authors:
+
+```bnf
+range-set ::= range ( logical-or range ) *
+logical-or ::= ( ' ' ) * '||' ( ' ' ) *
+range ::= hyphen | simple ( ' ' simple ) * | ''
+hyphen ::= partial ' - ' partial
+simple ::= primitive | partial | tilde | caret
+primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
+partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
+xr ::= 'x' | 'X' | '*' | nr
+nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
+tilde ::= '~' partial
+caret ::= '^' partial
+qualifier ::= ( '-' pre )? ( '+' build )?
+pre ::= parts
+build ::= parts
+parts ::= part ( '.' part ) *
+part ::= nr | [-0-9A-Za-z]+
+```
+
+## Functions
+
+All methods and classes take a final `loose` boolean argument that, if
+true, will be more forgiving about not-quite-valid semver strings.
+The resulting output will always be 100% strict, of course.
+
+Strict-mode Comparators and Ranges will be strict about the SemVer
+strings that they parse.
+
+* `valid(v)`: Return the parsed version, or null if it's not valid.
+* `inc(v, release)`: Return the version incremented by the release
+ type (`major`, `premajor`, `minor`, `preminor`, `patch`,
+ `prepatch`, or `prerelease`), or null if it's not valid
+ * `premajor` in one call will bump the version up to the next major
+ version and down to a prerelease of that major version.
+ `preminor`, and `prepatch` work the same way.
+ * If called from a non-prerelease version, the `prerelease` will work the
+ same as `prepatch`. It increments the patch version, then makes a
+ prerelease. If the input version is already a prerelease it simply
+ increments it.
+* `prerelease(v)`: Returns an array of prerelease components, or null
+ if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
+* `major(v)`: Return the major version number.
+* `minor(v)`: Return the minor version number.
+* `patch(v)`: Return the patch version number.
+
+### Comparison
+
+* `gt(v1, v2)`: `v1 > v2`
+* `gte(v1, v2)`: `v1 >= v2`
+* `lt(v1, v2)`: `v1 < v2`
+* `lte(v1, v2)`: `v1 <= v2`
+* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
+ even if they're not the exact same string. You already know how to
+ compare strings.
+* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
+* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
+ the corresponding function above. `"==="` and `"!=="` do simple
+ string comparison, but are included for completeness. Throws if an
+ invalid comparison string is provided.
+* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
+ `v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
+* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
+ in descending order when passed to `Array.sort()`.
+* `diff(v1, v2)`: Returns difference between two versions by the release type
+ (`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
+ or null if the versions are the same.
+
+
+### Ranges
+
+* `validRange(range)`: Return the valid range or null if it's not valid
+* `satisfies(version, range)`: Return true if the version satisfies the
+ range.
+* `maxSatisfying(versions, range)`: Return the highest version in the list
+ that satisfies the range, or `null` if none of them do.
+* `minSatisfying(versions, range)`: Return the lowest version in the list
+ that satisfies the range, or `null` if none of them do.
+* `gtr(version, range)`: Return `true` if version is greater than all the
+ versions possible in the range.
+* `ltr(version, range)`: Return `true` if version is less than all the
+ versions possible in the range.
+* `outside(version, range, hilo)`: Return true if the version is outside
+ the bounds of the range in either the high or low direction. The
+ `hilo` argument must be either the string `'>'` or `'<'`. (This is
+ the function called by `gtr` and `ltr`.)
+
+Note that, since ranges may be non-contiguous, a version might not be
+greater than a range, less than a range, *or* satisfy a range! For
+example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
+until `2.0.0`, so the version `1.2.10` would not be greater than the
+range (because `2.0.1` satisfies, which is higher), nor less than the
+range (since `1.2.8` satisfies, which is lower), and it also does not
+satisfy the range.
+
+If you want to know if a version satisfies or does not satisfy a
+range, use the `satisfies(version, range)` function.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/bin/semver b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/bin/semver
new file mode 100644
index 0000000..c5f2e85
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/bin/semver
@@ -0,0 +1,133 @@
+#!/usr/bin/env node
+// Standalone semver comparison program.
+// Exits successfully and prints matching version(s) if
+// any supplied version is valid and passes all tests.
+
+var argv = process.argv.slice(2)
+ , versions = []
+ , range = []
+ , gt = []
+ , lt = []
+ , eq = []
+ , inc = null
+ , version = require("../package.json").version
+ , loose = false
+ , identifier = undefined
+ , semver = require("../semver")
+ , reverse = false
+
+main()
+
+function main () {
+ if (!argv.length) return help()
+ while (argv.length) {
+ var a = argv.shift()
+ var i = a.indexOf('=')
+ if (i !== -1) {
+ a = a.slice(0, i)
+ argv.unshift(a.slice(i + 1))
+ }
+ switch (a) {
+ case "-rv": case "-rev": case "--rev": case "--reverse":
+ reverse = true
+ break
+ case "-l": case "--loose":
+ loose = true
+ break
+ case "-v": case "--version":
+ versions.push(argv.shift())
+ break
+ case "-i": case "--inc": case "--increment":
+ switch (argv[0]) {
+ case "major": case "minor": case "patch": case "prerelease":
+ case "premajor": case "preminor": case "prepatch":
+ inc = argv.shift()
+ break
+ default:
+ inc = "patch"
+ break
+ }
+ break
+ case "--preid":
+ identifier = argv.shift()
+ break
+ case "-r": case "--range":
+ range.push(argv.shift())
+ break
+ case "-h": case "--help": case "-?":
+ return help()
+ default:
+ versions.push(a)
+ break
+ }
+ }
+
+ versions = versions.filter(function (v) {
+ return semver.valid(v, loose)
+ })
+ if (!versions.length) return fail()
+ if (inc && (versions.length !== 1 || range.length))
+ return failInc()
+
+ for (var i = 0, l = range.length; i < l ; i ++) {
+ versions = versions.filter(function (v) {
+ return semver.satisfies(v, range[i], loose)
+ })
+ if (!versions.length) return fail()
+ }
+ return success(versions)
+}
+
+function failInc () {
+ console.error("--inc can only be used on a single version with no range")
+ fail()
+}
+
+function fail () { process.exit(1) }
+
+function success () {
+ var compare = reverse ? "rcompare" : "compare"
+ versions.sort(function (a, b) {
+ return semver[compare](a, b, loose)
+ }).map(function (v) {
+ return semver.clean(v, loose)
+ }).map(function (v) {
+ return inc ? semver.inc(v, inc, loose, identifier) : v
+ }).forEach(function (v,i,_) { console.log(v) })
+}
+
+function help () {
+ console.log(["SemVer " + version
+ ,""
+ ,"A JavaScript implementation of the http://semver.org/ specification"
+ ,"Copyright Isaac Z. Schlueter"
+ ,""
+ ,"Usage: semver [options] <version> [<version> [...]]"
+ ,"Prints valid versions sorted by SemVer precedence"
+ ,""
+ ,"Options:"
+ ,"-r --range <range>"
+ ," Print versions that match the specified range."
+ ,""
+ ,"-i --increment [<level>]"
+ ," Increment a version by the specified level. Level can"
+ ," be one of: major, minor, patch, premajor, preminor,"
+ ," prepatch, or prerelease. Default level is 'patch'."
+ ," Only one version may be specified."
+ ,""
+ ,"--preid <identifier>"
+ ," Identifier to be used to prefix premajor, preminor,"
+ ," prepatch or prerelease version increments."
+ ,""
+ ,"-l --loose"
+ ," Interpret versions and ranges loosely"
+ ,""
+ ,"Program exits successfully if any valid version satisfies"
+ ,"all supplied ranges, and prints all satisfying versions."
+ ,""
+ ,"If no satisfying versions are found, then exits failure."
+ ,""
+ ,"Versions are printed in ascending order, so supplying"
+ ,"multiple versions to the utility will just sort them."
+ ].join("\n"))
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/package.json
new file mode 100644
index 0000000..0924041
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/package.json
@@ -0,0 +1,59 @@
+{
+ "name": "semver",
+ "version": "5.3.0",
+ "description": "The semantic version parser used by npm.",
+ "main": "semver.js",
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "devDependencies": {
+ "tap": "^2.0.0"
+ },
+ "license": "ISC",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/npm/node-semver.git"
+ },
+ "bin": {
+ "semver": "./bin/semver"
+ },
+ "files": [
+ "bin",
+ "range.bnf",
+ "semver.js"
+ ],
+ "gitHead": "d21444a0658224b152ce54965d02dbe0856afb84",
+ "bugs": {
+ "url": "https://github.com/npm/node-semver/issues"
+ },
+ "homepage": "https://github.com/npm/node-semver#readme",
+ "_id": "semver@5.3.0",
+ "_shasum": "9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f",
+ "_from": "semver@>=5.1.0 <6.0.0",
+ "_npmVersion": "3.10.6",
+ "_nodeVersion": "4.4.4",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "dist": {
+ "shasum": "9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f",
+ "tarball": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "isaacs@npmjs.com"
+ },
+ {
+ "name": "othiym23",
+ "email": "ogd@aoaioxxysz.net"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/semver-5.3.0.tgz_1468515166602_0.9155273644719273"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/range.bnf b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/range.bnf
new file mode 100644
index 0000000..25ebd5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/range.bnf
@@ -0,0 +1,16 @@
+range-set ::= range ( logical-or range ) *
+logical-or ::= ( ' ' ) * '||' ( ' ' ) *
+range ::= hyphen | simple ( ' ' simple ) * | ''
+hyphen ::= partial ' - ' partial
+simple ::= primitive | partial | tilde | caret
+primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
+partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
+xr ::= 'x' | 'X' | '*' | nr
+nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
+tilde ::= '~' partial
+caret ::= '^' partial
+qualifier ::= ( '-' pre )? ( '+' build )?
+pre ::= parts
+build ::= parts
+parts ::= part ( '.' part ) *
+part ::= nr | [-0-9A-Za-z]+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/semver.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/semver.js
new file mode 100644
index 0000000..5f1a3c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/node_modules/semver/semver.js
@@ -0,0 +1,1203 @@
+exports = module.exports = SemVer;
+
+// The debug function is excluded entirely from the minified version.
+/* nomin */ var debug;
+/* nomin */ if (typeof process === 'object' &&
+ /* nomin */ process.env &&
+ /* nomin */ process.env.NODE_DEBUG &&
+ /* nomin */ /\bsemver\b/i.test(process.env.NODE_DEBUG))
+ /* nomin */ debug = function() {
+ /* nomin */ var args = Array.prototype.slice.call(arguments, 0);
+ /* nomin */ args.unshift('SEMVER');
+ /* nomin */ console.log.apply(console, args);
+ /* nomin */ };
+/* nomin */ else
+ /* nomin */ debug = function() {};
+
+// Note: this is the semver.org version of the spec that it implements
+// Not necessarily the package version of this code.
+exports.SEMVER_SPEC_VERSION = '2.0.0';
+
+var MAX_LENGTH = 256;
+var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
+
+// The actual regexps go on exports.re
+var re = exports.re = [];
+var src = exports.src = [];
+var R = 0;
+
+// The following Regular Expressions can be used for tokenizing,
+// validating, and parsing SemVer version strings.
+
+// ## Numeric Identifier
+// A single `0`, or a non-zero digit followed by zero or more digits.
+
+var NUMERICIDENTIFIER = R++;
+src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
+var NUMERICIDENTIFIERLOOSE = R++;
+src[NUMERICIDENTIFIERLOOSE] = '[0-9]+';
+
+
+// ## Non-numeric Identifier
+// Zero or more digits, followed by a letter or hyphen, and then zero or
+// more letters, digits, or hyphens.
+
+var NONNUMERICIDENTIFIER = R++;
+src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
+
+
+// ## Main Version
+// Three dot-separated numeric identifiers.
+
+var MAINVERSION = R++;
+src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
+ '(' + src[NUMERICIDENTIFIER] + ')\\.' +
+ '(' + src[NUMERICIDENTIFIER] + ')';
+
+var MAINVERSIONLOOSE = R++;
+src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
+ '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
+ '(' + src[NUMERICIDENTIFIERLOOSE] + ')';
+
+// ## Pre-release Version Identifier
+// A numeric identifier, or a non-numeric identifier.
+
+var PRERELEASEIDENTIFIER = R++;
+src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
+ '|' + src[NONNUMERICIDENTIFIER] + ')';
+
+var PRERELEASEIDENTIFIERLOOSE = R++;
+src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
+ '|' + src[NONNUMERICIDENTIFIER] + ')';
+
+
+// ## Pre-release Version
+// Hyphen, followed by one or more dot-separated pre-release version
+// identifiers.
+
+var PRERELEASE = R++;
+src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
+ '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
+
+var PRERELEASELOOSE = R++;
+src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
+ '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))';
+
+// ## Build Metadata Identifier
+// Any combination of digits, letters, or hyphens.
+
+var BUILDIDENTIFIER = R++;
+src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
+
+// ## Build Metadata
+// Plus sign, followed by one or more period-separated build metadata
+// identifiers.
+
+var BUILD = R++;
+src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
+ '(?:\\.' + src[BUILDIDENTIFIER] + ')*))';
+
+
+// ## Full Version String
+// A main version, followed optionally by a pre-release version and
+// build metadata.
+
+// Note that the only major, minor, patch, and pre-release sections of
+// the version string are capturing groups. The build metadata is not a
+// capturing group, because it should not ever be used in version
+// comparison.
+
+var FULL = R++;
+var FULLPLAIN = 'v?' + src[MAINVERSION] +
+ src[PRERELEASE] + '?' +
+ src[BUILD] + '?';
+
+src[FULL] = '^' + FULLPLAIN + '$';
+
+// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
+// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
+// common in the npm registry.
+var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
+ src[PRERELEASELOOSE] + '?' +
+ src[BUILD] + '?';
+
+var LOOSE = R++;
+src[LOOSE] = '^' + LOOSEPLAIN + '$';
+
+var GTLT = R++;
+src[GTLT] = '((?:<|>)?=?)';
+
+// Something like "2.*" or "1.2.x".
+// Note that "x.x" is a valid xRange identifer, meaning "any version"
+// Only the first item is strictly required.
+var XRANGEIDENTIFIERLOOSE = R++;
+src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
+var XRANGEIDENTIFIER = R++;
+src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
+
+var XRANGEPLAIN = R++;
+src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
+ '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
+ '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
+ '(?:' + src[PRERELEASE] + ')?' +
+ src[BUILD] + '?' +
+ ')?)?';
+
+var XRANGEPLAINLOOSE = R++;
+src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
+ '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
+ '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
+ '(?:' + src[PRERELEASELOOSE] + ')?' +
+ src[BUILD] + '?' +
+ ')?)?';
+
+var XRANGE = R++;
+src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
+var XRANGELOOSE = R++;
+src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$';
+
+// Tilde ranges.
+// Meaning is "reasonably at or greater than"
+var LONETILDE = R++;
+src[LONETILDE] = '(?:~>?)';
+
+var TILDETRIM = R++;
+src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
+re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
+var tildeTrimReplace = '$1~';
+
+var TILDE = R++;
+src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
+var TILDELOOSE = R++;
+src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$';
+
+// Caret ranges.
+// Meaning is "at least and backwards compatible with"
+var LONECARET = R++;
+src[LONECARET] = '(?:\\^)';
+
+var CARETTRIM = R++;
+src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
+re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
+var caretTrimReplace = '$1^';
+
+var CARET = R++;
+src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
+var CARETLOOSE = R++;
+src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$';
+
+// A simple gt/lt/eq thing, or just "" to indicate "any version"
+var COMPARATORLOOSE = R++;
+src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
+var COMPARATOR = R++;
+src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$';
+
+
+// An expression to strip any whitespace between the gtlt and the thing
+// it modifies, so that `> 1.2.3` ==> `>1.2.3`
+var COMPARATORTRIM = R++;
+src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
+ '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')';
+
+// this one has to use the /g flag
+re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
+var comparatorTrimReplace = '$1$2$3';
+
+
+// Something like `1.2.3 - 1.2.4`
+// Note that these all use the loose form, because they'll be
+// checked against either the strict or loose comparator form
+// later.
+var HYPHENRANGE = R++;
+src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
+ '\\s+-\\s+' +
+ '(' + src[XRANGEPLAIN] + ')' +
+ '\\s*$';
+
+var HYPHENRANGELOOSE = R++;
+src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
+ '\\s+-\\s+' +
+ '(' + src[XRANGEPLAINLOOSE] + ')' +
+ '\\s*$';
+
+// Star ranges basically just allow anything at all.
+var STAR = R++;
+src[STAR] = '(<|>)?=?\\s*\\*';
+
+// Compile to actual regexp objects.
+// All are flag-free, unless they were created above with a flag.
+for (var i = 0; i < R; i++) {
+ debug(i, src[i]);
+ if (!re[i])
+ re[i] = new RegExp(src[i]);
+}
+
+exports.parse = parse;
+function parse(version, loose) {
+ if (version instanceof SemVer)
+ return version;
+
+ if (typeof version !== 'string')
+ return null;
+
+ if (version.length > MAX_LENGTH)
+ return null;
+
+ var r = loose ? re[LOOSE] : re[FULL];
+ if (!r.test(version))
+ return null;
+
+ try {
+ return new SemVer(version, loose);
+ } catch (er) {
+ return null;
+ }
+}
+
+exports.valid = valid;
+function valid(version, loose) {
+ var v = parse(version, loose);
+ return v ? v.version : null;
+}
+
+
+exports.clean = clean;
+function clean(version, loose) {
+ var s = parse(version.trim().replace(/^[=v]+/, ''), loose);
+ return s ? s.version : null;
+}
+
+exports.SemVer = SemVer;
+
+function SemVer(version, loose) {
+ if (version instanceof SemVer) {
+ if (version.loose === loose)
+ return version;
+ else
+ version = version.version;
+ } else if (typeof version !== 'string') {
+ throw new TypeError('Invalid Version: ' + version);
+ }
+
+ if (version.length > MAX_LENGTH)
+ throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
+
+ if (!(this instanceof SemVer))
+ return new SemVer(version, loose);
+
+ debug('SemVer', version, loose);
+ this.loose = loose;
+ var m = version.trim().match(loose ? re[LOOSE] : re[FULL]);
+
+ if (!m)
+ throw new TypeError('Invalid Version: ' + version);
+
+ this.raw = version;
+
+ // these are actually numbers
+ this.major = +m[1];
+ this.minor = +m[2];
+ this.patch = +m[3];
+
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0)
+ throw new TypeError('Invalid major version')
+
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0)
+ throw new TypeError('Invalid minor version')
+
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0)
+ throw new TypeError('Invalid patch version')
+
+ // numberify any prerelease numeric ids
+ if (!m[4])
+ this.prerelease = [];
+ else
+ this.prerelease = m[4].split('.').map(function(id) {
+ if (/^[0-9]+$/.test(id)) {
+ var num = +id;
+ if (num >= 0 && num < MAX_SAFE_INTEGER)
+ return num;
+ }
+ return id;
+ });
+
+ this.build = m[5] ? m[5].split('.') : [];
+ this.format();
+}
+
+SemVer.prototype.format = function() {
+ this.version = this.major + '.' + this.minor + '.' + this.patch;
+ if (this.prerelease.length)
+ this.version += '-' + this.prerelease.join('.');
+ return this.version;
+};
+
+SemVer.prototype.toString = function() {
+ return this.version;
+};
+
+SemVer.prototype.compare = function(other) {
+ debug('SemVer.compare', this.version, this.loose, other);
+ if (!(other instanceof SemVer))
+ other = new SemVer(other, this.loose);
+
+ return this.compareMain(other) || this.comparePre(other);
+};
+
+SemVer.prototype.compareMain = function(other) {
+ if (!(other instanceof SemVer))
+ other = new SemVer(other, this.loose);
+
+ return compareIdentifiers(this.major, other.major) ||
+ compareIdentifiers(this.minor, other.minor) ||
+ compareIdentifiers(this.patch, other.patch);
+};
+
+SemVer.prototype.comparePre = function(other) {
+ if (!(other instanceof SemVer))
+ other = new SemVer(other, this.loose);
+
+ // NOT having a prerelease is > having one
+ if (this.prerelease.length && !other.prerelease.length)
+ return -1;
+ else if (!this.prerelease.length && other.prerelease.length)
+ return 1;
+ else if (!this.prerelease.length && !other.prerelease.length)
+ return 0;
+
+ var i = 0;
+ do {
+ var a = this.prerelease[i];
+ var b = other.prerelease[i];
+ debug('prerelease compare', i, a, b);
+ if (a === undefined && b === undefined)
+ return 0;
+ else if (b === undefined)
+ return 1;
+ else if (a === undefined)
+ return -1;
+ else if (a === b)
+ continue;
+ else
+ return compareIdentifiers(a, b);
+ } while (++i);
+};
+
+// preminor will bump the version up to the next minor release, and immediately
+// down to pre-release. premajor and prepatch work the same way.
+SemVer.prototype.inc = function(release, identifier) {
+ switch (release) {
+ case 'premajor':
+ this.prerelease.length = 0;
+ this.patch = 0;
+ this.minor = 0;
+ this.major++;
+ this.inc('pre', identifier);
+ break;
+ case 'preminor':
+ this.prerelease.length = 0;
+ this.patch = 0;
+ this.minor++;
+ this.inc('pre', identifier);
+ break;
+ case 'prepatch':
+ // If this is already a prerelease, it will bump to the next version
+ // drop any prereleases that might already exist, since they are not
+ // relevant at this point.
+ this.prerelease.length = 0;
+ this.inc('patch', identifier);
+ this.inc('pre', identifier);
+ break;
+ // If the input is a non-prerelease version, this acts the same as
+ // prepatch.
+ case 'prerelease':
+ if (this.prerelease.length === 0)
+ this.inc('patch', identifier);
+ this.inc('pre', identifier);
+ break;
+
+ case 'major':
+ // If this is a pre-major version, bump up to the same major version.
+ // Otherwise increment major.
+ // 1.0.0-5 bumps to 1.0.0
+ // 1.1.0 bumps to 2.0.0
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0)
+ this.major++;
+ this.minor = 0;
+ this.patch = 0;
+ this.prerelease = [];
+ break;
+ case 'minor':
+ // If this is a pre-minor version, bump up to the same minor version.
+ // Otherwise increment minor.
+ // 1.2.0-5 bumps to 1.2.0
+ // 1.2.1 bumps to 1.3.0
+ if (this.patch !== 0 || this.prerelease.length === 0)
+ this.minor++;
+ this.patch = 0;
+ this.prerelease = [];
+ break;
+ case 'patch':
+ // If this is not a pre-release version, it will increment the patch.
+ // If it is a pre-release it will bump up to the same patch version.
+ // 1.2.0-5 patches to 1.2.0
+ // 1.2.0 patches to 1.2.1
+ if (this.prerelease.length === 0)
+ this.patch++;
+ this.prerelease = [];
+ break;
+ // This probably shouldn't be used publicly.
+ // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
+ case 'pre':
+ if (this.prerelease.length === 0)
+ this.prerelease = [0];
+ else {
+ var i = this.prerelease.length;
+ while (--i >= 0) {
+ if (typeof this.prerelease[i] === 'number') {
+ this.prerelease[i]++;
+ i = -2;
+ }
+ }
+ if (i === -1) // didn't increment anything
+ this.prerelease.push(0);
+ }
+ if (identifier) {
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
+ if (this.prerelease[0] === identifier) {
+ if (isNaN(this.prerelease[1]))
+ this.prerelease = [identifier, 0];
+ } else
+ this.prerelease = [identifier, 0];
+ }
+ break;
+
+ default:
+ throw new Error('invalid increment argument: ' + release);
+ }
+ this.format();
+ this.raw = this.version;
+ return this;
+};
+
+exports.inc = inc;
+function inc(version, release, loose, identifier) {
+ if (typeof(loose) === 'string') {
+ identifier = loose;
+ loose = undefined;
+ }
+
+ try {
+ return new SemVer(version, loose).inc(release, identifier).version;
+ } catch (er) {
+ return null;
+ }
+}
+
+exports.diff = diff;
+function diff(version1, version2) {
+ if (eq(version1, version2)) {
+ return null;
+ } else {
+ var v1 = parse(version1);
+ var v2 = parse(version2);
+ if (v1.prerelease.length || v2.prerelease.length) {
+ for (var key in v1) {
+ if (key === 'major' || key === 'minor' || key === 'patch') {
+ if (v1[key] !== v2[key]) {
+ return 'pre'+key;
+ }
+ }
+ }
+ return 'prerelease';
+ }
+ for (var key in v1) {
+ if (key === 'major' || key === 'minor' || key === 'patch') {
+ if (v1[key] !== v2[key]) {
+ return key;
+ }
+ }
+ }
+ }
+}
+
+exports.compareIdentifiers = compareIdentifiers;
+
+var numeric = /^[0-9]+$/;
+function compareIdentifiers(a, b) {
+ var anum = numeric.test(a);
+ var bnum = numeric.test(b);
+
+ if (anum && bnum) {
+ a = +a;
+ b = +b;
+ }
+
+ return (anum && !bnum) ? -1 :
+ (bnum && !anum) ? 1 :
+ a < b ? -1 :
+ a > b ? 1 :
+ 0;
+}
+
+exports.rcompareIdentifiers = rcompareIdentifiers;
+function rcompareIdentifiers(a, b) {
+ return compareIdentifiers(b, a);
+}
+
+exports.major = major;
+function major(a, loose) {
+ return new SemVer(a, loose).major;
+}
+
+exports.minor = minor;
+function minor(a, loose) {
+ return new SemVer(a, loose).minor;
+}
+
+exports.patch = patch;
+function patch(a, loose) {
+ return new SemVer(a, loose).patch;
+}
+
+exports.compare = compare;
+function compare(a, b, loose) {
+ return new SemVer(a, loose).compare(b);
+}
+
+exports.compareLoose = compareLoose;
+function compareLoose(a, b) {
+ return compare(a, b, true);
+}
+
+exports.rcompare = rcompare;
+function rcompare(a, b, loose) {
+ return compare(b, a, loose);
+}
+
+exports.sort = sort;
+function sort(list, loose) {
+ return list.sort(function(a, b) {
+ return exports.compare(a, b, loose);
+ });
+}
+
+exports.rsort = rsort;
+function rsort(list, loose) {
+ return list.sort(function(a, b) {
+ return exports.rcompare(a, b, loose);
+ });
+}
+
+exports.gt = gt;
+function gt(a, b, loose) {
+ return compare(a, b, loose) > 0;
+}
+
+exports.lt = lt;
+function lt(a, b, loose) {
+ return compare(a, b, loose) < 0;
+}
+
+exports.eq = eq;
+function eq(a, b, loose) {
+ return compare(a, b, loose) === 0;
+}
+
+exports.neq = neq;
+function neq(a, b, loose) {
+ return compare(a, b, loose) !== 0;
+}
+
+exports.gte = gte;
+function gte(a, b, loose) {
+ return compare(a, b, loose) >= 0;
+}
+
+exports.lte = lte;
+function lte(a, b, loose) {
+ return compare(a, b, loose) <= 0;
+}
+
+exports.cmp = cmp;
+function cmp(a, op, b, loose) {
+ var ret;
+ switch (op) {
+ case '===':
+ if (typeof a === 'object') a = a.version;
+ if (typeof b === 'object') b = b.version;
+ ret = a === b;
+ break;
+ case '!==':
+ if (typeof a === 'object') a = a.version;
+ if (typeof b === 'object') b = b.version;
+ ret = a !== b;
+ break;
+ case '': case '=': case '==': ret = eq(a, b, loose); break;
+ case '!=': ret = neq(a, b, loose); break;
+ case '>': ret = gt(a, b, loose); break;
+ case '>=': ret = gte(a, b, loose); break;
+ case '<': ret = lt(a, b, loose); break;
+ case '<=': ret = lte(a, b, loose); break;
+ default: throw new TypeError('Invalid operator: ' + op);
+ }
+ return ret;
+}
+
+exports.Comparator = Comparator;
+function Comparator(comp, loose) {
+ if (comp instanceof Comparator) {
+ if (comp.loose === loose)
+ return comp;
+ else
+ comp = comp.value;
+ }
+
+ if (!(this instanceof Comparator))
+ return new Comparator(comp, loose);
+
+ debug('comparator', comp, loose);
+ this.loose = loose;
+ this.parse(comp);
+
+ if (this.semver === ANY)
+ this.value = '';
+ else
+ this.value = this.operator + this.semver.version;
+
+ debug('comp', this);
+}
+
+var ANY = {};
+Comparator.prototype.parse = function(comp) {
+ var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
+ var m = comp.match(r);
+
+ if (!m)
+ throw new TypeError('Invalid comparator: ' + comp);
+
+ this.operator = m[1];
+ if (this.operator === '=')
+ this.operator = '';
+
+ // if it literally is just '>' or '' then allow anything.
+ if (!m[2])
+ this.semver = ANY;
+ else
+ this.semver = new SemVer(m[2], this.loose);
+};
+
+Comparator.prototype.toString = function() {
+ return this.value;
+};
+
+Comparator.prototype.test = function(version) {
+ debug('Comparator.test', version, this.loose);
+
+ if (this.semver === ANY)
+ return true;
+
+ if (typeof version === 'string')
+ version = new SemVer(version, this.loose);
+
+ return cmp(version, this.operator, this.semver, this.loose);
+};
+
+
+exports.Range = Range;
+function Range(range, loose) {
+ if ((range instanceof Range) && range.loose === loose)
+ return range;
+
+ if (!(this instanceof Range))
+ return new Range(range, loose);
+
+ this.loose = loose;
+
+ // First, split based on boolean or ||
+ this.raw = range;
+ this.set = range.split(/\s*\|\|\s*/).map(function(range) {
+ return this.parseRange(range.trim());
+ }, this).filter(function(c) {
+ // throw out any that are not relevant for whatever reason
+ return c.length;
+ });
+
+ if (!this.set.length) {
+ throw new TypeError('Invalid SemVer Range: ' + range);
+ }
+
+ this.format();
+}
+
+Range.prototype.format = function() {
+ this.range = this.set.map(function(comps) {
+ return comps.join(' ').trim();
+ }).join('||').trim();
+ return this.range;
+};
+
+Range.prototype.toString = function() {
+ return this.range;
+};
+
+Range.prototype.parseRange = function(range) {
+ var loose = this.loose;
+ range = range.trim();
+ debug('range', range, loose);
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
+ var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
+ range = range.replace(hr, hyphenReplace);
+ debug('hyphen replace', range);
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
+ range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
+ debug('comparator trim', range, re[COMPARATORTRIM]);
+
+ // `~ 1.2.3` => `~1.2.3`
+ range = range.replace(re[TILDETRIM], tildeTrimReplace);
+
+ // `^ 1.2.3` => `^1.2.3`
+ range = range.replace(re[CARETTRIM], caretTrimReplace);
+
+ // normalize spaces
+ range = range.split(/\s+/).join(' ');
+
+ // At this point, the range is completely trimmed and
+ // ready to be split into comparators.
+
+ var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
+ var set = range.split(' ').map(function(comp) {
+ return parseComparator(comp, loose);
+ }).join(' ').split(/\s+/);
+ if (this.loose) {
+ // in loose mode, throw out any that are not valid comparators
+ set = set.filter(function(comp) {
+ return !!comp.match(compRe);
+ });
+ }
+ set = set.map(function(comp) {
+ return new Comparator(comp, loose);
+ });
+
+ return set;
+};
+
+// Mostly just for testing and legacy API reasons
+exports.toComparators = toComparators;
+function toComparators(range, loose) {
+ return new Range(range, loose).set.map(function(comp) {
+ return comp.map(function(c) {
+ return c.value;
+ }).join(' ').trim().split(' ');
+ });
+}
+
+// comprised of xranges, tildes, stars, and gtlt's at this point.
+// already replaced the hyphen ranges
+// turn into a set of JUST comparators.
+function parseComparator(comp, loose) {
+ debug('comp', comp);
+ comp = replaceCarets(comp, loose);
+ debug('caret', comp);
+ comp = replaceTildes(comp, loose);
+ debug('tildes', comp);
+ comp = replaceXRanges(comp, loose);
+ debug('xrange', comp);
+ comp = replaceStars(comp, loose);
+ debug('stars', comp);
+ return comp;
+}
+
+function isX(id) {
+ return !id || id.toLowerCase() === 'x' || id === '*';
+}
+
+// ~, ~> --> * (any, kinda silly)
+// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
+// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
+// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
+// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
+// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
+function replaceTildes(comp, loose) {
+ return comp.trim().split(/\s+/).map(function(comp) {
+ return replaceTilde(comp, loose);
+ }).join(' ');
+}
+
+function replaceTilde(comp, loose) {
+ var r = loose ? re[TILDELOOSE] : re[TILDE];
+ return comp.replace(r, function(_, M, m, p, pr) {
+ debug('tilde', comp, _, M, m, p, pr);
+ var ret;
+
+ if (isX(M))
+ ret = '';
+ else if (isX(m))
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
+ else if (isX(p))
+ // ~1.2 == >=1.2.0 <1.3.0
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
+ else if (pr) {
+ debug('replaceTilde pr', pr);
+ if (pr.charAt(0) !== '-')
+ pr = '-' + pr;
+ ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + M + '.' + (+m + 1) + '.0';
+ } else
+ // ~1.2.3 == >=1.2.3 <1.3.0
+ ret = '>=' + M + '.' + m + '.' + p +
+ ' <' + M + '.' + (+m + 1) + '.0';
+
+ debug('tilde return', ret);
+ return ret;
+ });
+}
+
+// ^ --> * (any, kinda silly)
+// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
+// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
+// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
+// ^1.2.3 --> >=1.2.3 <2.0.0
+// ^1.2.0 --> >=1.2.0 <2.0.0
+function replaceCarets(comp, loose) {
+ return comp.trim().split(/\s+/).map(function(comp) {
+ return replaceCaret(comp, loose);
+ }).join(' ');
+}
+
+function replaceCaret(comp, loose) {
+ debug('caret', comp, loose);
+ var r = loose ? re[CARETLOOSE] : re[CARET];
+ return comp.replace(r, function(_, M, m, p, pr) {
+ debug('caret', comp, _, M, m, p, pr);
+ var ret;
+
+ if (isX(M))
+ ret = '';
+ else if (isX(m))
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
+ else if (isX(p)) {
+ if (M === '0')
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
+ else
+ ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
+ } else if (pr) {
+ debug('replaceCaret pr', pr);
+ if (pr.charAt(0) !== '-')
+ pr = '-' + pr;
+ if (M === '0') {
+ if (m === '0')
+ ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + M + '.' + m + '.' + (+p + 1);
+ else
+ ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + M + '.' + (+m + 1) + '.0';
+ } else
+ ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + (+M + 1) + '.0.0';
+ } else {
+ debug('no pr');
+ if (M === '0') {
+ if (m === '0')
+ ret = '>=' + M + '.' + m + '.' + p +
+ ' <' + M + '.' + m + '.' + (+p + 1);
+ else
+ ret = '>=' + M + '.' + m + '.' + p +
+ ' <' + M + '.' + (+m + 1) + '.0';
+ } else
+ ret = '>=' + M + '.' + m + '.' + p +
+ ' <' + (+M + 1) + '.0.0';
+ }
+
+ debug('caret return', ret);
+ return ret;
+ });
+}
+
+function replaceXRanges(comp, loose) {
+ debug('replaceXRanges', comp, loose);
+ return comp.split(/\s+/).map(function(comp) {
+ return replaceXRange(comp, loose);
+ }).join(' ');
+}
+
+function replaceXRange(comp, loose) {
+ comp = comp.trim();
+ var r = loose ? re[XRANGELOOSE] : re[XRANGE];
+ return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
+ var xM = isX(M);
+ var xm = xM || isX(m);
+ var xp = xm || isX(p);
+ var anyX = xp;
+
+ if (gtlt === '=' && anyX)
+ gtlt = '';
+
+ if (xM) {
+ if (gtlt === '>' || gtlt === '<') {
+ // nothing is allowed
+ ret = '<0.0.0';
+ } else {
+ // nothing is forbidden
+ ret = '*';
+ }
+ } else if (gtlt && anyX) {
+ // replace X with 0
+ if (xm)
+ m = 0;
+ if (xp)
+ p = 0;
+
+ if (gtlt === '>') {
+ // >1 => >=2.0.0
+ // >1.2 => >=1.3.0
+ // >1.2.3 => >= 1.2.4
+ gtlt = '>=';
+ if (xm) {
+ M = +M + 1;
+ m = 0;
+ p = 0;
+ } else if (xp) {
+ m = +m + 1;
+ p = 0;
+ }
+ } else if (gtlt === '<=') {
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
+ gtlt = '<';
+ if (xm)
+ M = +M + 1;
+ else
+ m = +m + 1;
+ }
+
+ ret = gtlt + M + '.' + m + '.' + p;
+ } else if (xm) {
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
+ } else if (xp) {
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
+ }
+
+ debug('xRange return', ret);
+
+ return ret;
+ });
+}
+
+// Because * is AND-ed with everything else in the comparator,
+// and '' means "any version", just remove the *s entirely.
+function replaceStars(comp, loose) {
+ debug('replaceStars', comp, loose);
+ // Looseness is ignored here. star is always as loose as it gets!
+ return comp.trim().replace(re[STAR], '');
+}
+
+// This function is passed to string.replace(re[HYPHENRANGE])
+// M, m, patch, prerelease, build
+// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
+// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
+// 1.2 - 3.4 => >=1.2.0 <3.5.0
+function hyphenReplace($0,
+ from, fM, fm, fp, fpr, fb,
+ to, tM, tm, tp, tpr, tb) {
+
+ if (isX(fM))
+ from = '';
+ else if (isX(fm))
+ from = '>=' + fM + '.0.0';
+ else if (isX(fp))
+ from = '>=' + fM + '.' + fm + '.0';
+ else
+ from = '>=' + from;
+
+ if (isX(tM))
+ to = '';
+ else if (isX(tm))
+ to = '<' + (+tM + 1) + '.0.0';
+ else if (isX(tp))
+ to = '<' + tM + '.' + (+tm + 1) + '.0';
+ else if (tpr)
+ to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
+ else
+ to = '<=' + to;
+
+ return (from + ' ' + to).trim();
+}
+
+
+// if ANY of the sets match ALL of its comparators, then pass
+Range.prototype.test = function(version) {
+ if (!version)
+ return false;
+
+ if (typeof version === 'string')
+ version = new SemVer(version, this.loose);
+
+ for (var i = 0; i < this.set.length; i++) {
+ if (testSet(this.set[i], version))
+ return true;
+ }
+ return false;
+};
+
+function testSet(set, version) {
+ for (var i = 0; i < set.length; i++) {
+ if (!set[i].test(version))
+ return false;
+ }
+
+ if (version.prerelease.length) {
+ // Find the set of versions that are allowed to have prereleases
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
+ // That should allow `1.2.3-pr.2` to pass.
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
+ // even though it's within the range set by the comparators.
+ for (var i = 0; i < set.length; i++) {
+ debug(set[i].semver);
+ if (set[i].semver === ANY)
+ continue;
+
+ if (set[i].semver.prerelease.length > 0) {
+ var allowed = set[i].semver;
+ if (allowed.major === version.major &&
+ allowed.minor === version.minor &&
+ allowed.patch === version.patch)
+ return true;
+ }
+ }
+
+ // Version has a -pre, but it's not one of the ones we like.
+ return false;
+ }
+
+ return true;
+}
+
+exports.satisfies = satisfies;
+function satisfies(version, range, loose) {
+ try {
+ range = new Range(range, loose);
+ } catch (er) {
+ return false;
+ }
+ return range.test(version);
+}
+
+exports.maxSatisfying = maxSatisfying;
+function maxSatisfying(versions, range, loose) {
+ return versions.filter(function(version) {
+ return satisfies(version, range, loose);
+ }).sort(function(a, b) {
+ return rcompare(a, b, loose);
+ })[0] || null;
+}
+
+exports.minSatisfying = minSatisfying;
+function minSatisfying(versions, range, loose) {
+ return versions.filter(function(version) {
+ return satisfies(version, range, loose);
+ }).sort(function(a, b) {
+ return compare(a, b, loose);
+ })[0] || null;
+}
+
+exports.validRange = validRange;
+function validRange(range, loose) {
+ try {
+ // Return '*' instead of '' so that truthiness works.
+ // This will throw if it's invalid anyway
+ return new Range(range, loose).range || '*';
+ } catch (er) {
+ return null;
+ }
+}
+
+// Determine if version is less than all the versions possible in the range
+exports.ltr = ltr;
+function ltr(version, range, loose) {
+ return outside(version, range, '<', loose);
+}
+
+// Determine if version is greater than all the versions possible in the range.
+exports.gtr = gtr;
+function gtr(version, range, loose) {
+ return outside(version, range, '>', loose);
+}
+
+exports.outside = outside;
+function outside(version, range, hilo, loose) {
+ version = new SemVer(version, loose);
+ range = new Range(range, loose);
+
+ var gtfn, ltefn, ltfn, comp, ecomp;
+ switch (hilo) {
+ case '>':
+ gtfn = gt;
+ ltefn = lte;
+ ltfn = lt;
+ comp = '>';
+ ecomp = '>=';
+ break;
+ case '<':
+ gtfn = lt;
+ ltefn = gte;
+ ltfn = gt;
+ comp = '<';
+ ecomp = '<=';
+ break;
+ default:
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
+ }
+
+ // If it satisifes the range it is not outside
+ if (satisfies(version, range, loose)) {
+ return false;
+ }
+
+ // From now on, variable terms are as if we're in "gtr" mode.
+ // but note that everything is flipped for the "ltr" function.
+
+ for (var i = 0; i < range.set.length; ++i) {
+ var comparators = range.set[i];
+
+ var high = null;
+ var low = null;
+
+ comparators.forEach(function(comparator) {
+ if (comparator.semver === ANY) {
+ comparator = new Comparator('>=0.0.0')
+ }
+ high = high || comparator;
+ low = low || comparator;
+ if (gtfn(comparator.semver, high.semver, loose)) {
+ high = comparator;
+ } else if (ltfn(comparator.semver, low.semver, loose)) {
+ low = comparator;
+ }
+ });
+
+ // If the edge version comparator has a operator then our version
+ // isn't outside it
+ if (high.operator === comp || high.operator === ecomp) {
+ return false;
+ }
+
+ // If the lowest version comparator has an operator and our version
+ // is less than it then it isn't higher than the range
+ if ((!low.operator || low.operator === comp) &&
+ ltefn(version, low.semver)) {
+ return false;
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+exports.prerelease = prerelease;
+function prerelease(version, loose) {
+ var parsed = parse(version, loose);
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/package.json
new file mode 100644
index 0000000..9eed5fe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "require_optional",
+ "version": "1.0.0",
+ "description": "Allows you declare optionalPeerDependencies that can be satisfied by the top level module but ignored if they are not.",
+ "main": "index.js",
+ "scripts": {
+ "test": "mocha"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/christkv/require_optional.git"
+ },
+ "keywords": [
+ "optional",
+ "require",
+ "optionalPeerDependencies"
+ ],
+ "author": {
+ "name": "Christian Kvalheim Amor"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/christkv/require_optional/issues"
+ },
+ "homepage": "https://github.com/christkv/require_optional",
+ "dependencies": {
+ "semver": "^5.1.0",
+ "resolve-from": "^2.0.0"
+ },
+ "devDependencies": {
+ "bson": "0.4.21",
+ "co": "4.6.0",
+ "es6-promise": "^3.0.2",
+ "mocha": "^2.4.5"
+ },
+ "peerOptionalDependencies": {
+ "co": ">=5.6.0",
+ "es6-promise": "^3.0.2",
+ "es6-promise2": "^4.0.2",
+ "bson": "0.4.21"
+ },
+ "gitHead": "8eac964c8e31166a8fb483d0d56025b185cee03f",
+ "_id": "require_optional@1.0.0",
+ "_shasum": "52a86137a849728eb60a55533617f8f914f59abf",
+ "_from": "require_optional@>=1.0.0 <1.1.0",
+ "_npmVersion": "2.14.12",
+ "_nodeVersion": "4.2.4",
+ "_npmUser": {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "52a86137a849728eb60a55533617f8f914f59abf",
+ "tarball": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.0.tgz"
+ },
+ "_npmOperationalInternal": {
+ "host": "packages-5-east.internal.npmjs.com",
+ "tmp": "tmp/require_optional-1.0.0.tgz_1454503936164_0.7571216486394405"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/test/require_optional_tests.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/test/require_optional_tests.js
new file mode 100644
index 0000000..181d834
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/require_optional/test/require_optional_tests.js
@@ -0,0 +1,42 @@
+var assert = require('assert'),
+ require_optional = require('../');
+
+describe('Require Optional', function() {
+ describe('top level require', function() {
+ it('should correctly require co library', function() {
+ var promise = require_optional('es6-promise');
+ assert.ok(promise);
+ });
+
+ it('should fail to require es6-promise library', function() {
+ try {
+ require_optional('co');
+ } catch(e) {
+ assert.equal('OPTIONAL_MODULE_NOT_FOUND', e.code);
+ return;
+ }
+
+ assert.ok(false);
+ });
+
+ it('should ignore optional library not defined', function() {
+ assert.equal(undefined, require_optional('es6-promise2'));
+ });
+ });
+
+ describe('internal module file require', function() {
+ it('should correctly require co library', function() {
+ var Long = require_optional('bson/lib/bson/long.js');
+ assert.ok(Long);
+ });
+ });
+
+ describe('top level resolve', function() {
+ it('should correctly use exists method', function() {
+ assert.equal(false, require_optional.exists('co'));
+ assert.equal(true, require_optional.exists('es6-promise'));
+ assert.equal(true, require_optional.exists('bson/lib/bson/long.js'));
+ assert.equal(false, require_optional.exists('es6-promise2'));
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/package.json
new file mode 100644
index 0000000..57276c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/package.json
@@ -0,0 +1,74 @@
+{
+ "name": "mongodb-core",
+ "version": "2.0.13",
+ "description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications",
+ "main": "index.js",
+ "scripts": {
+ "test": "node test/runner.js -t functional",
+ "coverage": "nyc node test/runner.js -t functional -l && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/christkv/mongodb-core.git"
+ },
+ "keywords": [
+ "mongodb",
+ "core"
+ ],
+ "dependencies": {
+ "bson": "~0.5.6",
+ "require_optional": "~1.0.0"
+ },
+ "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": "^1.x",
+ "nyc": "^5.5.0",
+ "optimist": "latest",
+ "rimraf": "2.2.6",
+ "semver": "4.1.0"
+ },
+ "peerOptionalDependencies": {
+ "kerberos": "~0.0"
+ },
+ "author": {
+ "name": "Christian Kvalheim"
+ },
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/christkv/mongodb-core/issues"
+ },
+ "homepage": "https://github.com/christkv/mongodb-core",
+ "gitHead": "319f26dcbdf71a13f234ca33aac2a49642984b5b",
+ "_id": "mongodb-core@2.0.13",
+ "_shasum": "f9394b588dce0e579482e53d74dbc7d7a9d4519c",
+ "_from": "mongodb-core@2.0.13",
+ "_npmVersion": "3.10.8",
+ "_nodeVersion": "6.8.1",
+ "_npmUser": {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ },
+ "dist": {
+ "shasum": "f9394b588dce0e579482e53d74dbc7d7a9d4519c",
+ "tarball": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.0.13.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/mongodb-core-2.0.13.tgz_1477055863501_0.10637361486442387"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.0.13.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/simple_2_document_limit_toArray.dat b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/simple_2_document_limit_toArray.dat
new file mode 100644
index 0000000..25ccf0b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/simple_2_document_limit_toArray.dat
@@ -0,0 +1,11000 @@
+1 2
+2 1
+3 0
+4 0
+5 1
+6 0
+7 0
+8 0
+9 0
+10 1
+11 0
+12 0
+13 0
+14 1
+15 0
+16 0
+17 0
+18 1
+19 0
+20 0
+21 0
+22 1
+23 0
+24 0
+25 0
+26 0
+27 1
+28 0
+29 0
+30 0
+31 1
+32 0
+33 0
+34 0
+35 0
+36 0
+37 1
+38 0
+39 0
+40 0
+41 0
+42 0
+43 1
+44 0
+45 0
+46 0
+47 0
+48 0
+49 0
+50 0
+51 0
+52 0
+53 0
+54 0
+55 0
+56 0
+57 0
+58 0
+59 1
+60 0
+61 2
+62 0
+63 0
+64 1
+65 0
+66 0
+67 0
+68 1
+69 0
+70 0
+71 0
+72 0
+73 1
+74 0
+75 0
+76 0
+77 0
+78 0
+79 1
+80 0
+81 0
+82 0
+83 0
+84 0
+85 0
+86 1
+87 0
+88 0
+89 0
+90 0
+91 0
+92 0
+93 1
+94 0
+95 0
+96 0
+97 0
+98 0
+99 0
+100 0
+101 1
+102 0
+103 0
+104 0
+105 0
+106 0
+107 0
+108 1
+109 0
+110 0
+111 0
+112 0
+113 0
+114 0
+115 1
+116 0
+117 0
+118 0
+119 1
+120 0
+121 0
+122 0
+123 0
+124 0
+125 0
+126 1
+127 0
+128 1
+129 0
+130 0
+131 0
+132 1
+133 1
+134 0
+135 0
+136 0
+137 1
+138 0
+139 0
+140 0
+141 0
+142 0
+143 0
+144 1
+145 0
+146 0
+147 0
+148 0
+149 0
+150 0
+151 0
+152 0
+153 1
+154 0
+155 0
+156 0
+157 0
+158 0
+159 0
+160 0
+161 0
+162 0
+163 0
+164 0
+165 0
+166 0
+167 0
+168 0
+169 0
+170 1
+171 0
+172 0
+173 0
+174 0
+175 0
+176 0
+177 0
+178 1
+179 0
+180 0
+181 0
+182 0
+183 0
+184 0
+185 0
+186 1
+187 0
+188 0
+189 0
+190 0
+191 0
+192 1
+193 0
+194 0
+195 0
+196 1
+197 0
+198 0
+199 0
+200 1
+201 0
+202 0
+203 0
+204 0
+205 0
+206 0
+207 1
+208 0
+209 0
+210 0
+211 0
+212 0
+213 0
+214 0
+215 1
+216 0
+217 0
+218 0
+219 0
+220 0
+221 0
+222 0
+223 1
+224 0
+225 0
+226 0
+227 0
+228 0
+229 0
+230 1
+231 0
+232 0
+233 0
+234 0
+235 0
+236 0
+237 1
+238 0
+239 0
+240 0
+241 0
+242 0
+243 0
+244 0
+245 1
+246 0
+247 0
+248 0
+249 0
+250 0
+251 0
+252 0
+253 0
+254 1
+255 0
+256 0
+257 0
+258 0
+259 1
+260 0
+261 0
+262 0
+263 0
+264 0
+265 1
+266 0
+267 0
+268 0
+269 0
+270 0
+271 0
+272 1
+273 0
+274 0
+275 0
+276 0
+277 0
+278 0
+279 0
+280 0
+281 1
+282 0
+283 1
+284 0
+285 0
+286 1
+287 0
+288 0
+289 0
+290 0
+291 1
+292 0
+293 0
+294 0
+295 0
+296 1
+297 0
+298 0
+299 0
+300 0
+301 0
+302 0
+303 1
+304 0
+305 0
+306 0
+307 0
+308 0
+309 1
+310 0
+311 0
+312 0
+313 0
+314 0
+315 0
+316 1
+317 0
+318 0
+319 0
+320 0
+321 0
+322 0
+323 0
+324 0
+325 1
+326 0
+327 0
+328 0
+329 0
+330 0
+331 0
+332 0
+333 0
+334 1
+335 0
+336 0
+337 0
+338 0
+339 0
+340 0
+341 0
+342 0
+343 1
+344 0
+345 0
+346 0
+347 0
+348 0
+349 0
+350 0
+351 0
+352 1
+353 0
+354 0
+355 0
+356 0
+357 0
+358 0
+359 0
+360 0
+361 1
+362 0
+363 0
+364 0
+365 0
+366 0
+367 0
+368 0
+369 1
+370 0
+371 0
+372 0
+373 0
+374 0
+375 0
+376 0
+377 1
+378 0
+379 0
+380 0
+381 0
+382 0
+383 0
+384 0
+385 1
+386 0
+387 0
+388 0
+389 0
+390 1
+391 0
+392 0
+393 0
+394 0
+395 0
+396 0
+397 0
+398 0
+399 0
+400 0
+401 0
+402 1
+403 0
+404 0
+405 0
+406 0
+407 0
+408 0
+409 0
+410 1
+411 0
+412 0
+413 0
+414 0
+415 0
+416 0
+417 0
+418 0
+419 1
+420 0
+421 0
+422 0
+423 0
+424 0
+425 0
+426 0
+427 1
+428 0
+429 0
+430 0
+431 0
+432 0
+433 0
+434 0
+435 1
+436 0
+437 0
+438 0
+439 0
+440 0
+441 0
+442 0
+443 1
+444 0
+445 0
+446 0
+447 0
+448 0
+449 0
+450 1
+451 0
+452 0
+453 0
+454 0
+455 0
+456 1
+457 0
+458 0
+459 0
+460 0
+461 0
+462 0
+463 0
+464 1
+465 0
+466 0
+467 0
+468 0
+469 0
+470 0
+471 0
+472 0
+473 1
+474 0
+475 0
+476 0
+477 0
+478 0
+479 0
+480 0
+481 1
+482 0
+483 0
+484 0
+485 0
+486 0
+487 0
+488 0
+489 0
+490 1
+491 0
+492 0
+493 0
+494 0
+495 0
+496 0
+497 0
+498 0
+499 0
+500 0
+501 0
+502 0
+503 0
+504 1
+505 0
+506 0
+507 0
+508 0
+509 0
+510 0
+511 0
+512 1
+513 0
+514 0
+515 0
+516 0
+517 0
+518 0
+519 4
+520 0
+521 1
+522 0
+523 0
+524 0
+525 1
+526 0
+527 0
+528 0
+529 0
+530 1
+531 0
+532 0
+533 0
+534 1
+535 0
+536 0
+537 0
+538 0
+539 1
+540 0
+541 0
+542 0
+543 0
+544 0
+545 1
+546 0
+547 0
+548 0
+549 0
+550 0
+551 1
+552 0
+553 0
+554 0
+555 0
+556 0
+557 0
+558 0
+559 1
+560 0
+561 0
+562 0
+563 0
+564 0
+565 0
+566 0
+567 1
+568 0
+569 0
+570 0
+571 0
+572 0
+573 0
+574 0
+575 0
+576 1
+577 0
+578 0
+579 0
+580 0
+581 0
+582 0
+583 0
+584 0
+585 0
+586 0
+587 0
+588 0
+589 0
+590 0
+591 0
+592 0
+593 1
+594 0
+595 0
+596 0
+597 0
+598 0
+599 0
+600 0
+601 0
+602 1
+603 0
+604 0
+605 0
+606 0
+607 0
+608 0
+609 0
+610 0
+611 1
+612 0
+613 0
+614 0
+615 0
+616 0
+617 0
+618 0
+619 0
+620 1
+621 0
+622 0
+623 0
+624 0
+625 0
+626 0
+627 0
+628 0
+629 1
+630 0
+631 0
+632 0
+633 0
+634 0
+635 0
+636 0
+637 0
+638 0
+639 1
+640 0
+641 0
+642 0
+643 0
+644 0
+645 0
+646 1
+647 0
+648 0
+649 0
+650 0
+651 0
+652 1
+653 1
+654 0
+655 0
+656 1
+657 0
+658 1
+659 0
+660 0
+661 0
+662 0
+663 0
+664 1
+665 0
+666 0
+667 0
+668 0
+669 0
+670 0
+671 0
+672 0
+673 0
+674 0
+675 0
+676 0
+677 1
+678 0
+679 0
+680 0
+681 0
+682 0
+683 0
+684 0
+685 0
+686 1
+687 0
+688 0
+689 0
+690 0
+691 0
+692 0
+693 0
+694 0
+695 1
+696 0
+697 0
+698 0
+699 0
+700 0
+701 0
+702 0
+703 1
+704 0
+705 0
+706 0
+707 0
+708 0
+709 0
+710 0
+711 0
+712 1
+713 0
+714 0
+715 0
+716 0
+717 0
+718 0
+719 0
+720 1
+721 0
+722 0
+723 0
+724 0
+725 0
+726 0
+727 0
+728 1
+729 0
+730 0
+731 0
+732 0
+733 0
+734 0
+735 0
+736 0
+737 1
+738 0
+739 0
+740 0
+741 0
+742 0
+743 0
+744 0
+745 1
+746 0
+747 0
+748 0
+749 0
+750 0
+751 0
+752 0
+753 1
+754 0
+755 0
+756 0
+757 0
+758 0
+759 0
+760 0
+761 1
+762 0
+763 0
+764 0
+765 0
+766 0
+767 0
+768 1
+769 0
+770 0
+771 0
+772 0
+773 0
+774 0
+775 0
+776 0
+777 1
+778 0
+779 0
+780 0
+781 0
+782 0
+783 0
+784 0
+785 0
+786 1
+787 0
+788 0
+789 0
+790 0
+791 0
+792 1
+793 0
+794 0
+795 0
+796 0
+797 0
+798 0
+799 0
+800 0
+801 1
+802 0
+803 0
+804 0
+805 0
+806 0
+807 0
+808 0
+809 0
+810 0
+811 0
+812 0
+813 0
+814 0
+815 0
+816 0
+817 0
+818 0
+819 0
+820 1
+821 0
+822 0
+823 0
+824 0
+825 0
+826 0
+827 0
+828 0
+829 1
+830 0
+831 0
+832 0
+833 0
+834 0
+835 0
+836 0
+837 1
+838 0
+839 0
+840 0
+841 0
+842 0
+843 0
+844 0
+845 0
+846 1
+847 0
+848 0
+849 0
+850 0
+851 0
+852 0
+853 0
+854 0
+855 2
+856 0
+857 0
+858 0
+859 0
+860 0
+861 0
+862 1
+863 0
+864 0
+865 0
+866 0
+867 0
+868 0
+869 0
+870 0
+871 1
+872 0
+873 0
+874 0
+875 0
+876 0
+877 0
+878 1
+879 0
+880 0
+881 0
+882 0
+883 0
+884 0
+885 0
+886 0
+887 0
+888 0
+889 0
+890 0
+891 0
+892 0
+893 0
+894 0
+895 0
+896 1
+897 0
+898 0
+899 0
+900 0
+901 0
+902 0
+903 0
+904 0
+905 0
+906 1
+907 0
+908 0
+909 0
+910 0
+911 0
+912 0
+913 0
+914 0
+915 1
+916 0
+917 0
+918 0
+919 0
+920 0
+921 0
+922 1
+923 0
+924 0
+925 0
+926 0
+927 0
+928 0
+929 0
+930 1
+931 0
+932 0
+933 0
+934 0
+935 0
+936 0
+937 0
+938 0
+939 1
+940 0
+941 0
+942 0
+943 0
+944 0
+945 0
+946 0
+947 0
+948 0
+949 1
+950 0
+951 0
+952 0
+953 0
+954 0
+955 0
+956 0
+957 0
+958 1
+959 0
+960 0
+961 0
+962 0
+963 0
+964 0
+965 0
+966 0
+967 0
+968 1
+969 0
+970 0
+971 0
+972 0
+973 0
+974 0
+975 0
+976 0
+977 0
+978 1
+979 0
+980 0
+981 0
+982 0
+983 0
+984 0
+985 0
+986 0
+987 0
+988 1
+989 0
+990 0
+991 0
+992 0
+993 0
+994 0
+995 0
+996 0
+997 1
+998 0
+999 0
+1000 0
+1001 0
+1002 0
+1003 0
+1004 0
+1005 1
+1006 0
+1007 0
+1008 0
+1009 0
+1010 0
+1011 0
+1012 1
+1013 0
+1014 0
+1015 0
+1016 0
+1017 0
+1018 0
+1019 0
+1020 0
+1021 0
+1022 0
+1023 0
+1024 0
+1025 0
+1026 0
+1027 0
+1028 0
+1029 0
+1030 0
+1031 1
+1032 0
+1033 0
+1034 0
+1035 0
+1036 0
+1037 0
+1038 0
+1039 0
+1040 0
+1041 0
+1042 1
+1043 0
+1044 0
+1045 0
+1046 0
+1047 0
+1048 0
+1049 0
+1050 1
+1051 0
+1052 0
+1053 0
+1054 0
+1055 0
+1056 0
+1057 1
+1058 0
+1059 0
+1060 0
+1061 0
+1062 0
+1063 0
+1064 0
+1065 0
+1066 0
+1067 1
+1068 0
+1069 0
+1070 0
+1071 0
+1072 0
+1073 0
+1074 0
+1075 0
+1076 0
+1077 1
+1078 0
+1079 0
+1080 0
+1081 0
+1082 0
+1083 0
+1084 0
+1085 0
+1086 0
+1087 1
+1088 0
+1089 0
+1090 0
+1091 0
+1092 0
+1093 0
+1094 1
+1095 0
+1096 0
+1097 0
+1098 0
+1099 0
+1100 0
+1101 0
+1102 1
+1103 0
+1104 0
+1105 0
+1106 0
+1107 0
+1108 0
+1109 0
+1110 0
+1111 1
+1112 0
+1113 0
+1114 0
+1115 0
+1116 0
+1117 0
+1118 0
+1119 0
+1120 1
+1121 0
+1122 0
+1123 0
+1124 0
+1125 0
+1126 0
+1127 0
+1128 0
+1129 0
+1130 1
+1131 0
+1132 0
+1133 0
+1134 0
+1135 0
+1136 0
+1137 0
+1138 0
+1139 0
+1140 1
+1141 0
+1142 0
+1143 0
+1144 0
+1145 0
+1146 0
+1147 0
+1148 0
+1149 0
+1150 0
+1151 1
+1152 0
+1153 0
+1154 0
+1155 0
+1156 0
+1157 0
+1158 0
+1159 0
+1160 1
+1161 0
+1162 0
+1163 0
+1164 0
+1165 0
+1166 0
+1167 1
+1168 0
+1169 0
+1170 0
+1171 0
+1172 0
+1173 0
+1174 0
+1175 0
+1176 1
+1177 0
+1178 0
+1179 0
+1180 0
+1181 0
+1182 1
+1183 0
+1184 0
+1185 0
+1186 0
+1187 0
+1188 0
+1189 0
+1190 1
+1191 0
+1192 0
+1193 0
+1194 0
+1195 0
+1196 0
+1197 0
+1198 1
+1199 0
+1200 0
+1201 0
+1202 0
+1203 0
+1204 0
+1205 0
+1206 1
+1207 0
+1208 0
+1209 0
+1210 0
+1211 0
+1212 0
+1213 0
+1214 0
+1215 0
+1216 1
+1217 0
+1218 0
+1219 0
+1220 0
+1221 0
+1222 0
+1223 0
+1224 0
+1225 0
+1226 1
+1227 0
+1228 0
+1229 0
+1230 0
+1231 0
+1232 0
+1233 0
+1234 0
+1235 0
+1236 0
+1237 0
+1238 0
+1239 1
+1240 0
+1241 0
+1242 0
+1243 0
+1244 0
+1245 0
+1246 0
+1247 0
+1248 1
+1249 0
+1250 0
+1251 0
+1252 0
+1253 0
+1254 0
+1255 0
+1256 0
+1257 1
+1258 0
+1259 0
+1260 0
+1261 0
+1262 0
+1263 0
+1264 0
+1265 0
+1266 1
+1267 0
+1268 0
+1269 0
+1270 0
+1271 0
+1272 0
+1273 0
+1274 0
+1275 1
+1276 0
+1277 0
+1278 0
+1279 0
+1280 0
+1281 0
+1282 0
+1283 0
+1284 0
+1285 0
+1286 0
+1287 0
+1288 0
+1289 0
+1290 0
+1291 0
+1292 0
+1293 1
+1294 0
+1295 0
+1296 0
+1297 0
+1298 0
+1299 0
+1300 0
+1301 0
+1302 0
+1303 0
+1304 0
+1305 0
+1306 0
+1307 0
+1308 0
+1309 0
+1310 1
+1311 0
+1312 0
+1313 0
+1314 0
+1315 0
+1316 0
+1317 0
+1318 1
+1319 0
+1320 0
+1321 0
+1322 0
+1323 0
+1324 0
+1325 0
+1326 0
+1327 1
+1328 0
+1329 0
+1330 0
+1331 0
+1332 0
+1333 0
+1334 0
+1335 0
+1336 1
+1337 0
+1338 0
+1339 0
+1340 0
+1341 0
+1342 0
+1343 0
+1344 0
+1345 0
+1346 1
+1347 0
+1348 0
+1349 0
+1350 0
+1351 0
+1352 0
+1353 0
+1354 0
+1355 0
+1356 1
+1357 0
+1358 0
+1359 0
+1360 0
+1361 0
+1362 0
+1363 0
+1364 0
+1365 1
+1366 0
+1367 0
+1368 0
+1369 0
+1370 0
+1371 0
+1372 0
+1373 1
+1374 0
+1375 0
+1376 0
+1377 0
+1378 0
+1379 0
+1380 0
+1381 0
+1382 0
+1383 1
+1384 0
+1385 0
+1386 0
+1387 0
+1388 0
+1389 0
+1390 0
+1391 0
+1392 1
+1393 0
+1394 0
+1395 0
+1396 0
+1397 0
+1398 0
+1399 0
+1400 1
+1401 0
+1402 0
+1403 0
+1404 0
+1405 0
+1406 0
+1407 0
+1408 0
+1409 0
+1410 1
+1411 0
+1412 0
+1413 0
+1414 0
+1415 0
+1416 0
+1417 0
+1418 0
+1419 0
+1420 1
+1421 0
+1422 0
+1423 0
+1424 0
+1425 0
+1426 0
+1427 0
+1428 0
+1429 0
+1430 0
+1431 1
+1432 0
+1433 0
+1434 0
+1435 0
+1436 0
+1437 0
+1438 0
+1439 0
+1440 0
+1441 1
+1442 0
+1443 0
+1444 0
+1445 0
+1446 0
+1447 2
+1448 0
+1449 0
+1450 0
+1451 0
+1452 0
+1453 0
+1454 0
+1455 1
+1456 0
+1457 0
+1458 0
+1459 0
+1460 0
+1461 0
+1462 0
+1463 0
+1464 0
+1465 1
+1466 0
+1467 0
+1468 0
+1469 0
+1470 0
+1471 0
+1472 0
+1473 0
+1474 0
+1475 1
+1476 0
+1477 0
+1478 0
+1479 0
+1480 0
+1481 0
+1482 0
+1483 0
+1484 0
+1485 1
+1486 0
+1487 0
+1488 0
+1489 0
+1490 0
+1491 0
+1492 0
+1493 0
+1494 1
+1495 0
+1496 0
+1497 0
+1498 0
+1499 0
+1500 0
+1501 0
+1502 0
+1503 1
+1504 0
+1505 0
+1506 0
+1507 0
+1508 0
+1509 0
+1510 0
+1511 0
+1512 0
+1513 0
+1514 0
+1515 0
+1516 0
+1517 0
+1518 0
+1519 0
+1520 1
+1521 0
+1522 0
+1523 0
+1524 0
+1525 0
+1526 0
+1527 0
+1528 0
+1529 1
+1530 0
+1531 0
+1532 0
+1533 0
+1534 0
+1535 0
+1536 0
+1537 0
+1538 0
+1539 1
+1540 0
+1541 0
+1542 0
+1543 0
+1544 0
+1545 0
+1546 0
+1547 0
+1548 1
+1549 0
+1550 0
+1551 0
+1552 0
+1553 0
+1554 0
+1555 0
+1556 0
+1557 1
+1558 0
+1559 0
+1560 0
+1561 0
+1562 0
+1563 0
+1564 0
+1565 0
+1566 0
+1567 1
+1568 0
+1569 0
+1570 0
+1571 0
+1572 0
+1573 0
+1574 0
+1575 1
+1576 0
+1577 0
+1578 0
+1579 0
+1580 0
+1581 0
+1582 0
+1583 0
+1584 1
+1585 0
+1586 0
+1587 0
+1588 0
+1589 0
+1590 0
+1591 0
+1592 0
+1593 1
+1594 0
+1595 0
+1596 0
+1597 0
+1598 0
+1599 0
+1600 0
+1601 0
+1602 1
+1603 0
+1604 0
+1605 0
+1606 0
+1607 0
+1608 0
+1609 0
+1610 0
+1611 1
+1612 0
+1613 0
+1614 0
+1615 0
+1616 0
+1617 0
+1618 0
+1619 0
+1620 0
+1621 1
+1622 0
+1623 0
+1624 0
+1625 0
+1626 0
+1627 0
+1628 0
+1629 0
+1630 0
+1631 1
+1632 0
+1633 0
+1634 0
+1635 0
+1636 0
+1637 0
+1638 0
+1639 0
+1640 1
+1641 0
+1642 0
+1643 0
+1644 0
+1645 0
+1646 0
+1647 0
+1648 0
+1649 0
+1650 1
+1651 0
+1652 0
+1653 0
+1654 0
+1655 0
+1656 0
+1657 0
+1658 0
+1659 0
+1660 1
+1661 0
+1662 0
+1663 0
+1664 0
+1665 0
+1666 0
+1667 0
+1668 0
+1669 0
+1670 1
+1671 0
+1672 0
+1673 0
+1674 0
+1675 0
+1676 0
+1677 0
+1678 0
+1679 0
+1680 1
+1681 0
+1682 0
+1683 0
+1684 0
+1685 0
+1686 0
+1687 0
+1688 0
+1689 0
+1690 1
+1691 0
+1692 0
+1693 0
+1694 0
+1695 0
+1696 0
+1697 0
+1698 0
+1699 0
+1700 0
+1701 1
+1702 0
+1703 0
+1704 0
+1705 0
+1706 0
+1707 0
+1708 1
+1709 0
+1710 0
+1711 0
+1712 0
+1713 0
+1714 0
+1715 0
+1716 1
+1717 0
+1718 0
+1719 0
+1720 0
+1721 0
+1722 0
+1723 0
+1724 0
+1725 0
+1726 0
+1727 0
+1728 0
+1729 0
+1730 0
+1731 0
+1732 0
+1733 0
+1734 1
+1735 0
+1736 0
+1737 0
+1738 0
+1739 0
+1740 0
+1741 0
+1742 0
+1743 1
+1744 0
+1745 0
+1746 0
+1747 0
+1748 0
+1749 0
+1750 0
+1751 0
+1752 0
+1753 1
+1754 0
+1755 0
+1756 0
+1757 0
+1758 0
+1759 0
+1760 0
+1761 0
+1762 0
+1763 1
+1764 0
+1765 0
+1766 0
+1767 0
+1768 0
+1769 0
+1770 0
+1771 0
+1772 0
+1773 1
+1774 0
+1775 0
+1776 0
+1777 0
+1778 0
+1779 0
+1780 0
+1781 0
+1782 0
+1783 1
+1784 0
+1785 0
+1786 0
+1787 0
+1788 0
+1789 0
+1790 0
+1791 0
+1792 0
+1793 1
+1794 0
+1795 0
+1796 0
+1797 0
+1798 0
+1799 0
+1800 0
+1801 0
+1802 0
+1803 1
+1804 0
+1805 0
+1806 0
+1807 0
+1808 0
+1809 0
+1810 0
+1811 0
+1812 0
+1813 1
+1814 0
+1815 0
+1816 0
+1817 0
+1818 0
+1819 0
+1820 0
+1821 0
+1822 1
+1823 0
+1824 0
+1825 0
+1826 0
+1827 0
+1828 0
+1829 1
+1830 0
+1831 0
+1832 0
+1833 0
+1834 0
+1835 0
+1836 0
+1837 0
+1838 0
+1839 1
+1840 0
+1841 0
+1842 0
+1843 0
+1844 0
+1845 0
+1846 0
+1847 0
+1848 0
+1849 1
+1850 0
+1851 0
+1852 0
+1853 0
+1854 0
+1855 0
+1856 0
+1857 0
+1858 0
+1859 1
+1860 0
+1861 0
+1862 0
+1863 0
+1864 0
+1865 0
+1866 0
+1867 0
+1868 0
+1869 1
+1870 0
+1871 0
+1872 0
+1873 0
+1874 0
+1875 0
+1876 0
+1877 0
+1878 0
+1879 1
+1880 0
+1881 0
+1882 0
+1883 0
+1884 0
+1885 0
+1886 0
+1887 0
+1888 0
+1889 1
+1890 0
+1891 0
+1892 0
+1893 0
+1894 0
+1895 0
+1896 0
+1897 0
+1898 0
+1899 0
+1900 0
+1901 0
+1902 0
+1903 0
+1904 0
+1905 0
+1906 0
+1907 0
+1908 0
+1909 0
+1910 1
+1911 0
+1912 0
+1913 0
+1914 0
+1915 0
+1916 0
+1917 0
+1918 0
+1919 0
+1920 0
+1921 0
+1922 0
+1923 0
+1924 0
+1925 0
+1926 0
+1927 0
+1928 0
+1929 0
+1930 1
+1931 0
+1932 0
+1933 0
+1934 0
+1935 0
+1936 0
+1937 0
+1938 0
+1939 1
+1940 0
+1941 0
+1942 0
+1943 0
+1944 0
+1945 0
+1946 0
+1947 0
+1948 0
+1949 1
+1950 0
+1951 0
+1952 0
+1953 0
+1954 0
+1955 0
+1956 0
+1957 0
+1958 1
+1959 0
+1960 0
+1961 0
+1962 0
+1963 0
+1964 0
+1965 0
+1966 0
+1967 0
+1968 1
+1969 0
+1970 0
+1971 0
+1972 0
+1973 0
+1974 0
+1975 0
+1976 0
+1977 0
+1978 1
+1979 0
+1980 0
+1981 0
+1982 0
+1983 0
+1984 0
+1985 0
+1986 0
+1987 0
+1988 1
+1989 0
+1990 0
+1991 0
+1992 0
+1993 0
+1994 0
+1995 0
+1996 1
+1997 0
+1998 0
+1999 0
+2000 0
+2001 0
+2002 0
+2003 0
+2004 1
+2005 0
+2006 0
+2007 0
+2008 0
+2009 0
+2010 0
+2011 0
+2012 0
+2013 0
+2014 1
+2015 0
+2016 0
+2017 0
+2018 0
+2019 0
+2020 0
+2021 0
+2022 0
+2023 0
+2024 1
+2025 0
+2026 0
+2027 0
+2028 0
+2029 0
+2030 0
+2031 0
+2032 0
+2033 1
+2034 0
+2035 0
+2036 0
+2037 0
+2038 0
+2039 0
+2040 0
+2041 2
+2042 0
+2043 0
+2044 0
+2045 0
+2046 0
+2047 0
+2048 0
+2049 1
+2050 0
+2051 0
+2052 0
+2053 0
+2054 0
+2055 0
+2056 0
+2057 0
+2058 0
+2059 0
+2060 0
+2061 0
+2062 0
+2063 0
+2064 0
+2065 0
+2066 0
+2067 1
+2068 0
+2069 0
+2070 0
+2071 0
+2072 0
+2073 0
+2074 0
+2075 0
+2076 1
+2077 0
+2078 0
+2079 0
+2080 0
+2081 0
+2082 0
+2083 0
+2084 0
+2085 0
+2086 1
+2087 0
+2088 0
+2089 0
+2090 0
+2091 0
+2092 0
+2093 0
+2094 0
+2095 0
+2096 1
+2097 0
+2098 0
+2099 0
+2100 0
+2101 0
+2102 0
+2103 0
+2104 0
+2105 1
+2106 0
+2107 0
+2108 0
+2109 0
+2110 0
+2111 0
+2112 0
+2113 0
+2114 0
+2115 0
+2116 1
+2117 0
+2118 0
+2119 0
+2120 0
+2121 0
+2122 0
+2123 0
+2124 0
+2125 1
+2126 0
+2127 0
+2128 0
+2129 0
+2130 0
+2131 0
+2132 0
+2133 1
+2134 0
+2135 0
+2136 0
+2137 0
+2138 0
+2139 0
+2140 0
+2141 1
+2142 0
+2143 0
+2144 0
+2145 0
+2146 0
+2147 0
+2148 0
+2149 0
+2150 1
+2151 0
+2152 0
+2153 0
+2154 0
+2155 0
+2156 0
+2157 0
+2158 0
+2159 1
+2160 0
+2161 0
+2162 0
+2163 0
+2164 0
+2165 0
+2166 0
+2167 0
+2168 0
+2169 1
+2170 0
+2171 0
+2172 0
+2173 0
+2174 0
+2175 0
+2176 0
+2177 1
+2178 0
+2179 0
+2180 0
+2181 0
+2182 0
+2183 0
+2184 0
+2185 0
+2186 0
+2187 1
+2188 0
+2189 0
+2190 0
+2191 0
+2192 0
+2193 0
+2194 0
+2195 0
+2196 1
+2197 0
+2198 0
+2199 0
+2200 0
+2201 0
+2202 0
+2203 0
+2204 1
+2205 0
+2206 0
+2207 0
+2208 0
+2209 0
+2210 0
+2211 0
+2212 0
+2213 0
+2214 1
+2215 0
+2216 0
+2217 0
+2218 0
+2219 0
+2220 0
+2221 0
+2222 0
+2223 0
+2224 1
+2225 0
+2226 0
+2227 0
+2228 0
+2229 0
+2230 0
+2231 0
+2232 0
+2233 1
+2234 0
+2235 0
+2236 0
+2237 0
+2238 0
+2239 0
+2240 0
+2241 0
+2242 1
+2243 0
+2244 0
+2245 0
+2246 0
+2247 0
+2248 0
+2249 0
+2250 1
+2251 0
+2252 0
+2253 0
+2254 0
+2255 0
+2256 0
+2257 0
+2258 0
+2259 0
+2260 1
+2261 0
+2262 0
+2263 0
+2264 0
+2265 0
+2266 0
+2267 0
+2268 0
+2269 0
+2270 1
+2271 0
+2272 0
+2273 0
+2274 0
+2275 0
+2276 0
+2277 0
+2278 0
+2279 0
+2280 1
+2281 0
+2282 0
+2283 0
+2284 0
+2285 0
+2286 0
+2287 0
+2288 0
+2289 0
+2290 1
+2291 0
+2292 0
+2293 0
+2294 0
+2295 0
+2296 0
+2297 0
+2298 1
+2299 0
+2300 0
+2301 0
+2302 0
+2303 0
+2304 0
+2305 0
+2306 1
+2307 0
+2308 0
+2309 0
+2310 0
+2311 0
+2312 0
+2313 0
+2314 0
+2315 1
+2316 0
+2317 0
+2318 0
+2319 0
+2320 0
+2321 0
+2322 0
+2323 0
+2324 0
+2325 1
+2326 0
+2327 0
+2328 0
+2329 0
+2330 0
+2331 0
+2332 0
+2333 0
+2334 0
+2335 1
+2336 0
+2337 0
+2338 0
+2339 0
+2340 0
+2341 0
+2342 0
+2343 0
+2344 0
+2345 1
+2346 0
+2347 0
+2348 0
+2349 0
+2350 0
+2351 0
+2352 0
+2353 1
+2354 0
+2355 0
+2356 0
+2357 0
+2358 0
+2359 0
+2360 0
+2361 1
+2362 0
+2363 0
+2364 0
+2365 0
+2366 0
+2367 0
+2368 0
+2369 0
+2370 0
+2371 1
+2372 0
+2373 0
+2374 0
+2375 0
+2376 0
+2377 0
+2378 0
+2379 0
+2380 0
+2381 1
+2382 0
+2383 0
+2384 0
+2385 0
+2386 0
+2387 0
+2388 0
+2389 0
+2390 1
+2391 0
+2392 0
+2393 0
+2394 0
+2395 0
+2396 0
+2397 0
+2398 0
+2399 0
+2400 0
+2401 0
+2402 0
+2403 0
+2404 0
+2405 0
+2406 0
+2407 0
+2408 0
+2409 0
+2410 0
+2411 1
+2412 0
+2413 0
+2414 0
+2415 0
+2416 0
+2417 0
+2418 0
+2419 0
+2420 0
+2421 1
+2422 0
+2423 0
+2424 0
+2425 0
+2426 0
+2427 0
+2428 0
+2429 0
+2430 0
+2431 0
+2432 0
+2433 0
+2434 0
+2435 0
+2436 0
+2437 0
+2438 0
+2439 0
+2440 1
+2441 0
+2442 0
+2443 0
+2444 0
+2445 0
+2446 0
+2447 0
+2448 0
+2449 0
+2450 0
+2451 1
+2452 0
+2453 0
+2454 0
+2455 0
+2456 0
+2457 0
+2458 0
+2459 0
+2460 0
+2461 1
+2462 0
+2463 0
+2464 0
+2465 0
+2466 0
+2467 0
+2468 0
+2469 1
+2470 0
+2471 0
+2472 0
+2473 0
+2474 0
+2475 0
+2476 0
+2477 1
+2478 0
+2479 0
+2480 0
+2481 0
+2482 0
+2483 0
+2484 0
+2485 0
+2486 1
+2487 0
+2488 0
+2489 0
+2490 0
+2491 0
+2492 0
+2493 0
+2494 0
+2495 0
+2496 1
+2497 0
+2498 0
+2499 0
+2500 0
+2501 0
+2502 0
+2503 0
+2504 0
+2505 0
+2506 1
+2507 0
+2508 0
+2509 0
+2510 0
+2511 0
+2512 0
+2513 0
+2514 0
+2515 0
+2516 1
+2517 0
+2518 0
+2519 0
+2520 0
+2521 0
+2522 0
+2523 0
+2524 0
+2525 0
+2526 0
+2527 1
+2528 0
+2529 0
+2530 0
+2531 0
+2532 0
+2533 0
+2534 0
+2535 0
+2536 0
+2537 1
+2538 0
+2539 0
+2540 0
+2541 0
+2542 0
+2543 0
+2544 0
+2545 0
+2546 0
+2547 0
+2548 0
+2549 0
+2550 0
+2551 0
+2552 0
+2553 0
+2554 0
+2555 0
+2556 0
+2557 1
+2558 0
+2559 0
+2560 0
+2561 0
+2562 0
+2563 0
+2564 0
+2565 0
+2566 1
+2567 0
+2568 0
+2569 0
+2570 0
+2571 0
+2572 0
+2573 0
+2574 0
+2575 1
+2576 0
+2577 0
+2578 0
+2579 0
+2580 0
+2581 0
+2582 0
+2583 0
+2584 1
+2585 0
+2586 0
+2587 0
+2588 0
+2589 0
+2590 0
+2591 0
+2592 0
+2593 0
+2594 0
+2595 1
+2596 0
+2597 0
+2598 0
+2599 0
+2600 0
+2601 0
+2602 0
+2603 0
+2604 0
+2605 1
+2606 0
+2607 0
+2608 0
+2609 0
+2610 0
+2611 0
+2612 0
+2613 0
+2614 0
+2615 0
+2616 0
+2617 0
+2618 0
+2619 0
+2620 0
+2621 0
+2622 0
+2623 0
+2624 0
+2625 1
+2626 0
+2627 0
+2628 0
+2629 0
+2630 0
+2631 0
+2632 0
+2633 0
+2634 0
+2635 1
+2636 0
+2637 0
+2638 0
+2639 1
+2640 0
+2641 0
+2642 0
+2643 1
+2644 0
+2645 0
+2646 0
+2647 0
+2648 0
+2649 0
+2650 0
+2651 0
+2652 0
+2653 1
+2654 0
+2655 0
+2656 0
+2657 0
+2658 0
+2659 0
+2660 0
+2661 0
+2662 0
+2663 1
+2664 0
+2665 0
+2666 0
+2667 0
+2668 0
+2669 0
+2670 0
+2671 1
+2672 0
+2673 0
+2674 0
+2675 0
+2676 0
+2677 0
+2678 0
+2679 1
+2680 0
+2681 0
+2682 0
+2683 0
+2684 0
+2685 0
+2686 0
+2687 0
+2688 0
+2689 1
+2690 0
+2691 0
+2692 0
+2693 0
+2694 0
+2695 0
+2696 0
+2697 0
+2698 0
+2699 1
+2700 0
+2701 0
+2702 0
+2703 0
+2704 0
+2705 0
+2706 0
+2707 0
+2708 0
+2709 1
+2710 0
+2711 0
+2712 0
+2713 0
+2714 0
+2715 0
+2716 1
+2717 0
+2718 0
+2719 0
+2720 0
+2721 0
+2722 0
+2723 0
+2724 1
+2725 0
+2726 0
+2727 0
+2728 0
+2729 0
+2730 0
+2731 0
+2732 0
+2733 0
+2734 1
+2735 0
+2736 0
+2737 0
+2738 0
+2739 0
+2740 0
+2741 0
+2742 0
+2743 0
+2744 1
+2745 0
+2746 0
+2747 0
+2748 0
+2749 0
+2750 0
+2751 0
+2752 0
+2753 1
+2754 0
+2755 0
+2756 0
+2757 0
+2758 0
+2759 0
+2760 0
+2761 0
+2762 0
+2763 1
+2764 0
+2765 0
+2766 0
+2767 0
+2768 0
+2769 0
+2770 0
+2771 0
+2772 0
+2773 1
+2774 0
+2775 0
+2776 0
+2777 0
+2778 0
+2779 0
+2780 0
+2781 0
+2782 0
+2783 1
+2784 0
+2785 0
+2786 0
+2787 0
+2788 0
+2789 0
+2790 0
+2791 0
+2792 1
+2793 0
+2794 0
+2795 0
+2796 0
+2797 0
+2798 0
+2799 0
+2800 0
+2801 0
+2802 0
+2803 0
+2804 0
+2805 0
+2806 0
+2807 0
+2808 0
+2809 0
+2810 0
+2811 0
+2812 0
+2813 0
+2814 0
+2815 0
+2816 0
+2817 0
+2818 0
+2819 0
+2820 0
+2821 1
+2822 0
+2823 0
+2824 0
+2825 0
+2826 0
+2827 0
+2828 0
+2829 0
+2830 0
+2831 1
+2832 0
+2833 0
+2834 0
+2835 0
+2836 0
+2837 0
+2838 0
+2839 0
+2840 0
+2841 1
+2842 0
+2843 0
+2844 0
+2845 0
+2846 0
+2847 0
+2848 0
+2849 0
+2850 0
+2851 1
+2852 0
+2853 0
+2854 0
+2855 0
+2856 0
+2857 0
+2858 0
+2859 0
+2860 0
+2861 1
+2862 0
+2863 0
+2864 0
+2865 0
+2866 0
+2867 0
+2868 0
+2869 0
+2870 0
+2871 1
+2872 0
+2873 0
+2874 0
+2875 0
+2876 0
+2877 0
+2878 0
+2879 0
+2880 1
+2881 0
+2882 0
+2883 0
+2884 0
+2885 0
+2886 0
+2887 0
+2888 1
+2889 0
+2890 0
+2891 0
+2892 0
+2893 0
+2894 0
+2895 0
+2896 0
+2897 1
+2898 0
+2899 0
+2900 0
+2901 0
+2902 0
+2903 0
+2904 0
+2905 0
+2906 1
+2907 0
+2908 0
+2909 0
+2910 0
+2911 0
+2912 0
+2913 0
+2914 1
+2915 0
+2916 0
+2917 0
+2918 0
+2919 0
+2920 0
+2921 0
+2922 1
+2923 0
+2924 0
+2925 0
+2926 0
+2927 0
+2928 0
+2929 0
+2930 0
+2931 0
+2932 0
+2933 0
+2934 0
+2935 0
+2936 0
+2937 0
+2938 1
+2939 0
+2940 0
+2941 0
+2942 0
+2943 0
+2944 0
+2945 0
+2946 0
+2947 0
+2948 0
+2949 1
+2950 0
+2951 0
+2952 0
+2953 0
+2954 0
+2955 0
+2956 0
+2957 0
+2958 0
+2959 1
+2960 0
+2961 0
+2962 0
+2963 0
+2964 0
+2965 0
+2966 0
+2967 0
+2968 1
+2969 0
+2970 0
+2971 0
+2972 0
+2973 0
+2974 0
+2975 0
+2976 0
+2977 1
+2978 0
+2979 0
+2980 0
+2981 0
+2982 0
+2983 0
+2984 0
+2985 0
+2986 0
+2987 1
+2988 0
+2989 0
+2990 0
+2991 0
+2992 0
+2993 0
+2994 0
+2995 0
+2996 0
+2997 1
+2998 0
+2999 0
+3000 0
+3001 0
+3002 0
+3003 0
+3004 0
+3005 0
+3006 0
+3007 0
+3008 0
+3009 0
+3010 0
+3011 0
+3012 0
+3013 0
+3014 0
+3015 1
+3016 0
+3017 0
+3018 0
+3019 0
+3020 0
+3021 0
+3022 0
+3023 0
+3024 0
+3025 1
+3026 0
+3027 0
+3028 0
+3029 0
+3030 0
+3031 0
+3032 0
+3033 0
+3034 1
+3035 0
+3036 0
+3037 0
+3038 0
+3039 0
+3040 0
+3041 0
+3042 1
+3043 0
+3044 0
+3045 0
+3046 0
+3047 0
+3048 0
+3049 0
+3050 0
+3051 0
+3052 1
+3053 0
+3054 0
+3055 0
+3056 0
+3057 0
+3058 0
+3059 0
+3060 0
+3061 0
+3062 1
+3063 0
+3064 0
+3065 0
+3066 0
+3067 0
+3068 0
+3069 0
+3070 0
+3071 0
+3072 1
+3073 0
+3074 0
+3075 0
+3076 0
+3077 0
+3078 0
+3079 0
+3080 0
+3081 0
+3082 1
+3083 0
+3084 0
+3085 0
+3086 0
+3087 0
+3088 0
+3089 0
+3090 0
+3091 0
+3092 1
+3093 0
+3094 0
+3095 0
+3096 0
+3097 0
+3098 0
+3099 0
+3100 0
+3101 0
+3102 1
+3103 0
+3104 0
+3105 0
+3106 0
+3107 0
+3108 0
+3109 0
+3110 0
+3111 0
+3112 1
+3113 0
+3114 0
+3115 0
+3116 0
+3117 0
+3118 0
+3119 0
+3120 1
+3121 0
+3122 0
+3123 0
+3124 0
+3125 0
+3126 0
+3127 0
+3128 0
+3129 1
+3130 0
+3131 0
+3132 0
+3133 0
+3134 0
+3135 0
+3136 0
+3137 0
+3138 0
+3139 1
+3140 0
+3141 0
+3142 0
+3143 0
+3144 0
+3145 0
+3146 0
+3147 0
+3148 0
+3149 1
+3150 0
+3151 0
+3152 0
+3153 0
+3154 0
+3155 0
+3156 0
+3157 1
+3158 0
+3159 0
+3160 0
+3161 0
+3162 0
+3163 0
+3164 0
+3165 1
+3166 0
+3167 0
+3168 0
+3169 0
+3170 0
+3171 0
+3172 0
+3173 0
+3174 0
+3175 1
+3176 0
+3177 0
+3178 0
+3179 0
+3180 0
+3181 0
+3182 0
+3183 0
+3184 0
+3185 1
+3186 0
+3187 0
+3188 0
+3189 0
+3190 0
+3191 0
+3192 0
+3193 0
+3194 0
+3195 0
+3196 1
+3197 0
+3198 0
+3199 0
+3200 0
+3201 0
+3202 0
+3203 0
+3204 0
+3205 0
+3206 0
+3207 1
+3208 0
+3209 0
+3210 0
+3211 0
+3212 0
+3213 0
+3214 0
+3215 1
+3216 0
+3217 0
+3218 0
+3219 0
+3220 0
+3221 0
+3222 0
+3223 1
+3224 0
+3225 0
+3226 0
+3227 0
+3228 0
+3229 0
+3230 0
+3231 0
+3232 1
+3233 0
+3234 1
+3235 0
+3236 0
+3237 0
+3238 0
+3239 1
+3240 0
+3241 0
+3242 0
+3243 0
+3244 0
+3245 0
+3246 0
+3247 0
+3248 1
+3249 0
+3250 0
+3251 0
+3252 0
+3253 0
+3254 0
+3255 0
+3256 0
+3257 0
+3258 1
+3259 0
+3260 0
+3261 0
+3262 0
+3263 0
+3264 0
+3265 0
+3266 0
+3267 0
+3268 0
+3269 1
+3270 0
+3271 0
+3272 0
+3273 0
+3274 0
+3275 0
+3276 0
+3277 0
+3278 1
+3279 0
+3280 0
+3281 0
+3282 0
+3283 0
+3284 0
+3285 0
+3286 0
+3287 1
+3288 0
+3289 0
+3290 0
+3291 0
+3292 0
+3293 0
+3294 0
+3295 0
+3296 0
+3297 1
+3298 0
+3299 0
+3300 0
+3301 0
+3302 0
+3303 0
+3304 0
+3305 0
+3306 0
+3307 1
+3308 0
+3309 0
+3310 0
+3311 0
+3312 0
+3313 0
+3314 0
+3315 0
+3316 0
+3317 1
+3318 0
+3319 0
+3320 0
+3321 0
+3322 0
+3323 0
+3324 0
+3325 1
+3326 0
+3327 0
+3328 0
+3329 0
+3330 0
+3331 0
+3332 0
+3333 0
+3334 0
+3335 1
+3336 0
+3337 0
+3338 0
+3339 0
+3340 0
+3341 0
+3342 0
+3343 0
+3344 1
+3345 0
+3346 0
+3347 0
+3348 0
+3349 0
+3350 0
+3351 0
+3352 0
+3353 0
+3354 1
+3355 0
+3356 0
+3357 0
+3358 0
+3359 0
+3360 0
+3361 0
+3362 0
+3363 0
+3364 0
+3365 1
+3366 0
+3367 0
+3368 0
+3369 0
+3370 0
+3371 0
+3372 0
+3373 0
+3374 0
+3375 1
+3376 0
+3377 0
+3378 0
+3379 0
+3380 0
+3381 0
+3382 0
+3383 0
+3384 0
+3385 0
+3386 1
+3387 0
+3388 0
+3389 0
+3390 0
+3391 0
+3392 0
+3393 0
+3394 0
+3395 0
+3396 0
+3397 1
+3398 0
+3399 0
+3400 0
+3401 0
+3402 0
+3403 0
+3404 0
+3405 0
+3406 0
+3407 1
+3408 0
+3409 0
+3410 0
+3411 0
+3412 0
+3413 0
+3414 0
+3415 0
+3416 0
+3417 1
+3418 0
+3419 0
+3420 0
+3421 0
+3422 0
+3423 0
+3424 0
+3425 0
+3426 0
+3427 0
+3428 1
+3429 0
+3430 0
+3431 0
+3432 0
+3433 0
+3434 0
+3435 0
+3436 0
+3437 1
+3438 0
+3439 0
+3440 0
+3441 0
+3442 0
+3443 0
+3444 0
+3445 1
+3446 0
+3447 0
+3448 0
+3449 0
+3450 0
+3451 0
+3452 0
+3453 0
+3454 1
+3455 0
+3456 0
+3457 0
+3458 0
+3459 0
+3460 0
+3461 0
+3462 0
+3463 0
+3464 1
+3465 0
+3466 0
+3467 0
+3468 0
+3469 0
+3470 0
+3471 0
+3472 0
+3473 0
+3474 1
+3475 0
+3476 0
+3477 0
+3478 0
+3479 0
+3480 0
+3481 0
+3482 0
+3483 0
+3484 1
+3485 0
+3486 0
+3487 0
+3488 0
+3489 0
+3490 0
+3491 0
+3492 0
+3493 0
+3494 1
+3495 0
+3496 0
+3497 0
+3498 0
+3499 0
+3500 0
+3501 0
+3502 0
+3503 0
+3504 1
+3505 0
+3506 0
+3507 0
+3508 0
+3509 0
+3510 0
+3511 0
+3512 0
+3513 0
+3514 1
+3515 0
+3516 0
+3517 0
+3518 0
+3519 0
+3520 0
+3521 0
+3522 0
+3523 0
+3524 1
+3525 0
+3526 0
+3527 0
+3528 0
+3529 0
+3530 0
+3531 0
+3532 0
+3533 1
+3534 0
+3535 0
+3536 0
+3537 0
+3538 0
+3539 0
+3540 0
+3541 0
+3542 0
+3543 0
+3544 0
+3545 0
+3546 0
+3547 0
+3548 0
+3549 0
+3550 0
+3551 1
+3552 0
+3553 0
+3554 0
+3555 0
+3556 0
+3557 0
+3558 0
+3559 0
+3560 0
+3561 1
+3562 0
+3563 0
+3564 0
+3565 0
+3566 0
+3567 0
+3568 0
+3569 0
+3570 1
+3571 0
+3572 0
+3573 0
+3574 0
+3575 0
+3576 0
+3577 0
+3578 0
+3579 0
+3580 1
+3581 0
+3582 0
+3583 0
+3584 0
+3585 0
+3586 0
+3587 0
+3588 0
+3589 0
+3590 1
+3591 0
+3592 0
+3593 0
+3594 0
+3595 0
+3596 0
+3597 0
+3598 0
+3599 1
+3600 0
+3601 0
+3602 0
+3603 0
+3604 0
+3605 0
+3606 0
+3607 0
+3608 0
+3609 1
+3610 0
+3611 0
+3612 0
+3613 0
+3614 0
+3615 0
+3616 0
+3617 0
+3618 0
+3619 0
+3620 1
+3621 0
+3622 0
+3623 0
+3624 0
+3625 0
+3626 0
+3627 0
+3628 0
+3629 0
+3630 1
+3631 0
+3632 0
+3633 0
+3634 0
+3635 0
+3636 0
+3637 0
+3638 0
+3639 1
+3640 0
+3641 0
+3642 0
+3643 0
+3644 0
+3645 1
+3646 0
+3647 0
+3648 0
+3649 0
+3650 0
+3651 1
+3652 0
+3653 0
+3654 0
+3655 0
+3656 0
+3657 0
+3658 1
+3659 0
+3660 0
+3661 0
+3662 0
+3663 0
+3664 0
+3665 0
+3666 1
+3667 0
+3668 0
+3669 0
+3670 0
+3671 0
+3672 0
+3673 0
+3674 0
+3675 0
+3676 1
+3677 0
+3678 0
+3679 0
+3680 0
+3681 0
+3682 0
+3683 0
+3684 0
+3685 1
+3686 0
+3687 0
+3688 0
+3689 0
+3690 0
+3691 0
+3692 0
+3693 0
+3694 0
+3695 1
+3696 0
+3697 0
+3698 0
+3699 0
+3700 0
+3701 0
+3702 0
+3703 0
+3704 0
+3705 0
+3706 1
+3707 0
+3708 0
+3709 0
+3710 0
+3711 0
+3712 0
+3713 0
+3714 0
+3715 0
+3716 1
+3717 0
+3718 0
+3719 0
+3720 0
+3721 0
+3722 0
+3723 0
+3724 0
+3725 0
+3726 0
+3727 0
+3728 0
+3729 0
+3730 0
+3731 0
+3732 0
+3733 0
+3734 0
+3735 0
+3736 1
+3737 0
+3738 0
+3739 0
+3740 0
+3741 0
+3742 0
+3743 0
+3744 0
+3745 0
+3746 1
+3747 0
+3748 0
+3749 0
+3750 0
+3751 0
+3752 0
+3753 0
+3754 0
+3755 0
+3756 1
+3757 0
+3758 0
+3759 0
+3760 0
+3761 0
+3762 0
+3763 1
+3764 0
+3765 0
+3766 0
+3767 0
+3768 0
+3769 0
+3770 0
+3771 1
+3772 0
+3773 0
+3774 0
+3775 0
+3776 0
+3777 0
+3778 1
+3779 0
+3780 0
+3781 0
+3782 0
+3783 0
+3784 0
+3785 0
+3786 0
+3787 0
+3788 0
+3789 0
+3790 0
+3791 0
+3792 0
+3793 0
+3794 0
+3795 0
+3796 0
+3797 1
+3798 0
+3799 0
+3800 0
+3801 0
+3802 0
+3803 0
+3804 0
+3805 0
+3806 1
+3807 0
+3808 0
+3809 0
+3810 0
+3811 0
+3812 0
+3813 0
+3814 0
+3815 0
+3816 0
+3817 1
+3818 0
+3819 0
+3820 0
+3821 0
+3822 0
+3823 0
+3824 0
+3825 0
+3826 0
+3827 1
+3828 0
+3829 1
+3830 0
+3831 0
+3832 0
+3833 0
+3834 1
+3835 0
+3836 0
+3837 0
+3838 0
+3839 0
+3840 0
+3841 0
+3842 0
+3843 0
+3844 0
+3845 1
+3846 0
+3847 0
+3848 0
+3849 0
+3850 0
+3851 0
+3852 0
+3853 0
+3854 0
+3855 1
+3856 0
+3857 0
+3858 0
+3859 0
+3860 0
+3861 0
+3862 0
+3863 1
+3864 0
+3865 0
+3866 0
+3867 0
+3868 0
+3869 0
+3870 0
+3871 0
+3872 0
+3873 1
+3874 0
+3875 0
+3876 0
+3877 0
+3878 0
+3879 0
+3880 0
+3881 0
+3882 0
+3883 1
+3884 0
+3885 0
+3886 0
+3887 0
+3888 0
+3889 0
+3890 0
+3891 0
+3892 0
+3893 0
+3894 1
+3895 0
+3896 0
+3897 0
+3898 0
+3899 0
+3900 0
+3901 0
+3902 0
+3903 0
+3904 0
+3905 1
+3906 0
+3907 0
+3908 0
+3909 0
+3910 0
+3911 0
+3912 0
+3913 0
+3914 1
+3915 0
+3916 0
+3917 0
+3918 0
+3919 0
+3920 0
+3921 0
+3922 0
+3923 0
+3924 0
+3925 1
+3926 0
+3927 0
+3928 0
+3929 0
+3930 0
+3931 0
+3932 0
+3933 0
+3934 1
+3935 0
+3936 0
+3937 0
+3938 0
+3939 0
+3940 0
+3941 0
+3942 0
+3943 0
+3944 0
+3945 1
+3946 0
+3947 0
+3948 0
+3949 0
+3950 0
+3951 0
+3952 0
+3953 0
+3954 0
+3955 1
+3956 0
+3957 0
+3958 0
+3959 0
+3960 0
+3961 0
+3962 0
+3963 0
+3964 0
+3965 0
+3966 1
+3967 0
+3968 0
+3969 0
+3970 0
+3971 0
+3972 0
+3973 0
+3974 0
+3975 1
+3976 0
+3977 0
+3978 0
+3979 0
+3980 0
+3981 0
+3982 0
+3983 0
+3984 1
+3985 0
+3986 0
+3987 0
+3988 0
+3989 0
+3990 0
+3991 0
+3992 0
+3993 0
+3994 1
+3995 0
+3996 0
+3997 0
+3998 0
+3999 0
+4000 0
+4001 0
+4002 0
+4003 0
+4004 0
+4005 0
+4006 0
+4007 0
+4008 0
+4009 0
+4010 0
+4011 0
+4012 0
+4013 0
+4014 1
+4015 0
+4016 0
+4017 0
+4018 0
+4019 0
+4020 0
+4021 0
+4022 0
+4023 0
+4024 1
+4025 0
+4026 0
+4027 0
+4028 0
+4029 0
+4030 0
+4031 0
+4032 0
+4033 0
+4034 0
+4035 1
+4036 0
+4037 0
+4038 0
+4039 0
+4040 0
+4041 0
+4042 0
+4043 0
+4044 0
+4045 1
+4046 0
+4047 0
+4048 0
+4049 0
+4050 0
+4051 0
+4052 0
+4053 0
+4054 0
+4055 0
+4056 1
+4057 0
+4058 0
+4059 0
+4060 0
+4061 0
+4062 0
+4063 0
+4064 0
+4065 0
+4066 1
+4067 0
+4068 0
+4069 0
+4070 0
+4071 0
+4072 0
+4073 0
+4074 1
+4075 0
+4076 0
+4077 0
+4078 0
+4079 0
+4080 0
+4081 0
+4082 0
+4083 0
+4084 1
+4085 0
+4086 0
+4087 0
+4088 0
+4089 0
+4090 0
+4091 0
+4092 0
+4093 1
+4094 0
+4095 0
+4096 0
+4097 0
+4098 0
+4099 0
+4100 0
+4101 0
+4102 1
+4103 0
+4104 0
+4105 0
+4106 0
+4107 0
+4108 0
+4109 0
+4110 0
+4111 0
+4112 1
+4113 0
+4114 0
+4115 0
+4116 0
+4117 0
+4118 0
+4119 0
+4120 0
+4121 0
+4122 1
+4123 0
+4124 0
+4125 0
+4126 0
+4127 0
+4128 0
+4129 0
+4130 0
+4131 0
+4132 0
+4133 1
+4134 0
+4135 0
+4136 0
+4137 0
+4138 0
+4139 0
+4140 0
+4141 0
+4142 0
+4143 0
+4144 1
+4145 0
+4146 0
+4147 0
+4148 0
+4149 0
+4150 0
+4151 0
+4152 0
+4153 0
+4154 1
+4155 0
+4156 0
+4157 0
+4158 0
+4159 0
+4160 0
+4161 0
+4162 0
+4163 0
+4164 0
+4165 1
+4166 0
+4167 0
+4168 0
+4169 0
+4170 0
+4171 0
+4172 0
+4173 0
+4174 0
+4175 0
+4176 1
+4177 0
+4178 0
+4179 0
+4180 0
+4181 0
+4182 0
+4183 0
+4184 0
+4185 1
+4186 0
+4187 0
+4188 0
+4189 0
+4190 0
+4191 0
+4192 0
+4193 0
+4194 0
+4195 1
+4196 0
+4197 0
+4198 0
+4199 0
+4200 0
+4201 0
+4202 0
+4203 0
+4204 0
+4205 0
+4206 0
+4207 0
+4208 0
+4209 0
+4210 0
+4211 0
+4212 1
+4213 0
+4214 0
+4215 0
+4216 0
+4217 0
+4218 0
+4219 0
+4220 0
+4221 1
+4222 0
+4223 0
+4224 0
+4225 0
+4226 0
+4227 0
+4228 0
+4229 0
+4230 1
+4231 0
+4232 0
+4233 0
+4234 0
+4235 0
+4236 0
+4237 0
+4238 0
+4239 1
+4240 0
+4241 0
+4242 0
+4243 0
+4244 0
+4245 0
+4246 0
+4247 0
+4248 0
+4249 1
+4250 0
+4251 0
+4252 0
+4253 0
+4254 0
+4255 0
+4256 0
+4257 0
+4258 1
+4259 0
+4260 0
+4261 0
+4262 0
+4263 0
+4264 0
+4265 0
+4266 0
+4267 0
+4268 1
+4269 0
+4270 0
+4271 0
+4272 0
+4273 0
+4274 0
+4275 0
+4276 0
+4277 0
+4278 1
+4279 0
+4280 0
+4281 0
+4282 0
+4283 0
+4284 0
+4285 0
+4286 0
+4287 0
+4288 0
+4289 1
+4290 0
+4291 0
+4292 0
+4293 0
+4294 0
+4295 0
+4296 0
+4297 0
+4298 0
+4299 1
+4300 0
+4301 0
+4302 0
+4303 0
+4304 0
+4305 0
+4306 0
+4307 0
+4308 0
+4309 1
+4310 0
+4311 0
+4312 0
+4313 0
+4314 0
+4315 0
+4316 0
+4317 0
+4318 1
+4319 0
+4320 0
+4321 0
+4322 0
+4323 0
+4324 0
+4325 0
+4326 0
+4327 1
+4328 0
+4329 0
+4330 0
+4331 0
+4332 0
+4333 0
+4334 0
+4335 0
+4336 0
+4337 1
+4338 0
+4339 0
+4340 0
+4341 0
+4342 0
+4343 0
+4344 0
+4345 0
+4346 0
+4347 1
+4348 0
+4349 0
+4350 0
+4351 0
+4352 0
+4353 0
+4354 0
+4355 1
+4356 0
+4357 0
+4358 0
+4359 0
+4360 0
+4361 0
+4362 0
+4363 0
+4364 0
+4365 0
+4366 0
+4367 0
+4368 0
+4369 0
+4370 0
+4371 0
+4372 0
+4373 0
+4374 1
+4375 0
+4376 0
+4377 0
+4378 0
+4379 0
+4380 0
+4381 0
+4382 0
+4383 0
+4384 1
+4385 0
+4386 0
+4387 0
+4388 0
+4389 0
+4390 0
+4391 0
+4392 0
+4393 1
+4394 0
+4395 0
+4396 0
+4397 0
+4398 0
+4399 0
+4400 0
+4401 0
+4402 0
+4403 1
+4404 0
+4405 0
+4406 0
+4407 0
+4408 0
+4409 0
+4410 0
+4411 0
+4412 1
+4413 0
+4414 0
+4415 0
+4416 0
+4417 0
+4418 0
+4419 0
+4420 0
+4421 0
+4422 0
+4423 1
+4424 0
+4425 0
+4426 0
+4427 0
+4428 0
+4429 0
+4430 2
+4431 0
+4432 0
+4433 0
+4434 0
+4435 0
+4436 0
+4437 1
+4438 0
+4439 0
+4440 0
+4441 0
+4442 0
+4443 0
+4444 0
+4445 1
+4446 0
+4447 0
+4448 0
+4449 0
+4450 0
+4451 0
+4452 0
+4453 0
+4454 1
+4455 0
+4456 0
+4457 0
+4458 0
+4459 0
+4460 0
+4461 0
+4462 1
+4463 0
+4464 0
+4465 0
+4466 0
+4467 0
+4468 0
+4469 0
+4470 0
+4471 1
+4472 0
+4473 0
+4474 0
+4475 0
+4476 0
+4477 0
+4478 0
+4479 0
+4480 1
+4481 0
+4482 0
+4483 0
+4484 0
+4485 0
+4486 0
+4487 0
+4488 1
+4489 0
+4490 0
+4491 0
+4492 0
+4493 0
+4494 0
+4495 0
+4496 0
+4497 1
+4498 0
+4499 0
+4500 0
+4501 0
+4502 0
+4503 0
+4504 0
+4505 1
+4506 0
+4507 0
+4508 0
+4509 0
+4510 0
+4511 0
+4512 0
+4513 1
+4514 0
+4515 0
+4516 0
+4517 0
+4518 0
+4519 0
+4520 1
+4521 0
+4522 0
+4523 0
+4524 0
+4525 0
+4526 0
+4527 0
+4528 0
+4529 1
+4530 0
+4531 0
+4532 0
+4533 0
+4534 0
+4535 0
+4536 0
+4537 0
+4538 1
+4539 0
+4540 0
+4541 0
+4542 0
+4543 0
+4544 0
+4545 0
+4546 1
+4547 0
+4548 0
+4549 0
+4550 0
+4551 0
+4552 1
+4553 0
+4554 0
+4555 0
+4556 0
+4557 0
+4558 0
+4559 1
+4560 0
+4561 0
+4562 0
+4563 0
+4564 0
+4565 0
+4566 0
+4567 1
+4568 0
+4569 0
+4570 0
+4571 0
+4572 0
+4573 0
+4574 0
+4575 1
+4576 0
+4577 0
+4578 0
+4579 0
+4580 0
+4581 0
+4582 0
+4583 1
+4584 0
+4585 0
+4586 0
+4587 0
+4588 0
+4589 0
+4590 0
+4591 1
+4592 0
+4593 0
+4594 0
+4595 0
+4596 0
+4597 0
+4598 0
+4599 0
+4600 1
+4601 0
+4602 0
+4603 0
+4604 0
+4605 0
+4606 0
+4607 1
+4608 0
+4609 0
+4610 0
+4611 0
+4612 0
+4613 0
+4614 0
+4615 0
+4616 1
+4617 0
+4618 0
+4619 0
+4620 0
+4621 0
+4622 0
+4623 0
+4624 0
+4625 1
+4626 0
+4627 0
+4628 0
+4629 0
+4630 0
+4631 0
+4632 0
+4633 0
+4634 1
+4635 0
+4636 0
+4637 0
+4638 0
+4639 0
+4640 0
+4641 0
+4642 0
+4643 0
+4644 0
+4645 0
+4646 0
+4647 0
+4648 0
+4649 0
+4650 0
+4651 0
+4652 1
+4653 0
+4654 0
+4655 0
+4656 0
+4657 0
+4658 0
+4659 0
+4660 0
+4661 1
+4662 0
+4663 0
+4664 0
+4665 1
+4666 0
+4667 0
+4668 0
+4669 0
+4670 0
+4671 0
+4672 1
+4673 0
+4674 0
+4675 0
+4676 0
+4677 0
+4678 1
+4679 0
+4680 0
+4681 0
+4682 0
+4683 0
+4684 0
+4685 0
+4686 1
+4687 0
+4688 0
+4689 0
+4690 0
+4691 0
+4692 0
+4693 0
+4694 1
+4695 0
+4696 0
+4697 0
+4698 0
+4699 0
+4700 0
+4701 0
+4702 1
+4703 0
+4704 0
+4705 0
+4706 0
+4707 0
+4708 0
+4709 1
+4710 0
+4711 0
+4712 0
+4713 0
+4714 0
+4715 0
+4716 0
+4717 1
+4718 0
+4719 0
+4720 0
+4721 0
+4722 0
+4723 0
+4724 0
+4725 1
+4726 0
+4727 0
+4728 0
+4729 0
+4730 0
+4731 0
+4732 0
+4733 0
+4734 1
+4735 0
+4736 0
+4737 0
+4738 0
+4739 0
+4740 0
+4741 0
+4742 0
+4743 0
+4744 1
+4745 0
+4746 0
+4747 0
+4748 0
+4749 0
+4750 0
+4751 0
+4752 1
+4753 0
+4754 0
+4755 0
+4756 0
+4757 0
+4758 0
+4759 0
+4760 1
+4761 0
+4762 0
+4763 0
+4764 0
+4765 0
+4766 0
+4767 0
+4768 0
+4769 1
+4770 0
+4771 0
+4772 0
+4773 0
+4774 0
+4775 0
+4776 0
+4777 0
+4778 1
+4779 0
+4780 0
+4781 0
+4782 0
+4783 0
+4784 0
+4785 0
+4786 1
+4787 0
+4788 0
+4789 0
+4790 0
+4791 0
+4792 0
+4793 0
+4794 0
+4795 0
+4796 1
+4797 0
+4798 0
+4799 0
+4800 0
+4801 0
+4802 0
+4803 0
+4804 1
+4805 0
+4806 0
+4807 0
+4808 0
+4809 0
+4810 0
+4811 0
+4812 0
+4813 1
+4814 0
+4815 0
+4816 0
+4817 0
+4818 0
+4819 0
+4820 0
+4821 0
+4822 1
+4823 0
+4824 0
+4825 0
+4826 0
+4827 0
+4828 0
+4829 0
+4830 0
+4831 1
+4832 0
+4833 0
+4834 0
+4835 0
+4836 0
+4837 0
+4838 0
+4839 0
+4840 0
+4841 0
+4842 0
+4843 0
+4844 0
+4845 0
+4846 0
+4847 0
+4848 0
+4849 0
+4850 0
+4851 0
+4852 0
+4853 0
+4854 0
+4855 0
+4856 0
+4857 0
+4858 0
+4859 0
+4860 0
+4861 0
+4862 0
+4863 0
+4864 0
+4865 1
+4866 0
+4867 0
+4868 0
+4869 0
+4870 0
+4871 0
+4872 1
+4873 0
+4874 0
+4875 0
+4876 0
+4877 0
+4878 0
+4879 0
+4880 1
+4881 0
+4882 0
+4883 0
+4884 0
+4885 0
+4886 0
+4887 0
+4888 0
+4889 0
+4890 1
+4891 0
+4892 0
+4893 0
+4894 0
+4895 0
+4896 0
+4897 0
+4898 1
+4899 0
+4900 0
+4901 0
+4902 0
+4903 0
+4904 0
+4905 1
+4906 0
+4907 0
+4908 0
+4909 0
+4910 0
+4911 0
+4912 0
+4913 1
+4914 0
+4915 0
+4916 0
+4917 0
+4918 0
+4919 0
+4920 0
+4921 0
+4922 0
+4923 1
+4924 0
+4925 0
+4926 0
+4927 0
+4928 0
+4929 0
+4930 0
+4931 0
+4932 0
+4933 1
+4934 0
+4935 0
+4936 0
+4937 0
+4938 0
+4939 0
+4940 0
+4941 0
+4942 0
+4943 0
+4944 0
+4945 0
+4946 0
+4947 0
+4948 1
+4949 0
+4950 0
+4951 0
+4952 0
+4953 0
+4954 0
+4955 0
+4956 1
+4957 0
+4958 0
+4959 0
+4960 0
+4961 0
+4962 0
+4963 0
+4964 1
+4965 0
+4966 0
+4967 0
+4968 0
+4969 0
+4970 0
+4971 0
+4972 1
+4973 0
+4974 0
+4975 0
+4976 0
+4977 0
+4978 0
+4979 1
+4980 0
+4981 0
+4982 0
+4983 0
+4984 0
+4985 0
+4986 0
+4987 1
+4988 0
+4989 0
+4990 0
+4991 0
+4992 0
+4993 0
+4994 1
+4995 0
+4996 0
+4997 0
+4998 0
+4999 0
+5000 0
+5001 0
+5002 0
+5003 1
+5004 0
+5005 0
+5006 0
+5007 0
+5008 0
+5009 0
+5010 0
+5011 0
+5012 1
+5013 0
+5014 0
+5015 0
+5016 0
+5017 0
+5018 0
+5019 0
+5020 1
+5021 0
+5022 0
+5023 0
+5024 0
+5025 0
+5026 0
+5027 0
+5028 0
+5029 1
+5030 0
+5031 0
+5032 0
+5033 0
+5034 0
+5035 0
+5036 0
+5037 1
+5038 0
+5039 0
+5040 0
+5041 0
+5042 0
+5043 0
+5044 0
+5045 1
+5046 0
+5047 0
+5048 0
+5049 0
+5050 0
+5051 0
+5052 0
+5053 1
+5054 0
+5055 0
+5056 0
+5057 0
+5058 0
+5059 0
+5060 0
+5061 0
+5062 1
+5063 0
+5064 0
+5065 0
+5066 0
+5067 0
+5068 0
+5069 0
+5070 0
+5071 0
+5072 0
+5073 0
+5074 0
+5075 0
+5076 0
+5077 0
+5078 0
+5079 1
+5080 0
+5081 0
+5082 0
+5083 0
+5084 0
+5085 0
+5086 1
+5087 0
+5088 0
+5089 0
+5090 0
+5091 0
+5092 0
+5093 0
+5094 1
+5095 0
+5096 0
+5097 0
+5098 0
+5099 0
+5100 0
+5101 0
+5102 0
+5103 1
+5104 0
+5105 0
+5106 0
+5107 0
+5108 0
+5109 0
+5110 1
+5111 0
+5112 0
+5113 0
+5114 0
+5115 0
+5116 0
+5117 0
+5118 1
+5119 0
+5120 0
+5121 0
+5122 0
+5123 0
+5124 0
+5125 0
+5126 0
+5127 1
+5128 0
+5129 0
+5130 0
+5131 0
+5132 0
+5133 0
+5134 1
+5135 0
+5136 0
+5137 0
+5138 0
+5139 0
+5140 0
+5141 1
+5142 0
+5143 0
+5144 0
+5145 0
+5146 0
+5147 0
+5148 0
+5149 1
+5150 0
+5151 0
+5152 0
+5153 0
+5154 0
+5155 0
+5156 0
+5157 0
+5158 1
+5159 0
+5160 0
+5161 0
+5162 0
+5163 0
+5164 0
+5165 0
+5166 0
+5167 1
+5168 0
+5169 0
+5170 0
+5171 0
+5172 0
+5173 0
+5174 0
+5175 1
+5176 0
+5177 0
+5178 0
+5179 0
+5180 0
+5181 0
+5182 1
+5183 0
+5184 0
+5185 0
+5186 0
+5187 0
+5188 0
+5189 0
+5190 1
+5191 0
+5192 0
+5193 0
+5194 0
+5195 0
+5196 0
+5197 0
+5198 0
+5199 1
+5200 0
+5201 0
+5202 0
+5203 0
+5204 0
+5205 0
+5206 0
+5207 0
+5208 1
+5209 0
+5210 0
+5211 0
+5212 0
+5213 0
+5214 0
+5215 0
+5216 0
+5217 0
+5218 1
+5219 0
+5220 0
+5221 0
+5222 0
+5223 0
+5224 0
+5225 0
+5226 1
+5227 0
+5228 0
+5229 0
+5230 0
+5231 0
+5232 0
+5233 0
+5234 1
+5235 0
+5236 0
+5237 0
+5238 0
+5239 0
+5240 0
+5241 0
+5242 1
+5243 0
+5244 0
+5245 0
+5246 0
+5247 0
+5248 0
+5249 0
+5250 0
+5251 1
+5252 0
+5253 0
+5254 0
+5255 0
+5256 0
+5257 0
+5258 0
+5259 0
+5260 0
+5261 0
+5262 0
+5263 0
+5264 0
+5265 0
+5266 0
+5267 0
+5268 1
+5269 0
+5270 0
+5271 0
+5272 0
+5273 0
+5274 0
+5275 0
+5276 1
+5277 0
+5278 0
+5279 0
+5280 0
+5281 0
+5282 0
+5283 1
+5284 0
+5285 0
+5286 0
+5287 0
+5288 0
+5289 0
+5290 0
+5291 0
+5292 0
+5293 1
+5294 0
+5295 0
+5296 0
+5297 0
+5298 0
+5299 0
+5300 0
+5301 1
+5302 0
+5303 0
+5304 0
+5305 0
+5306 0
+5307 0
+5308 0
+5309 0
+5310 1
+5311 0
+5312 0
+5313 0
+5314 0
+5315 0
+5316 0
+5317 0
+5318 1
+5319 0
+5320 0
+5321 0
+5322 0
+5323 0
+5324 0
+5325 1
+5326 0
+5327 0
+5328 0
+5329 0
+5330 0
+5331 0
+5332 0
+5333 0
+5334 0
+5335 0
+5336 0
+5337 0
+5338 0
+5339 0
+5340 0
+5341 0
+5342 1
+5343 0
+5344 0
+5345 0
+5346 0
+5347 0
+5348 0
+5349 1
+5350 0
+5351 0
+5352 0
+5353 0
+5354 0
+5355 0
+5356 0
+5357 0
+5358 1
+5359 0
+5360 0
+5361 0
+5362 0
+5363 0
+5364 0
+5365 0
+5366 1
+5367 0
+5368 0
+5369 0
+5370 0
+5371 0
+5372 0
+5373 1
+5374 0
+5375 0
+5376 0
+5377 0
+5378 0
+5379 0
+5380 0
+5381 1
+5382 0
+5383 0
+5384 0
+5385 0
+5386 0
+5387 0
+5388 0
+5389 0
+5390 1
+5391 0
+5392 0
+5393 0
+5394 0
+5395 0
+5396 0
+5397 0
+5398 1
+5399 0
+5400 0
+5401 0
+5402 0
+5403 0
+5404 0
+5405 0
+5406 1
+5407 0
+5408 0
+5409 0
+5410 0
+5411 0
+5412 0
+5413 0
+5414 1
+5415 0
+5416 0
+5417 0
+5418 0
+5419 0
+5420 0
+5421 0
+5422 1
+5423 0
+5424 0
+5425 0
+5426 0
+5427 0
+5428 0
+5429 0
+5430 0
+5431 0
+5432 0
+5433 0
+5434 0
+5435 0
+5436 0
+5437 0
+5438 1
+5439 0
+5440 0
+5441 0
+5442 0
+5443 0
+5444 0
+5445 0
+5446 0
+5447 1
+5448 0
+5449 0
+5450 0
+5451 0
+5452 0
+5453 0
+5454 0
+5455 0
+5456 1
+5457 0
+5458 0
+5459 0
+5460 0
+5461 0
+5462 0
+5463 0
+5464 1
+5465 0
+5466 0
+5467 0
+5468 0
+5469 0
+5470 0
+5471 0
+5472 1
+5473 0
+5474 0
+5475 0
+5476 0
+5477 0
+5478 0
+5479 0
+5480 0
+5481 1
+5482 0
+5483 0
+5484 0
+5485 0
+5486 0
+5487 0
+5488 0
+5489 1
+5490 0
+5491 0
+5492 0
+5493 0
+5494 0
+5495 0
+5496 0
+5497 0
+5498 1
+5499 0
+5500 0
+5501 0
+5502 0
+5503 0
+5504 0
+5505 0
+5506 1
+5507 0
+5508 0
+5509 0
+5510 0
+5511 0
+5512 0
+5513 0
+5514 1
+5515 0
+5516 0
+5517 0
+5518 0
+5519 0
+5520 0
+5521 0
+5522 0
+5523 1
+5524 0
+5525 0
+5526 0
+5527 0
+5528 0
+5529 0
+5530 0
+5531 1
+5532 0
+5533 0
+5534 0
+5535 0
+5536 0
+5537 0
+5538 0
+5539 0
+5540 1
+5541 0
+5542 0
+5543 0
+5544 0
+5545 0
+5546 0
+5547 0
+5548 0
+5549 1
+5550 0
+5551 0
+5552 0
+5553 0
+5554 0
+5555 0
+5556 0
+5557 0
+5558 0
+5559 0
+5560 0
+5561 0
+5562 0
+5563 0
+5564 0
+5565 1
+5566 0
+5567 0
+5568 0
+5569 0
+5570 0
+5571 1
+5572 0
+5573 0
+5574 0
+5575 0
+5576 0
+5577 0
+5578 0
+5579 1
+5580 0
+5581 0
+5582 0
+5583 0
+5584 0
+5585 0
+5586 0
+5587 0
+5588 1
+5589 0
+5590 0
+5591 0
+5592 0
+5593 0
+5594 0
+5595 0
+5596 1
+5597 0
+5598 0
+5599 0
+5600 0
+5601 0
+5602 0
+5603 0
+5604 0
+5605 0
+5606 1
+5607 0
+5608 0
+5609 0
+5610 0
+5611 0
+5612 0
+5613 0
+5614 1
+5615 0
+5616 0
+5617 0
+5618 0
+5619 0
+5620 0
+5621 0
+5622 1
+5623 0
+5624 0
+5625 0
+5626 0
+5627 0
+5628 0
+5629 0
+5630 0
+5631 0
+5632 0
+5633 0
+5634 0
+5635 0
+5636 0
+5637 0
+5638 1
+5639 0
+5640 0
+5641 0
+5642 0
+5643 0
+5644 0
+5645 0
+5646 0
+5647 1
+5648 0
+5649 0
+5650 0
+5651 0
+5652 0
+5653 0
+5654 1
+5655 0
+5656 0
+5657 0
+5658 0
+5659 0
+5660 0
+5661 0
+5662 1
+5663 0
+5664 0
+5665 0
+5666 0
+5667 0
+5668 0
+5669 0
+5670 1
+5671 0
+5672 0
+5673 0
+5674 0
+5675 0
+5676 0
+5677 0
+5678 0
+5679 1
+5680 2
+5681 1
+5682 0
+5683 0
+5684 0
+5685 0
+5686 0
+5687 1
+5688 0
+5689 0
+5690 0
+5691 0
+5692 1
+5693 0
+5694 0
+5695 0
+5696 0
+5697 1
+5698 0
+5699 0
+5700 0
+5701 0
+5702 0
+5703 0
+5704 0
+5705 1
+5706 0
+5707 0
+5708 0
+5709 0
+5710 0
+5711 1
+5712 0
+5713 0
+5714 0
+5715 0
+5716 0
+5717 0
+5718 0
+5719 0
+5720 0
+5721 0
+5722 0
+5723 0
+5724 0
+5725 0
+5726 1
+5727 0
+5728 0
+5729 0
+5730 0
+5731 0
+5732 0
+5733 0
+5734 1
+5735 0
+5736 0
+5737 0
+5738 0
+5739 0
+5740 0
+5741 0
+5742 1
+5743 0
+5744 0
+5745 0
+5746 0
+5747 0
+5748 0
+5749 0
+5750 0
+5751 1
+5752 0
+5753 0
+5754 0
+5755 0
+5756 0
+5757 0
+5758 0
+5759 1
+5760 0
+5761 0
+5762 0
+5763 0
+5764 0
+5765 0
+5766 1
+5767 0
+5768 0
+5769 0
+5770 0
+5771 0
+5772 0
+5773 0
+5774 1
+5775 0
+5776 0
+5777 0
+5778 0
+5779 0
+5780 0
+5781 0
+5782 1
+5783 0
+5784 0
+5785 0
+5786 0
+5787 0
+5788 0
+5789 0
+5790 0
+5791 1
+5792 0
+5793 0
+5794 0
+5795 0
+5796 0
+5797 0
+5798 0
+5799 0
+5800 1
+5801 0
+5802 0
+5803 0
+5804 0
+5805 0
+5806 0
+5807 0
+5808 0
+5809 1
+5810 0
+5811 0
+5812 0
+5813 0
+5814 0
+5815 0
+5816 1
+5817 0
+5818 0
+5819 0
+5820 0
+5821 0
+5822 0
+5823 0
+5824 0
+5825 1
+5826 0
+5827 0
+5828 0
+5829 0
+5830 0
+5831 0
+5832 0
+5833 0
+5834 1
+5835 0
+5836 0
+5837 0
+5838 0
+5839 0
+5840 0
+5841 0
+5842 1
+5843 0
+5844 0
+5845 0
+5846 0
+5847 0
+5848 0
+5849 0
+5850 1
+5851 0
+5852 0
+5853 0
+5854 0
+5855 0
+5856 0
+5857 0
+5858 1
+5859 0
+5860 0
+5861 0
+5862 0
+5863 0
+5864 0
+5865 0
+5866 0
+5867 1
+5868 0
+5869 0
+5870 0
+5871 0
+5872 0
+5873 0
+5874 0
+5875 1
+5876 0
+5877 0
+5878 0
+5879 0
+5880 0
+5881 0
+5882 0
+5883 0
+5884 1
+5885 0
+5886 0
+5887 0
+5888 0
+5889 0
+5890 0
+5891 1
+5892 0
+5893 0
+5894 0
+5895 0
+5896 0
+5897 0
+5898 0
+5899 0
+5900 1
+5901 0
+5902 0
+5903 0
+5904 0
+5905 0
+5906 0
+5907 0
+5908 0
+5909 1
+5910 0
+5911 0
+5912 0
+5913 0
+5914 0
+5915 0
+5916 0
+5917 1
+5918 0
+5919 0
+5920 0
+5921 0
+5922 0
+5923 0
+5924 0
+5925 0
+5926 1
+5927 0
+5928 0
+5929 0
+5930 0
+5931 0
+5932 0
+5933 0
+5934 1
+5935 0
+5936 0
+5937 0
+5938 0
+5939 0
+5940 0
+5941 0
+5942 0
+5943 0
+5944 1
+5945 0
+5946 0
+5947 0
+5948 0
+5949 0
+5950 0
+5951 0
+5952 0
+5953 0
+5954 0
+5955 0
+5956 0
+5957 0
+5958 0
+5959 0
+5960 0
+5961 0
+5962 0
+5963 0
+5964 0
+5965 0
+5966 0
+5967 0
+5968 0
+5969 0
+5970 1
+5971 0
+5972 0
+5973 0
+5974 0
+5975 0
+5976 0
+5977 0
+5978 1
+5979 0
+5980 0
+5981 0
+5982 0
+5983 0
+5984 0
+5985 0
+5986 0
+5987 1
+5988 0
+5989 0
+5990 0
+5991 0
+5992 0
+5993 0
+5994 0
+5995 0
+5996 1
+5997 0
+5998 0
+5999 0
+6000 0
+6001 0
+6002 0
+6003 0
+6004 0
+6005 0
+6006 1
+6007 0
+6008 0
+6009 0
+6010 0
+6011 0
+6012 0
+6013 0
+6014 1
+6015 0
+6016 0
+6017 0
+6018 0
+6019 0
+6020 0
+6021 0
+6022 0
+6023 1
+6024 0
+6025 0
+6026 0
+6027 0
+6028 0
+6029 0
+6030 0
+6031 1
+6032 0
+6033 0
+6034 0
+6035 0
+6036 0
+6037 0
+6038 1
+6039 0
+6040 0
+6041 0
+6042 0
+6043 0
+6044 0
+6045 0
+6046 0
+6047 0
+6048 1
+6049 0
+6050 0
+6051 0
+6052 0
+6053 0
+6054 0
+6055 1
+6056 0
+6057 0
+6058 0
+6059 0
+6060 0
+6061 1
+6062 0
+6063 0
+6064 0
+6065 0
+6066 0
+6067 0
+6068 1
+6069 0
+6070 0
+6071 0
+6072 0
+6073 0
+6074 0
+6075 0
+6076 1
+6077 0
+6078 0
+6079 0
+6080 0
+6081 0
+6082 0
+6083 0
+6084 0
+6085 1
+6086 0
+6087 0
+6088 0
+6089 0
+6090 0
+6091 0
+6092 0
+6093 0
+6094 0
+6095 1
+6096 0
+6097 0
+6098 0
+6099 0
+6100 0
+6101 0
+6102 0
+6103 0
+6104 1
+6105 0
+6106 0
+6107 0
+6108 0
+6109 0
+6110 0
+6111 0
+6112 1
+6113 0
+6114 0
+6115 0
+6116 0
+6117 0
+6118 0
+6119 0
+6120 0
+6121 0
+6122 0
+6123 0
+6124 0
+6125 1
+6126 0
+6127 0
+6128 0
+6129 0
+6130 0
+6131 0
+6132 0
+6133 0
+6134 0
+6135 0
+6136 0
+6137 0
+6138 0
+6139 0
+6140 0
+6141 0
+6142 1
+6143 0
+6144 0
+6145 0
+6146 0
+6147 0
+6148 0
+6149 0
+6150 1
+6151 0
+6152 0
+6153 0
+6154 0
+6155 0
+6156 0
+6157 0
+6158 0
+6159 1
+6160 0
+6161 0
+6162 0
+6163 0
+6164 0
+6165 0
+6166 0
+6167 1
+6168 0
+6169 0
+6170 0
+6171 0
+6172 0
+6173 0
+6174 0
+6175 1
+6176 0
+6177 0
+6178 0
+6179 0
+6180 0
+6181 0
+6182 0
+6183 1
+6184 0
+6185 0
+6186 0
+6187 0
+6188 0
+6189 0
+6190 0
+6191 0
+6192 1
+6193 0
+6194 0
+6195 0
+6196 0
+6197 0
+6198 0
+6199 0
+6200 0
+6201 1
+6202 0
+6203 0
+6204 0
+6205 0
+6206 0
+6207 0
+6208 0
+6209 0
+6210 1
+6211 0
+6212 0
+6213 0
+6214 0
+6215 0
+6216 0
+6217 1
+6218 0
+6219 0
+6220 0
+6221 0
+6222 0
+6223 0
+6224 0
+6225 1
+6226 0
+6227 0
+6228 0
+6229 0
+6230 0
+6231 0
+6232 0
+6233 0
+6234 1
+6235 0
+6236 0
+6237 0
+6238 0
+6239 0
+6240 0
+6241 1
+6242 0
+6243 0
+6244 0
+6245 0
+6246 0
+6247 0
+6248 0
+6249 0
+6250 1
+6251 0
+6252 0
+6253 0
+6254 0
+6255 0
+6256 0
+6257 0
+6258 1
+6259 0
+6260 0
+6261 0
+6262 0
+6263 0
+6264 0
+6265 0
+6266 0
+6267 0
+6268 1
+6269 0
+6270 0
+6271 0
+6272 0
+6273 0
+6274 0
+6275 0
+6276 0
+6277 1
+6278 0
+6279 0
+6280 0
+6281 0
+6282 0
+6283 0
+6284 0
+6285 1
+6286 0
+6287 0
+6288 0
+6289 0
+6290 0
+6291 0
+6292 1
+6293 0
+6294 0
+6295 0
+6296 0
+6297 0
+6298 0
+6299 1
+6300 0
+6301 0
+6302 0
+6303 0
+6304 0
+6305 0
+6306 0
+6307 1
+6308 0
+6309 0
+6310 0
+6311 0
+6312 0
+6313 0
+6314 0
+6315 1
+6316 0
+6317 0
+6318 0
+6319 0
+6320 0
+6321 0
+6322 0
+6323 0
+6324 1
+6325 0
+6326 0
+6327 0
+6328 0
+6329 0
+6330 0
+6331 0
+6332 1
+6333 0
+6334 0
+6335 0
+6336 0
+6337 0
+6338 0
+6339 0
+6340 0
+6341 1
+6342 0
+6343 0
+6344 0
+6345 0
+6346 0
+6347 0
+6348 0
+6349 0
+6350 1
+6351 0
+6352 0
+6353 0
+6354 0
+6355 0
+6356 0
+6357 0
+6358 1
+6359 0
+6360 0
+6361 0
+6362 0
+6363 0
+6364 0
+6365 0
+6366 1
+6367 0
+6368 0
+6369 0
+6370 0
+6371 0
+6372 0
+6373 0
+6374 0
+6375 1
+6376 0
+6377 0
+6378 0
+6379 0
+6380 0
+6381 0
+6382 0
+6383 1
+6384 0
+6385 0
+6386 0
+6387 0
+6388 0
+6389 0
+6390 0
+6391 4
+6392 0
+6393 1
+6394 0
+6395 0
+6396 0
+6397 1
+6398 0
+6399 0
+6400 0
+6401 0
+6402 1
+6403 0
+6404 0
+6405 0
+6406 0
+6407 1
+6408 0
+6409 0
+6410 0
+6411 0
+6412 1
+6413 0
+6414 0
+6415 0
+6416 0
+6417 0
+6418 1
+6419 0
+6420 0
+6421 0
+6422 0
+6423 0
+6424 0
+6425 1
+6426 0
+6427 0
+6428 0
+6429 0
+6430 0
+6431 0
+6432 0
+6433 0
+6434 1
+6435 0
+6436 0
+6437 0
+6438 0
+6439 0
+6440 0
+6441 0
+6442 0
+6443 1
+6444 0
+6445 0
+6446 0
+6447 0
+6448 0
+6449 0
+6450 0
+6451 0
+6452 1
+6453 0
+6454 0
+6455 0
+6456 0
+6457 0
+6458 0
+6459 0
+6460 0
+6461 0
+6462 0
+6463 1
+6464 0
+6465 0
+6466 0
+6467 0
+6468 0
+6469 0
+6470 0
+6471 0
+6472 1
+6473 0
+6474 0
+6475 0
+6476 0
+6477 0
+6478 0
+6479 0
+6480 0
+6481 0
+6482 1
+6483 0
+6484 0
+6485 0
+6486 0
+6487 0
+6488 0
+6489 0
+6490 0
+6491 0
+6492 1
+6493 0
+6494 0
+6495 0
+6496 0
+6497 0
+6498 0
+6499 0
+6500 0
+6501 0
+6502 0
+6503 0
+6504 0
+6505 0
+6506 0
+6507 0
+6508 0
+6509 0
+6510 0
+6511 0
+6512 1
+6513 0
+6514 0
+6515 0
+6516 0
+6517 0
+6518 0
+6519 0
+6520 0
+6521 1
+6522 0
+6523 0
+6524 0
+6525 0
+6526 0
+6527 0
+6528 0
+6529 0
+6530 0
+6531 1
+6532 0
+6533 0
+6534 0
+6535 0
+6536 0
+6537 0
+6538 0
+6539 0
+6540 1
+6541 0
+6542 0
+6543 0
+6544 0
+6545 0
+6546 0
+6547 0
+6548 0
+6549 0
+6550 1
+6551 0
+6552 0
+6553 0
+6554 0
+6555 0
+6556 0
+6557 0
+6558 0
+6559 0
+6560 1
+6561 0
+6562 0
+6563 0
+6564 0
+6565 0
+6566 0
+6567 0
+6568 0
+6569 1
+6570 0
+6571 0
+6572 0
+6573 0
+6574 0
+6575 0
+6576 0
+6577 1
+6578 0
+6579 0
+6580 0
+6581 0
+6582 0
+6583 0
+6584 0
+6585 0
+6586 1
+6587 0
+6588 0
+6589 0
+6590 0
+6591 0
+6592 0
+6593 0
+6594 0
+6595 1
+6596 0
+6597 0
+6598 0
+6599 0
+6600 0
+6601 0
+6602 0
+6603 0
+6604 1
+6605 0
+6606 0
+6607 0
+6608 0
+6609 0
+6610 0
+6611 0
+6612 0
+6613 1
+6614 0
+6615 0
+6616 0
+6617 0
+6618 0
+6619 0
+6620 0
+6621 0
+6622 1
+6623 0
+6624 0
+6625 0
+6626 0
+6627 0
+6628 0
+6629 0
+6630 0
+6631 1
+6632 0
+6633 0
+6634 0
+6635 0
+6636 0
+6637 0
+6638 0
+6639 0
+6640 1
+6641 0
+6642 0
+6643 0
+6644 0
+6645 0
+6646 0
+6647 0
+6648 0
+6649 0
+6650 1
+6651 0
+6652 0
+6653 0
+6654 0
+6655 0
+6656 0
+6657 0
+6658 0
+6659 0
+6660 1
+6661 0
+6662 0
+6663 0
+6664 0
+6665 0
+6666 0
+6667 0
+6668 0
+6669 1
+6670 0
+6671 0
+6672 0
+6673 0
+6674 0
+6675 0
+6676 0
+6677 0
+6678 0
+6679 1
+6680 0
+6681 0
+6682 0
+6683 0
+6684 0
+6685 0
+6686 0
+6687 0
+6688 1
+6689 0
+6690 0
+6691 0
+6692 0
+6693 0
+6694 0
+6695 0
+6696 0
+6697 0
+6698 1
+6699 0
+6700 0
+6701 0
+6702 0
+6703 0
+6704 0
+6705 0
+6706 1
+6707 0
+6708 0
+6709 0
+6710 0
+6711 0
+6712 0
+6713 0
+6714 0
+6715 0
+6716 1
+6717 0
+6718 0
+6719 0
+6720 0
+6721 0
+6722 0
+6723 0
+6724 0
+6725 0
+6726 1
+6727 0
+6728 0
+6729 0
+6730 0
+6731 0
+6732 0
+6733 0
+6734 0
+6735 0
+6736 0
+6737 1
+6738 0
+6739 0
+6740 0
+6741 0
+6742 0
+6743 0
+6744 0
+6745 0
+6746 1
+6747 0
+6748 0
+6749 0
+6750 0
+6751 0
+6752 0
+6753 0
+6754 0
+6755 0
+6756 1
+6757 0
+6758 0
+6759 0
+6760 0
+6761 0
+6762 0
+6763 0
+6764 0
+6765 0
+6766 1
+6767 0
+6768 0
+6769 0
+6770 0
+6771 0
+6772 0
+6773 0
+6774 0
+6775 1
+6776 0
+6777 0
+6778 0
+6779 0
+6780 0
+6781 0
+6782 0
+6783 0
+6784 1
+6785 0
+6786 0
+6787 0
+6788 0
+6789 0
+6790 0
+6791 0
+6792 0
+6793 0
+6794 1
+6795 0
+6796 0
+6797 0
+6798 0
+6799 0
+6800 0
+6801 0
+6802 0
+6803 1
+6804 0
+6805 0
+6806 0
+6807 0
+6808 0
+6809 0
+6810 0
+6811 0
+6812 0
+6813 1
+6814 0
+6815 0
+6816 0
+6817 0
+6818 0
+6819 0
+6820 0
+6821 0
+6822 0
+6823 0
+6824 1
+6825 0
+6826 0
+6827 0
+6828 0
+6829 0
+6830 0
+6831 0
+6832 1
+6833 0
+6834 0
+6835 0
+6836 0
+6837 0
+6838 0
+6839 0
+6840 0
+6841 0
+6842 1
+6843 0
+6844 0
+6845 0
+6846 0
+6847 0
+6848 0
+6849 0
+6850 0
+6851 1
+6852 0
+6853 0
+6854 0
+6855 0
+6856 0
+6857 0
+6858 0
+6859 0
+6860 0
+6861 0
+6862 1
+6863 0
+6864 0
+6865 0
+6866 0
+6867 0
+6868 0
+6869 0
+6870 0
+6871 1
+6872 0
+6873 0
+6874 0
+6875 0
+6876 0
+6877 0
+6878 0
+6879 1
+6880 0
+6881 0
+6882 0
+6883 0
+6884 0
+6885 0
+6886 1
+6887 0
+6888 0
+6889 0
+6890 0
+6891 0
+6892 0
+6893 0
+6894 0
+6895 1
+6896 0
+6897 0
+6898 0
+6899 0
+6900 0
+6901 0
+6902 0
+6903 0
+6904 0
+6905 0
+6906 0
+6907 0
+6908 0
+6909 0
+6910 0
+6911 0
+6912 0
+6913 0
+6914 1
+6915 0
+6916 0
+6917 0
+6918 0
+6919 0
+6920 0
+6921 0
+6922 0
+6923 1
+6924 0
+6925 0
+6926 0
+6927 0
+6928 0
+6929 0
+6930 0
+6931 0
+6932 0
+6933 0
+6934 1
+6935 0
+6936 0
+6937 0
+6938 0
+6939 0
+6940 0
+6941 0
+6942 0
+6943 0
+6944 1
+6945 0
+6946 0
+6947 0
+6948 0
+6949 0
+6950 0
+6951 0
+6952 0
+6953 0
+6954 1
+6955 0
+6956 0
+6957 0
+6958 0
+6959 0
+6960 0
+6961 0
+6962 0
+6963 0
+6964 1
+6965 0
+6966 0
+6967 0
+6968 0
+6969 0
+6970 0
+6971 0
+6972 0
+6973 0
+6974 1
+6975 0
+6976 0
+6977 0
+6978 0
+6979 0
+6980 0
+6981 0
+6982 0
+6983 1
+6984 0
+6985 0
+6986 0
+6987 0
+6988 0
+6989 0
+6990 0
+6991 0
+6992 1
+6993 0
+6994 0
+6995 0
+6996 0
+6997 0
+6998 0
+6999 0
+7000 0
+7001 1
+7002 0
+7003 0
+7004 0
+7005 0
+7006 0
+7007 0
+7008 0
+7009 0
+7010 1
+7011 0
+7012 0
+7013 0
+7014 0
+7015 0
+7016 0
+7017 0
+7018 0
+7019 0
+7020 1
+7021 0
+7022 0
+7023 0
+7024 0
+7025 0
+7026 0
+7027 0
+7028 0
+7029 0
+7030 1
+7031 0
+7032 0
+7033 0
+7034 0
+7035 0
+7036 0
+7037 0
+7038 0
+7039 1
+7040 0
+7041 0
+7042 0
+7043 0
+7044 0
+7045 0
+7046 0
+7047 0
+7048 1
+7049 0
+7050 0
+7051 0
+7052 0
+7053 0
+7054 0
+7055 0
+7056 0
+7057 0
+7058 0
+7059 1
+7060 0
+7061 0
+7062 0
+7063 0
+7064 0
+7065 0
+7066 0
+7067 0
+7068 0
+7069 1
+7070 0
+7071 0
+7072 0
+7073 0
+7074 0
+7075 0
+7076 0
+7077 0
+7078 0
+7079 1
+7080 0
+7081 0
+7082 0
+7083 0
+7084 0
+7085 0
+7086 0
+7087 1
+7088 0
+7089 0
+7090 0
+7091 0
+7092 0
+7093 0
+7094 0
+7095 0
+7096 0
+7097 1
+7098 0
+7099 0
+7100 0
+7101 0
+7102 0
+7103 0
+7104 0
+7105 1
+7106 0
+7107 0
+7108 0
+7109 0
+7110 0
+7111 0
+7112 0
+7113 0
+7114 1
+7115 0
+7116 0
+7117 0
+7118 0
+7119 0
+7120 0
+7121 0
+7122 0
+7123 0
+7124 1
+7125 0
+7126 0
+7127 0
+7128 0
+7129 0
+7130 0
+7131 0
+7132 0
+7133 0
+7134 1
+7135 0
+7136 0
+7137 0
+7138 0
+7139 0
+7140 0
+7141 0
+7142 0
+7143 1
+7144 0
+7145 0
+7146 0
+7147 0
+7148 0
+7149 0
+7150 0
+7151 0
+7152 1
+7153 0
+7154 0
+7155 0
+7156 0
+7157 0
+7158 0
+7159 0
+7160 0
+7161 0
+7162 1
+7163 0
+7164 0
+7165 0
+7166 0
+7167 0
+7168 0
+7169 0
+7170 0
+7171 0
+7172 1
+7173 0
+7174 0
+7175 0
+7176 0
+7177 0
+7178 0
+7179 0
+7180 0
+7181 0
+7182 1
+7183 0
+7184 0
+7185 0
+7186 0
+7187 0
+7188 0
+7189 0
+7190 0
+7191 0
+7192 0
+7193 1
+7194 0
+7195 0
+7196 0
+7197 0
+7198 0
+7199 0
+7200 0
+7201 0
+7202 0
+7203 1
+7204 0
+7205 0
+7206 0
+7207 0
+7208 0
+7209 0
+7210 0
+7211 0
+7212 0
+7213 0
+7214 0
+7215 0
+7216 0
+7217 0
+7218 0
+7219 0
+7220 0
+7221 0
+7222 1
+7223 0
+7224 0
+7225 0
+7226 0
+7227 0
+7228 0
+7229 0
+7230 0
+7231 0
+7232 1
+7233 0
+7234 0
+7235 0
+7236 0
+7237 0
+7238 0
+7239 0
+7240 0
+7241 0
+7242 0
+7243 1
+7244 0
+7245 0
+7246 0
+7247 0
+7248 0
+7249 0
+7250 0
+7251 0
+7252 0
+7253 1
+7254 0
+7255 0
+7256 0
+7257 0
+7258 0
+7259 0
+7260 0
+7261 0
+7262 0
+7263 0
+7264 1
+7265 0
+7266 0
+7267 0
+7268 0
+7269 0
+7270 0
+7271 0
+7272 0
+7273 0
+7274 1
+7275 0
+7276 0
+7277 0
+7278 0
+7279 0
+7280 0
+7281 0
+7282 0
+7283 0
+7284 0
+7285 1
+7286 0
+7287 0
+7288 0
+7289 0
+7290 0
+7291 0
+7292 0
+7293 0
+7294 0
+7295 0
+7296 0
+7297 0
+7298 0
+7299 0
+7300 0
+7301 0
+7302 0
+7303 0
+7304 1
+7305 0
+7306 0
+7307 0
+7308 0
+7309 0
+7310 0
+7311 0
+7312 0
+7313 0
+7314 0
+7315 1
+7316 0
+7317 0
+7318 0
+7319 0
+7320 0
+7321 0
+7322 0
+7323 0
+7324 1
+7325 0
+7326 0
+7327 0
+7328 0
+7329 0
+7330 0
+7331 0
+7332 0
+7333 1
+7334 0
+7335 0
+7336 0
+7337 0
+7338 0
+7339 0
+7340 0
+7341 0
+7342 1
+7343 0
+7344 0
+7345 0
+7346 0
+7347 0
+7348 0
+7349 0
+7350 0
+7351 0
+7352 1
+7353 0
+7354 0
+7355 0
+7356 0
+7357 0
+7358 0
+7359 0
+7360 0
+7361 0
+7362 0
+7363 1
+7364 0
+7365 0
+7366 0
+7367 0
+7368 0
+7369 0
+7370 0
+7371 0
+7372 1
+7373 0
+7374 0
+7375 0
+7376 0
+7377 0
+7378 0
+7379 0
+7380 0
+7381 0
+7382 1
+7383 0
+7384 0
+7385 0
+7386 0
+7387 0
+7388 0
+7389 0
+7390 0
+7391 1
+7392 0
+7393 0
+7394 0
+7395 0
+7396 0
+7397 0
+7398 0
+7399 0
+7400 0
+7401 1
+7402 0
+7403 0
+7404 0
+7405 0
+7406 0
+7407 0
+7408 0
+7409 0
+7410 0
+7411 0
+7412 1
+7413 0
+7414 0
+7415 0
+7416 0
+7417 0
+7418 0
+7419 0
+7420 0
+7421 0
+7422 1
+7423 0
+7424 0
+7425 0
+7426 0
+7427 0
+7428 0
+7429 0
+7430 0
+7431 0
+7432 1
+7433 0
+7434 0
+7435 0
+7436 0
+7437 0
+7438 0
+7439 0
+7440 0
+7441 1
+7442 0
+7443 0
+7444 0
+7445 0
+7446 0
+7447 0
+7448 0
+7449 1
+7450 0
+7451 0
+7452 0
+7453 0
+7454 0
+7455 0
+7456 0
+7457 0
+7458 0
+7459 0
+7460 1
+7461 0
+7462 0
+7463 0
+7464 0
+7465 0
+7466 0
+7467 0
+7468 0
+7469 1
+7470 0
+7471 0
+7472 0
+7473 0
+7474 0
+7475 0
+7476 0
+7477 0
+7478 1
+7479 0
+7480 0
+7481 0
+7482 0
+7483 0
+7484 0
+7485 0
+7486 0
+7487 1
+7488 0
+7489 0
+7490 0
+7491 0
+7492 0
+7493 0
+7494 0
+7495 0
+7496 0
+7497 1
+7498 0
+7499 0
+7500 0
+7501 0
+7502 0
+7503 0
+7504 0
+7505 0
+7506 0
+7507 0
+7508 1
+7509 0
+7510 0
+7511 0
+7512 0
+7513 0
+7514 0
+7515 0
+7516 0
+7517 0
+7518 1
+7519 0
+7520 0
+7521 0
+7522 0
+7523 0
+7524 0
+7525 0
+7526 0
+7527 0
+7528 0
+7529 0
+7530 0
+7531 0
+7532 0
+7533 0
+7534 0
+7535 0
+7536 0
+7537 0
+7538 0
+7539 1
+7540 0
+7541 0
+7542 0
+7543 0
+7544 0
+7545 0
+7546 0
+7547 0
+7548 0
+7549 2
+7550 0
+7551 0
+7552 0
+7553 0
+7554 0
+7555 0
+7556 0
+7557 1
+7558 0
+7559 0
+7560 0
+7561 0
+7562 0
+7563 0
+7564 0
+7565 0
+7566 0
+7567 0
+7568 1
+7569 0
+7570 0
+7571 0
+7572 0
+7573 0
+7574 0
+7575 0
+7576 0
+7577 0
+7578 0
+7579 0
+7580 0
+7581 0
+7582 0
+7583 0
+7584 0
+7585 0
+7586 0
+7587 0
+7588 1
+7589 0
+7590 0
+7591 0
+7592 0
+7593 0
+7594 0
+7595 0
+7596 0
+7597 0
+7598 0
+7599 1
+7600 0
+7601 0
+7602 0
+7603 0
+7604 0
+7605 0
+7606 0
+7607 0
+7608 0
+7609 0
+7610 1
+7611 0
+7612 0
+7613 0
+7614 0
+7615 0
+7616 0
+7617 0
+7618 0
+7619 0
+7620 0
+7621 1
+7622 0
+7623 0
+7624 0
+7625 0
+7626 0
+7627 1
+7628 0
+7629 0
+7630 0
+7631 0
+7632 0
+7633 0
+7634 1
+7635 0
+7636 0
+7637 0
+7638 0
+7639 0
+7640 0
+7641 1
+7642 0
+7643 0
+7644 0
+7645 0
+7646 0
+7647 0
+7648 0
+7649 1
+7650 0
+7651 0
+7652 0
+7653 0
+7654 0
+7655 0
+7656 0
+7657 0
+7658 0
+7659 0
+7660 1
+7661 0
+7662 0
+7663 0
+7664 0
+7665 0
+7666 0
+7667 0
+7668 0
+7669 0
+7670 1
+7671 0
+7672 0
+7673 0
+7674 0
+7675 0
+7676 0
+7677 0
+7678 0
+7679 0
+7680 0
+7681 1
+7682 0
+7683 0
+7684 0
+7685 0
+7686 0
+7687 0
+7688 0
+7689 0
+7690 0
+7691 1
+7692 0
+7693 0
+7694 0
+7695 0
+7696 0
+7697 0
+7698 0
+7699 0
+7700 0
+7701 0
+7702 1
+7703 0
+7704 0
+7705 0
+7706 0
+7707 0
+7708 0
+7709 0
+7710 0
+7711 0
+7712 1
+7713 0
+7714 0
+7715 0
+7716 0
+7717 0
+7718 0
+7719 0
+7720 0
+7721 0
+7722 1
+7723 0
+7724 0
+7725 0
+7726 0
+7727 0
+7728 0
+7729 0
+7730 0
+7731 0
+7732 1
+7733 0
+7734 0
+7735 0
+7736 0
+7737 0
+7738 0
+7739 0
+7740 0
+7741 0
+7742 1
+7743 0
+7744 0
+7745 0
+7746 0
+7747 0
+7748 0
+7749 0
+7750 0
+7751 0
+7752 1
+7753 0
+7754 0
+7755 0
+7756 0
+7757 0
+7758 0
+7759 0
+7760 0
+7761 1
+7762 0
+7763 0
+7764 0
+7765 0
+7766 0
+7767 0
+7768 0
+7769 0
+7770 1
+7771 0
+7772 0
+7773 0
+7774 0
+7775 0
+7776 0
+7777 0
+7778 0
+7779 1
+7780 0
+7781 0
+7782 0
+7783 0
+7784 0
+7785 0
+7786 0
+7787 0
+7788 0
+7789 1
+7790 0
+7791 0
+7792 0
+7793 0
+7794 0
+7795 0
+7796 0
+7797 0
+7798 0
+7799 1
+7800 0
+7801 0
+7802 0
+7803 0
+7804 0
+7805 0
+7806 0
+7807 0
+7808 0
+7809 0
+7810 1
+7811 0
+7812 0
+7813 0
+7814 0
+7815 0
+7816 0
+7817 0
+7818 0
+7819 1
+7820 0
+7821 0
+7822 0
+7823 0
+7824 0
+7825 0
+7826 0
+7827 0
+7828 1
+7829 0
+7830 0
+7831 0
+7832 0
+7833 0
+7834 0
+7835 0
+7836 0
+7837 0
+7838 0
+7839 1
+7840 0
+7841 0
+7842 0
+7843 0
+7844 0
+7845 0
+7846 0
+7847 0
+7848 0
+7849 1
+7850 0
+7851 0
+7852 0
+7853 0
+7854 0
+7855 0
+7856 0
+7857 0
+7858 1
+7859 0
+7860 0
+7861 0
+7862 0
+7863 0
+7864 0
+7865 0
+7866 0
+7867 0
+7868 1
+7869 0
+7870 0
+7871 0
+7872 0
+7873 0
+7874 0
+7875 0
+7876 0
+7877 0
+7878 0
+7879 0
+7880 0
+7881 0
+7882 0
+7883 0
+7884 0
+7885 0
+7886 0
+7887 1
+7888 0
+7889 0
+7890 0
+7891 0
+7892 0
+7893 0
+7894 0
+7895 0
+7896 0
+7897 0
+7898 1
+7899 0
+7900 0
+7901 0
+7902 0
+7903 0
+7904 0
+7905 0
+7906 0
+7907 0
+7908 1
+7909 0
+7910 0
+7911 0
+7912 0
+7913 0
+7914 0
+7915 0
+7916 0
+7917 0
+7918 1
+7919 0
+7920 0
+7921 0
+7922 0
+7923 0
+7924 0
+7925 0
+7926 0
+7927 0
+7928 1
+7929 0
+7930 0
+7931 0
+7932 0
+7933 0
+7934 0
+7935 0
+7936 0
+7937 0
+7938 1
+7939 0
+7940 0
+7941 0
+7942 0
+7943 0
+7944 0
+7945 0
+7946 0
+7947 0
+7948 1
+7949 0
+7950 0
+7951 0
+7952 0
+7953 0
+7954 0
+7955 0
+7956 0
+7957 0
+7958 1
+7959 0
+7960 0
+7961 0
+7962 0
+7963 0
+7964 0
+7965 0
+7966 0
+7967 0
+7968 1
+7969 0
+7970 0
+7971 0
+7972 0
+7973 0
+7974 0
+7975 0
+7976 0
+7977 0
+7978 1
+7979 0
+7980 0
+7981 0
+7982 0
+7983 0
+7984 0
+7985 1
+7986 0
+7987 0
+7988 0
+7989 0
+7990 0
+7991 0
+7992 0
+7993 0
+7994 0
+7995 1
+7996 0
+7997 0
+7998 0
+7999 0
+8000 0
+8001 0
+8002 0
+8003 0
+8004 0
+8005 0
+8006 1
+8007 0
+8008 0
+8009 0
+8010 0
+8011 0
+8012 0
+8013 0
+8014 0
+8015 1
+8016 0
+8017 0
+8018 0
+8019 0
+8020 0
+8021 0
+8022 0
+8023 0
+8024 0
+8025 1
+8026 0
+8027 0
+8028 0
+8029 0
+8030 0
+8031 0
+8032 0
+8033 0
+8034 0
+8035 0
+8036 1
+8037 0
+8038 0
+8039 0
+8040 0
+8041 0
+8042 0
+8043 0
+8044 0
+8045 0
+8046 1
+8047 0
+8048 0
+8049 0
+8050 0
+8051 0
+8052 0
+8053 0
+8054 0
+8055 0
+8056 0
+8057 1
+8058 0
+8059 0
+8060 0
+8061 0
+8062 0
+8063 0
+8064 0
+8065 0
+8066 0
+8067 1
+8068 0
+8069 0
+8070 0
+8071 0
+8072 0
+8073 0
+8074 0
+8075 0
+8076 0
+8077 0
+8078 1
+8079 0
+8080 0
+8081 0
+8082 0
+8083 0
+8084 0
+8085 0
+8086 0
+8087 0
+8088 1
+8089 0
+8090 0
+8091 0
+8092 0
+8093 0
+8094 0
+8095 0
+8096 0
+8097 0
+8098 1
+8099 0
+8100 0
+8101 0
+8102 0
+8103 0
+8104 0
+8105 1
+8106 0
+8107 0
+8108 0
+8109 0
+8110 0
+8111 0
+8112 0
+8113 0
+8114 0
+8115 1
+8116 0
+8117 0
+8118 0
+8119 0
+8120 0
+8121 0
+8122 0
+8123 0
+8124 0
+8125 1
+8126 0
+8127 0
+8128 0
+8129 0
+8130 0
+8131 0
+8132 0
+8133 0
+8134 1
+8135 0
+8136 0
+8137 0
+8138 0
+8139 0
+8140 0
+8141 0
+8142 0
+8143 0
+8144 0
+8145 1
+8146 0
+8147 0
+8148 0
+8149 0
+8150 0
+8151 0
+8152 0
+8153 0
+8154 0
+8155 0
+8156 1
+8157 0
+8158 0
+8159 0
+8160 0
+8161 0
+8162 0
+8163 0
+8164 0
+8165 0
+8166 1
+8167 0
+8168 0
+8169 0
+8170 0
+8171 0
+8172 0
+8173 0
+8174 0
+8175 0
+8176 1
+8177 0
+8178 0
+8179 0
+8180 0
+8181 0
+8182 0
+8183 0
+8184 0
+8185 0
+8186 1
+8187 0
+8188 0
+8189 0
+8190 0
+8191 0
+8192 0
+8193 0
+8194 0
+8195 0
+8196 0
+8197 1
+8198 0
+8199 0
+8200 0
+8201 0
+8202 0
+8203 0
+8204 0
+8205 0
+8206 0
+8207 1
+8208 0
+8209 0
+8210 0
+8211 0
+8212 0
+8213 0
+8214 0
+8215 0
+8216 1
+8217 0
+8218 0
+8219 0
+8220 0
+8221 0
+8222 0
+8223 0
+8224 0
+8225 1
+8226 0
+8227 0
+8228 0
+8229 0
+8230 0
+8231 0
+8232 0
+8233 0
+8234 0
+8235 1
+8236 0
+8237 0
+8238 0
+8239 0
+8240 0
+8241 0
+8242 0
+8243 0
+8244 1
+8245 0
+8246 0
+8247 0
+8248 0
+8249 0
+8250 0
+8251 0
+8252 0
+8253 0
+8254 1
+8255 0
+8256 0
+8257 0
+8258 0
+8259 0
+8260 0
+8261 0
+8262 0
+8263 0
+8264 0
+8265 1
+8266 0
+8267 0
+8268 0
+8269 0
+8270 0
+8271 0
+8272 0
+8273 0
+8274 0
+8275 1
+8276 0
+8277 0
+8278 0
+8279 0
+8280 0
+8281 0
+8282 0
+8283 0
+8284 0
+8285 0
+8286 1
+8287 0
+8288 0
+8289 0
+8290 0
+8291 0
+8292 0
+8293 0
+8294 0
+8295 0
+8296 1
+8297 0
+8298 0
+8299 0
+8300 0
+8301 0
+8302 0
+8303 0
+8304 1
+8305 0
+8306 0
+8307 0
+8308 0
+8309 0
+8310 0
+8311 0
+8312 0
+8313 0
+8314 1
+8315 0
+8316 0
+8317 0
+8318 0
+8319 0
+8320 0
+8321 0
+8322 0
+8323 0
+8324 1
+8325 0
+8326 0
+8327 0
+8328 0
+8329 0
+8330 0
+8331 0
+8332 0
+8333 0
+8334 0
+8335 0
+8336 0
+8337 0
+8338 0
+8339 0
+8340 0
+8341 0
+8342 1
+8343 0
+8344 0
+8345 0
+8346 0
+8347 0
+8348 0
+8349 0
+8350 0
+8351 1
+8352 0
+8353 0
+8354 0
+8355 0
+8356 0
+8357 0
+8358 0
+8359 0
+8360 0
+8361 1
+8362 0
+8363 0
+8364 0
+8365 0
+8366 0
+8367 0
+8368 0
+8369 0
+8370 0
+8371 1
+8372 0
+8373 0
+8374 0
+8375 0
+8376 0
+8377 0
+8378 0
+8379 0
+8380 1
+8381 0
+8382 0
+8383 0
+8384 0
+8385 0
+8386 0
+8387 0
+8388 0
+8389 1
+8390 0
+8391 0
+8392 0
+8393 0
+8394 0
+8395 0
+8396 0
+8397 0
+8398 0
+8399 1
+8400 0
+8401 0
+8402 0
+8403 0
+8404 0
+8405 0
+8406 0
+8407 0
+8408 0
+8409 1
+8410 0
+8411 0
+8412 0
+8413 0
+8414 0
+8415 0
+8416 0
+8417 0
+8418 0
+8419 1
+8420 0
+8421 0
+8422 0
+8423 0
+8424 0
+8425 0
+8426 0
+8427 0
+8428 0
+8429 0
+8430 1
+8431 0
+8432 0
+8433 0
+8434 0
+8435 0
+8436 0
+8437 0
+8438 1
+8439 0
+8440 0
+8441 0
+8442 0
+8443 0
+8444 0
+8445 0
+8446 0
+8447 1
+8448 0
+8449 0
+8450 0
+8451 0
+8452 0
+8453 0
+8454 0
+8455 0
+8456 0
+8457 1
+8458 0
+8459 0
+8460 0
+8461 0
+8462 0
+8463 0
+8464 0
+8465 0
+8466 0
+8467 1
+8468 0
+8469 0
+8470 0
+8471 0
+8472 0
+8473 0
+8474 0
+8475 0
+8476 0
+8477 1
+8478 0
+8479 0
+8480 0
+8481 0
+8482 0
+8483 0
+8484 0
+8485 0
+8486 1
+8487 0
+8488 0
+8489 0
+8490 0
+8491 0
+8492 0
+8493 0
+8494 0
+8495 0
+8496 0
+8497 0
+8498 0
+8499 0
+8500 0
+8501 0
+8502 0
+8503 0
+8504 0
+8505 0
+8506 1
+8507 0
+8508 0
+8509 0
+8510 0
+8511 0
+8512 0
+8513 0
+8514 0
+8515 0
+8516 0
+8517 0
+8518 0
+8519 0
+8520 0
+8521 0
+8522 0
+8523 1
+8524 0
+8525 0
+8526 0
+8527 0
+8528 0
+8529 0
+8530 0
+8531 0
+8532 1
+8533 0
+8534 0
+8535 0
+8536 0
+8537 0
+8538 0
+8539 0
+8540 0
+8541 1
+8542 0
+8543 0
+8544 0
+8545 0
+8546 0
+8547 0
+8548 0
+8549 1
+8550 0
+8551 0
+8552 0
+8553 0
+8554 0
+8555 0
+8556 0
+8557 0
+8558 0
+8559 1
+8560 0
+8561 0
+8562 0
+8563 0
+8564 0
+8565 0
+8566 0
+8567 0
+8568 1
+8569 0
+8570 0
+8571 0
+8572 0
+8573 0
+8574 0
+8575 0
+8576 0
+8577 1
+8578 0
+8579 0
+8580 0
+8581 0
+8582 0
+8583 0
+8584 0
+8585 0
+8586 1
+8587 0
+8588 0
+8589 0
+8590 0
+8591 0
+8592 0
+8593 0
+8594 0
+8595 0
+8596 1
+8597 0
+8598 0
+8599 0
+8600 0
+8601 0
+8602 0
+8603 0
+8604 0
+8605 0
+8606 1
+8607 0
+8608 0
+8609 0
+8610 0
+8611 0
+8612 0
+8613 0
+8614 0
+8615 0
+8616 1
+8617 0
+8618 0
+8619 0
+8620 0
+8621 0
+8622 0
+8623 0
+8624 0
+8625 1
+8626 0
+8627 0
+8628 0
+8629 0
+8630 0
+8631 0
+8632 0
+8633 1
+8634 0
+8635 0
+8636 0
+8637 0
+8638 0
+8639 0
+8640 0
+8641 0
+8642 0
+8643 1
+8644 0
+8645 0
+8646 0
+8647 0
+8648 0
+8649 0
+8650 0
+8651 1
+8652 0
+8653 0
+8654 0
+8655 0
+8656 0
+8657 0
+8658 0
+8659 0
+8660 1
+8661 0
+8662 0
+8663 0
+8664 0
+8665 0
+8666 0
+8667 0
+8668 0
+8669 1
+8670 0
+8671 0
+8672 0
+8673 0
+8674 0
+8675 0
+8676 0
+8677 1
+8678 0
+8679 0
+8680 0
+8681 0
+8682 0
+8683 0
+8684 0
+8685 0
+8686 1
+8687 0
+8688 0
+8689 0
+8690 0
+8691 0
+8692 0
+8693 0
+8694 0
+8695 0
+8696 1
+8697 0
+8698 0
+8699 0
+8700 0
+8701 0
+8702 0
+8703 0
+8704 0
+8705 1
+8706 0
+8707 0
+8708 0
+8709 0
+8710 0
+8711 0
+8712 0
+8713 0
+8714 0
+8715 1
+8716 0
+8717 0
+8718 0
+8719 0
+8720 0
+8721 0
+8722 0
+8723 0
+8724 0
+8725 1
+8726 0
+8727 0
+8728 0
+8729 0
+8730 0
+8731 0
+8732 0
+8733 0
+8734 0
+8735 1
+8736 0
+8737 0
+8738 0
+8739 0
+8740 0
+8741 0
+8742 0
+8743 0
+8744 0
+8745 1
+8746 0
+8747 0
+8748 0
+8749 0
+8750 0
+8751 0
+8752 0
+8753 0
+8754 0
+8755 1
+8756 0
+8757 0
+8758 0
+8759 0
+8760 0
+8761 0
+8762 0
+8763 1
+8764 0
+8765 0
+8766 0
+8767 0
+8768 0
+8769 0
+8770 1
+8771 0
+8772 0
+8773 0
+8774 0
+8775 0
+8776 0
+8777 0
+8778 0
+8779 0
+8780 1
+8781 0
+8782 0
+8783 0
+8784 0
+8785 0
+8786 0
+8787 0
+8788 0
+8789 1
+8790 0
+8791 0
+8792 0
+8793 0
+8794 0
+8795 0
+8796 0
+8797 0
+8798 1
+8799 0
+8800 0
+8801 0
+8802 0
+8803 0
+8804 0
+8805 0
+8806 0
+8807 3
+8808 0
+8809 0
+8810 1
+8811 0
+8812 0
+8813 0
+8814 0
+8815 1
+8816 0
+8817 0
+8818 0
+8819 0
+8820 1
+8821 0
+8822 0
+8823 0
+8824 1
+8825 0
+8826 0
+8827 0
+8828 0
+8829 0
+8830 1
+8831 0
+8832 0
+8833 0
+8834 0
+8835 0
+8836 0
+8837 1
+8838 0
+8839 0
+8840 0
+8841 0
+8842 0
+8843 0
+8844 0
+8845 1
+8846 0
+8847 0
+8848 0
+8849 0
+8850 0
+8851 0
+8852 0
+8853 0
+8854 0
+8855 1
+8856 0
+8857 0
+8858 0
+8859 0
+8860 0
+8861 0
+8862 0
+8863 0
+8864 0
+8865 1
+8866 0
+8867 0
+8868 0
+8869 0
+8870 0
+8871 0
+8872 1
+8873 0
+8874 0
+8875 0
+8876 0
+8877 0
+8878 0
+8879 0
+8880 1
+8881 0
+8882 0
+8883 0
+8884 0
+8885 0
+8886 0
+8887 0
+8888 1
+8889 0
+8890 0
+8891 0
+8892 0
+8893 0
+8894 0
+8895 0
+8896 0
+8897 0
+8898 0
+8899 0
+8900 0
+8901 0
+8902 0
+8903 0
+8904 0
+8905 1
+8906 0
+8907 0
+8908 0
+8909 0
+8910 0
+8911 0
+8912 1
+8913 0
+8914 0
+8915 0
+8916 0
+8917 0
+8918 0
+8919 0
+8920 1
+8921 0
+8922 0
+8923 0
+8924 0
+8925 0
+8926 0
+8927 0
+8928 0
+8929 1
+8930 0
+8931 0
+8932 0
+8933 0
+8934 0
+8935 0
+8936 0
+8937 0
+8938 0
+8939 1
+8940 0
+8941 0
+8942 0
+8943 0
+8944 0
+8945 0
+8946 0
+8947 0
+8948 0
+8949 1
+8950 0
+8951 0
+8952 0
+8953 0
+8954 0
+8955 0
+8956 0
+8957 0
+8958 0
+8959 1
+8960 0
+8961 0
+8962 0
+8963 0
+8964 0
+8965 0
+8966 0
+8967 0
+8968 0
+8969 1
+8970 0
+8971 0
+8972 0
+8973 0
+8974 0
+8975 0
+8976 0
+8977 0
+8978 1
+8979 0
+8980 0
+8981 0
+8982 0
+8983 0
+8984 0
+8985 0
+8986 0
+8987 1
+8988 0
+8989 0
+8990 0
+8991 0
+8992 0
+8993 0
+8994 0
+8995 0
+8996 0
+8997 1
+8998 0
+8999 0
+9000 0
+9001 0
+9002 0
+9003 0
+9004 0
+9005 0
+9006 1
+9007 0
+9008 0
+9009 0
+9010 0
+9011 0
+9012 0
+9013 0
+9014 1
+9015 0
+9016 0
+9017 0
+9018 0
+9019 0
+9020 0
+9021 0
+9022 1
+9023 0
+9024 0
+9025 0
+9026 0
+9027 0
+9028 0
+9029 0
+9030 1
+9031 0
+9032 0
+9033 0
+9034 0
+9035 0
+9036 0
+9037 0
+9038 1
+9039 0
+9040 0
+9041 0
+9042 0
+9043 0
+9044 0
+9045 0
+9046 0
+9047 1
+9048 0
+9049 0
+9050 0
+9051 0
+9052 0
+9053 0
+9054 0
+9055 1
+9056 0
+9057 0
+9058 0
+9059 0
+9060 0
+9061 0
+9062 0
+9063 1
+9064 0
+9065 0
+9066 0
+9067 0
+9068 0
+9069 0
+9070 0
+9071 0
+9072 0
+9073 1
+9074 0
+9075 0
+9076 0
+9077 0
+9078 0
+9079 0
+9080 0
+9081 0
+9082 0
+9083 0
+9084 0
+9085 0
+9086 0
+9087 0
+9088 0
+9089 0
+9090 0
+9091 0
+9092 1
+9093 0
+9094 0
+9095 0
+9096 0
+9097 0
+9098 0
+9099 0
+9100 1
+9101 0
+9102 0
+9103 0
+9104 0
+9105 0
+9106 0
+9107 0
+9108 1
+9109 0
+9110 0
+9111 0
+9112 0
+9113 0
+9114 0
+9115 0
+9116 0
+9117 1
+9118 0
+9119 0
+9120 0
+9121 0
+9122 0
+9123 0
+9124 0
+9125 0
+9126 1
+9127 0
+9128 0
+9129 0
+9130 0
+9131 0
+9132 0
+9133 0
+9134 0
+9135 1
+9136 0
+9137 0
+9138 0
+9139 0
+9140 0
+9141 0
+9142 0
+9143 1
+9144 0
+9145 0
+9146 0
+9147 0
+9148 0
+9149 0
+9150 0
+9151 0
+9152 1
+9153 0
+9154 0
+9155 0
+9156 0
+9157 0
+9158 0
+9159 0
+9160 0
+9161 1
+9162 0
+9163 0
+9164 0
+9165 0
+9166 0
+9167 0
+9168 0
+9169 1
+9170 0
+9171 0
+9172 0
+9173 0
+9174 0
+9175 0
+9176 0
+9177 0
+9178 1
+9179 0
+9180 0
+9181 0
+9182 0
+9183 0
+9184 0
+9185 0
+9186 0
+9187 0
+9188 1
+9189 0
+9190 0
+9191 0
+9192 0
+9193 0
+9194 0
+9195 0
+9196 0
+9197 1
+9198 0
+9199 0
+9200 0
+9201 0
+9202 0
+9203 0
+9204 0
+9205 0
+9206 0
+9207 0
+9208 0
+9209 0
+9210 0
+9211 0
+9212 0
+9213 0
+9214 0
+9215 0
+9216 0
+9217 0
+9218 0
+9219 0
+9220 0
+9221 1
+9222 0
+9223 0
+9224 0
+9225 0
+9226 0
+9227 0
+9228 1
+9229 0
+9230 0
+9231 0
+9232 0
+9233 0
+9234 0
+9235 0
+9236 0
+9237 1
+9238 0
+9239 0
+9240 0
+9241 0
+9242 0
+9243 0
+9244 0
+9245 0
+9246 1
+9247 0
+9248 0
+9249 0
+9250 0
+9251 0
+9252 0
+9253 0
+9254 0
+9255 1
+9256 0
+9257 0
+9258 0
+9259 0
+9260 0
+9261 1
+9262 0
+9263 0
+9264 0
+9265 0
+9266 0
+9267 0
+9268 0
+9269 0
+9270 0
+9271 0
+9272 0
+9273 0
+9274 0
+9275 0
+9276 1
+9277 0
+9278 0
+9279 0
+9280 0
+9281 0
+9282 0
+9283 0
+9284 0
+9285 0
+9286 0
+9287 0
+9288 0
+9289 0
+9290 1
+9291 0
+9292 0
+9293 0
+9294 0
+9295 0
+9296 0
+9297 0
+9298 0
+9299 0
+9300 1
+9301 0
+9302 0
+9303 0
+9304 0
+9305 0
+9306 0
+9307 0
+9308 1
+9309 0
+9310 0
+9311 0
+9312 0
+9313 0
+9314 0
+9315 0
+9316 1
+9317 0
+9318 0
+9319 0
+9320 0
+9321 0
+9322 0
+9323 1
+9324 0
+9325 0
+9326 0
+9327 0
+9328 0
+9329 0
+9330 0
+9331 1
+9332 0
+9333 0
+9334 0
+9335 0
+9336 0
+9337 0
+9338 1
+9339 0
+9340 0
+9341 0
+9342 0
+9343 0
+9344 0
+9345 1
+9346 0
+9347 0
+9348 0
+9349 0
+9350 0
+9351 0
+9352 0
+9353 0
+9354 0
+9355 1
+9356 0
+9357 0
+9358 0
+9359 0
+9360 0
+9361 0
+9362 0
+9363 1
+9364 0
+9365 0
+9366 0
+9367 0
+9368 0
+9369 0
+9370 1
+9371 0
+9372 0
+9373 0
+9374 0
+9375 0
+9376 0
+9377 0
+9378 1
+9379 0
+9380 0
+9381 0
+9382 0
+9383 0
+9384 0
+9385 0
+9386 0
+9387 0
+9388 0
+9389 0
+9390 0
+9391 0
+9392 0
+9393 0
+9394 0
+9395 1
+9396 0
+9397 0
+9398 0
+9399 0
+9400 0
+9401 0
+9402 0
+9403 1
+9404 0
+9405 0
+9406 0
+9407 0
+9408 0
+9409 0
+9410 0
+9411 0
+9412 1
+9413 0
+9414 0
+9415 0
+9416 0
+9417 0
+9418 0
+9419 0
+9420 1
+9421 0
+9422 0
+9423 0
+9424 0
+9425 0
+9426 0
+9427 0
+9428 0
+9429 1
+9430 0
+9431 0
+9432 0
+9433 0
+9434 0
+9435 0
+9436 0
+9437 0
+9438 0
+9439 1
+9440 0
+9441 0
+9442 0
+9443 0
+9444 0
+9445 0
+9446 0
+9447 0
+9448 0
+9449 1
+9450 0
+9451 0
+9452 0
+9453 0
+9454 0
+9455 0
+9456 0
+9457 1
+9458 0
+9459 0
+9460 0
+9461 0
+9462 0
+9463 0
+9464 1
+9465 0
+9466 0
+9467 0
+9468 0
+9469 0
+9470 0
+9471 0
+9472 0
+9473 1
+9474 0
+9475 0
+9476 0
+9477 0
+9478 0
+9479 0
+9480 0
+9481 1
+9482 0
+9483 0
+9484 0
+9485 0
+9486 0
+9487 0
+9488 1
+9489 0
+9490 0
+9491 0
+9492 0
+9493 0
+9494 0
+9495 0
+9496 0
+9497 1
+9498 0
+9499 0
+9500 0
+9501 0
+9502 0
+9503 0
+9504 0
+9505 0
+9506 0
+9507 0
+9508 0
+9509 0
+9510 0
+9511 0
+9512 0
+9513 0
+9514 1
+9515 0
+9516 0
+9517 0
+9518 0
+9519 0
+9520 0
+9521 0
+9522 1
+9523 0
+9524 0
+9525 0
+9526 0
+9527 0
+9528 0
+9529 0
+9530 1
+9531 0
+9532 0
+9533 0
+9534 0
+9535 0
+9536 0
+9537 0
+9538 1
+9539 0
+9540 0
+9541 0
+9542 0
+9543 0
+9544 0
+9545 0
+9546 0
+9547 1
+9548 0
+9549 0
+9550 0
+9551 0
+9552 0
+9553 0
+9554 0
+9555 1
+9556 0
+9557 0
+9558 0
+9559 0
+9560 0
+9561 0
+9562 0
+9563 1
+9564 0
+9565 0
+9566 0
+9567 0
+9568 0
+9569 0
+9570 0
+9571 0
+9572 1
+9573 0
+9574 0
+9575 0
+9576 0
+9577 0
+9578 0
+9579 0
+9580 1
+9581 0
+9582 0
+9583 0
+9584 0
+9585 0
+9586 0
+9587 0
+9588 0
+9589 1
+9590 0
+9591 0
+9592 0
+9593 0
+9594 0
+9595 0
+9596 0
+9597 0
+9598 0
+9599 0
+9600 0
+9601 0
+9602 0
+9603 0
+9604 0
+9605 0
+9606 0
+9607 0
+9608 1
+9609 0
+9610 0
+9611 0
+9612 0
+9613 0
+9614 0
+9615 1
+9616 0
+9617 0
+9618 0
+9619 0
+9620 0
+9621 0
+9622 1
+9623 0
+9624 0
+9625 0
+9626 0
+9627 0
+9628 0
+9629 0
+9630 1
+9631 0
+9632 0
+9633 0
+9634 0
+9635 0
+9636 0
+9637 0
+9638 0
+9639 1
+9640 0
+9641 0
+9642 0
+9643 0
+9644 0
+9645 0
+9646 0
+9647 0
+9648 1
+9649 0
+9650 0
+9651 0
+9652 0
+9653 0
+9654 0
+9655 0
+9656 1
+9657 0
+9658 0
+9659 0
+9660 0
+9661 0
+9662 0
+9663 1
+9664 0
+9665 0
+9666 0
+9667 0
+9668 0
+9669 0
+9670 0
+9671 0
+9672 0
+9673 1
+9674 0
+9675 0
+9676 0
+9677 0
+9678 0
+9679 0
+9680 0
+9681 1
+9682 0
+9683 0
+9684 0
+9685 0
+9686 0
+9687 0
+9688 0
+9689 1
+9690 0
+9691 0
+9692 0
+9693 0
+9694 0
+9695 0
+9696 1
+9697 0
+9698 0
+9699 0
+9700 0
+9701 0
+9702 0
+9703 0
+9704 1
+9705 0
+9706 0
+9707 0
+9708 0
+9709 0
+9710 0
+9711 0
+9712 1
+9713 0
+9714 0
+9715 0
+9716 0
+9717 0
+9718 0
+9719 0
+9720 0
+9721 0
+9722 1
+9723 0
+9724 0
+9725 0
+9726 0
+9727 0
+9728 0
+9729 0
+9730 0
+9731 1
+9732 0
+9733 0
+9734 0
+9735 0
+9736 0
+9737 0
+9738 0
+9739 0
+9740 1
+9741 0
+9742 0
+9743 0
+9744 0
+9745 0
+9746 0
+9747 0
+9748 0
+9749 1
+9750 0
+9751 0
+9752 0
+9753 0
+9754 0
+9755 0
+9756 1
+9757 0
+9758 0
+9759 0
+9760 0
+9761 0
+9762 0
+9763 0
+9764 0
+9765 0
+9766 0
+9767 0
+9768 0
+9769 0
+9770 0
+9771 0
+9772 0
+9773 1
+9774 0
+9775 0
+9776 0
+9777 0
+9778 0
+9779 0
+9780 1
+9781 0
+9782 0
+9783 0
+9784 0
+9785 0
+9786 0
+9787 0
+9788 1
+9789 0
+9790 0
+9791 0
+9792 0
+9793 0
+9794 0
+9795 0
+9796 0
+9797 0
+9798 0
+9799 0
+9800 0
+9801 0
+9802 0
+9803 1
+9804 0
+9805 0
+9806 0
+9807 0
+9808 0
+9809 0
+9810 0
+9811 0
+9812 1
+9813 0
+9814 0
+9815 0
+9816 0
+9817 0
+9818 0
+9819 0
+9820 1
+9821 0
+9822 0
+9823 0
+9824 0
+9825 0
+9826 0
+9827 0
+9828 0
+9829 1
+9830 0
+9831 0
+9832 0
+9833 0
+9834 0
+9835 0
+9836 0
+9837 0
+9838 1
+9839 0
+9840 0
+9841 0
+9842 0
+9843 0
+9844 0
+9845 0
+9846 0
+9847 0
+9848 1
+9849 0
+9850 0
+9851 0
+9852 0
+9853 0
+9854 4
+9855 0
+9856 0
+9857 1
+9858 0
+9859 0
+9860 0
+9861 0
+9862 1
+9863 0
+9864 0
+9865 0
+9866 0
+9867 0
+9868 1
+9869 0
+9870 0
+9871 0
+9872 0
+9873 1
+9874 0
+9875 0
+9876 0
+9877 0
+9878 1
+9879 0
+9880 0
+9881 0
+9882 0
+9883 0
+9884 0
+9885 0
+9886 1
+9887 0
+9888 0
+9889 0
+9890 0
+9891 0
+9892 0
+9893 0
+9894 0
+9895 1
+9896 0
+9897 0
+9898 0
+9899 0
+9900 0
+9901 0
+9902 0
+9903 0
+9904 1
+9905 0
+9906 0
+9907 0
+9908 0
+9909 0
+9910 0
+9911 0
+9912 0
+9913 0
+9914 0
+9915 0
+9916 0
+9917 0
+9918 0
+9919 0
+9920 0
+9921 0
+9922 0
+9923 0
+9924 1
+9925 0
+9926 0
+9927 0
+9928 0
+9929 0
+9930 0
+9931 0
+9932 0
+9933 0
+9934 1
+9935 0
+9936 0
+9937 0
+9938 0
+9939 0
+9940 0
+9941 0
+9942 0
+9943 0
+9944 1
+9945 0
+9946 0
+9947 0
+9948 0
+9949 0
+9950 0
+9951 0
+9952 0
+9953 0
+9954 1
+9955 0
+9956 0
+9957 0
+9958 0
+9959 0
+9960 0
+9961 0
+9962 0
+9963 1
+9964 0
+9965 0
+9966 0
+9967 0
+9968 0
+9969 0
+9970 0
+9971 0
+9972 1
+9973 0
+9974 0
+9975 0
+9976 0
+9977 0
+9978 0
+9979 0
+9980 0
+9981 0
+9982 0
+9983 1
+9984 0
+9985 0
+9986 0
+9987 0
+9988 0
+9989 0
+9990 0
+9991 0
+9992 0
+9993 1
+9994 0
+9995 0
+9996 0
+9997 0
+9998 0
+9999 0
+10000 0
+10001 0
+10002 0
+10003 0
+10004 1
+10005 0
+10006 0
+10007 0
+10008 0
+10009 0
+10010 0
+10011 0
+10012 0
+10013 1
+10014 0
+10015 0
+10016 0
+10017 0
+10018 0
+10019 0
+10020 0
+10021 0
+10022 0
+10023 1
+10024 0
+10025 0
+10026 0
+10027 0
+10028 0
+10029 0
+10030 0
+10031 1
+10032 0
+10033 0
+10034 0
+10035 0
+10036 0
+10037 0
+10038 0
+10039 0
+10040 0
+10041 1
+10042 0
+10043 0
+10044 0
+10045 0
+10046 0
+10047 0
+10048 0
+10049 0
+10050 0
+10051 1
+10052 0
+10053 0
+10054 0
+10055 0
+10056 0
+10057 0
+10058 0
+10059 0
+10060 1
+10061 0
+10062 0
+10063 0
+10064 0
+10065 0
+10066 0
+10067 0
+10068 0
+10069 1
+10070 0
+10071 0
+10072 0
+10073 0
+10074 0
+10075 0
+10076 0
+10077 0
+10078 1
+10079 0
+10080 0
+10081 0
+10082 0
+10083 0
+10084 0
+10085 0
+10086 0
+10087 1
+10088 0
+10089 0
+10090 0
+10091 0
+10092 0
+10093 0
+10094 0
+10095 0
+10096 0
+10097 1
+10098 0
+10099 0
+10100 0
+10101 0
+10102 0
+10103 0
+10104 0
+10105 0
+10106 0
+10107 0
+10108 1
+10109 0
+10110 0
+10111 0
+10112 0
+10113 0
+10114 0
+10115 0
+10116 0
+10117 0
+10118 1
+10119 0
+10120 0
+10121 0
+10122 0
+10123 0
+10124 0
+10125 0
+10126 0
+10127 1
+10128 0
+10129 0
+10130 0
+10131 0
+10132 0
+10133 0
+10134 0
+10135 0
+10136 0
+10137 1
+10138 0
+10139 0
+10140 0
+10141 0
+10142 0
+10143 0
+10144 0
+10145 0
+10146 0
+10147 1
+10148 0
+10149 0
+10150 0
+10151 0
+10152 0
+10153 0
+10154 0
+10155 0
+10156 0
+10157 1
+10158 0
+10159 0
+10160 0
+10161 0
+10162 0
+10163 0
+10164 0
+10165 0
+10166 0
+10167 1
+10168 0
+10169 0
+10170 0
+10171 0
+10172 0
+10173 0
+10174 0
+10175 0
+10176 1
+10177 0
+10178 0
+10179 0
+10180 0
+10181 0
+10182 0
+10183 0
+10184 0
+10185 1
+10186 0
+10187 0
+10188 0
+10189 0
+10190 0
+10191 0
+10192 0
+10193 1
+10194 0
+10195 0
+10196 0
+10197 0
+10198 0
+10199 0
+10200 0
+10201 1
+10202 0
+10203 0
+10204 0
+10205 0
+10206 0
+10207 0
+10208 0
+10209 0
+10210 0
+10211 1
+10212 0
+10213 0
+10214 0
+10215 0
+10216 0
+10217 0
+10218 0
+10219 0
+10220 1
+10221 0
+10222 0
+10223 0
+10224 0
+10225 0
+10226 0
+10227 0
+10228 0
+10229 0
+10230 1
+10231 0
+10232 0
+10233 0
+10234 0
+10235 0
+10236 0
+10237 0
+10238 0
+10239 0
+10240 1
+10241 0
+10242 0
+10243 0
+10244 0
+10245 0
+10246 0
+10247 0
+10248 0
+10249 0
+10250 1
+10251 0
+10252 0
+10253 0
+10254 0
+10255 0
+10256 0
+10257 0
+10258 0
+10259 0
+10260 1
+10261 0
+10262 0
+10263 0
+10264 1
+10265 0
+10266 0
+10267 0
+10268 0
+10269 0
+10270 1
+10271 0
+10272 0
+10273 0
+10274 0
+10275 0
+10276 0
+10277 0
+10278 1
+10279 0
+10280 0
+10281 0
+10282 0
+10283 0
+10284 0
+10285 0
+10286 1
+10287 0
+10288 0
+10289 0
+10290 0
+10291 0
+10292 0
+10293 0
+10294 0
+10295 0
+10296 1
+10297 0
+10298 0
+10299 0
+10300 0
+10301 0
+10302 0
+10303 0
+10304 0
+10305 1
+10306 0
+10307 0
+10308 0
+10309 0
+10310 0
+10311 0
+10312 0
+10313 0
+10314 1
+10315 0
+10316 0
+10317 0
+10318 0
+10319 0
+10320 0
+10321 0
+10322 0
+10323 1
+10324 0
+10325 0
+10326 0
+10327 0
+10328 0
+10329 0
+10330 0
+10331 0
+10332 0
+10333 1
+10334 0
+10335 0
+10336 0
+10337 0
+10338 0
+10339 0
+10340 0
+10341 0
+10342 0
+10343 0
+10344 0
+10345 0
+10346 0
+10347 0
+10348 0
+10349 0
+10350 0
+10351 1
+10352 0
+10353 0
+10354 0
+10355 0
+10356 0
+10357 0
+10358 0
+10359 0
+10360 1
+10361 0
+10362 0
+10363 0
+10364 0
+10365 0
+10366 0
+10367 0
+10368 0
+10369 0
+10370 1
+10371 0
+10372 0
+10373 0
+10374 0
+10375 0
+10376 0
+10377 0
+10378 0
+10379 0
+10380 1
+10381 0
+10382 0
+10383 0
+10384 0
+10385 0
+10386 0
+10387 1
+10388 0
+10389 0
+10390 0
+10391 0
+10392 0
+10393 0
+10394 0
+10395 1
+10396 0
+10397 0
+10398 0
+10399 0
+10400 0
+10401 0
+10402 0
+10403 0
+10404 1
+10405 0
+10406 0
+10407 0
+10408 0
+10409 0
+10410 0
+10411 0
+10412 0
+10413 0
+10414 1
+10415 0
+10416 0
+10417 0
+10418 0
+10419 0
+10420 0
+10421 0
+10422 0
+10423 1
+10424 0
+10425 0
+10426 0
+10427 0
+10428 0
+10429 0
+10430 0
+10431 0
+10432 0
+10433 1
+10434 0
+10435 0
+10436 0
+10437 0
+10438 0
+10439 0
+10440 0
+10441 0
+10442 0
+10443 1
+10444 0
+10445 0
+10446 0
+10447 0
+10448 0
+10449 0
+10450 0
+10451 0
+10452 1
+10453 0
+10454 0
+10455 0
+10456 0
+10457 0
+10458 0
+10459 0
+10460 1
+10461 0
+10462 0
+10463 0
+10464 0
+10465 0
+10466 0
+10467 0
+10468 0
+10469 1
+10470 0
+10471 0
+10472 0
+10473 0
+10474 0
+10475 0
+10476 0
+10477 0
+10478 0
+10479 1
+10480 0
+10481 0
+10482 0
+10483 0
+10484 0
+10485 0
+10486 0
+10487 0
+10488 0
+10489 1
+10490 0
+10491 0
+10492 0
+10493 0
+10494 0
+10495 0
+10496 0
+10497 0
+10498 1
+10499 0
+10500 0
+10501 0
+10502 0
+10503 0
+10504 0
+10505 0
+10506 1
+10507 0
+10508 0
+10509 0
+10510 0
+10511 0
+10512 0
+10513 0
+10514 0
+10515 0
+10516 0
+10517 1
+10518 0
+10519 0
+10520 0
+10521 0
+10522 0
+10523 0
+10524 0
+10525 0
+10526 0
+10527 1
+10528 0
+10529 0
+10530 0
+10531 0
+10532 0
+10533 0
+10534 0
+10535 0
+10536 1
+10537 0
+10538 0
+10539 0
+10540 0
+10541 0
+10542 0
+10543 0
+10544 0
+10545 1
+10546 0
+10547 0
+10548 0
+10549 0
+10550 0
+10551 0
+10552 0
+10553 0
+10554 0
+10555 1
+10556 0
+10557 0
+10558 0
+10559 0
+10560 0
+10561 0
+10562 0
+10563 0
+10564 0
+10565 0
+10566 1
+10567 0
+10568 0
+10569 0
+10570 0
+10571 0
+10572 0
+10573 0
+10574 0
+10575 0
+10576 0
+10577 0
+10578 0
+10579 0
+10580 0
+10581 0
+10582 0
+10583 0
+10584 0
+10585 0
+10586 0
+10587 1
+10588 0
+10589 0
+10590 0
+10591 0
+10592 0
+10593 0
+10594 0
+10595 0
+10596 0
+10597 0
+10598 1
+10599 0
+10600 0
+10601 0
+10602 0
+10603 0
+10604 0
+10605 0
+10606 0
+10607 0
+10608 0
+10609 1
+10610 0
+10611 0
+10612 0
+10613 0
+10614 0
+10615 0
+10616 0
+10617 1
+10618 0
+10619 0
+10620 0
+10621 0
+10622 0
+10623 0
+10624 0
+10625 1
+10626 0
+10627 0
+10628 0
+10629 0
+10630 0
+10631 0
+10632 0
+10633 0
+10634 1
+10635 0
+10636 0
+10637 0
+10638 0
+10639 0
+10640 0
+10641 0
+10642 0
+10643 0
+10644 1
+10645 0
+10646 0
+10647 0
+10648 0
+10649 0
+10650 0
+10651 0
+10652 0
+10653 1
+10654 0
+10655 0
+10656 0
+10657 0
+10658 0
+10659 0
+10660 0
+10661 1
+10662 0
+10663 0
+10664 0
+10665 0
+10666 0
+10667 0
+10668 0
+10669 0
+10670 0
+10671 1
+10672 0
+10673 0
+10674 0
+10675 0
+10676 0
+10677 0
+10678 0
+10679 0
+10680 0
+10681 1
+10682 0
+10683 0
+10684 0
+10685 0
+10686 0
+10687 0
+10688 0
+10689 0
+10690 0
+10691 0
+10692 0
+10693 0
+10694 0
+10695 0
+10696 0
+10697 0
+10698 0
+10699 0
+10700 0
+10701 1
+10702 0
+10703 0
+10704 0
+10705 0
+10706 0
+10707 0
+10708 0
+10709 0
+10710 0
+10711 1
+10712 0
+10713 0
+10714 0
+10715 0
+10716 0
+10717 0
+10718 0
+10719 0
+10720 0
+10721 1
+10722 0
+10723 0
+10724 0
+10725 0
+10726 0
+10727 0
+10728 0
+10729 0
+10730 1
+10731 0
+10732 0
+10733 0
+10734 0
+10735 0
+10736 0
+10737 0
+10738 0
+10739 0
+10740 1
+10741 0
+10742 0
+10743 0
+10744 0
+10745 0
+10746 0
+10747 0
+10748 0
+10749 1
+10750 0
+10751 0
+10752 0
+10753 0
+10754 0
+10755 0
+10756 0
+10757 0
+10758 0
+10759 1
+10760 0
+10761 0
+10762 0
+10763 0
+10764 0
+10765 0
+10766 0
+10767 0
+10768 0
+10769 0
+10770 1
+10771 0
+10772 0
+10773 0
+10774 0
+10775 0
+10776 0
+10777 0
+10778 0
+10779 0
+10780 1
+10781 0
+10782 0
+10783 0
+10784 0
+10785 0
+10786 0
+10787 0
+10788 0
+10789 0
+10790 1
+10791 0
+10792 0
+10793 0
+10794 0
+10795 0
+10796 0
+10797 0
+10798 0
+10799 0
+10800 1
+10801 0
+10802 0
+10803 0
+10804 0
+10805 0
+10806 0
+10807 0
+10808 0
+10809 0
+10810 0
+10811 0
+10812 0
+10813 0
+10814 0
+10815 0
+10816 0
+10817 0
+10818 0
+10819 0
+10820 1
+10821 0
+10822 0
+10823 0
+10824 0
+10825 0
+10826 0
+10827 0
+10828 0
+10829 0
+10830 0
+10831 1
+10832 0
+10833 0
+10834 0
+10835 0
+10836 0
+10837 0
+10838 0
+10839 0
+10840 1
+10841 0
+10842 0
+10843 0
+10844 0
+10845 0
+10846 0
+10847 0
+10848 0
+10849 0
+10850 0
+10851 0
+10852 0
+10853 0
+10854 0
+10855 0
+10856 0
+10857 0
+10858 0
+10859 0
+10860 1
+10861 0
+10862 0
+10863 0
+10864 0
+10865 0
+10866 0
+10867 0
+10868 0
+10869 1
+10870 0
+10871 0
+10872 0
+10873 0
+10874 0
+10875 0
+10876 0
+10877 0
+10878 0
+10879 0
+10880 1
+10881 0
+10882 0
+10883 0
+10884 0
+10885 0
+10886 0
+10887 0
+10888 0
+10889 0
+10890 1
+10891 0
+10892 0
+10893 0
+10894 0
+10895 0
+10896 0
+10897 0
+10898 0
+10899 0
+10900 1
+10901 0
+10902 0
+10903 0
+10904 0
+10905 0
+10906 0
+10907 0
+10908 0
+10909 0
+10910 0
+10911 1
+10912 0
+10913 0
+10914 0
+10915 0
+10916 0
+10917 0
+10918 0
+10919 0
+10920 0
+10921 1
+10922 0
+10923 0
+10924 0
+10925 0
+10926 0
+10927 0
+10928 0
+10929 0
+10930 0
+10931 1
+10932 0
+10933 0
+10934 0
+10935 0
+10936 0
+10937 0
+10938 0
+10939 0
+10940 1
+10941 0
+10942 0
+10943 0
+10944 0
+10945 0
+10946 0
+10947 0
+10948 0
+10949 1
+10950 0
+10951 0
+10952 0
+10953 0
+10954 0
+10955 0
+10956 0
+10957 0
+10958 1
+10959 0
+10960 0
+10961 0
+10962 0
+10963 0
+10964 0
+10965 0
+10966 0
+10967 0
+10968 1
+10969 0
+10970 0
+10971 0
+10972 0
+10973 0
+10974 0
+10975 0
+10976 0
+10977 0
+10978 1
+10979 0
+10980 0
+10981 0
+10982 0
+10983 0
+10984 0
+10985 0
+10986 0
+10987 0
+10988 0
+10989 1
+10990 0
+10991 0
+10992 0
+10993 0
+10994 0
+10995 0
+10996 0
+10997 0
+10998 0
+10999 0
+11000 1 \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test.js
new file mode 100644
index 0000000..8864284
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test.js
@@ -0,0 +1,71 @@
+var ReplSet = require('./lib2/topologies/replset'),
+ ReadPreference = require('./lib2/topologies/read_preference');
+
+// Attempt to connect
+var server = new ReplSet([{
+ host: 'localhost', port: 31000
+}, {
+ host: 'localhost', port: 31001
+}], {
+ setName: 'rs'
+});
+
+function executeCursors(_server, cb) {
+ var count = 100;
+
+ for(var i = 0; i < 100; i++) {
+ // Execute the write
+ var cursor = _server.cursor('test.test', {
+ find: 'test.test'
+ , query: {a:1}
+ }, {readPreference: new ReadPreference('secondary')});
+
+ // Get the first document
+ cursor.next(function(err, doc) {
+ count = count - 1;
+ if(err) console.dir(err)
+ if(count == 0) return cb();
+ });
+ }
+}
+
+server.on('connect', function(_server) {
+ console.log("---------------------------------- 0")
+ // Attempt authentication
+ _server.auth('scram-sha-1', 'admin', 'root', 'root', function(err, r) {
+ console.log("---------------------------------- 1")
+ // console.dir(err)
+ // console.dir(r)
+
+ _server.insert('test.test', [{a:1}], function(err, r) {
+ console.log("---------------------------------- 2")
+ console.dir(err)
+ if(r)console.dir(r.result)
+ var name = null;
+
+ _server.on('joined', function(_t, _server) {
+ if(name == _server.name) {
+ console.log("=========== joined :: " + _t + " :: " + _server.name)
+ executeCursors(_server, function() {
+ });
+ }
+ })
+
+ // var s = _server.s.replicaSetState.secondaries[0];
+ // s.destroy({emitClose:true});
+ executeCursors(_server, function() {
+ console.log("============== 0")
+ // Attempt to force a server reconnect
+ var s = _server.s.replicaSetState.secondaries[0];
+ name = s.name;
+ s.destroy({emitClose:true});
+ // console.log("============== 1")
+
+ // _server.destroy();
+ // test.done();
+ });
+ });
+ });
+});
+
+server.connect();
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test1.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test1.js
new file mode 100644
index 0000000..6e05ebd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/test1.js
@@ -0,0 +1,72 @@
+var Server = require('./lib/topologies/server');
+
+// Attempt to connect
+var server = new Server({
+ host: 'localhost', port: 27017, socketTimeout: 500
+});
+
+// function executeCursors(_server, cb) {
+// var count = 100;
+//
+// for(var i = 0; i < 100; i++) {
+// // Execute the write
+// var cursor = _server.cursor('test.test', {
+// find: 'test.test'
+// , query: {a:1}
+// }, {readPreference: new ReadPreference('secondary')});
+//
+// // Get the first document
+// cursor.next(function(err, doc) {
+// count = count - 1;
+// if(err) console.dir(err)
+// if(count == 0) return cb();
+// });
+// }
+// }
+
+server.on('connect', function(_server) {
+
+ setInterval(function() {
+ _server.insert('test.test', [{a:1}], function(err, r) {
+ console.log("insert")
+ });
+ }, 1000)
+ // console.log("---------------------------------- 0")
+ // // Attempt authentication
+ // _server.auth('scram-sha-1', 'admin', 'root', 'root', function(err, r) {
+ // console.log("---------------------------------- 1")
+ // // console.dir(err)
+ // // console.dir(r)
+ //
+ // _server.insert('test.test', [{a:1}], function(err, r) {
+ // console.log("---------------------------------- 2")
+ // console.dir(err)
+ // if(r)console.dir(r.result)
+ // var name = null;
+ //
+ // _server.on('joined', function(_t, _server) {
+ // if(name == _server.name) {
+ // console.log("=========== joined :: " + _t + " :: " + _server.name)
+ // executeCursors(_server, function() {
+ // });
+ // }
+ // })
+ //
+ // // var s = _server.s.replicaSetState.secondaries[0];
+ // // s.destroy({emitClose:true});
+ // executeCursors(_server, function() {
+ // console.log("============== 0")
+ // // Attempt to force a server reconnect
+ // var s = _server.s.replicaSetState.secondaries[0];
+ // name = s.name;
+ // s.destroy({emitClose:true});
+ // // console.log("============== 1")
+ //
+ // // _server.destroy();
+ // // test.done();
+ // });
+ // });
+ // });
+});
+
+server.connect();
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.npmignore
new file mode 100644
index 0000000..265ff73
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.npmignore
@@ -0,0 +1,8 @@
+build/
+test/
+examples/
+fs.js
+zlib.js
+.zuul.yml
+.nyc_output
+coverage
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.travis.yml
new file mode 100644
index 0000000..84504c9
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/.travis.yml
@@ -0,0 +1,49 @@
+sudo: false
+language: node_js
+before_install:
+ - npm install -g npm@2
+ - npm install -g npm
+notifications:
+ email: false
+matrix:
+ fast_finish: true
+ include:
+ - node_js: '0.8'
+ env: TASK=test
+ - node_js: '0.10'
+ env: TASK=test
+ - node_js: '0.11'
+ env: TASK=test
+ - node_js: '0.12'
+ env: TASK=test
+ - node_js: 1
+ env: TASK=test
+ - node_js: 2
+ env: TASK=test
+ - node_js: 3
+ env: TASK=test
+ - node_js: 4
+ env: TASK=test
+ - node_js: 5
+ env: TASK=test
+ - node_js: 6
+ env: TASK=test
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="-3..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
+ - node_js: 5
+ env: TASK=browser BROWSER_NAME=microsoftedge BROWSER_VERSION=latest
+script: "npm run $TASK"
+env:
+ global:
+ - secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
+ - secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/LICENSE
new file mode 100644
index 0000000..e3d4e69
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/LICENSE
@@ -0,0 +1,18 @@
+Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/README.md
new file mode 100644
index 0000000..9fb4fea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/README.md
@@ -0,0 +1,36 @@
+# readable-stream
+
+***Node-core v6.3.1 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
+
+
+[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
+[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)
+
+
+[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream)
+
+```bash
+npm install --save readable-stream
+```
+
+***Node-core streams for userland***
+
+This package is a mirror of the Streams2 and Streams3 implementations in
+Node-core, including [documentation](doc/stream.md).
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
+
+As of version 2.0.0 **readable-stream** uses semantic versioning.
+
+# Streams WG Team Members
+
+* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) &lt;christopher.s.dickinson@gmail.com&gt;
+ - Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
+* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
+ - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
+* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) &lt;rod@vagg.org&gt;
+ - Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
+* **Sam Newman** ([@sonewman](https://github.com/sonewman)) &lt;newmansam@outlook.com&gt;
+* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
+* **Domenic Denicola** ([@domenic](https://github.com/domenic)) &lt;d@domenic.me&gt;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/stream.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/stream.md
new file mode 100644
index 0000000..fc269c8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/stream.md
@@ -0,0 +1,2015 @@
+# Stream
+
+ Stability: 2 - Stable
+
+A stream is an abstract interface for working with streaming data in Node.js.
+The `stream` module provides a base API that makes it easy to build objects
+that implement the stream interface.
+
+There are many stream objects provided by Node.js. For instance, a
+[request to an HTTP server][http-incoming-message] and [`process.stdout`][]
+are both stream instances.
+
+Streams can be readable, writable, or both. All streams are instances of
+[`EventEmitter`][].
+
+The `stream` module can be accessed using:
+
+```js
+const stream = require('stream');
+```
+
+While it is important for all Node.js users to understand how streams works,
+the `stream` module itself is most useful for developer's that are creating new
+types of stream instances. Developer's who are primarily *consuming* stream
+objects will rarely (if ever) have need to use the `stream` module directly.
+
+## Organization of this document
+
+This document is divided into two primary sections and third section for
+additional notes. The first section explains the elements of the stream API that
+are required to *use* streams within an application. The second section explains
+the elements of the API that are required to *implement* new types of streams.
+
+## Types of Streams
+
+There are four fundamental stream types within Node.js:
+
+* [Readable][] - streams from which data can be read (for example
+ [`fs.createReadStream()`][]).
+* [Writable][] - streams to which data can be written (for example
+ [`fs.createWriteStream()`][]).
+* [Duplex][] - streams that are both Readable and Writable (for example
+ [`net.Socket`][]).
+* [Transform][] - Duplex streams that can modify or transform the data as it
+ is written and read (for example [`zlib.createDeflate()`][]).
+
+### Object Mode
+
+All streams created by Node.js APIs operate exclusively on strings and `Buffer`
+objects. It is possible, however, for stream implementations to work with other
+types of JavaScript values (with the exception of `null` which serves a special
+purpose within streams). Such streams are considered to operate in "object
+mode".
+
+Stream instances are switched into object mode using the `objectMode` option
+when the stream is created. Attempting to switch an existing stream into
+object mode is not safe.
+
+### Buffering
+
+<!--type=misc-->
+
+Both [Writable][] and [Readable][] streams will store data in an internal
+buffer that can be retrieved using `writable._writableState.getBuffer()` or
+`readable._readableState.buffer`, respectively.
+
+The amount of data potentially buffered depends on the `highWaterMark` option
+passed into the streams constructor. For normal streams, the `highWaterMark`
+option specifies a total number of bytes. For streams operating in object mode,
+the `highWaterMark` specifies a total number of objects.
+
+Data is buffered in Readable streams when the implementation calls
+[`stream.push(chunk)`][stream-push]. If the consumer of the Stream does not
+call [`stream.read()`][stream-read], the data will sit in the internal
+queue until it is consumed.
+
+Once the total size of the internal read buffer reaches the threshold specified
+by `highWaterMark`, the stream will temporarily stop reading data from the
+underlying resource until the data currently buffered can be consumed (that is,
+the stream will stop calling the internal `readable._read()` method that is
+used to fill the read buffer).
+
+Data is buffered in Writable streams when the
+[`writable.write(chunk)`][stream-write] method is called repeatedly. While the
+total size of the internal write buffer is below the threshold set by
+`highWaterMark`, calls to `writable.write()` will return `true`. Once the
+the size of the internal buffer reaches or exceeds the `highWaterMark`, `false`
+will be returned.
+
+A key goal of the `stream` API, and in particular the [`stream.pipe()`] method,
+is to limit the buffering of data to acceptable levels such that sources and
+destinations of differing speeds will not overwhelm the available memory.
+
+Because [Duplex][] and [Transform][] streams are both Readable and Writable,
+each maintain *two* separate internal buffers used for reading and writing,
+allowing each side to operate independently of the other while maintaining an
+appropriate and efficient flow of data. For example, [`net.Socket`][] instances
+are [Duplex][] streams whose Readable side allows consumption of data received
+*from* the socket and whose Writable side allows writing data *to* the socket.
+Because data may be written to the socket at a faster or slower rate than data
+is received, it is important each side operate (and buffer) independently of
+the other.
+
+## API for Stream Consumers
+
+<!--type=misc-->
+
+Almost all Node.js applications, no matter how simple, use streams in some
+manner. The following is an example of using streams in a Node.js application
+that implements an HTTP server:
+
+```js
+const http = require('http');
+
+const server = http.createServer( (req, res) => {
+ // req is an http.IncomingMessage, which is a Readable Stream
+ // res is an http.ServerResponse, which is a Writable Stream
+
+ let body = '';
+ // Get the data as utf8 strings.
+ // If an encoding is not set, Buffer objects will be received.
+ req.setEncoding('utf8');
+
+ // Readable streams emit 'data' events once a listener is added
+ req.on('data', (chunk) => {
+ body += chunk;
+ });
+
+ // the end event indicates that the entire body has been received
+ req.on('end', () => {
+ try {
+ const data = JSON.parse(body);
+ } catch (er) {
+ // uh oh! bad json!
+ res.statusCode = 400;
+ return res.end(`error: ${er.message}`);
+ }
+
+ // write back something interesting to the user:
+ res.write(typeof data);
+ res.end();
+ });
+});
+
+server.listen(1337);
+
+// $ curl localhost:1337 -d '{}'
+// object
+// $ curl localhost:1337 -d '"foo"'
+// string
+// $ curl localhost:1337 -d 'not json'
+// error: Unexpected token o
+```
+
+[Writable][] streams (such as `res` in the example) expose methods such as
+`write()` and `end()` that are used to write data onto the stream.
+
+[Readable][] streams use the [`EventEmitter`][] API for notifying application
+code when data is available to be read off the stream. That available data can
+be read from the stream in multiple ways.
+
+Both [Writable][] and [Readable][] streams use the [`EventEmitter`][] API in
+various ways to communicate the current state of the stream.
+
+[Duplex][] and [Transform][] streams are both [Writable][] and [Readable][].
+
+Applications that are either writing data to or consuming data from a stream
+are not required to implement the stream interfaces directly and will generally
+have no reason to call `require('stream')`.
+
+Developers wishing to implement new types of streams should refer to the
+section [API for Stream Implementers][].
+
+### Writable Streams
+
+Writable streams are an abstraction for a *destination* to which data is
+written.
+
+Examples of [Writable][] streams include:
+
+* [HTTP requests, on the client][]
+* [HTTP responses, on the server][]
+* [fs write streams][]
+* [zlib streams][zlib]
+* [crypto streams][crypto]
+* [TCP sockets][]
+* [child process stdin][]
+* [`process.stdout`][], [`process.stderr`][]
+
+*Note*: Some of these examples are actually [Duplex][] streams that implement
+the [Writable][] interface.
+
+All [Writable][] streams implement the interface defined by the
+`stream.Writable` class.
+
+While specific instances of [Writable][] streams may differ in various ways,
+all Writable streams follow the same fundamental usage pattern as illustrated
+in the example below:
+
+```js
+const myStream = getWritableStreamSomehow();
+myStream.write('some data');
+myStream.write('some more data');
+myStream.end('done writing data');
+```
+
+#### Class: stream.Writable
+<!-- YAML
+added: v0.9.4
+-->
+
+<!--type=class-->
+
+##### Event: 'close'
+<!-- YAML
+added: v0.9.4
+-->
+
+The `'close'` event is emitted when the stream and any of its underlying
+resources (a file descriptor, for example) have been closed. The event indicates
+that no more events will be emitted, and no further computation will occur.
+
+Not all Writable streams will emit the `'close'` event.
+
+##### Event: 'drain'
+<!-- YAML
+added: v0.9.4
+-->
+
+If a call to [`stream.write(chunk)`][stream-write] returns `false`, the
+`'drain'` event will be emitted when it is appropriate to resume writing data
+to the stream.
+
+```js
+// Write the data to the supplied writable stream one million times.
+// Be attentive to back-pressure.
+function writeOneMillionTimes(writer, data, encoding, callback) {
+ let i = 1000000;
+ write();
+ function write() {
+ var ok = true;
+ do {
+ i--;
+ if (i === 0) {
+ // last time!
+ writer.write(data, encoding, callback);
+ } else {
+ // see if we should continue, or wait
+ // don't pass the callback, because we're not done yet.
+ ok = writer.write(data, encoding);
+ }
+ } while (i > 0 && ok);
+ if (i > 0) {
+ // had to stop early!
+ // write some more once it drains
+ writer.once('drain', write);
+ }
+ }
+}
+```
+
+##### Event: 'error'
+<!-- YAML
+added: v0.9.4
+-->
+
+* {Error}
+
+The `'error'` event is emitted if an error occurred while writing or piping
+data. The listener callback is passed a single `Error` argument when called.
+
+*Note*: The stream is not closed when the `'error'` event is emitted.
+
+##### Event: 'finish'
+<!-- YAML
+added: v0.9.4
+-->
+
+The `'finish'` event is emitted after the [`stream.end()`][stream-end] method
+has been called, and all data has been flushed to the underlying system.
+
+```js
+const writer = getWritableStreamSomehow();
+for (var i = 0; i < 100; i ++) {
+ writer.write('hello, #${i}!\n');
+}
+writer.end('This is the end\n');
+writer.on('finish', () => {
+ console.error('All writes are now complete.');
+});
+```
+
+##### Event: 'pipe'
+<!-- YAML
+added: v0.9.4
+-->
+
+* `src` {stream.Readable} source stream that is piping to this writable
+
+The `'pipe'` event is emitted when the [`stream.pipe()`][] method is called on
+a readable stream, adding this writable to its set of destinations.
+
+```js
+const writer = getWritableStreamSomehow();
+const reader = getReadableStreamSomehow();
+writer.on('pipe', (src) => {
+ console.error('something is piping into the writer');
+ assert.equal(src, reader);
+});
+reader.pipe(writer);
+```
+
+##### Event: 'unpipe'
+<!-- YAML
+added: v0.9.4
+-->
+
+* `src` {[Readable][] Stream} The source stream that
+ [unpiped][`stream.unpipe()`] this writable
+
+The `'unpipe'` event is emitted when the [`stream.unpipe()`][] method is called
+on a [Readable][] stream, removing this [Writable][] from its set of
+destinations.
+
+```js
+const writer = getWritableStreamSomehow();
+const reader = getReadableStreamSomehow();
+writer.on('unpipe', (src) => {
+ console.error('Something has stopped piping into the writer.');
+ assert.equal(src, reader);
+});
+reader.pipe(writer);
+reader.unpipe(writer);
+```
+
+##### writable.cork()
+<!-- YAML
+added: v0.11.2
+-->
+
+The `writable.cork()` method forces all written data to be buffered in memory.
+The buffered data will be flushed when either the [`stream.uncork()`][] or
+[`stream.end()`][stream-end] methods are called.
+
+The primary intent of `writable.cork()` is to avoid a situation where writing
+many small chunks of data to a stream do not cause an backup in the internal
+buffer that would have an adverse impact on performance. In such situations,
+implementations that implement the `writable._writev()` method can perform
+buffered writes in a more optimized manner.
+
+##### writable.end([chunk][, encoding][, callback])
+<!-- YAML
+added: v0.9.4
+-->
+
+* `chunk` {String|Buffer|any} Optional data to write. For streams not operating
+ in object mode, `chunk` must be a string or a `Buffer`. For object mode
+ streams, `chunk` may be any JavaScript value other than `null`.
+* `encoding` {String} The encoding, if `chunk` is a String
+* `callback` {Function} Optional callback for when the stream is finished
+
+Calling the `writable.end()` method signals that no more data will be written
+to the [Writable][]. The optional `chunk` and `encoding` arguments allow one
+final additional chunk of data to be written immediately before closing the
+stream. If provided, the optional `callback` function is attached as a listener
+for the [`'finish'`][] event.
+
+Calling the [`stream.write()`][stream-write] method after calling
+[`stream.end()`][stream-end] will raise an error.
+
+```js
+// write 'hello, ' and then end with 'world!'
+const file = fs.createWriteStream('example.txt');
+file.write('hello, ');
+file.end('world!');
+// writing more now is not allowed!
+```
+
+##### writable.setDefaultEncoding(encoding)
+<!-- YAML
+added: v0.11.15
+-->
+
+* `encoding` {String} The new default encoding
+* Return: `this`
+
+The `writable.setDefaultEncoding()` method sets the default `encoding` for a
+[Writable][] stream.
+
+##### writable.uncork()
+<!-- YAML
+added: v0.11.2
+-->
+
+The `writable.uncork()` method flushes all data buffered since
+[`stream.cork()`][] was called.
+
+When using `writable.cork()` and `writable.uncork()` to manage the buffering
+of writes to a stream, it is recommended that calls to `writable.uncork()` be
+deferred using `process.nextTick()`. Doing so allows batching of all
+`writable.write()` calls that occur within a given Node.js event loop phase.
+
+```js
+stream.cork();
+stream.write('some ');
+stream.write('data ');
+process.nextTick(() => stream.uncork());
+```
+
+If the `writable.cork()` method is called multiple times on a stream, the same
+number of calls to `writable.uncork()` must be called to flush the buffered
+data.
+
+```
+stream.cork();
+stream.write('some ');
+stream.cork();
+stream.write('data ');
+process.nextTick(() => {
+ stream.uncork();
+ // The data will not be flushed until uncork() is called a second time.
+ stream.uncork();
+});
+```
+
+##### writable.write(chunk[, encoding][, callback])
+<!-- YAML
+added: v0.9.4
+-->
+
+* `chunk` {String|Buffer} The data to write
+* `encoding` {String} The encoding, if `chunk` is a String
+* `callback` {Function} Callback for when this chunk of data is flushed
+* Returns: {Boolean} `false` if the stream wishes for the calling code to
+ wait for the `'drain'` event to be emitted before continuing to write
+ additional data; otherwise `true`.
+
+The `writable.write()` method writes some data to the stream, and calls the
+supplied `callback` once the data has been fully handled. If an error
+occurs, the `callback` *may or may not* be called with the error as its
+first argument. To reliably detect write errors, add a listener for the
+`'error'` event.
+
+The return value indicates whether the written `chunk` was buffered internally
+and the buffer has exceeded the `highWaterMark` configured when the stream was
+created. If `false` is returned, further attempts to write data to the stream
+should be paused until the `'drain'` event is emitted.
+
+A Writable stream in object mode will always ignore the `encoding` argument.
+
+### Readable Streams
+
+Readable streams are an abstraction for a *source* from which data is
+consumed.
+
+Examples of Readable streams include:
+
+* [HTTP responses, on the client][http-incoming-message]
+* [HTTP requests, on the server][http-incoming-message]
+* [fs read streams][]
+* [zlib streams][zlib]
+* [crypto streams][crypto]
+* [TCP sockets][]
+* [child process stdout and stderr][]
+* [`process.stdin`][]
+
+All [Readable][] streams implement the interface defined by the
+`stream.Readable` class.
+
+#### Two Modes
+
+Readable streams effectively operate in one of two modes: flowing and paused.
+
+When in flowing mode, data is read from the underlying system automatically
+and provided to an application as quickly as possible using events via the
+[`EventEmitter`][] interface.
+
+In paused mode, the [`stream.read()`][stream-read] method must be called
+explicitly to read chunks of data from the stream.
+
+All [Readable][] streams begin in paused mode but can be switched to flowing
+mode in one of the following ways:
+
+* Adding a [`'data'`][] event handler.
+* Calling the [`stream.resume()`][stream-resume] method.
+* Calling the [`stream.pipe()`][] method to send the data to a [Writable][].
+
+The Readable can switch back to paused mode using one of the following:
+
+* If there are no pipe destinations, by calling the
+ [`stream.pause()`][stream-pause] method.
+* If there are pipe destinations, by removing any [`'data'`][] event
+ handlers, and removing all pipe destinations by calling the
+ [`stream.unpipe()`][] method.
+
+The important concept to remember is that a Readable will not generate data
+until a mechanism for either consuming or ignoring that data is provided. If
+the consuming mechanism is disabled or taken away, the Readable will *attempt*
+to stop generating the data.
+
+*Note*: For backwards compatibility reasons, removing [`'data'`][] event
+handlers will **not** automatically pause the stream. Also, if there are piped
+destinations, then calling [`stream.pause()`][stream-pause] will not guarantee
+that the stream will *remain* paused once those destinations drain and ask for
+more data.
+
+*Note*: If a [Readable][] is switched into flowing mode and there are no
+consumers available handle the data, that data will be lost. This can occur,
+for instance, when the `readable.resume()` method is called without a listener
+attached to the `'data'` event, or when a `'data'` event handler is removed
+from the stream.
+
+#### Three States
+
+The "two modes" of operation for a Readable stream are a simplified abstraction
+for the more complicated internal state management that is happening within the
+Readable stream implementation.
+
+Specifically, at any given point in time, every Readable is in one of three
+possible states:
+
+* `readable._readableState.flowing = null`
+* `readable._readableState.flowing = false`
+* `readable._readableState.flowing = true`
+
+When `readable._readableState.flowing` is `null`, no mechanism for consuming the
+streams data is provided so the stream will not generate its data.
+
+Attaching a listener for the `'data'` event, calling the `readable.pipe()`
+method, or calling the `readable.resume()` method will switch
+`readable._readableState.flowing` to `true`, causing the Readable to begin
+actively emitting events as data is generated.
+
+Calling `readable.pause()`, `readable.unpipe()`, or receiving "back pressure"
+will cause the `readable._readableState.flowing` to be set as `false`,
+temporarily halting the flowing of events but *not* halting the generation of
+data.
+
+While `readable._readableState.flowing` is `false`, data may be accumulating
+within the streams internal buffer.
+
+#### Choose One
+
+The Readable stream API evolved across multiple Node.js versions and provides
+multiple methods of consuming stream data. In general, developers should choose
+*one* of the methods of consuming data and *should never* use multiple methods
+to consume data from a single stream.
+
+Use of the `readable.pipe()` method is recommended for most users as it has been
+implemented to provide the easiest way of consuming stream data. Developers that
+require more fine-grained control over the transfer and generation of data can
+use the [`EventEmitter`][] and `readable.pause()`/`readable.resume()` APIs.
+
+#### Class: stream.Readable
+<!-- YAML
+added: v0.9.4
+-->
+
+<!--type=class-->
+
+##### Event: 'close'
+<!-- YAML
+added: v0.9.4
+-->
+
+The `'close'` event is emitted when the stream and any of its underlying
+resources (a file descriptor, for example) have been closed. The event indicates
+that no more events will be emitted, and no further computation will occur.
+
+Not all [Readable][] streams will emit the `'close'` event.
+
+##### Event: 'data'
+<!-- YAML
+added: v0.9.4
+-->
+
+* `chunk` {Buffer|String|any} The chunk of data. For streams that are not
+ operating in object mode, the chunk will be either a string or `Buffer`.
+ For streams that are in object mode, the chunk can be any JavaScript value
+ other than `null`.
+
+The `'data'` event is emitted whenever the stream is relinquishing ownership of
+a chunk of data to a consumer. This may occur whenever the stream is switched
+in flowing mode by calling `readable.pipe()`, `readable.resume()`, or by
+attaching a listener callback to the `'data'` event. The `'data'` event will
+also be emitted whenever the `readable.read()` method is called and a chunk of
+data is available to be returned.
+
+Attaching a `'data'` event listener to a stream that has not been explicitly
+paused will switch the stream into flowing mode. Data will then be passed as
+soon as it is available.
+
+The listener callback will be passed the chunk of data as a string if a default
+encoding has been specified for the stream using the
+`readable.setEncoding()` method; otherwise the data will be passed as a
+`Buffer`.
+
+```js
+const readable = getReadableStreamSomehow();
+readable.on('data', (chunk) => {
+ console.log(`Received ${chunk.length} bytes of data.`);
+});
+```
+
+##### Event: 'end'
+<!-- YAML
+added: v0.9.4
+-->
+
+The `'end'` event is emitted when there is no more data to be consumed from
+the stream.
+
+*Note*: The `'end'` event **will not be emitted** unless the data is
+completely consumed. This can be accomplished by switching the stream into
+flowing mode, or by calling [`stream.read()`][stream-read] repeatedly until
+all data has been consumed.
+
+```js
+const readable = getReadableStreamSomehow();
+readable.on('data', (chunk) => {
+ console.log(`Received ${chunk.length} bytes of data.`);
+});
+readable.on('end', () => {
+ console.log('There will be no more data.');
+});
+```
+
+##### Event: 'error'
+<!-- YAML
+added: v0.9.4
+-->
+
+* {Error}
+
+The `'error'` event may be emitted by a Readable implementation at any time.
+Typically, this may occur if the underlying stream in unable to generate data
+due to an underlying internal failure, or when a stream implementation attempts
+to push an invalid chunk of data.
+
+The listener callback will be passed a single `Error` object.
+
+##### Event: 'readable'
+<!-- YAML
+added: v0.9.4
+-->
+
+The `'readable'` event is emitted when there is data available to be read from
+the stream. In some cases, attaching a listener for the `'readable'` event will
+cause some amount of data to be read into an internal buffer.
+
+```javascript
+const readable = getReadableStreamSomehow();
+readable.on('readable', () => {
+ // there is some data to read now
+});
+```
+The `'readable'` event will also be emitted once the end of the stream data
+has been reached but before the `'end'` event is emitted.
+
+Effectively, the `'readable'` event indicates that the stream has new
+information: either new data is available or the end of the stream has been
+reached. In the former case, [`stream.read()`][stream-read] will return the
+available data. In the latter case, [`stream.read()`][stream-read] will return
+`null`. For instance, in the following example, `foo.txt` is an empty file:
+
+```js
+const fs = require('fs');
+const rr = fs.createReadStream('foo.txt');
+rr.on('readable', () => {
+ console.log('readable:', rr.read());
+});
+rr.on('end', () => {
+ console.log('end');
+});
+```
+
+The output of running this script is:
+
+```
+$ node test.js
+readable: null
+end
+```
+
+*Note*: In general, the `readable.pipe()` and `'data'` event mechanisms are
+preferred over the use of the `'readable'` event.
+
+##### readable.isPaused()
+<!--
+added: v0.11.14
+-->
+
+* Return: {Boolean}
+
+The `readable.isPaused()` method returns the current operating state of the
+Readable. This is used primarily by the mechanism that underlies the
+`readable.pipe()` method. In most typical cases, there will be no reason to
+use this method directly.
+
+```js
+const readable = new stream.Readable
+
+readable.isPaused() // === false
+readable.pause()
+readable.isPaused() // === true
+readable.resume()
+readable.isPaused() // === false
+```
+
+##### readable.pause()
+<!-- YAML
+added: v0.9.4
+-->
+
+* Return: `this`
+
+The `readable.pause()` method will cause a stream in flowing mode to stop
+emitting [`'data'`][] events, switching out of flowing mode. Any data that
+becomes available will remain in the internal buffer.
+
+```js
+const readable = getReadableStreamSomehow();
+readable.on('data', (chunk) => {
+ console.log(`Received ${chunk.length} bytes of data.`);
+ readable.pause();
+ console.log('There will be no additional data for 1 second.');
+ setTimeout(() => {
+ console.log('Now data will start flowing again.');
+ readable.resume();
+ }, 1000);
+});
+```
+
+##### readable.pipe(destination[, options])
+<!-- YAML
+added: v0.9.4
+-->
+
+* `destination` {stream.Writable} The destination for writing data
+* `options` {Object} Pipe options
+ * `end` {Boolean} End the writer when the reader ends. Defaults to `true`.
+
+The `readable.pipe()` method attaches a [Writable][] stream to the `readable`,
+causing it to switch automatically into flowing mode and push all of its data
+to the attached [Writable][]. The flow of data will be automatically managed so
+that the destination Writable stream is not overwhelmed by a faster Readable
+stream.
+
+The following example pipes all of the data from the `readable` into a file
+named `file.txt`:
+
+```js
+const readable = getReadableStreamSomehow();
+const writable = fs.createWriteStream('file.txt');
+// All the data from readable goes into 'file.txt'
+readable.pipe(writable);
+```
+It is possible to attach multiple Writable streams to a single Readable stream.
+
+The `readable.pipe()` method returns a reference to the *destination* stream
+making it possible to set up chains of piped streams:
+
+```js
+const r = fs.createReadStream('file.txt');
+const z = zlib.createGzip();
+const w = fs.createWriteStream('file.txt.gz');
+r.pipe(z).pipe(w);
+```
+
+By default, [`stream.end()`][stream-end] is called on the destination Writable
+stream when the source Readable stream emits [`'end'`][], so that the
+destination is no longer writable. To disable this default behavior, the `end`
+option can be passed as `false`, causing the destination stream to remain open,
+as illustrated in the following example:
+
+```js
+reader.pipe(writer, { end: false });
+reader.on('end', () => {
+ writer.end('Goodbye\n');
+});
+```
+
+One important caveat is that if the Readable stream emits an error during
+processing, the Writable destination *is not closed* automatically. If an
+error occurs, it will be necessary to *manually* close each stream in order
+to prevent memory leaks.
+
+*Note*: The [`process.stderr`][] and [`process.stdout`][] Writable streams are
+never closed until the Node.js process exits, regardless of the specified
+options.
+
+##### readable.read([size])
+<!-- YAML
+added: v0.9.4
+-->
+
+* `size` {Number} Optional argument to specify how much data to read.
+* Return {String|Buffer|Null}
+
+The `readable.read()` method pulls some data out of the internal buffer and
+returns it. If no data available to be read, `null` is returned. By default,
+the data will be returned as a `Buffer` object unless an encoding has been
+specified using the `readable.setEncoding()` method or the stream is operating
+in object mode.
+
+The optional `size` argument specifies a specific number of bytes to read. If
+`size` bytes are not available to be read, `null` will be returned *unless*
+the stream has ended, in which case all of the data remaining in the internal
+buffer will be returned (*even if it exceeds `size` bytes*).
+
+If the `size` argument is not specified, all of the data contained in the
+internal buffer will be returned.
+
+The `readable.read()` method should only be called on Readable streams operating
+in paused mode. In flowing mode, `readable.read()` is called automatically until
+the internal buffer is fully drained.
+
+```js
+const readable = getReadableStreamSomehow();
+readable.on('readable', () => {
+ var chunk;
+ while (null !== (chunk = readable.read())) {
+ console.log(`Received ${chunk.length} bytes of data.`);
+ }
+});
+```
+
+In general, it is recommended that developers avoid the use of the `'readable'`
+event and the `readable.read()` method in favor of using either
+`readable.pipe()` or the `'data'` event.
+
+A Readable stream in object mode will always return a single item from
+a call to [`readable.read(size)`][stream-read], regardless of the value of the
+`size` argument.
+
+*Note:* If the `readable.read()` method returns a chunk of data, a `'data'`
+event will also be emitted.
+
+*Note*: Calling [`stream.read([size])`][stream-read] after the [`'end'`][]
+event has been emitted will return `null`. No runtime error will be raised.
+
+##### readable.resume()
+<!-- YAML
+added: v0.9.4
+-->
+
+* Return: `this`
+
+The `readable.resume()` method causes an explicitly paused Readable stream to
+resume emitting [`'data'`][] events, switching the stream into flowing mode.
+
+The `readable.resume()` method can be used to fully consume the data from a
+stream without actually processing any of that data as illustrated in the
+following example:
+
+```js
+getReadableStreamSomehow()
+ .resume()
+ .on('end', () => {
+ console.log('Reached the end, but did not read anything.');
+ });
+```
+
+##### readable.setEncoding(encoding)
+<!-- YAML
+added: v0.9.4
+-->
+
+* `encoding` {String} The encoding to use.
+* Return: `this`
+
+The `readable.setEncoding()` method sets the default character encoding for
+data read from the Readable stream.
+
+Setting an encoding causes the stream data
+to be returned as string of the specified encoding rather than as `Buffer`
+objects. For instance, calling `readable.setEncoding('utf8')` will cause the
+output data will be interpreted as UTF-8 data, and passed as strings. Calling
+`readable.setEncoding('hex')` will cause the data to be encoded in hexadecimal
+string format.
+
+The Readable stream will properly handle multi-byte characters delivered through
+the stream that would otherwise become improperly decoded if simply pulled from
+the stream as `Buffer` objects.
+
+Encoding can be disabled by calling `readable.setEncoding(null)`. This approach
+is useful when working with binary data or with large multi-byte strings spread
+out over multiple chunks.
+
+```js
+const readable = getReadableStreamSomehow();
+readable.setEncoding('utf8');
+readable.on('data', (chunk) => {
+ assert.equal(typeof chunk, 'string');
+ console.log('got %d characters of string data', chunk.length);
+});
+```
+
+##### readable.unpipe([destination])
+<!-- YAML
+added: v0.9.4
+-->
+
+* `destination` {stream.Writable} Optional specific stream to unpipe
+
+The `readable.unpipe()` method detaches a Writable stream previously attached
+using the [`stream.pipe()`][] method.
+
+If the `destination` is not specified, then *all* pipes are detached.
+
+If the `destination` is specified, but no pipe is set up for it, then
+the method does nothing.
+
+```js
+const readable = getReadableStreamSomehow();
+const writable = fs.createWriteStream('file.txt');
+// All the data from readable goes into 'file.txt',
+// but only for the first second
+readable.pipe(writable);
+setTimeout(() => {
+ console.log('Stop writing to file.txt');
+ readable.unpipe(writable);
+ console.log('Manually close the file stream');
+ writable.end();
+}, 1000);
+```
+
+##### readable.unshift(chunk)
+<!-- YAML
+added: v0.9.11
+-->
+
+* `chunk` {Buffer|String} Chunk of data to unshift onto the read queue
+
+The `readable.unshift()` method pushes a chunk of data back into the internal
+buffer. This is useful in certain situations where a stream is being consumed by
+code that needs to "un-consume" some amount of data that it has optimistically
+pulled out of the source, so that the data can be passed on to some other party.
+
+*Note*: The `stream.unshift(chunk)` method cannot be called after the
+[`'end'`][] event has been emitted or a runtime error will be thrown.
+
+Developers using `stream.unshift()` often should consider switching to
+use of a [Transform][] stream instead. See the [API for Stream Implementers][]
+section for more information.
+
+```js
+// Pull off a header delimited by \n\n
+// use unshift() if we get too much
+// Call the callback with (error, header, stream)
+const StringDecoder = require('string_decoder').StringDecoder;
+function parseHeader(stream, callback) {
+ stream.on('error', callback);
+ stream.on('readable', onReadable);
+ const decoder = new StringDecoder('utf8');
+ var header = '';
+ function onReadable() {
+ var chunk;
+ while (null !== (chunk = stream.read())) {
+ var str = decoder.write(chunk);
+ if (str.match(/\n\n/)) {
+ // found the header boundary
+ var split = str.split(/\n\n/);
+ header += split.shift();
+ const remaining = split.join('\n\n');
+ const buf = Buffer.from(remaining, 'utf8');
+ if (buf.length)
+ stream.unshift(buf);
+ stream.removeListener('error', callback);
+ stream.removeListener('readable', onReadable);
+ // now the body of the message can be read from the stream.
+ callback(null, header, stream);
+ } else {
+ // still reading the header.
+ header += str;
+ }
+ }
+ }
+}
+```
+
+*Note*: Unlike [`stream.push(chunk)`][stream-push], `stream.unshift(chunk)`
+will not end the reading process by resetting the internal reading state of the
+stream. This can cause unexpected results if `readable.unshift()` is called
+during a read (i.e. from within a [`stream._read()`][stream-_read]
+implementation on a custom stream). Following the call to `readable.unshift()`
+with an immediate [`stream.push('')`][stream-push] will reset the reading state
+appropriately, however it is best to simply avoid calling `readable.unshift()`
+while in the process of performing a read.
+
+##### readable.wrap(stream)
+<!-- YAML
+added: v0.9.4
+-->
+
+* `stream` {Stream} An "old style" readable stream
+
+Versions of Node.js prior to v0.10 had streams that did not implement the
+entire `stream` module API as it is currently defined. (See [Compatibility][]
+for more information.)
+
+When using an older Node.js library that emits [`'data'`][] events and has a
+[`stream.pause()`][stream-pause] method that is advisory only, the
+`readable.wrap()` method can be used to create a [Readable][] stream that uses
+the old stream as its data source.
+
+It will rarely be necessary to use `readable.wrap()` but the method has been
+provided as a convenience for interacting with older Node.js applications and
+libraries.
+
+For example:
+
+```js
+const OldReader = require('./old-api-module.js').OldReader;
+const Readable = require('stream').Readable;
+const oreader = new OldReader;
+const myReader = new Readable().wrap(oreader);
+
+myReader.on('readable', () => {
+ myReader.read(); // etc.
+});
+```
+
+### Duplex and Transform Streams
+
+#### Class: stream.Duplex
+<!-- YAML
+added: v0.9.4
+-->
+
+<!--type=class-->
+
+Duplex streams are streams that implement both the [Readable][] and
+[Writable][] interfaces.
+
+Examples of Duplex streams include:
+
+* [TCP sockets][]
+* [zlib streams][zlib]
+* [crypto streams][crypto]
+
+#### Class: stream.Transform
+<!-- YAML
+added: v0.9.4
+-->
+
+<!--type=class-->
+
+Transform streams are [Duplex][] streams where the output is in some way
+related to the input. Like all [Duplex][] streams, Transform streams
+implement both the [Readable][] and [Writable][] interfaces.
+
+Examples of Transform streams include:
+
+* [zlib streams][zlib]
+* [crypto streams][crypto]
+
+
+## API for Stream Implementers
+
+<!--type=misc-->
+
+The `stream` module API has been designed to make it possible to easily
+implement streams using JavaScript's prototypical inheritance model.
+
+First, a stream developer would declare a new JavaScript class that extends one
+of the four basic stream classes (`stream.Writable`, `stream.Readable`,
+`stream.Duplex`, or `stream.Transform`), making sure the call the appropriate
+parent class constructor:
+
+```js
+const Writable = require('stream').Writable;
+
+class MyWritable extends Writable {
+ constructor(options) {
+ super(options);
+ }
+}
+```
+
+The new stream class must then implement one or more specific methods, depending
+on the type of stream being created, as detailed in the chart below:
+
+<table>
+ <thead>
+ <tr>
+ <th>
+ <p>Use-case</p>
+ </th>
+ <th>
+ <p>Class</p>
+ </th>
+ <th>
+ <p>Method(s) to implement</p>
+ </th>
+ </tr>
+ </thead>
+ <tr>
+ <td>
+ <p>Reading only</p>
+ </td>
+ <td>
+ <p>[Readable](#stream_class_stream_readable)</p>
+ </td>
+ <td>
+ <p><code>[_read][stream-_read]</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Writing only</p>
+ </td>
+ <td>
+ <p>[Writable](#stream_class_stream_writable)</p>
+ </td>
+ <td>
+ <p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Reading and writing</p>
+ </td>
+ <td>
+ <p>[Duplex](#stream_class_stream_duplex)</p>
+ </td>
+ <td>
+ <p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <p>Operate on written data, then read the result</p>
+ </td>
+ <td>
+ <p>[Transform](#stream_class_stream_transform)</p>
+ </td>
+ <td>
+ <p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code></p>
+ </td>
+ </tr>
+</table>
+
+*Note*: The implementation code for a stream should *never* call the "public"
+methods of a stream that are intended for use by consumers (as described in
+the [API for Stream Consumers][] section). Doing so may lead to adverse
+side effects in application code consuming the stream.
+
+### Simplified Construction
+
+For many simple cases, it is possible to construct a stream without relying on
+inheritance. This can be accomplished by directly creating instances of the
+`stream.Writable`, `stream.Readable`, `stream.Duplex` or `stream.Transform`
+objects and passing appropriate methods as constructor options.
+
+For example:
+
+```js
+const Writable = require('stream').Writable;
+
+const myWritable = new Writable({
+ write(chunk, encoding, callback) {
+ // ...
+ }
+});
+```
+
+### Implementing a Writable Stream
+
+The `stream.Writable` class is extended to implement a [Writable][] stream.
+
+Custom Writable streams *must* call the `new stream.Writable([options])`
+constructor and implement the `writable._write()` method. The
+`writable._writev()` method *may* also be implemented.
+
+#### Constructor: new stream.Writable([options])
+
+* `options` {Object}
+ * `highWaterMark` {Number} Buffer level when
+ [`stream.write()`][stream-write] starts returning `false`. Defaults to
+ `16384` (16kb), or `16` for `objectMode` streams.
+ * `decodeStrings` {Boolean} Whether or not to decode strings into
+ Buffers before passing them to [`stream._write()`][stream-_write].
+ Defaults to `true`
+ * `objectMode` {Boolean} Whether or not the
+ [`stream.write(anyObj)`][stream-write] is a valid operation. When set,
+ it becomes possible to write JavaScript values other than string or
+ `Buffer` if supported by the stream implementation. Defaults to `false`
+ * `write` {Function} Implementation for the
+ [`stream._write()`][stream-_write] method.
+ * `writev` {Function} Implementation for the
+ [`stream._writev()`][stream-_writev] method.
+
+For example:
+
+```js
+const Writable = require('stream').Writable;
+
+class MyWritable extends Writable {
+ constructor(options) {
+ // Calls the stream.Writable() constructor
+ super(options);
+ }
+}
+```
+
+Or, when using pre-ES6 style constructors:
+
+```js
+const Writable = require('stream').Writable;
+const util = require('util');
+
+function MyWritable(options) {
+ if (!(this instanceof MyWritable))
+ return new MyWritable(options);
+ Writable.call(this, options);
+}
+util.inherits(MyWritable, Writable);
+```
+
+Or, using the Simplified Constructor approach:
+
+```js
+const Writable = require('stream').Writable;
+
+const myWritable = new Writable({
+ write(chunk, encoding, callback) {
+ // ...
+ },
+ writev(chunks, callback) {
+ // ...
+ }
+});
+```
+
+#### writable.\_write(chunk, encoding, callback)
+
+* `chunk` {Buffer|String} The chunk to be written. Will **always**
+ be a buffer unless the `decodeStrings` option was set to `false`.
+* `encoding` {String} If the chunk is a string, then `encoding` is the
+ character encoding of that string. If chunk is a `Buffer`, or if the
+ stream is operating in object mode, `encoding` may be ignored.
+* `callback` {Function} Call this function (optionally with an error
+ argument) when processing is complete for the supplied chunk.
+
+All Writable stream implementations must provide a
+[`writable._write()`][stream-_write] method to send data to the underlying
+resource.
+
+*Note*: [Transform][] streams provide their own implementation of the
+[`writable._write()`][stream-_write].
+
+*Note*: **This function MUST NOT be called by application code directly.** It
+should be implemented by child classes, and called only by the internal Writable
+class methods only.
+
+The `callback` method must be called to signal either that the write completed
+successfully or failed with an error. The first argument passed to the
+`callback` must be the `Error` object if the call failed or `null` if the
+write succeeded.
+
+It is important to note that all calls to `writable.write()` that occur between
+the time `writable._write()` is called and the `callback` is called will cause
+the written data to be buffered. Once the `callback` is invoked, the stream will
+emit a `'drain'` event. If a stream implementation is capable of processing
+multiple chunks of data at once, the `writable._writev()` method should be
+implemented.
+
+If the `decodeStrings` property is set in the constructor options, then
+`chunk` may be a string rather than a Buffer, and `encoding` will
+indicate the character encoding of the string. This is to support
+implementations that have an optimized handling for certain string
+data encodings. If the `decodeStrings` property is explicitly set to `false`,
+the `encoding` argument can be safely ignored, and `chunk` will always be a
+`Buffer`.
+
+The `writable._write()` method is prefixed with an underscore because it is
+internal to the class that defines it, and should never be called directly by
+user programs.
+
+#### writable.\_writev(chunks, callback)
+
+* `chunks` {Array} The chunks to be written. Each chunk has following
+ format: `{ chunk: ..., encoding: ... }`.
+* `callback` {Function} A callback function (optionally with an error
+ argument) to be invoked when processing is complete for the supplied chunks.
+
+*Note*: **This function MUST NOT be called by application code directly.** It
+should be implemented by child classes, and called only by the internal Writable
+class methods only.
+
+The `writable._writev()` method may be implemented in addition to
+`writable._write()` in stream implementations that are capable of processing
+multiple chunks of data at once. If implemented, the method will be called with
+all chunks of data currently buffered in the write queue.
+
+The `writable._writev()` method is prefixed with an underscore because it is
+internal to the class that defines it, and should never be called directly by
+user programs.
+
+#### Errors While Writing
+
+It is recommended that errors occurring during the processing of the
+`writable._write()` and `writable._writev()` methods are reported by invoking
+the callback and passing the error as the first argument. This will cause an
+`'error'` event to be emitted by the Writable. Throwing an Error from within
+`writable._write()` can result in expected and inconsistent behavior depending
+on how the stream is being used. Using the callback ensures consistent and
+predictable handling of errors.
+
+```js
+const Writable = require('stream').Writable;
+
+const myWritable = new Writable({
+ write(chunk, encoding, callback) {
+ if (chunk.toString().indexOf('a') >= 0) {
+ callback(new Error('chunk is invalid'));
+ } else {
+ callback();
+ }
+ }
+});
+```
+
+#### An Example Writable Stream
+
+The following illustrates a rather simplistic (and somewhat pointless) custom
+Writable stream implementation. While this specific Writable stream instance
+is not of any real particular usefulness, the example illustrates each of the
+required elements of a custom [Writable][] stream instance:
+
+```js
+const Writable = require('stream').Writable;
+
+class MyWritable extends Writable {
+ constructor(options) {
+ super(options);
+ }
+
+ _write(chunk, encoding, callback) {
+ if (chunk.toString().indexOf('a') >= 0) {
+ callback(new Error('chunk is invalid'));
+ } else {
+ callback();
+ }
+ }
+}
+```
+
+### Implementing a Readable Stream
+
+The `stream.Readable` class is extended to implement a [Readable][] stream.
+
+Custom Readable streams *must* call the `new stream.Readable([options])`
+constructor and implement the `readable._read()` method.
+
+#### new stream.Readable([options])
+
+* `options` {Object}
+ * `highWaterMark` {Number} The maximum number of bytes to store in
+ the internal buffer before ceasing to read from the underlying
+ resource. Defaults to `16384` (16kb), or `16` for `objectMode` streams
+ * `encoding` {String} If specified, then buffers will be decoded to
+ strings using the specified encoding. Defaults to `null`
+ * `objectMode` {Boolean} Whether this stream should behave
+ as a stream of objects. Meaning that [`stream.read(n)`][stream-read] returns
+ a single value instead of a Buffer of size n. Defaults to `false`
+ * `read` {Function} Implementation for the [`stream._read()`][stream-_read]
+ method.
+
+For example:
+
+```js
+const Readable = require('stream').Readable;
+
+class MyReadable extends Readable {
+ constructor(options) {
+ // Calls the stream.Readable(options) constructor
+ super(options);
+ }
+}
+```
+
+Or, when using pre-ES6 style constructors:
+
+```js
+const Readable = require('stream').Readable;
+const util = require('util');
+
+function MyReadable(options) {
+ if (!(this instanceof MyReadable))
+ return new MyReadable(options);
+ Readable.call(this, options);
+}
+util.inherits(MyReadable, Readable);
+```
+
+Or, using the Simplified Constructor approach:
+
+```js
+const Readable = require('stream').Readable;
+
+const myReadable = new Readable({
+ read(size) {
+ // ...
+ }
+});
+```
+
+#### readable.\_read(size)
+
+* `size` {Number} Number of bytes to read asynchronously
+
+*Note*: **This function MUST NOT be called by application code directly.** It
+should be implemented by child classes, and called only by the internal Readable
+class methods only.
+
+All Readable stream implementations must provide an implementation of the
+`readable._read()` method to fetch data from the underlying resource.
+
+When `readable._read()` is called, if data is available from the resource, the
+implementation should begin pushing that data into the read queue using the
+[`this.push(dataChunk)`][stream-push] method. `_read()` should continue reading
+from the resource and pushing data until `readable.push()` returns `false`. Only
+when `_read()` is called again after it has stopped should it resume pushing
+additional data onto the queue.
+
+*Note*: Once the `readable._read()` method has been called, it will not be
+called again until the [`readable.push()`][stream-push] method is called.
+
+The `size` argument is advisory. For implementations where a "read" is a
+single operation that returns data can use the `size` argument to determine how
+much data to fetch. Other implementations may ignore this argument and simply
+provide data whenever it becomes available. There is no need to "wait" until
+`size` bytes are available before calling [`stream.push(chunk)`][stream-push].
+
+The `readable._read()` method is prefixed with an underscore because it is
+internal to the class that defines it, and should never be called directly by
+user programs.
+
+#### readable.push(chunk[, encoding])
+
+* `chunk` {Buffer|Null|String} Chunk of data to push into the read queue
+* `encoding` {String} Encoding of String chunks. Must be a valid
+ Buffer encoding, such as `'utf8'` or `'ascii'`
+* Returns {Boolean} `true` if additional chunks of data may continued to be
+ pushed; `false` otherwise.
+
+When `chunk` is a `Buffer` or `string`, the `chunk` of data will be added to the
+internal queue for users of the stream to consume. Passing `chunk` as `null`
+signals the end of the stream (EOF), after which no more data can be written.
+
+When the Readable is operating in paused mode, the data added with
+`readable.push()` can be read out by calling the
+[`readable.read()`][stream-read] method when the [`'readable'`][] event is
+emitted.
+
+When the Readable is operating in flowing mode, the data added with
+`readable.push()` will be delivered by emitting a `'data'` event.
+
+The `readable.push()` method is designed to be as flexible as possible. For
+example, when wrapping a lower-level source that provides some form of
+pause/resume mechanism, and a data callback, the low-level source can be wrapped
+by the custom Readable instance as illustrated in the following example:
+
+```js
+// source is an object with readStop() and readStart() methods,
+// and an `ondata` member that gets called when it has data, and
+// an `onend` member that gets called when the data is over.
+
+class SourceWrapper extends Readable {
+ constructor(options) {
+ super(options);
+
+ this._source = getLowlevelSourceObject();
+
+ // Every time there's data, push it into the internal buffer.
+ this._source.ondata = (chunk) => {
+ // if push() returns false, then stop reading from source
+ if (!this.push(chunk))
+ this._source.readStop();
+ };
+
+ // When the source ends, push the EOF-signaling `null` chunk
+ this._source.onend = () => {
+ this.push(null);
+ };
+ }
+ // _read will be called when the stream wants to pull more data in
+ // the advisory size argument is ignored in this case.
+ _read(size) {
+ this._source.readStart();
+ }
+}
+```
+*Note*: The `readable.push()` method is intended be called only by Readable
+Implementers, and only from within the `readable._read()` method.
+
+#### Errors While Reading
+
+It is recommended that errors occurring during the processing of the
+`readable._read()` method are emitted using the `'error'` event rather than
+being thrown. Throwing an Error from within `readable._read()` can result in
+expected and inconsistent behavior depending on whether the stream is operating
+in flowing or paused mode. Using the `'error'` event ensures consistent and
+predictable handling of errors.
+
+```js
+const Readable = require('stream').Readable;
+
+const myReadable = new Readable({
+ read(size) {
+ if (checkSomeErrorCondition()) {
+ process.nextTick(() => this.emit('error', err));
+ return;
+ }
+ // do some work
+ }
+});
+```
+
+#### An Example Counting Stream
+
+<!--type=example-->
+
+The following is a basic example of a Readable stream that emits the numerals
+from 1 to 1,000,000 in ascending order, and then ends.
+
+```js
+const Readable = require('stream').Readable;
+
+class Counter extends Readable {
+ constructor(opt) {
+ super(opt);
+ this._max = 1000000;
+ this._index = 1;
+ }
+
+ _read() {
+ var i = this._index++;
+ if (i > this._max)
+ this.push(null);
+ else {
+ var str = '' + i;
+ var buf = Buffer.from(str, 'ascii');
+ this.push(buf);
+ }
+ }
+}
+```
+
+### Implementing a Duplex Stream
+
+A [Duplex][] stream is one that implements both [Readable][] and [Writable][],
+such as a TCP socket connection.
+
+Because Javascript does not have support for multiple inheritance, the
+`stream.Duplex` class is extended to implement a [Duplex][] stream (as opposed
+to extending the `stream.Readable` *and* `stream.Writable` classes).
+
+*Note*: The `stream.Duplex` class prototypically inherits from `stream.Readable`
+and parasitically from `stream.Writable`.
+
+Custom Duplex streams *must* call the `new stream.Duplex([options])`
+constructor and implement *both* the `readable._read()` and
+`writable._write()` methods.
+
+#### new stream.Duplex(options)
+
+* `options` {Object} Passed to both Writable and Readable
+ constructors. Also has the following fields:
+ * `allowHalfOpen` {Boolean} Defaults to `true`. If set to `false`, then
+ the stream will automatically end the readable side when the
+ writable side ends and vice versa.
+ * `readableObjectMode` {Boolean} Defaults to `false`. Sets `objectMode`
+ for readable side of the stream. Has no effect if `objectMode`
+ is `true`.
+ * `writableObjectMode` {Boolean} Defaults to `false`. Sets `objectMode`
+ for writable side of the stream. Has no effect if `objectMode`
+ is `true`.
+
+For example:
+
+```js
+const Duplex = require('stream').Duplex;
+
+class MyDuplex extends Duplex {
+ constructor(options) {
+ super(options);
+ }
+}
+```
+
+Or, when using pre-ES6 style constructors:
+
+```js
+const Duplex = require('stream').Duplex;
+const util = require('util');
+
+function MyDuplex(options) {
+ if (!(this instanceof MyDuplex))
+ return new MyDuplex(options);
+ Duplex.call(this, options);
+}
+util.inherits(MyDuplex, Duplex);
+```
+
+Or, using the Simplified Constructor approach:
+
+```js
+const Duplex = require('stream').Duplex;
+
+const myDuplex = new Duplex({
+ read(size) {
+ // ...
+ },
+ write(chunk, encoding, callback) {
+ // ...
+ }
+});
+```
+
+#### An Example Duplex Stream
+
+The following illustrates a simple example of a Duplex stream that wraps a
+hypothetical lower-level source object to which data can be written, and
+from which data can be read, albeit using an API that is not compatible with
+Node.js streams.
+The following illustrates a simple example of a Duplex stream that buffers
+incoming written data via the [Writable][] interface that is read back out
+via the [Readable][] interface.
+
+```js
+const Duplex = require('stream').Duplex;
+const kSource = Symbol('source');
+
+class MyDuplex extends Duplex {
+ constructor(source, options) {
+ super(options);
+ this[kSource] = source;
+ }
+
+ _write(chunk, encoding, callback) {
+ // The underlying source only deals with strings
+ if (Buffer.isBuffer(chunk))
+ chunk = chunk.toString(encoding);
+ this[kSource].writeSomeData(chunk, encoding);
+ callback();
+ }
+
+ _read(size) {
+ this[kSource].fetchSomeData(size, (data, encoding) => {
+ this.push(Buffer.from(data, encoding));
+ });
+ }
+}
+```
+
+The most important aspect of a Duplex stream is that the Readable and Writable
+sides operate independently of one another despite co-existing within a single
+object instance.
+
+#### Object Mode Duplex Streams
+
+For Duplex streams, `objectMode` can be set exclusively for either the Readable
+or Writable side using the `readableObjectMode` and `writableObjectMode` options
+respectively.
+
+In the following example, for instance, a new Transform stream (which is a
+type of [Duplex][] stream) is created that has an object mode Writable side
+that accepts JavaScript numbers that are converted to hexidecimal strings on
+the Readable side.
+
+```js
+const Transform = require('stream').Transform;
+
+// All Transform streams are also Duplex Streams
+const myTransform = new Transform({
+ writableObjectMode: true,
+
+ transform(chunk, encoding, callback) {
+ // Coerce the chunk to a number if necessary
+ chunk |= 0;
+
+ // Transform the chunk into something else.
+ const data = chunk.toString(16);
+
+ // Push the data onto the readable queue.
+ callback(null, '0'.repeat(data.length % 2) + data);
+ }
+});
+
+myTransform.setEncoding('ascii');
+myTransform.on('data', (chunk) => console.log(chunk));
+
+myTransform.write(1);
+ // Prints: 01
+myTransform.write(10);
+ // Prints: 0a
+myTransform.write(100);
+ // Prints: 64
+```
+
+### Implementing a Transform Stream
+
+A [Transform][] stream is a [Duplex][] stream where the output is computed
+in some way from the input. Examples include [zlib][] streams or [crypto][]
+streams that compress, encrypt, or decrypt data.
+
+*Note*: There is no requirement that the output be the same size as the input,
+the same number of chunks, or arrive at the same time. For example, a
+Hash stream will only ever have a single chunk of output which is
+provided when the input is ended. A `zlib` stream will produce output
+that is either much smaller or much larger than its input.
+
+The `stream.Transform` class is extended to implement a [Transform][] stream.
+
+The `stream.Transform` class prototypically inherits from `stream.Duplex` and
+implements its own versions of the `writable._write()` and `readable._read()`
+methods. Custom Transform implementations *must* implement the
+[`transform._transform()`][stream-_transform] method and *may* also implement
+the [`transform._flush()`][stream-_flush] method.
+
+*Note*: Care must be taken when using Transform streams in that data written
+to the stream can cause the Writable side of the stream to become paused if
+the output on the Readable side is not consumed.
+
+#### new stream.Transform([options])
+
+* `options` {Object} Passed to both Writable and Readable
+ constructors. Also has the following fields:
+ * `transform` {Function} Implementation for the
+ [`stream._transform()`][stream-_transform] method.
+ * `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush]
+ method.
+
+For example:
+
+```js
+const Transform = require('stream').Transform;
+
+class MyTransform extends Transform {
+ constructor(options) {
+ super(options);
+ }
+}
+```
+
+Or, when using pre-ES6 style constructors:
+
+```js
+const Transform = require('stream').Transform;
+const util = require('util');
+
+function MyTransform(options) {
+ if (!(this instanceof MyTransform))
+ return new MyTransform(options);
+ Transform.call(this, options);
+}
+util.inherits(MyTransform, Transform);
+```
+
+Or, using the Simplified Constructor approach:
+
+```js
+const Transform = require('stream').Transform;
+
+const myTransform = new Transform({
+ transform(chunk, encoding, callback) {
+ // ...
+ }
+});
+```
+
+#### Events: 'finish' and 'end'
+
+The [`'finish'`][] and [`'end'`][] events are from the `stream.Writable`
+and `stream.Readable` classes, respectively. The `'finish'` event is emitted
+after [`stream.end()`][stream-end] is called and all chunks have been processed
+by [`stream._transform()`][stream-_transform]. The `'end'` event is emitted
+after all data has been output, which occurs after the callback in
+[`transform._flush()`][stream-_flush] has been called.
+
+#### transform.\_flush(callback)
+
+* `callback` {Function} A callback function (optionally with an error
+ argument) to be called when remaining data has been flushed.
+
+*Note*: **This function MUST NOT be called by application code directly.** It
+should be implemented by child classes, and called only by the internal Readable
+class methods only.
+
+In some cases, a transform operation may need to emit an additional bit of
+data at the end of the stream. For example, a `zlib` compression stream will
+store an amount of internal state used to optimally compress the output. When
+the stream ends, however, that additional data needs to be flushed so that the
+compressed data will be complete.
+
+Custom [Transform][] implementations *may* implement the `transform._flush()`
+method. This will be called when there is no more written data to be consumed,
+but before the [`'end'`][] event is emitted signaling the end of the
+[Readable][] stream.
+
+Within the `transform._flush()` implementation, the `readable.push()` method
+may be called zero or more times, as appropriate. The `callback` function must
+be called when the flush operation is complete.
+
+The `transform._flush()` method is prefixed with an underscore because it is
+internal to the class that defines it, and should never be called directly by
+user programs.
+
+#### transform.\_transform(chunk, encoding, callback)
+
+* `chunk` {Buffer|String} The chunk to be transformed. Will **always**
+ be a buffer unless the `decodeStrings` option was set to `false`.
+* `encoding` {String} If the chunk is a string, then this is the
+ encoding type. If chunk is a buffer, then this is the special
+ value - 'buffer', ignore it in this case.
+* `callback` {Function} A callback function (optionally with an error
+ argument and data) to be called after the supplied `chunk` has been
+ processed.
+
+*Note*: **This function MUST NOT be called by application code directly.** It
+should be implemented by child classes, and called only by the internal Readable
+class methods only.
+
+All Transform stream implementations must provide a `_transform()`
+method to accept input and produce output. The `transform._transform()`
+implementation handles the bytes being written, computes an output, then passes
+that output off to the readable portion using the `readable.push()` method.
+
+The `transform.push()` method may be called zero or more times to generate
+output from a single input chunk, depending on how much is to be output
+as a result of the chunk.
+
+It is possible that no output is generated from any given chunk of input data.
+
+The `callback` function must be called only when the current chunk is completely
+consumed. The first argument passed to the `callback` must be an `Error` object
+if an error occurred while processing the input or `null` otherwise. If a second
+argument is passed to the `callback`, it will be forwarded on to the
+`readable.push()` method. In other words the following are equivalent:
+
+```js
+transform.prototype._transform = function (data, encoding, callback) {
+ this.push(data);
+ callback();
+};
+
+transform.prototype._transform = function (data, encoding, callback) {
+ callback(null, data);
+};
+```
+
+The `transform._transform()` method is prefixed with an underscore because it
+is internal to the class that defines it, and should never be called directly by
+user programs.
+
+#### Class: stream.PassThrough
+
+The `stream.PassThrough` class is a trivial implementation of a [Transform][]
+stream that simply passes the input bytes across to the output. Its purpose is
+primarily for examples and testing, but there are some use cases where
+`stream.PassThrough` is useful as a building block for novel sorts of streams.
+
+## Additional Notes
+
+<!--type=misc-->
+
+### Compatibility with Older Node.js Versions
+
+<!--type=misc-->
+
+In versions of Node.js prior to v0.10, the Readable stream interface was
+simpler, but also less powerful and less useful.
+
+* Rather than waiting for calls the [`stream.read()`][stream-read] method,
+ [`'data'`][] events would begin emitting immediately. Applications that
+ would need to perform some amount of work to decide how to handle data
+ were required to store read data into buffers so the data would not be lost.
+* The [`stream.pause()`][stream-pause] method was advisory, rather than
+ guaranteed. This meant that it was still necessary to be prepared to receive
+ [`'data'`][] events *even when the stream was in a paused state*.
+
+In Node.js v0.10, the [Readable][] class was added. For backwards compatibility
+with older Node.js programs, Readable streams switch into "flowing mode" when a
+[`'data'`][] event handler is added, or when the
+[`stream.resume()`][stream-resume] method is called. The effect is that, even
+when not using the new [`stream.read()`][stream-read] method and
+[`'readable'`][] event, it is no longer necessary to worry about losing
+[`'data'`][] chunks.
+
+While most applications will continue to function normally, this introduces an
+edge case in the following conditions:
+
+* No [`'data'`][] event listener is added.
+* The [`stream.resume()`][stream-resume] method is never called.
+* The stream is not piped to any writable destination.
+
+For example, consider the following code:
+
+```js
+// WARNING! BROKEN!
+net.createServer((socket) => {
+
+ // we add an 'end' method, but never consume the data
+ socket.on('end', () => {
+ // It will never get here.
+ socket.end('The message was received but was not processed.\n');
+ });
+
+}).listen(1337);
+```
+
+In versions of Node.js prior to v0.10, the incoming message data would be
+simply discarded. However, in Node.js v0.10 and beyond, the socket remains
+paused forever.
+
+The workaround in this situation is to call the
+[`stream.resume()`][stream-resume] method to begin the flow of data:
+
+```js
+// Workaround
+net.createServer((socket) => {
+
+ socket.on('end', () => {
+ socket.end('The message was received but was not processed.\n');
+ });
+
+ // start the flow of data, discarding it.
+ socket.resume();
+
+}).listen(1337);
+```
+
+In addition to new Readable streams switching into flowing mode,
+pre-v0.10 style streams can be wrapped in a Readable class using the
+[`readable.wrap()`][`stream.wrap()`] method.
+
+
+### `readable.read(0)`
+
+There are some cases where it is necessary to trigger a refresh of the
+underlying readable stream mechanisms, without actually consuming any
+data. In such cases, it is possible to call `readable.read(0)`, which will
+always return `null`.
+
+If the internal read buffer is below the `highWaterMark`, and the
+stream is not currently reading, then calling `stream.read(0)` will trigger
+a low-level [`stream._read()`][stream-_read] call.
+
+While most applications will almost never need to do this, there are
+situations within Node.js where this is done, particularly in the
+Readable stream class internals.
+
+### `readable.push('')`
+
+Use of `readable.push('')` is not recommended.
+
+Pushing a zero-byte string or `Buffer` to a stream that is not in object mode
+has an interesting side effect. Because it *is* a call to
+[`readable.push()`][stream-push], the call will end the reading process.
+However, because the argument is an empty string, no data is added to the
+readable buffer so there is nothing for a user to consume.
+
+[`'data'`]: #stream_event_data
+[`'drain'`]: #stream_event_drain
+[`'end'`]: #stream_event_end
+[`'finish'`]: #stream_event_finish
+[`'readable'`]: #stream_event_readable
+[`buf.toString(encoding)`]: https://nodejs.org/docs/v6.3.1/api/buffer.html#buffer_buf_tostring_encoding_start_end
+[`EventEmitter`]: https://nodejs.org/docs/v6.3.1/api/events.html#events_class_eventemitter
+[`process.stderr`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stderr
+[`process.stdin`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdin
+[`process.stdout`]: https://nodejs.org/docs/v6.3.1/api/process.html#process_process_stdout
+[`stream.cork()`]: #stream_writable_cork
+[`stream.pipe()`]: #stream_readable_pipe_destination_options
+[`stream.uncork()`]: #stream_writable_uncork
+[`stream.unpipe()`]: #stream_readable_unpipe_destination
+[`stream.wrap()`]: #stream_readable_wrap_stream
+[`tls.CryptoStream`]: https://nodejs.org/docs/v6.3.1/api/tls.html#tls_class_cryptostream
+[API for Stream Consumers]: #stream_api_for_stream_consumers
+[API for Stream Implementers]: #stream_api_for_stream_implementers
+[child process stdin]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdin
+[child process stdout and stderr]: https://nodejs.org/docs/v6.3.1/api/child_process.html#child_process_child_stdout
+[Compatibility]: #stream_compatibility_with_older_node_js_versions
+[crypto]: crypto.html
+[Duplex]: #stream_class_stream_duplex
+[fs read streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_readstream
+[fs write streams]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_class_fs_writestream
+[`fs.createReadStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createreadstream_path_options
+[`fs.createWriteStream()`]: https://nodejs.org/docs/v6.3.1/api/fs.html#fs_fs_createwritestream_path_options
+[`net.Socket`]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
+[`zlib.createDeflate()`]: https://nodejs.org/docs/v6.3.1/api/zlib.html#zlib_zlib_createdeflate_options
+[HTTP requests, on the client]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_clientrequest
+[HTTP responses, on the server]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_serverresponse
+[http-incoming-message]: https://nodejs.org/docs/v6.3.1/api/http.html#http_class_http_incomingmessage
+[Object mode]: #stream_object_mode
+[Readable]: #stream_class_stream_readable
+[SimpleProtocol v2]: #stream_example_simpleprotocol_parser_v2
+[stream-_flush]: #stream_transform_flush_callback
+[stream-_read]: #stream_readable_read_size_1
+[stream-_transform]: #stream_transform_transform_chunk_encoding_callback
+[stream-_write]: #stream_writable_write_chunk_encoding_callback_1
+[stream-_writev]: #stream_writable_writev_chunks_callback
+[stream-end]: #stream_writable_end_chunk_encoding_callback
+[stream-pause]: #stream_readable_pause
+[stream-push]: #stream_readable_push_chunk_encoding
+[stream-read]: #stream_readable_read_size
+[stream-resume]: #stream_readable_resume
+[stream-write]: #stream_writable_write_chunk_encoding_callback
+[TCP sockets]: https://nodejs.org/docs/v6.3.1/api/net.html#net_class_net_socket
+[Transform]: #stream_class_stream_transform
+[Writable]: #stream_class_stream_writable
+[zlib]: zlib.html
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
new file mode 100644
index 0000000..83275f1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
@@ -0,0 +1,60 @@
+# streams WG Meeting 2015-01-30
+
+## Links
+
+* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
+* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
+* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
+
+## Agenda
+
+Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
+
+* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
+* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
+* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
+* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
+
+## Minutes
+
+### adopt a charter
+
+* group: +1's all around
+
+### What versioning scheme should be adopted?
+* group: +1’s 3.0.0
+* domenic+group: pulling in patches from other sources where appropriate
+* mikeal: version independently, suggesting versions for io.js
+* mikeal+domenic: work with TC to notify in advance of changes
+simpler stream creation
+
+### streamline creation of streams
+* sam: streamline creation of streams
+* domenic: nice simple solution posted
+ but, we lose the opportunity to change the model
+ may not be backwards incompatible (double check keys)
+
+ **action item:** domenic will check
+
+### remove implicit flowing of streams on(‘data’)
+* add isFlowing / isPaused
+* mikeal: worrying that we’re documenting polyfill methods – confuses users
+* domenic: more reflective API is probably good, with warning labels for users
+* new section for mad scientists (reflective stream access)
+* calvin: name the “third state”
+* mikeal: maybe borrow the name from whatwg?
+* domenic: we’re missing the “third state”
+* consensus: kind of difficult to name the third state
+* mikeal: figure out differences in states / compat
+* mathias: always flow on data – eliminates third state
+ * explore what it breaks
+
+**action items:**
+* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
+* ask rod/build for infrastructure
+* **chris**: explore the “flow on data” approach
+* add isPaused/isFlowing
+* add new docs section
+* move isPaused to that section
+
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/duplex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/duplex.js
new file mode 100644
index 0000000..ca807af
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/duplex.js
@@ -0,0 +1 @@
+module.exports = require("./lib/_stream_duplex.js")
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_duplex.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_duplex.js
new file mode 100644
index 0000000..736693b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_duplex.js
@@ -0,0 +1,75 @@
+// a duplex stream is just a stream that is both readable and writable.
+// Since JS doesn't have multiple prototypal inheritance, this class
+// prototypally inherits from Readable, and then parasitically from
+// Writable.
+
+'use strict';
+
+/*<replacement>*/
+
+var objectKeys = Object.keys || function (obj) {
+ var keys = [];
+ for (var key in obj) {
+ keys.push(key);
+ }return keys;
+};
+/*</replacement>*/
+
+module.exports = Duplex;
+
+/*<replacement>*/
+var processNextTick = require('process-nextick-args');
+/*</replacement>*/
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+var Readable = require('./_stream_readable');
+var Writable = require('./_stream_writable');
+
+util.inherits(Duplex, Readable);
+
+var keys = objectKeys(Writable.prototype);
+for (var v = 0; v < keys.length; v++) {
+ var method = keys[v];
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
+}
+
+function Duplex(options) {
+ if (!(this instanceof Duplex)) return new Duplex(options);
+
+ Readable.call(this, options);
+ Writable.call(this, options);
+
+ if (options && options.readable === false) this.readable = false;
+
+ if (options && options.writable === false) this.writable = false;
+
+ this.allowHalfOpen = true;
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
+
+ this.once('end', onend);
+}
+
+// the no-half-open enforcer
+function onend() {
+ // if we allow half-open state, or if the writable side ended,
+ // then we're ok.
+ if (this.allowHalfOpen || this._writableState.ended) return;
+
+ // no more data can be written.
+ // But allow more writes to happen in this tick.
+ processNextTick(onEndNT, this);
+}
+
+function onEndNT(self) {
+ self.end();
+}
+
+function forEach(xs, f) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ f(xs[i], i);
+ }
+} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_passthrough.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_passthrough.js
new file mode 100644
index 0000000..d06f71f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_passthrough.js
@@ -0,0 +1,26 @@
+// a passthrough stream.
+// basically just the most minimal sort of Transform stream.
+// Every written chunk gets output as-is.
+
+'use strict';
+
+module.exports = PassThrough;
+
+var Transform = require('./_stream_transform');
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+util.inherits(PassThrough, Transform);
+
+function PassThrough(options) {
+ if (!(this instanceof PassThrough)) return new PassThrough(options);
+
+ Transform.call(this, options);
+}
+
+PassThrough.prototype._transform = function (chunk, encoding, cb) {
+ cb(null, chunk);
+}; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_readable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_readable.js
new file mode 100644
index 0000000..208cc65
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_readable.js
@@ -0,0 +1,937 @@
+'use strict';
+
+module.exports = Readable;
+
+/*<replacement>*/
+var processNextTick = require('process-nextick-args');
+/*</replacement>*/
+
+/*<replacement>*/
+var isArray = require('isarray');
+/*</replacement>*/
+
+Readable.ReadableState = ReadableState;
+
+/*<replacement>*/
+var EE = require('events').EventEmitter;
+
+var EElistenerCount = function (emitter, type) {
+ return emitter.listeners(type).length;
+};
+/*</replacement>*/
+
+/*<replacement>*/
+var Stream;
+(function () {
+ try {
+ Stream = require('st' + 'ream');
+ } catch (_) {} finally {
+ if (!Stream) Stream = require('events').EventEmitter;
+ }
+})();
+/*</replacement>*/
+
+var Buffer = require('buffer').Buffer;
+/*<replacement>*/
+var bufferShim = require('buffer-shims');
+/*</replacement>*/
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+/*<replacement>*/
+var debugUtil = require('util');
+var debug = void 0;
+if (debugUtil && debugUtil.debuglog) {
+ debug = debugUtil.debuglog('stream');
+} else {
+ debug = function () {};
+}
+/*</replacement>*/
+
+var BufferList = require('./internal/streams/BufferList');
+var StringDecoder;
+
+util.inherits(Readable, Stream);
+
+function prependListener(emitter, event, fn) {
+ if (typeof emitter.prependListener === 'function') {
+ return emitter.prependListener(event, fn);
+ } else {
+ // This is a hack to make sure that our error handler is attached before any
+ // userland ones. NEVER DO THIS. This is here only because this code needs
+ // to continue to work with older versions of Node.js that do not include
+ // the prependListener() method. The goal is to eventually remove this hack.
+ if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
+ }
+}
+
+var Duplex;
+function ReadableState(options, stream) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ options = options || {};
+
+ // object stream flag. Used to make read(n) ignore n and to
+ // make all the buffer merging and length checks go away
+ this.objectMode = !!options.objectMode;
+
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
+
+ // the point at which it stops calling _read() to fill the buffer
+ // Note: 0 is a valid value, means "don't call _read preemptively ever"
+ var hwm = options.highWaterMark;
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
+
+ // cast to ints.
+ this.highWaterMark = ~ ~this.highWaterMark;
+
+ // A linked list is used to store data chunks instead of an array because the
+ // linked list can remove elements from the beginning faster than
+ // array.shift()
+ this.buffer = new BufferList();
+ this.length = 0;
+ this.pipes = null;
+ this.pipesCount = 0;
+ this.flowing = null;
+ this.ended = false;
+ this.endEmitted = false;
+ this.reading = false;
+
+ // a flag to be able to tell if the onwrite cb is called immediately,
+ // or on a later tick. We set this to true at first, because any
+ // actions that shouldn't happen until "later" should generally also
+ // not happen before the first write call.
+ this.sync = true;
+
+ // whenever we return null, then we set a flag to say
+ // that we're awaiting a 'readable' event emission.
+ this.needReadable = false;
+ this.emittedReadable = false;
+ this.readableListening = false;
+ this.resumeScheduled = false;
+
+ // Crypto is kind of old and crusty. Historically, its default string
+ // encoding is 'binary' so we have to make this configurable.
+ // Everything else in the universe uses 'utf8', though.
+ this.defaultEncoding = options.defaultEncoding || 'utf8';
+
+ // when piping, we only care about 'readable' events that happen
+ // after read()ing all the bytes and not getting any pushback.
+ this.ranOut = false;
+
+ // the number of writers that are awaiting a drain event in .pipe()s
+ this.awaitDrain = 0;
+
+ // if true, a maybeReadMore has been scheduled
+ this.readingMore = false;
+
+ this.decoder = null;
+ this.encoding = null;
+ if (options.encoding) {
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
+ this.decoder = new StringDecoder(options.encoding);
+ this.encoding = options.encoding;
+ }
+}
+
+var Duplex;
+function Readable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ if (!(this instanceof Readable)) return new Readable(options);
+
+ this._readableState = new ReadableState(options, this);
+
+ // legacy
+ this.readable = true;
+
+ if (options && typeof options.read === 'function') this._read = options.read;
+
+ Stream.call(this);
+}
+
+// Manually shove something into the read() buffer.
+// This returns true if the highWaterMark has not been hit yet,
+// similar to how Writable.write() returns true if you should
+// write() some more.
+Readable.prototype.push = function (chunk, encoding) {
+ var state = this._readableState;
+
+ if (!state.objectMode && typeof chunk === 'string') {
+ encoding = encoding || state.defaultEncoding;
+ if (encoding !== state.encoding) {
+ chunk = bufferShim.from(chunk, encoding);
+ encoding = '';
+ }
+ }
+
+ return readableAddChunk(this, state, chunk, encoding, false);
+};
+
+// Unshift should *always* be something directly out of read()
+Readable.prototype.unshift = function (chunk) {
+ var state = this._readableState;
+ return readableAddChunk(this, state, chunk, '', true);
+};
+
+Readable.prototype.isPaused = function () {
+ return this._readableState.flowing === false;
+};
+
+function readableAddChunk(stream, state, chunk, encoding, addToFront) {
+ var er = chunkInvalid(state, chunk);
+ if (er) {
+ stream.emit('error', er);
+ } else if (chunk === null) {
+ state.reading = false;
+ onEofChunk(stream, state);
+ } else if (state.objectMode || chunk && chunk.length > 0) {
+ if (state.ended && !addToFront) {
+ var e = new Error('stream.push() after EOF');
+ stream.emit('error', e);
+ } else if (state.endEmitted && addToFront) {
+ var _e = new Error('stream.unshift() after end event');
+ stream.emit('error', _e);
+ } else {
+ var skipAdd;
+ if (state.decoder && !addToFront && !encoding) {
+ chunk = state.decoder.write(chunk);
+ skipAdd = !state.objectMode && chunk.length === 0;
+ }
+
+ if (!addToFront) state.reading = false;
+
+ // Don't add to the buffer if we've decoded to an empty string chunk and
+ // we're not in object mode
+ if (!skipAdd) {
+ // if we want the data now, just emit it.
+ if (state.flowing && state.length === 0 && !state.sync) {
+ stream.emit('data', chunk);
+ stream.read(0);
+ } else {
+ // update the buffer info.
+ state.length += state.objectMode ? 1 : chunk.length;
+ if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
+
+ if (state.needReadable) emitReadable(stream);
+ }
+ }
+
+ maybeReadMore(stream, state);
+ }
+ } else if (!addToFront) {
+ state.reading = false;
+ }
+
+ return needMoreData(state);
+}
+
+// if it's past the high water mark, we can push in some more.
+// Also, if we have no data yet, we can stand some
+// more bytes. This is to work around cases where hwm=0,
+// such as the repl. Also, if the push() triggered a
+// readable event, and the user called read(largeNumber) such that
+// needReadable was set, then we ought to push more, so that another
+// 'readable' event will be triggered.
+function needMoreData(state) {
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
+}
+
+// backwards compatibility.
+Readable.prototype.setEncoding = function (enc) {
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
+ this._readableState.decoder = new StringDecoder(enc);
+ this._readableState.encoding = enc;
+ return this;
+};
+
+// Don't raise the hwm > 8MB
+var MAX_HWM = 0x800000;
+function computeNewHighWaterMark(n) {
+ if (n >= MAX_HWM) {
+ n = MAX_HWM;
+ } else {
+ // Get the next highest power of 2 to prevent increasing hwm excessively in
+ // tiny amounts
+ n--;
+ n |= n >>> 1;
+ n |= n >>> 2;
+ n |= n >>> 4;
+ n |= n >>> 8;
+ n |= n >>> 16;
+ n++;
+ }
+ return n;
+}
+
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function howMuchToRead(n, state) {
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
+ if (state.objectMode) return 1;
+ if (n !== n) {
+ // Only flow one buffer at a time
+ if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
+ }
+ // If we're asking for more than the current hwm, then raise the hwm.
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
+ if (n <= state.length) return n;
+ // Don't have enough
+ if (!state.ended) {
+ state.needReadable = true;
+ return 0;
+ }
+ return state.length;
+}
+
+// you can override either this method, or the async _read(n) below.
+Readable.prototype.read = function (n) {
+ debug('read', n);
+ n = parseInt(n, 10);
+ var state = this._readableState;
+ var nOrig = n;
+
+ if (n !== 0) state.emittedReadable = false;
+
+ // if we're doing read(0) to trigger a readable event, but we
+ // already have a bunch of data in the buffer, then just trigger
+ // the 'readable' event and move on.
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
+ debug('read: emitReadable', state.length, state.ended);
+ if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
+ return null;
+ }
+
+ n = howMuchToRead(n, state);
+
+ // if we've ended, and we're now clear, then finish it up.
+ if (n === 0 && state.ended) {
+ if (state.length === 0) endReadable(this);
+ return null;
+ }
+
+ // All the actual chunk generation logic needs to be
+ // *below* the call to _read. The reason is that in certain
+ // synthetic stream cases, such as passthrough streams, _read
+ // may be a completely synchronous operation which may change
+ // the state of the read buffer, providing enough data when
+ // before there was *not* enough.
+ //
+ // So, the steps are:
+ // 1. Figure out what the state of things will be after we do
+ // a read from the buffer.
+ //
+ // 2. If that resulting state will trigger a _read, then call _read.
+ // Note that this may be asynchronous, or synchronous. Yes, it is
+ // deeply ugly to write APIs this way, but that still doesn't mean
+ // that the Readable class should behave improperly, as streams are
+ // designed to be sync/async agnostic.
+ // Take note if the _read call is sync or async (ie, if the read call
+ // has returned yet), so that we know whether or not it's safe to emit
+ // 'readable' etc.
+ //
+ // 3. Actually pull the requested chunks out of the buffer and return.
+
+ // if we need a readable event, then we need to do some reading.
+ var doRead = state.needReadable;
+ debug('need readable', doRead);
+
+ // if we currently have less than the highWaterMark, then also read some
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
+ doRead = true;
+ debug('length less than watermark', doRead);
+ }
+
+ // however, if we've ended, then there's no point, and if we're already
+ // reading, then it's unnecessary.
+ if (state.ended || state.reading) {
+ doRead = false;
+ debug('reading or ended', doRead);
+ } else if (doRead) {
+ debug('do read');
+ state.reading = true;
+ state.sync = true;
+ // if the length is currently zero, then we *need* a readable event.
+ if (state.length === 0) state.needReadable = true;
+ // call internal read method
+ this._read(state.highWaterMark);
+ state.sync = false;
+ // If _read pushed data synchronously, then `reading` will be false,
+ // and we need to re-evaluate how much data we can return to the user.
+ if (!state.reading) n = howMuchToRead(nOrig, state);
+ }
+
+ var ret;
+ if (n > 0) ret = fromList(n, state);else ret = null;
+
+ if (ret === null) {
+ state.needReadable = true;
+ n = 0;
+ } else {
+ state.length -= n;
+ }
+
+ if (state.length === 0) {
+ // If we have nothing in the buffer, then we want to know
+ // as soon as we *do* get something into the buffer.
+ if (!state.ended) state.needReadable = true;
+
+ // If we tried to read() past the EOF, then emit end on the next tick.
+ if (nOrig !== n && state.ended) endReadable(this);
+ }
+
+ if (ret !== null) this.emit('data', ret);
+
+ return ret;
+};
+
+function chunkInvalid(state, chunk) {
+ var er = null;
+ if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
+ er = new TypeError('Invalid non-string/buffer chunk');
+ }
+ return er;
+}
+
+function onEofChunk(stream, state) {
+ if (state.ended) return;
+ if (state.decoder) {
+ var chunk = state.decoder.end();
+ if (chunk && chunk.length) {
+ state.buffer.push(chunk);
+ state.length += state.objectMode ? 1 : chunk.length;
+ }
+ }
+ state.ended = true;
+
+ // emit 'readable' now to make sure it gets picked up.
+ emitReadable(stream);
+}
+
+// Don't emit readable right away in sync mode, because this can trigger
+// another read() call => stack overflow. This way, it might trigger
+// a nextTick recursion warning, but that's not so bad.
+function emitReadable(stream) {
+ var state = stream._readableState;
+ state.needReadable = false;
+ if (!state.emittedReadable) {
+ debug('emitReadable', state.flowing);
+ state.emittedReadable = true;
+ if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
+ }
+}
+
+function emitReadable_(stream) {
+ debug('emit readable');
+ stream.emit('readable');
+ flow(stream);
+}
+
+// at this point, the user has presumably seen the 'readable' event,
+// and called read() to consume some data. that may have triggered
+// in turn another _read(n) call, in which case reading = true if
+// it's in progress.
+// However, if we're not ended, or reading, and the length < hwm,
+// then go ahead and try to read some more preemptively.
+function maybeReadMore(stream, state) {
+ if (!state.readingMore) {
+ state.readingMore = true;
+ processNextTick(maybeReadMore_, stream, state);
+ }
+}
+
+function maybeReadMore_(stream, state) {
+ var len = state.length;
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
+ debug('maybeReadMore read 0');
+ stream.read(0);
+ if (len === state.length)
+ // didn't get any data, stop spinning.
+ break;else len = state.length;
+ }
+ state.readingMore = false;
+}
+
+// abstract method. to be overridden in specific implementation classes.
+// call cb(er, data) where data is <= n in length.
+// for virtual (non-string, non-buffer) streams, "length" is somewhat
+// arbitrary, and perhaps not very meaningful.
+Readable.prototype._read = function (n) {
+ this.emit('error', new Error('not implemented'));
+};
+
+Readable.prototype.pipe = function (dest, pipeOpts) {
+ var src = this;
+ var state = this._readableState;
+
+ switch (state.pipesCount) {
+ case 0:
+ state.pipes = dest;
+ break;
+ case 1:
+ state.pipes = [state.pipes, dest];
+ break;
+ default:
+ state.pipes.push(dest);
+ break;
+ }
+ state.pipesCount += 1;
+ debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
+
+ var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
+
+ var endFn = doEnd ? onend : cleanup;
+ if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
+
+ dest.on('unpipe', onunpipe);
+ function onunpipe(readable) {
+ debug('onunpipe');
+ if (readable === src) {
+ cleanup();
+ }
+ }
+
+ function onend() {
+ debug('onend');
+ dest.end();
+ }
+
+ // when the dest drains, it reduces the awaitDrain counter
+ // on the source. This would be more elegant with a .once()
+ // handler in flow(), but adding and removing repeatedly is
+ // too slow.
+ var ondrain = pipeOnDrain(src);
+ dest.on('drain', ondrain);
+
+ var cleanedUp = false;
+ function cleanup() {
+ debug('cleanup');
+ // cleanup event handlers once the pipe is broken
+ dest.removeListener('close', onclose);
+ dest.removeListener('finish', onfinish);
+ dest.removeListener('drain', ondrain);
+ dest.removeListener('error', onerror);
+ dest.removeListener('unpipe', onunpipe);
+ src.removeListener('end', onend);
+ src.removeListener('end', cleanup);
+ src.removeListener('data', ondata);
+
+ cleanedUp = true;
+
+ // if the reader is waiting for a drain event from this
+ // specific writer, then it would cause it to never start
+ // flowing again.
+ // So, if this is awaiting a drain, then we just call it now.
+ // If we don't know, then assume that we are waiting for one.
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
+ }
+
+ // If the user pushes more data while we're writing to dest then we'll end up
+ // in ondata again. However, we only want to increase awaitDrain once because
+ // dest will only emit one 'drain' event for the multiple writes.
+ // => Introduce a guard on increasing awaitDrain.
+ var increasedAwaitDrain = false;
+ src.on('data', ondata);
+ function ondata(chunk) {
+ debug('ondata');
+ increasedAwaitDrain = false;
+ var ret = dest.write(chunk);
+ if (false === ret && !increasedAwaitDrain) {
+ // If the user unpiped during `dest.write()`, it is possible
+ // to get stuck in a permanently paused state if that write
+ // also returned false.
+ // => Check whether `dest` is still a piping destination.
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
+ debug('false write response, pause', src._readableState.awaitDrain);
+ src._readableState.awaitDrain++;
+ increasedAwaitDrain = true;
+ }
+ src.pause();
+ }
+ }
+
+ // if the dest has an error, then stop piping into it.
+ // however, don't suppress the throwing behavior for this.
+ function onerror(er) {
+ debug('onerror', er);
+ unpipe();
+ dest.removeListener('error', onerror);
+ if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
+ }
+
+ // Make sure our error handler is attached before userland ones.
+ prependListener(dest, 'error', onerror);
+
+ // Both close and finish should trigger unpipe, but only once.
+ function onclose() {
+ dest.removeListener('finish', onfinish);
+ unpipe();
+ }
+ dest.once('close', onclose);
+ function onfinish() {
+ debug('onfinish');
+ dest.removeListener('close', onclose);
+ unpipe();
+ }
+ dest.once('finish', onfinish);
+
+ function unpipe() {
+ debug('unpipe');
+ src.unpipe(dest);
+ }
+
+ // tell the dest that it's being piped to
+ dest.emit('pipe', src);
+
+ // start the flow if it hasn't been started already.
+ if (!state.flowing) {
+ debug('pipe resume');
+ src.resume();
+ }
+
+ return dest;
+};
+
+function pipeOnDrain(src) {
+ return function () {
+ var state = src._readableState;
+ debug('pipeOnDrain', state.awaitDrain);
+ if (state.awaitDrain) state.awaitDrain--;
+ if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
+ state.flowing = true;
+ flow(src);
+ }
+ };
+}
+
+Readable.prototype.unpipe = function (dest) {
+ var state = this._readableState;
+
+ // if we're not piping anywhere, then do nothing.
+ if (state.pipesCount === 0) return this;
+
+ // just one destination. most common case.
+ if (state.pipesCount === 1) {
+ // passed in one, but it's not the right one.
+ if (dest && dest !== state.pipes) return this;
+
+ if (!dest) dest = state.pipes;
+
+ // got a match.
+ state.pipes = null;
+ state.pipesCount = 0;
+ state.flowing = false;
+ if (dest) dest.emit('unpipe', this);
+ return this;
+ }
+
+ // slow case. multiple pipe destinations.
+
+ if (!dest) {
+ // remove all.
+ var dests = state.pipes;
+ var len = state.pipesCount;
+ state.pipes = null;
+ state.pipesCount = 0;
+ state.flowing = false;
+
+ for (var _i = 0; _i < len; _i++) {
+ dests[_i].emit('unpipe', this);
+ }return this;
+ }
+
+ // try to find the right one.
+ var i = indexOf(state.pipes, dest);
+ if (i === -1) return this;
+
+ state.pipes.splice(i, 1);
+ state.pipesCount -= 1;
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
+
+ dest.emit('unpipe', this);
+
+ return this;
+};
+
+// set up data events if they are asked for
+// Ensure readable listeners eventually get something
+Readable.prototype.on = function (ev, fn) {
+ var res = Stream.prototype.on.call(this, ev, fn);
+
+ if (ev === 'data') {
+ // Start flowing on next tick if stream isn't explicitly paused
+ if (this._readableState.flowing !== false) this.resume();
+ } else if (ev === 'readable') {
+ var state = this._readableState;
+ if (!state.endEmitted && !state.readableListening) {
+ state.readableListening = state.needReadable = true;
+ state.emittedReadable = false;
+ if (!state.reading) {
+ processNextTick(nReadingNextTick, this);
+ } else if (state.length) {
+ emitReadable(this, state);
+ }
+ }
+ }
+
+ return res;
+};
+Readable.prototype.addListener = Readable.prototype.on;
+
+function nReadingNextTick(self) {
+ debug('readable nexttick read 0');
+ self.read(0);
+}
+
+// pause() and resume() are remnants of the legacy readable stream API
+// If the user uses them, then switch into old mode.
+Readable.prototype.resume = function () {
+ var state = this._readableState;
+ if (!state.flowing) {
+ debug('resume');
+ state.flowing = true;
+ resume(this, state);
+ }
+ return this;
+};
+
+function resume(stream, state) {
+ if (!state.resumeScheduled) {
+ state.resumeScheduled = true;
+ processNextTick(resume_, stream, state);
+ }
+}
+
+function resume_(stream, state) {
+ if (!state.reading) {
+ debug('resume read 0');
+ stream.read(0);
+ }
+
+ state.resumeScheduled = false;
+ state.awaitDrain = 0;
+ stream.emit('resume');
+ flow(stream);
+ if (state.flowing && !state.reading) stream.read(0);
+}
+
+Readable.prototype.pause = function () {
+ debug('call pause flowing=%j', this._readableState.flowing);
+ if (false !== this._readableState.flowing) {
+ debug('pause');
+ this._readableState.flowing = false;
+ this.emit('pause');
+ }
+ return this;
+};
+
+function flow(stream) {
+ var state = stream._readableState;
+ debug('flow', state.flowing);
+ while (state.flowing && stream.read() !== null) {}
+}
+
+// wrap an old-style stream as the async data source.
+// This is *not* part of the readable stream interface.
+// It is an ugly unfortunate mess of history.
+Readable.prototype.wrap = function (stream) {
+ var state = this._readableState;
+ var paused = false;
+
+ var self = this;
+ stream.on('end', function () {
+ debug('wrapped end');
+ if (state.decoder && !state.ended) {
+ var chunk = state.decoder.end();
+ if (chunk && chunk.length) self.push(chunk);
+ }
+
+ self.push(null);
+ });
+
+ stream.on('data', function (chunk) {
+ debug('wrapped data');
+ if (state.decoder) chunk = state.decoder.write(chunk);
+
+ // don't skip over falsy values in objectMode
+ if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
+
+ var ret = self.push(chunk);
+ if (!ret) {
+ paused = true;
+ stream.pause();
+ }
+ });
+
+ // proxy all the other methods.
+ // important when wrapping filters and duplexes.
+ for (var i in stream) {
+ if (this[i] === undefined && typeof stream[i] === 'function') {
+ this[i] = function (method) {
+ return function () {
+ return stream[method].apply(stream, arguments);
+ };
+ }(i);
+ }
+ }
+
+ // proxy certain important events.
+ var events = ['error', 'close', 'destroy', 'pause', 'resume'];
+ forEach(events, function (ev) {
+ stream.on(ev, self.emit.bind(self, ev));
+ });
+
+ // when we try to consume some more bytes, simply unpause the
+ // underlying stream.
+ self._read = function (n) {
+ debug('wrapped _read', n);
+ if (paused) {
+ paused = false;
+ stream.resume();
+ }
+ };
+
+ return self;
+};
+
+// exposed for testing purposes only.
+Readable._fromList = fromList;
+
+// Pluck off n bytes from an array of buffers.
+// Length is the combined lengths of all the buffers in the list.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function fromList(n, state) {
+ // nothing buffered
+ if (state.length === 0) return null;
+
+ var ret;
+ if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
+ // read it all, truncate the list
+ if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
+ state.buffer.clear();
+ } else {
+ // read part of list
+ ret = fromListPartial(n, state.buffer, state.decoder);
+ }
+
+ return ret;
+}
+
+// Extracts only enough buffered data to satisfy the amount requested.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function fromListPartial(n, list, hasStrings) {
+ var ret;
+ if (n < list.head.data.length) {
+ // slice is the same for buffers and strings
+ ret = list.head.data.slice(0, n);
+ list.head.data = list.head.data.slice(n);
+ } else if (n === list.head.data.length) {
+ // first chunk is a perfect match
+ ret = list.shift();
+ } else {
+ // result spans more than one buffer
+ ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
+ }
+ return ret;
+}
+
+// Copies a specified amount of characters from the list of buffered data
+// chunks.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function copyFromBufferString(n, list) {
+ var p = list.head;
+ var c = 1;
+ var ret = p.data;
+ n -= ret.length;
+ while (p = p.next) {
+ var str = p.data;
+ var nb = n > str.length ? str.length : n;
+ if (nb === str.length) ret += str;else ret += str.slice(0, n);
+ n -= nb;
+ if (n === 0) {
+ if (nb === str.length) {
+ ++c;
+ if (p.next) list.head = p.next;else list.head = list.tail = null;
+ } else {
+ list.head = p;
+ p.data = str.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ list.length -= c;
+ return ret;
+}
+
+// Copies a specified amount of bytes from the list of buffered data chunks.
+// This function is designed to be inlinable, so please take care when making
+// changes to the function body.
+function copyFromBuffer(n, list) {
+ var ret = bufferShim.allocUnsafe(n);
+ var p = list.head;
+ var c = 1;
+ p.data.copy(ret);
+ n -= p.data.length;
+ while (p = p.next) {
+ var buf = p.data;
+ var nb = n > buf.length ? buf.length : n;
+ buf.copy(ret, ret.length - n, 0, nb);
+ n -= nb;
+ if (n === 0) {
+ if (nb === buf.length) {
+ ++c;
+ if (p.next) list.head = p.next;else list.head = list.tail = null;
+ } else {
+ list.head = p;
+ p.data = buf.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ list.length -= c;
+ return ret;
+}
+
+function endReadable(stream) {
+ var state = stream._readableState;
+
+ // If we get here before consuming all the bytes, then that is a
+ // bug in node. Should never happen.
+ if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
+
+ if (!state.endEmitted) {
+ state.ended = true;
+ processNextTick(endReadableNT, state, stream);
+ }
+}
+
+function endReadableNT(state, stream) {
+ // Check that we didn't get one last unshift.
+ if (!state.endEmitted && state.length === 0) {
+ state.endEmitted = true;
+ stream.readable = false;
+ stream.emit('end');
+ }
+}
+
+function forEach(xs, f) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ f(xs[i], i);
+ }
+}
+
+function indexOf(xs, x) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ if (xs[i] === x) return i;
+ }
+ return -1;
+} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_transform.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_transform.js
new file mode 100644
index 0000000..dbc996e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_transform.js
@@ -0,0 +1,180 @@
+// a transform stream is a readable/writable stream where you do
+// something with the data. Sometimes it's called a "filter",
+// but that's not a great name for it, since that implies a thing where
+// some bits pass through, and others are simply ignored. (That would
+// be a valid example of a transform, of course.)
+//
+// While the output is causally related to the input, it's not a
+// necessarily symmetric or synchronous transformation. For example,
+// a zlib stream might take multiple plain-text writes(), and then
+// emit a single compressed chunk some time in the future.
+//
+// Here's how this works:
+//
+// The Transform stream has all the aspects of the readable and writable
+// stream classes. When you write(chunk), that calls _write(chunk,cb)
+// internally, and returns false if there's a lot of pending writes
+// buffered up. When you call read(), that calls _read(n) until
+// there's enough pending readable data buffered up.
+//
+// In a transform stream, the written data is placed in a buffer. When
+// _read(n) is called, it transforms the queued up data, calling the
+// buffered _write cb's as it consumes chunks. If consuming a single
+// written chunk would result in multiple output chunks, then the first
+// outputted bit calls the readcb, and subsequent chunks just go into
+// the read buffer, and will cause it to emit 'readable' if necessary.
+//
+// This way, back-pressure is actually determined by the reading side,
+// since _read has to be called to start processing a new chunk. However,
+// a pathological inflate type of transform can cause excessive buffering
+// here. For example, imagine a stream where every byte of input is
+// interpreted as an integer from 0-255, and then results in that many
+// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
+// 1kb of data being output. In this case, you could write a very small
+// amount of input, and end up with a very large amount of output. In
+// such a pathological inflating mechanism, there'd be no way to tell
+// the system to stop doing the transform. A single 4MB write could
+// cause the system to run out of memory.
+//
+// However, even in such a pathological case, only a single written chunk
+// would be consumed, and then the rest would wait (un-transformed) until
+// the results of the previous transformed chunk were consumed.
+
+'use strict';
+
+module.exports = Transform;
+
+var Duplex = require('./_stream_duplex');
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+util.inherits(Transform, Duplex);
+
+function TransformState(stream) {
+ this.afterTransform = function (er, data) {
+ return afterTransform(stream, er, data);
+ };
+
+ this.needTransform = false;
+ this.transforming = false;
+ this.writecb = null;
+ this.writechunk = null;
+ this.writeencoding = null;
+}
+
+function afterTransform(stream, er, data) {
+ var ts = stream._transformState;
+ ts.transforming = false;
+
+ var cb = ts.writecb;
+
+ if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
+
+ ts.writechunk = null;
+ ts.writecb = null;
+
+ if (data !== null && data !== undefined) stream.push(data);
+
+ cb(er);
+
+ var rs = stream._readableState;
+ rs.reading = false;
+ if (rs.needReadable || rs.length < rs.highWaterMark) {
+ stream._read(rs.highWaterMark);
+ }
+}
+
+function Transform(options) {
+ if (!(this instanceof Transform)) return new Transform(options);
+
+ Duplex.call(this, options);
+
+ this._transformState = new TransformState(this);
+
+ // when the writable side finishes, then flush out anything remaining.
+ var stream = this;
+
+ // start out asking for a readable event once data is transformed.
+ this._readableState.needReadable = true;
+
+ // we have implemented the _read method, and done the other things
+ // that Readable wants before the first _read call, so unset the
+ // sync guard flag.
+ this._readableState.sync = false;
+
+ if (options) {
+ if (typeof options.transform === 'function') this._transform = options.transform;
+
+ if (typeof options.flush === 'function') this._flush = options.flush;
+ }
+
+ this.once('prefinish', function () {
+ if (typeof this._flush === 'function') this._flush(function (er) {
+ done(stream, er);
+ });else done(stream);
+ });
+}
+
+Transform.prototype.push = function (chunk, encoding) {
+ this._transformState.needTransform = false;
+ return Duplex.prototype.push.call(this, chunk, encoding);
+};
+
+// This is the part where you do stuff!
+// override this function in implementation classes.
+// 'chunk' is an input chunk.
+//
+// Call `push(newChunk)` to pass along transformed output
+// to the readable side. You may call 'push' zero or more times.
+//
+// Call `cb(err)` when you are done with this chunk. If you pass
+// an error, then that'll put the hurt on the whole operation. If you
+// never call cb(), then you'll never get another chunk.
+Transform.prototype._transform = function (chunk, encoding, cb) {
+ throw new Error('Not implemented');
+};
+
+Transform.prototype._write = function (chunk, encoding, cb) {
+ var ts = this._transformState;
+ ts.writecb = cb;
+ ts.writechunk = chunk;
+ ts.writeencoding = encoding;
+ if (!ts.transforming) {
+ var rs = this._readableState;
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
+ }
+};
+
+// Doesn't matter what the args are here.
+// _transform does all the work.
+// That we got here means that the readable side wants more data.
+Transform.prototype._read = function (n) {
+ var ts = this._transformState;
+
+ if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
+ ts.transforming = true;
+ this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
+ } else {
+ // mark that we need a transform, so that any data that comes in
+ // will get processed, now that we've asked for it.
+ ts.needTransform = true;
+ }
+};
+
+function done(stream, er) {
+ if (er) return stream.emit('error', er);
+
+ // if there's nothing in the write buffer, then that means
+ // that nothing more will ever be provided
+ var ws = stream._writableState;
+ var ts = stream._transformState;
+
+ if (ws.length) throw new Error('Calling transform done when ws.length != 0');
+
+ if (ts.transforming) throw new Error('Calling transform done when still transforming');
+
+ return stream.push(null);
+} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_writable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_writable.js
new file mode 100644
index 0000000..ed5efcb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/_stream_writable.js
@@ -0,0 +1,526 @@
+// A bit simpler than readable streams.
+// Implement an async ._write(chunk, encoding, cb), and it'll handle all
+// the drain event emission and buffering.
+
+'use strict';
+
+module.exports = Writable;
+
+/*<replacement>*/
+var processNextTick = require('process-nextick-args');
+/*</replacement>*/
+
+/*<replacement>*/
+var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
+/*</replacement>*/
+
+Writable.WritableState = WritableState;
+
+/*<replacement>*/
+var util = require('core-util-is');
+util.inherits = require('inherits');
+/*</replacement>*/
+
+/*<replacement>*/
+var internalUtil = {
+ deprecate: require('util-deprecate')
+};
+/*</replacement>*/
+
+/*<replacement>*/
+var Stream;
+(function () {
+ try {
+ Stream = require('st' + 'ream');
+ } catch (_) {} finally {
+ if (!Stream) Stream = require('events').EventEmitter;
+ }
+})();
+/*</replacement>*/
+
+var Buffer = require('buffer').Buffer;
+/*<replacement>*/
+var bufferShim = require('buffer-shims');
+/*</replacement>*/
+
+util.inherits(Writable, Stream);
+
+function nop() {}
+
+function WriteReq(chunk, encoding, cb) {
+ this.chunk = chunk;
+ this.encoding = encoding;
+ this.callback = cb;
+ this.next = null;
+}
+
+var Duplex;
+function WritableState(options, stream) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ options = options || {};
+
+ // object stream flag to indicate whether or not this stream
+ // contains buffers or objects.
+ this.objectMode = !!options.objectMode;
+
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
+
+ // the point at which write() starts returning false
+ // Note: 0 is a valid value, means that we always return false if
+ // the entire buffer is not flushed immediately on write()
+ var hwm = options.highWaterMark;
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
+
+ // cast to ints.
+ this.highWaterMark = ~ ~this.highWaterMark;
+
+ this.needDrain = false;
+ // at the start of calling end()
+ this.ending = false;
+ // when end() has been called, and returned
+ this.ended = false;
+ // when 'finish' is emitted
+ this.finished = false;
+
+ // should we decode strings into buffers before passing to _write?
+ // this is here so that some node-core streams can optimize string
+ // handling at a lower level.
+ var noDecode = options.decodeStrings === false;
+ this.decodeStrings = !noDecode;
+
+ // Crypto is kind of old and crusty. Historically, its default string
+ // encoding is 'binary' so we have to make this configurable.
+ // Everything else in the universe uses 'utf8', though.
+ this.defaultEncoding = options.defaultEncoding || 'utf8';
+
+ // not an actual buffer we keep track of, but a measurement
+ // of how much we're waiting to get pushed to some underlying
+ // socket or file.
+ this.length = 0;
+
+ // a flag to see when we're in the middle of a write.
+ this.writing = false;
+
+ // when true all writes will be buffered until .uncork() call
+ this.corked = 0;
+
+ // a flag to be able to tell if the onwrite cb is called immediately,
+ // or on a later tick. We set this to true at first, because any
+ // actions that shouldn't happen until "later" should generally also
+ // not happen before the first write call.
+ this.sync = true;
+
+ // a flag to know if we're processing previously buffered items, which
+ // may call the _write() callback in the same tick, so that we don't
+ // end up in an overlapped onwrite situation.
+ this.bufferProcessing = false;
+
+ // the callback that's passed to _write(chunk,cb)
+ this.onwrite = function (er) {
+ onwrite(stream, er);
+ };
+
+ // the callback that the user supplies to write(chunk,encoding,cb)
+ this.writecb = null;
+
+ // the amount that is being written when _write is called.
+ this.writelen = 0;
+
+ this.bufferedRequest = null;
+ this.lastBufferedRequest = null;
+
+ // number of pending user-supplied write callbacks
+ // this must be 0 before 'finish' can be emitted
+ this.pendingcb = 0;
+
+ // emit prefinish if the only thing we're waiting for is _write cbs
+ // This is relevant for synchronous Transform streams
+ this.prefinished = false;
+
+ // True if the error was already emitted and should not be thrown again
+ this.errorEmitted = false;
+
+ // count buffered requests
+ this.bufferedRequestCount = 0;
+
+ // allocate the first CorkedRequest, there is always
+ // one allocated and free to use, and we maintain at most two
+ this.corkedRequestsFree = new CorkedRequest(this);
+}
+
+WritableState.prototype.getBuffer = function writableStateGetBuffer() {
+ var current = this.bufferedRequest;
+ var out = [];
+ while (current) {
+ out.push(current);
+ current = current.next;
+ }
+ return out;
+};
+
+(function () {
+ try {
+ Object.defineProperty(WritableState.prototype, 'buffer', {
+ get: internalUtil.deprecate(function () {
+ return this.getBuffer();
+ }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
+ });
+ } catch (_) {}
+})();
+
+var Duplex;
+function Writable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ // Writable ctor is applied to Duplexes, though they're not
+ // instanceof Writable, they're instanceof Readable.
+ if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
+
+ this._writableState = new WritableState(options, this);
+
+ // legacy.
+ this.writable = true;
+
+ if (options) {
+ if (typeof options.write === 'function') this._write = options.write;
+
+ if (typeof options.writev === 'function') this._writev = options.writev;
+ }
+
+ Stream.call(this);
+}
+
+// Otherwise people can pipe Writable streams, which is just wrong.
+Writable.prototype.pipe = function () {
+ this.emit('error', new Error('Cannot pipe, not readable'));
+};
+
+function writeAfterEnd(stream, cb) {
+ var er = new Error('write after end');
+ // TODO: defer error events consistently everywhere, not just the cb
+ stream.emit('error', er);
+ processNextTick(cb, er);
+}
+
+// If we get something that is not a buffer, string, null, or undefined,
+// and we're not in objectMode, then that's an error.
+// Otherwise stream chunks are all considered to be of length=1, and the
+// watermarks determine how many objects to keep in the buffer, rather than
+// how many bytes or characters.
+function validChunk(stream, state, chunk, cb) {
+ var valid = true;
+ var er = false;
+ // Always throw error if a null is written
+ // if we are not in object mode then throw
+ // if it is not a buffer, string, or undefined.
+ if (chunk === null) {
+ er = new TypeError('May not write null values to stream');
+ } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+ er = new TypeError('Invalid non-string/buffer chunk');
+ }
+ if (er) {
+ stream.emit('error', er);
+ processNextTick(cb, er);
+ valid = false;
+ }
+ return valid;
+}
+
+Writable.prototype.write = function (chunk, encoding, cb) {
+ var state = this._writableState;
+ var ret = false;
+
+ if (typeof encoding === 'function') {
+ cb = encoding;
+ encoding = null;
+ }
+
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
+
+ if (typeof cb !== 'function') cb = nop;
+
+ if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
+ state.pendingcb++;
+ ret = writeOrBuffer(this, state, chunk, encoding, cb);
+ }
+
+ return ret;
+};
+
+Writable.prototype.cork = function () {
+ var state = this._writableState;
+
+ state.corked++;
+};
+
+Writable.prototype.uncork = function () {
+ var state = this._writableState;
+
+ if (state.corked) {
+ state.corked--;
+
+ if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
+ }
+};
+
+Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
+ // node::ParseEncoding() requires lower case.
+ if (typeof encoding === 'string') encoding = encoding.toLowerCase();
+ if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
+ this._writableState.defaultEncoding = encoding;
+ return this;
+};
+
+function decodeChunk(state, chunk, encoding) {
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
+ chunk = bufferShim.from(chunk, encoding);
+ }
+ return chunk;
+}
+
+// if we're already writing something, then just put this
+// in the queue, and wait our turn. Otherwise, call _write
+// If we return false, then we need a drain event, so set that flag.
+function writeOrBuffer(stream, state, chunk, encoding, cb) {
+ chunk = decodeChunk(state, chunk, encoding);
+
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';
+ var len = state.objectMode ? 1 : chunk.length;
+
+ state.length += len;
+
+ var ret = state.length < state.highWaterMark;
+ // we must ensure that previous needDrain will not be reset to false.
+ if (!ret) state.needDrain = true;
+
+ if (state.writing || state.corked) {
+ var last = state.lastBufferedRequest;
+ state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
+ if (last) {
+ last.next = state.lastBufferedRequest;
+ } else {
+ state.bufferedRequest = state.lastBufferedRequest;
+ }
+ state.bufferedRequestCount += 1;
+ } else {
+ doWrite(stream, state, false, len, chunk, encoding, cb);
+ }
+
+ return ret;
+}
+
+function doWrite(stream, state, writev, len, chunk, encoding, cb) {
+ state.writelen = len;
+ state.writecb = cb;
+ state.writing = true;
+ state.sync = true;
+ if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
+ state.sync = false;
+}
+
+function onwriteError(stream, state, sync, er, cb) {
+ --state.pendingcb;
+ if (sync) processNextTick(cb, er);else cb(er);
+
+ stream._writableState.errorEmitted = true;
+ stream.emit('error', er);
+}
+
+function onwriteStateUpdate(state) {
+ state.writing = false;
+ state.writecb = null;
+ state.length -= state.writelen;
+ state.writelen = 0;
+}
+
+function onwrite(stream, er) {
+ var state = stream._writableState;
+ var sync = state.sync;
+ var cb = state.writecb;
+
+ onwriteStateUpdate(state);
+
+ if (er) onwriteError(stream, state, sync, er, cb);else {
+ // Check if we're actually ready to finish, but don't emit yet
+ var finished = needFinish(state);
+
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
+ clearBuffer(stream, state);
+ }
+
+ if (sync) {
+ /*<replacement>*/
+ asyncWrite(afterWrite, stream, state, finished, cb);
+ /*</replacement>*/
+ } else {
+ afterWrite(stream, state, finished, cb);
+ }
+ }
+}
+
+function afterWrite(stream, state, finished, cb) {
+ if (!finished) onwriteDrain(stream, state);
+ state.pendingcb--;
+ cb();
+ finishMaybe(stream, state);
+}
+
+// Must force callback to be called on nextTick, so that we don't
+// emit 'drain' before the write() consumer gets the 'false' return
+// value, and has a chance to attach a 'drain' listener.
+function onwriteDrain(stream, state) {
+ if (state.length === 0 && state.needDrain) {
+ state.needDrain = false;
+ stream.emit('drain');
+ }
+}
+
+// if there's something in the buffer waiting, then process it
+function clearBuffer(stream, state) {
+ state.bufferProcessing = true;
+ var entry = state.bufferedRequest;
+
+ if (stream._writev && entry && entry.next) {
+ // Fast case, write everything using _writev()
+ var l = state.bufferedRequestCount;
+ var buffer = new Array(l);
+ var holder = state.corkedRequestsFree;
+ holder.entry = entry;
+
+ var count = 0;
+ while (entry) {
+ buffer[count] = entry;
+ entry = entry.next;
+ count += 1;
+ }
+
+ doWrite(stream, state, true, state.length, buffer, '', holder.finish);
+
+ // doWrite is almost always async, defer these to save a bit of time
+ // as the hot path ends with doWrite
+ state.pendingcb++;
+ state.lastBufferedRequest = null;
+ if (holder.next) {
+ state.corkedRequestsFree = holder.next;
+ holder.next = null;
+ } else {
+ state.corkedRequestsFree = new CorkedRequest(state);
+ }
+ } else {
+ // Slow case, write chunks one-by-one
+ while (entry) {
+ var chunk = entry.chunk;
+ var encoding = entry.encoding;
+ var cb = entry.callback;
+ var len = state.objectMode ? 1 : chunk.length;
+
+ doWrite(stream, state, false, len, chunk, encoding, cb);
+ entry = entry.next;
+ // if we didn't call the onwrite immediately, then
+ // it means that we need to wait until it does.
+ // also, that means that the chunk and cb are currently
+ // being processed, so move the buffer counter past them.
+ if (state.writing) {
+ break;
+ }
+ }
+
+ if (entry === null) state.lastBufferedRequest = null;
+ }
+
+ state.bufferedRequestCount = 0;
+ state.bufferedRequest = entry;
+ state.bufferProcessing = false;
+}
+
+Writable.prototype._write = function (chunk, encoding, cb) {
+ cb(new Error('not implemented'));
+};
+
+Writable.prototype._writev = null;
+
+Writable.prototype.end = function (chunk, encoding, cb) {
+ var state = this._writableState;
+
+ if (typeof chunk === 'function') {
+ cb = chunk;
+ chunk = null;
+ encoding = null;
+ } else if (typeof encoding === 'function') {
+ cb = encoding;
+ encoding = null;
+ }
+
+ if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
+
+ // .end() fully uncorks
+ if (state.corked) {
+ state.corked = 1;
+ this.uncork();
+ }
+
+ // ignore unnecessary end() calls.
+ if (!state.ending && !state.finished) endWritable(this, state, cb);
+};
+
+function needFinish(state) {
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
+}
+
+function prefinish(stream, state) {
+ if (!state.prefinished) {
+ state.prefinished = true;
+ stream.emit('prefinish');
+ }
+}
+
+function finishMaybe(stream, state) {
+ var need = needFinish(state);
+ if (need) {
+ if (state.pendingcb === 0) {
+ prefinish(stream, state);
+ state.finished = true;
+ stream.emit('finish');
+ } else {
+ prefinish(stream, state);
+ }
+ }
+ return need;
+}
+
+function endWritable(stream, state, cb) {
+ state.ending = true;
+ finishMaybe(stream, state);
+ if (cb) {
+ if (state.finished) processNextTick(cb);else stream.once('finish', cb);
+ }
+ state.ended = true;
+ stream.writable = false;
+}
+
+// It seems a linked list but it is not
+// there will be only 2 of these for each stream
+function CorkedRequest(state) {
+ var _this = this;
+
+ this.next = null;
+ this.entry = null;
+
+ this.finish = function (err) {
+ var entry = _this.entry;
+ _this.entry = null;
+ while (entry) {
+ var cb = entry.callback;
+ state.pendingcb--;
+ cb(err);
+ entry = entry.next;
+ }
+ if (state.corkedRequestsFree) {
+ state.corkedRequestsFree.next = _this;
+ } else {
+ state.corkedRequestsFree = _this;
+ }
+ };
+} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/internal/streams/BufferList.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/internal/streams/BufferList.js
new file mode 100644
index 0000000..e4bfcf0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/lib/internal/streams/BufferList.js
@@ -0,0 +1,64 @@
+'use strict';
+
+var Buffer = require('buffer').Buffer;
+/*<replacement>*/
+var bufferShim = require('buffer-shims');
+/*</replacement>*/
+
+module.exports = BufferList;
+
+function BufferList() {
+ this.head = null;
+ this.tail = null;
+ this.length = 0;
+}
+
+BufferList.prototype.push = function (v) {
+ var entry = { data: v, next: null };
+ if (this.length > 0) this.tail.next = entry;else this.head = entry;
+ this.tail = entry;
+ ++this.length;
+};
+
+BufferList.prototype.unshift = function (v) {
+ var entry = { data: v, next: this.head };
+ if (this.length === 0) this.tail = entry;
+ this.head = entry;
+ ++this.length;
+};
+
+BufferList.prototype.shift = function () {
+ if (this.length === 0) return;
+ var ret = this.head.data;
+ if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
+ --this.length;
+ return ret;
+};
+
+BufferList.prototype.clear = function () {
+ this.head = this.tail = null;
+ this.length = 0;
+};
+
+BufferList.prototype.join = function (s) {
+ if (this.length === 0) return '';
+ var p = this.head;
+ var ret = '' + p.data;
+ while (p = p.next) {
+ ret += s + p.data;
+ }return ret;
+};
+
+BufferList.prototype.concat = function (n) {
+ if (this.length === 0) return bufferShim.alloc(0);
+ if (this.length === 1) return this.head.data;
+ var ret = bufferShim.allocUnsafe(n >>> 0);
+ var p = this.head;
+ var i = 0;
+ while (p) {
+ p.data.copy(ret, i);
+ i += p.data.length;
+ p = p.next;
+ }
+ return ret;
+}; \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/index.js
new file mode 100644
index 0000000..1cab4c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/index.js
@@ -0,0 +1,108 @@
+'use strict';
+
+var buffer = require('buffer');
+var Buffer = buffer.Buffer;
+var SlowBuffer = buffer.SlowBuffer;
+var MAX_LEN = buffer.kMaxLength || 2147483647;
+exports.alloc = function alloc(size, fill, encoding) {
+ if (typeof Buffer.alloc === 'function') {
+ return Buffer.alloc(size, fill, encoding);
+ }
+ if (typeof encoding === 'number') {
+ throw new TypeError('encoding must not be number');
+ }
+ if (typeof size !== 'number') {
+ throw new TypeError('size must be a number');
+ }
+ if (size > MAX_LEN) {
+ throw new RangeError('size is too large');
+ }
+ var enc = encoding;
+ var _fill = fill;
+ if (_fill === undefined) {
+ enc = undefined;
+ _fill = 0;
+ }
+ var buf = new Buffer(size);
+ if (typeof _fill === 'string') {
+ var fillBuf = new Buffer(_fill, enc);
+ var flen = fillBuf.length;
+ var i = -1;
+ while (++i < size) {
+ buf[i] = fillBuf[i % flen];
+ }
+ } else {
+ buf.fill(_fill);
+ }
+ return buf;
+}
+exports.allocUnsafe = function allocUnsafe(size) {
+ if (typeof Buffer.allocUnsafe === 'function') {
+ return Buffer.allocUnsafe(size);
+ }
+ if (typeof size !== 'number') {
+ throw new TypeError('size must be a number');
+ }
+ if (size > MAX_LEN) {
+ throw new RangeError('size is too large');
+ }
+ return new Buffer(size);
+}
+exports.from = function from(value, encodingOrOffset, length) {
+ if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
+ return Buffer.from(value, encodingOrOffset, length);
+ }
+ if (typeof value === 'number') {
+ throw new TypeError('"value" argument must not be a number');
+ }
+ if (typeof value === 'string') {
+ return new Buffer(value, encodingOrOffset);
+ }
+ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
+ var offset = encodingOrOffset;
+ if (arguments.length === 1) {
+ return new Buffer(value);
+ }
+ if (typeof offset === 'undefined') {
+ offset = 0;
+ }
+ var len = length;
+ if (typeof len === 'undefined') {
+ len = value.byteLength - offset;
+ }
+ if (offset >= value.byteLength) {
+ throw new RangeError('\'offset\' is out of bounds');
+ }
+ if (len > value.byteLength - offset) {
+ throw new RangeError('\'length\' is out of bounds');
+ }
+ return new Buffer(value.slice(offset, offset + len));
+ }
+ if (Buffer.isBuffer(value)) {
+ var out = new Buffer(value.length);
+ value.copy(out, 0, 0, value.length);
+ return out;
+ }
+ if (value) {
+ if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
+ return new Buffer(value);
+ }
+ if (value.type === 'Buffer' && Array.isArray(value.data)) {
+ return new Buffer(value.data);
+ }
+ }
+
+ throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
+}
+exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
+ if (typeof Buffer.allocUnsafeSlow === 'function') {
+ return Buffer.allocUnsafeSlow(size);
+ }
+ if (typeof size !== 'number') {
+ throw new TypeError('size must be a number');
+ }
+ if (size >= MAX_LEN) {
+ throw new RangeError('size is too large');
+ }
+ return new SlowBuffer(size);
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/license.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/license.md
new file mode 100644
index 0000000..01cfaef
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/license.md
@@ -0,0 +1,19 @@
+# Copyright (c) 2016 Calvin Metcalf
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/package.json
new file mode 100644
index 0000000..63307f6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "buffer-shims",
+ "version": "1.0.0",
+ "description": "some shims for node buffers",
+ "main": "index.js",
+ "scripts": {
+ "test": "tape test/*.js"
+ },
+ "files": [
+ "index.js"
+ ],
+ "license": "MIT",
+ "devDependencies": {
+ "tape": "^4.5.1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:calvinmetcalf/buffer-shims.git"
+ },
+ "gitHead": "ea89b3857ab5b8203957922a84e9a48cf4c47e0a",
+ "bugs": {
+ "url": "https://github.com/calvinmetcalf/buffer-shims/issues"
+ },
+ "_id": "buffer-shims@1.0.0",
+ "_shasum": "9978ce317388c649ad8793028c3477ef044a8b51",
+ "_from": "buffer-shims@>=1.0.0 <2.0.0",
+ "_npmVersion": "3.8.6",
+ "_nodeVersion": "5.11.0",
+ "_npmUser": {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ },
+ "dist": {
+ "shasum": "9978ce317388c649ad8793028c3477ef044a8b51",
+ "tarball": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/buffer-shims-1.0.0.tgz_1462560889323_0.8640750856138766"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/readme.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/readme.md
new file mode 100644
index 0000000..7ea6475
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/buffer-shims/readme.md
@@ -0,0 +1,21 @@
+buffer-shims
+===
+
+functions to make sure the new buffer methods work in older browsers.
+
+```js
+var bufferShim = require('buffer-shims');
+bufferShim.from('foo');
+bufferShim.alloc(9, 'cafeface', 'hex');
+bufferShim.allocUnsafe(15);
+bufferShim.allocUnsafeSlow(21);
+```
+
+should just use the original in newer nodes and on older nodes uses fallbacks.
+
+Known Issues
+===
+- this does not patch the buffer object, only the constructor stuff
+- it's actually a polyfill
+
+![](https://i.imgur.com/zxII3jJ.gif)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/LICENSE
new file mode 100644
index 0000000..d8d7f94
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/LICENSE
@@ -0,0 +1,19 @@
+Copyright Node.js contributors. All rights reserved.
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/README.md
new file mode 100644
index 0000000..5a76b41
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/README.md
@@ -0,0 +1,3 @@
+# core-util-is
+
+The `util.is*` functions introduced in Node v0.12.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/float.patch b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/float.patch
new file mode 100644
index 0000000..a06d5c0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/float.patch
@@ -0,0 +1,604 @@
+diff --git a/lib/util.js b/lib/util.js
+index a03e874..9074e8e 100644
+--- a/lib/util.js
++++ b/lib/util.js
+@@ -19,430 +19,6 @@
+ // 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);
+- }
+-
+- // 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)) {
+- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
+- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
+- if (value === 0 && 1 / value < 0)
+- return ctx.stylize('-0', 'number');
+- 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) {
+@@ -522,166 +98,10 @@ function isPrimitive(arg) {
+ exports.isPrimitive = isPrimitive;
+
+ function isBuffer(arg) {
+- return arg instanceof Buffer;
++ return Buffer.isBuffer(arg);
+ }
+ exports.isBuffer = isBuffer;
+
+ 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 = function(ctor, superCtor) {
+- ctor.super_ = superCtor;
+- ctor.prototype = Object.create(superCtor.prototype, {
+- constructor: {
+- value: ctor,
+- enumerable: false,
+- writable: true,
+- configurable: true
+- }
+- });
+-};
+-
+-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);
+-}
+-
+-
+-// Deprecated old stuff.
+-
+-exports.p = exports.deprecate(function() {
+- for (var i = 0, len = arguments.length; i < len; ++i) {
+- console.error(exports.inspect(arguments[i]));
+- }
+-}, 'util.p: Use console.error() instead');
+-
+-
+-exports.exec = exports.deprecate(function() {
+- return require('child_process').exec.apply(this, arguments);
+-}, 'util.exec is now called `child_process.exec`.');
+-
+-
+-exports.print = exports.deprecate(function() {
+- for (var i = 0, len = arguments.length; i < len; ++i) {
+- process.stdout.write(String(arguments[i]));
+- }
+-}, 'util.print: Use console.log instead');
+-
+-
+-exports.puts = exports.deprecate(function() {
+- for (var i = 0, len = arguments.length; i < len; ++i) {
+- process.stdout.write(arguments[i] + '\n');
+- }
+-}, 'util.puts: Use console.log instead');
+-
+-
+-exports.debug = exports.deprecate(function(x) {
+- process.stderr.write('DEBUG: ' + x + '\n');
+-}, 'util.debug: Use console.error instead');
+-
+-
+-exports.error = exports.deprecate(function(x) {
+- for (var i = 0, len = arguments.length; i < len; ++i) {
+- process.stderr.write(arguments[i] + '\n');
+- }
+-}, 'util.error: Use console.error instead');
+-
+-
+-exports.pump = exports.deprecate(function(readStream, writeStream, callback) {
+- var callbackCalled = false;
+-
+- function call(a, b, c) {
+- if (callback && !callbackCalled) {
+- callback(a, b, c);
+- callbackCalled = true;
+- }
+- }
+-
+- readStream.addListener('data', function(chunk) {
+- if (writeStream.write(chunk) === false) readStream.pause();
+- });
+-
+- writeStream.addListener('drain', function() {
+- readStream.resume();
+- });
+-
+- readStream.addListener('end', function() {
+- writeStream.end();
+- });
+-
+- readStream.addListener('close', function() {
+- call();
+- });
+-
+- readStream.addListener('error', function(err) {
+- writeStream.end();
+- call(err);
+- });
+-
+- writeStream.addListener('error', function(err) {
+- readStream.destroy();
+- call(err);
+- });
+-}, 'util.pump(): Use readableStream.pipe() instead');
+-
+-
+-var uv;
+-exports._errnoException = function(err, syscall) {
+- if (isUndefined(uv)) uv = process.binding('uv');
+- var errname = uv.errname(err);
+- var e = new Error(syscall + ' ' + errname);
+- e.code = errname;
+- e.errno = errname;
+- e.syscall = syscall;
+- return e;
+-};
++} \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/lib/util.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/lib/util.js
new file mode 100644
index 0000000..ff4c851
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/lib/util.js
@@ -0,0 +1,107 @@
+// 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.
+
+// NOTE: These type checking functions intentionally don't use `instanceof`
+// because it is fragile and can be easily faked with `Object.create()`.
+
+function isArray(arg) {
+ if (Array.isArray) {
+ return Array.isArray(arg);
+ }
+ return objectToString(arg) === '[object Array]';
+}
+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 objectToString(re) === '[object RegExp]';
+}
+exports.isRegExp = isRegExp;
+
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+exports.isObject = isObject;
+
+function isDate(d) {
+ return objectToString(d) === '[object Date]';
+}
+exports.isDate = isDate;
+
+function isError(e) {
+ return (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 = Buffer.isBuffer;
+
+function objectToString(o) {
+ return Object.prototype.toString.call(o);
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/package.json
new file mode 100644
index 0000000..f65d83f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/package.json
@@ -0,0 +1,59 @@
+{
+ "name": "core-util-is",
+ "version": "1.0.2",
+ "description": "The `util.is*` functions introduced in Node v0.12.",
+ "main": "lib/util.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/core-util-is.git"
+ },
+ "keywords": [
+ "util",
+ "isBuffer",
+ "isArray",
+ "isNumber",
+ "isString",
+ "isRegExp",
+ "isThis",
+ "isThat",
+ "polyfill"
+ ],
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/isaacs/core-util-is/issues"
+ },
+ "scripts": {
+ "test": "tap test.js"
+ },
+ "devDependencies": {
+ "tap": "^2.3.0"
+ },
+ "gitHead": "a177da234df5638b363ddc15fa324619a38577c8",
+ "homepage": "https://github.com/isaacs/core-util-is#readme",
+ "_id": "core-util-is@1.0.2",
+ "_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7",
+ "_from": "core-util-is@>=1.0.0 <1.1.0",
+ "_npmVersion": "3.3.2",
+ "_nodeVersion": "4.0.0",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "dist": {
+ "shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7",
+ "tarball": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ }
+ ],
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/test.js
new file mode 100644
index 0000000..1a490c6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/core-util-is/test.js
@@ -0,0 +1,68 @@
+var assert = require('tap');
+
+var t = require('./lib/util');
+
+assert.equal(t.isArray([]), true);
+assert.equal(t.isArray({}), false);
+
+assert.equal(t.isBoolean(null), false);
+assert.equal(t.isBoolean(true), true);
+assert.equal(t.isBoolean(false), true);
+
+assert.equal(t.isNull(null), true);
+assert.equal(t.isNull(undefined), false);
+assert.equal(t.isNull(false), false);
+assert.equal(t.isNull(), false);
+
+assert.equal(t.isNullOrUndefined(null), true);
+assert.equal(t.isNullOrUndefined(undefined), true);
+assert.equal(t.isNullOrUndefined(false), false);
+assert.equal(t.isNullOrUndefined(), true);
+
+assert.equal(t.isNumber(null), false);
+assert.equal(t.isNumber('1'), false);
+assert.equal(t.isNumber(1), true);
+
+assert.equal(t.isString(null), false);
+assert.equal(t.isString('1'), true);
+assert.equal(t.isString(1), false);
+
+assert.equal(t.isSymbol(null), false);
+assert.equal(t.isSymbol('1'), false);
+assert.equal(t.isSymbol(1), false);
+assert.equal(t.isSymbol(Symbol()), true);
+
+assert.equal(t.isUndefined(null), false);
+assert.equal(t.isUndefined(undefined), true);
+assert.equal(t.isUndefined(false), false);
+assert.equal(t.isUndefined(), true);
+
+assert.equal(t.isRegExp(null), false);
+assert.equal(t.isRegExp('1'), false);
+assert.equal(t.isRegExp(new RegExp()), true);
+
+assert.equal(t.isObject({}), true);
+assert.equal(t.isObject([]), true);
+assert.equal(t.isObject(new RegExp()), true);
+assert.equal(t.isObject(new Date()), true);
+
+assert.equal(t.isDate(null), false);
+assert.equal(t.isDate('1'), false);
+assert.equal(t.isDate(new Date()), true);
+
+assert.equal(t.isError(null), false);
+assert.equal(t.isError({ err: true }), false);
+assert.equal(t.isError(new Error()), true);
+
+assert.equal(t.isFunction(null), false);
+assert.equal(t.isFunction({ }), false);
+assert.equal(t.isFunction(function() {}), true);
+
+assert.equal(t.isPrimitive(null), true);
+assert.equal(t.isPrimitive(''), true);
+assert.equal(t.isPrimitive(0), true);
+assert.equal(t.isPrimitive(new Date()), false);
+
+assert.equal(t.isBuffer(null), false);
+assert.equal(t.isBuffer({}), false);
+assert.equal(t.isBuffer(new Buffer(0)), true);
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/LICENSE
new file mode 100644
index 0000000..dea3013
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/LICENSE
@@ -0,0 +1,16 @@
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/README.md
new file mode 100644
index 0000000..b1c5665
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/README.md
@@ -0,0 +1,42 @@
+Browser-friendly inheritance fully compatible with standard node.js
+[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
+
+This package exports standard `inherits` from node.js `util` module in
+node environment, but also provides alternative browser-friendly
+implementation through [browser
+field](https://gist.github.com/shtylman/4339901). Alternative
+implementation is a literal copy of standard one located in standalone
+module to avoid requiring of `util`. It also has a shim for old
+browsers with no `Object.create` support.
+
+While keeping you sure you are using standard `inherits`
+implementation in node.js environment, it allows bundlers such as
+[browserify](https://github.com/substack/node-browserify) to not
+include full `util` package to your client code if all you need is
+just `inherits` function. It worth, because browser shim for `util`
+package is large and `inherits` is often the single function you need
+from it.
+
+It's recommended to use this package instead of
+`require('util').inherits` for any code that has chances to be used
+not only in node.js but in browser too.
+
+## usage
+
+```js
+var inherits = require('inherits');
+// then use exactly as the standard one
+```
+
+## note on version ~1.0
+
+Version ~1.0 had completely different motivation and is not compatible
+neither with 2.0 nor with standard node.js `inherits`.
+
+If you are using version ~1.0 and planning to switch to ~2.0, be
+careful:
+
+* new version uses `super_` instead of `super` for referencing
+ superclass
+* new version overwrites current prototype while old one preserves any
+ existing fields on it
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits.js
new file mode 100644
index 0000000..3b94763
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits.js
@@ -0,0 +1,7 @@
+try {
+ var util = require('util');
+ if (typeof util.inherits !== 'function') throw '';
+ module.exports = util.inherits;
+} catch (e) {
+ module.exports = require('./inherits_browser.js');
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits_browser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits_browser.js
new file mode 100644
index 0000000..c1e78a7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/inherits_browser.js
@@ -0,0 +1,23 @@
+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
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/package.json
new file mode 100644
index 0000000..9146e75
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/inherits/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "inherits",
+ "description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
+ "version": "2.0.3",
+ "keywords": [
+ "inheritance",
+ "class",
+ "klass",
+ "oop",
+ "object-oriented",
+ "inherits",
+ "browser",
+ "browserify"
+ ],
+ "main": "./inherits.js",
+ "browser": "./inherits_browser.js",
+ "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.1 <2.1.0",
+ "_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!"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.npmignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.travis.yml
new file mode 100644
index 0000000..cc4dba2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - "0.8"
+ - "0.10"
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/Makefile
new file mode 100644
index 0000000..787d56e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/Makefile
@@ -0,0 +1,6 @@
+
+test:
+ @node_modules/.bin/tape test.js
+
+.PHONY: test
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/README.md
new file mode 100644
index 0000000..16d2c59
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/README.md
@@ -0,0 +1,60 @@
+
+# isarray
+
+`Array#isArray` for older browsers.
+
+[![build status](https://secure.travis-ci.org/juliangruber/isarray.svg)](http://travis-ci.org/juliangruber/isarray)
+[![downloads](https://img.shields.io/npm/dm/isarray.svg)](https://www.npmjs.org/package/isarray)
+
+[![browser support](https://ci.testling.com/juliangruber/isarray.png)
+](https://ci.testling.com/juliangruber/isarray)
+
+## Usage
+
+```js
+var isArray = require('isarray');
+
+console.log(isArray([])); // => true
+console.log(isArray({})); // => false
+```
+
+## Installation
+
+With [npm](http://npmjs.org) do
+
+```bash
+$ npm install isarray
+```
+
+Then bundle for the browser with
+[browserify](https://github.com/substack/browserify).
+
+With [component](http://component.io) do
+
+```bash
+$ component install juliangruber/isarray
+```
+
+## License
+
+(MIT)
+
+Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/component.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/component.json
new file mode 100644
index 0000000..9e31b68
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/component.json
@@ -0,0 +1,19 @@
+{
+ "name" : "isarray",
+ "description" : "Array#isArray for older browsers",
+ "version" : "0.0.1",
+ "repository" : "juliangruber/isarray",
+ "homepage": "https://github.com/juliangruber/isarray",
+ "main" : "index.js",
+ "scripts" : [
+ "index.js"
+ ],
+ "dependencies" : {},
+ "keywords": ["browser","isarray","array"],
+ "author": {
+ "name": "Julian Gruber",
+ "email": "mail@juliangruber.com",
+ "url": "http://juliangruber.com"
+ },
+ "license": "MIT"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/index.js
new file mode 100644
index 0000000..a57f634
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/index.js
@@ -0,0 +1,5 @@
+var toString = {}.toString;
+
+module.exports = Array.isArray || function (arr) {
+ return toString.call(arr) == '[object Array]';
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/package.json
new file mode 100644
index 0000000..d4834ea
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/package.json
@@ -0,0 +1,70 @@
+{
+ "name": "isarray",
+ "description": "Array#isArray for older browsers",
+ "version": "1.0.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/juliangruber/isarray.git"
+ },
+ "homepage": "https://github.com/juliangruber/isarray",
+ "main": "index.js",
+ "dependencies": {},
+ "devDependencies": {
+ "tape": "~2.13.4"
+ },
+ "keywords": [
+ "browser",
+ "isarray",
+ "array"
+ ],
+ "author": {
+ "name": "Julian Gruber",
+ "email": "mail@juliangruber.com",
+ "url": "http://juliangruber.com"
+ },
+ "license": "MIT",
+ "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"
+ ]
+ },
+ "scripts": {
+ "test": "tape test.js"
+ },
+ "gitHead": "2a23a281f369e9ae06394c0fb4d2381355a6ba33",
+ "bugs": {
+ "url": "https://github.com/juliangruber/isarray/issues"
+ },
+ "_id": "isarray@1.0.0",
+ "_shasum": "bb935d48582cba168c06834957a54a3e07124f11",
+ "_from": "isarray@>=1.0.0 <1.1.0",
+ "_npmVersion": "3.3.12",
+ "_nodeVersion": "5.1.0",
+ "_npmUser": {
+ "name": "juliangruber",
+ "email": "julian@juliangruber.com"
+ },
+ "dist": {
+ "shasum": "bb935d48582cba168c06834957a54a3e07124f11",
+ "tarball": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "juliangruber",
+ "email": "julian@juliangruber.com"
+ }
+ ],
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/test.js
new file mode 100644
index 0000000..e0c3444
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/isarray/test.js
@@ -0,0 +1,20 @@
+var isArray = require('./');
+var test = require('tape');
+
+test('is array', function(t){
+ t.ok(isArray([]));
+ t.notOk(isArray({}));
+ t.notOk(isArray(null));
+ t.notOk(isArray(false));
+
+ var obj = {};
+ obj[0] = true;
+ t.notOk(isArray(obj));
+
+ var arr = [];
+ arr.foo = 'bar';
+ t.ok(isArray(arr));
+
+ t.end();
+});
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/.travis.yml
new file mode 100644
index 0000000..36201b1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/.travis.yml
@@ -0,0 +1,12 @@
+language: node_js
+node_js:
+ - "0.8"
+ - "0.10"
+ - "0.11"
+ - "0.12"
+ - "1.7.1"
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/index.js
new file mode 100644
index 0000000..a4f40f8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/index.js
@@ -0,0 +1,43 @@
+'use strict';
+
+if (!process.version ||
+ process.version.indexOf('v0.') === 0 ||
+ process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
+ module.exports = nextTick;
+} else {
+ module.exports = process.nextTick;
+}
+
+function nextTick(fn, arg1, arg2, arg3) {
+ if (typeof fn !== 'function') {
+ throw new TypeError('"callback" argument must be a function');
+ }
+ var len = arguments.length;
+ var args, i;
+ switch (len) {
+ case 0:
+ case 1:
+ return process.nextTick(fn);
+ case 2:
+ return process.nextTick(function afterTickOne() {
+ fn.call(null, arg1);
+ });
+ case 3:
+ return process.nextTick(function afterTickTwo() {
+ fn.call(null, arg1, arg2);
+ });
+ case 4:
+ return process.nextTick(function afterTickThree() {
+ fn.call(null, arg1, arg2, arg3);
+ });
+ default:
+ args = new Array(len - 1);
+ i = 0;
+ while (i < args.length) {
+ args[i++] = arguments[i];
+ }
+ return process.nextTick(function afterTick() {
+ fn.apply(null, args);
+ });
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/license.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/license.md
new file mode 100644
index 0000000..c67e353
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/license.md
@@ -0,0 +1,19 @@
+# Copyright (c) 2015 Calvin Metcalf
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/package.json
new file mode 100644
index 0000000..ea49e09
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "process-nextick-args",
+ "version": "1.0.7",
+ "description": "process.nextTick but always with args",
+ "main": "index.js",
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/calvinmetcalf/process-nextick-args.git"
+ },
+ "author": "",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/calvinmetcalf/process-nextick-args/issues"
+ },
+ "homepage": "https://github.com/calvinmetcalf/process-nextick-args",
+ "devDependencies": {
+ "tap": "~0.2.6"
+ },
+ "gitHead": "5c00899ab01dd32f93ad4b5743da33da91404f39",
+ "_id": "process-nextick-args@1.0.7",
+ "_shasum": "150e20b756590ad3f91093f25a4f2ad8bff30ba3",
+ "_from": "process-nextick-args@>=1.0.6 <1.1.0",
+ "_npmVersion": "3.8.6",
+ "_nodeVersion": "5.11.0",
+ "_npmUser": {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ },
+ "dist": {
+ "shasum": "150e20b756590ad3f91093f25a4f2ad8bff30ba3",
+ "tarball": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/process-nextick-args-1.0.7.tgz_1462394251778_0.36989671061746776"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/readme.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/readme.md
new file mode 100644
index 0000000..78e7cfa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/readme.md
@@ -0,0 +1,18 @@
+process-nextick-args
+=====
+
+[![Build Status](https://travis-ci.org/calvinmetcalf/process-nextick-args.svg?branch=master)](https://travis-ci.org/calvinmetcalf/process-nextick-args)
+
+```bash
+npm install --save process-nextick-args
+```
+
+Always be able to pass arguments to process.nextTick, no matter the platform
+
+```js
+var nextTick = require('process-nextick-args');
+
+nextTick(function (a, b, c) {
+ console.log(a, b, c);
+}, 'step', 3, 'profit');
+```
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/test.js
new file mode 100644
index 0000000..ef15721
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/process-nextick-args/test.js
@@ -0,0 +1,24 @@
+var test = require("tap").test;
+var nextTick = require('./');
+
+test('should work', function (t) {
+ t.plan(5);
+ nextTick(function (a) {
+ t.ok(a);
+ nextTick(function (thing) {
+ t.equals(thing, 7);
+ }, 7);
+ }, true);
+ nextTick(function (a, b, c) {
+ t.equals(a, 'step');
+ t.equals(b, 3);
+ t.equals(c, 'profit');
+ }, 'step', 3, 'profit');
+});
+
+test('correct number of arguments', function (t) {
+ t.plan(1);
+ nextTick(function () {
+ t.equals(2, arguments.length, 'correct number');
+ }, 1, 2);
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/.npmignore
new file mode 100644
index 0000000..206320c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/.npmignore
@@ -0,0 +1,2 @@
+build
+test
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/LICENSE
new file mode 100644
index 0000000..6de584a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/LICENSE
@@ -0,0 +1,20 @@
+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.
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/README.md
new file mode 100644
index 0000000..4d2aa00
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/README.md
@@ -0,0 +1,7 @@
+**string_decoder.js** (`require('string_decoder')`) from Node.js core
+
+Copyright Joyent, Inc. and other Node contributors. See LICENCE file for details.
+
+Version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10. **Prefer the stable version over the unstable.**
+
+The *build/* directory contains a build script that will scrape the source from the [joyent/node](https://github.com/joyent/node) repo given a specific Node version. \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/index.js
new file mode 100644
index 0000000..b00e54f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/index.js
@@ -0,0 +1,221 @@
+// 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 Buffer = require('buffer').Buffer;
+
+var isBufferEncoding = Buffer.isEncoding
+ || function(encoding) {
+ switch (encoding && encoding.toLowerCase()) {
+ case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
+ default: return false;
+ }
+ }
+
+
+function assertEncoding(encoding) {
+ if (encoding && !isBufferEncoding(encoding)) {
+ throw new Error('Unknown encoding: ' + encoding);
+ }
+}
+
+// StringDecoder provides an interface for efficiently splitting a series of
+// buffers into a series of JS strings without breaking apart multi-byte
+// characters. CESU-8 is handled as part of the UTF-8 encoding.
+//
+// @TODO Handling all encodings inside a single object makes it very difficult
+// to reason about this code, so it should be split up in the future.
+// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
+// points as used by CESU-8.
+var StringDecoder = exports.StringDecoder = function(encoding) {
+ this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
+ assertEncoding(encoding);
+ switch (this.encoding) {
+ case 'utf8':
+ // CESU-8 represents each of Surrogate Pair by 3-bytes
+ this.surrogateSize = 3;
+ break;
+ case 'ucs2':
+ case 'utf16le':
+ // UTF-16 represents each of Surrogate Pair by 2-bytes
+ this.surrogateSize = 2;
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
+ break;
+ case 'base64':
+ // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
+ this.surrogateSize = 3;
+ this.detectIncompleteChar = base64DetectIncompleteChar;
+ break;
+ default:
+ this.write = passThroughWrite;
+ return;
+ }
+
+ // Enough space to store all bytes of a single character. UTF-8 needs 4
+ // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
+ this.charBuffer = new Buffer(6);
+ // Number of bytes received for the current incomplete multi-byte character.
+ this.charReceived = 0;
+ // Number of bytes expected for the current incomplete multi-byte character.
+ this.charLength = 0;
+};
+
+
+// write decodes the given buffer and returns it as JS string that is
+// guaranteed to not contain any partial multi-byte characters. Any partial
+// character found at the end of the buffer is buffered up, and will be
+// returned when calling write again with the remaining bytes.
+//
+// Note: Converting a Buffer containing an orphan surrogate to a String
+// currently works, but converting a String to a Buffer (via `new Buffer`, or
+// Buffer#write) will replace incomplete surrogates with the unicode
+// replacement character. See https://codereview.chromium.org/121173009/ .
+StringDecoder.prototype.write = function(buffer) {
+ var charStr = '';
+ // if our last write ended with an incomplete multibyte character
+ while (this.charLength) {
+ // determine how many remaining bytes this buffer has to offer for this char
+ var available = (buffer.length >= this.charLength - this.charReceived) ?
+ this.charLength - this.charReceived :
+ buffer.length;
+
+ // add the new bytes to the char buffer
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
+ this.charReceived += available;
+
+ if (this.charReceived < this.charLength) {
+ // still not enough chars in this buffer? wait for more ...
+ return '';
+ }
+
+ // remove bytes belonging to the current character from the buffer
+ buffer = buffer.slice(available, buffer.length);
+
+ // get the character that was split
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
+
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
+ var charCode = charStr.charCodeAt(charStr.length - 1);
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
+ this.charLength += this.surrogateSize;
+ charStr = '';
+ continue;
+ }
+ this.charReceived = this.charLength = 0;
+
+ // if there are no more bytes in this buffer, just emit our char
+ if (buffer.length === 0) {
+ return charStr;
+ }
+ break;
+ }
+
+ // determine and set charLength / charReceived
+ this.detectIncompleteChar(buffer);
+
+ var end = buffer.length;
+ if (this.charLength) {
+ // buffer the incomplete character bytes we got
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
+ end -= this.charReceived;
+ }
+
+ charStr += buffer.toString(this.encoding, 0, end);
+
+ var end = charStr.length - 1;
+ var charCode = charStr.charCodeAt(end);
+ // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
+ if (charCode >= 0xD800 && charCode <= 0xDBFF) {
+ var size = this.surrogateSize;
+ this.charLength += size;
+ this.charReceived += size;
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
+ buffer.copy(this.charBuffer, 0, 0, size);
+ return charStr.substring(0, end);
+ }
+
+ // or just emit the charStr
+ return charStr;
+};
+
+// detectIncompleteChar determines if there is an incomplete UTF-8 character at
+// the end of the given buffer. If so, it sets this.charLength to the byte
+// length that character, and sets this.charReceived to the number of bytes
+// that are available for this character.
+StringDecoder.prototype.detectIncompleteChar = function(buffer) {
+ // determine how many bytes we have to check at the end of this buffer
+ var i = (buffer.length >= 3) ? 3 : buffer.length;
+
+ // Figure out if one of the last i bytes of our buffer announces an
+ // incomplete char.
+ for (; i > 0; i--) {
+ var c = buffer[buffer.length - i];
+
+ // See http://en.wikipedia.org/wiki/UTF-8#Description
+
+ // 110XXXXX
+ if (i == 1 && c >> 5 == 0x06) {
+ this.charLength = 2;
+ break;
+ }
+
+ // 1110XXXX
+ if (i <= 2 && c >> 4 == 0x0E) {
+ this.charLength = 3;
+ break;
+ }
+
+ // 11110XXX
+ if (i <= 3 && c >> 3 == 0x1E) {
+ this.charLength = 4;
+ break;
+ }
+ }
+ this.charReceived = i;
+};
+
+StringDecoder.prototype.end = function(buffer) {
+ var res = '';
+ if (buffer && buffer.length)
+ res = this.write(buffer);
+
+ if (this.charReceived) {
+ var cr = this.charReceived;
+ var buf = this.charBuffer;
+ var enc = this.encoding;
+ res += buf.slice(0, cr).toString(enc);
+ }
+
+ return res;
+};
+
+function passThroughWrite(buffer) {
+ return buffer.toString(this.encoding);
+}
+
+function utf16DetectIncompleteChar(buffer) {
+ this.charReceived = buffer.length % 2;
+ this.charLength = this.charReceived ? 2 : 0;
+}
+
+function base64DetectIncompleteChar(buffer) {
+ this.charReceived = buffer.length % 3;
+ this.charLength = this.charReceived ? 3 : 0;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/package.json
new file mode 100644
index 0000000..fdf923e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/string_decoder/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "string_decoder",
+ "version": "0.10.31",
+ "description": "The string_decoder module from Node core",
+ "main": "index.js",
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "~0.4.8"
+ },
+ "scripts": {
+ "test": "tap test/simple/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/rvagg/string_decoder.git"
+ },
+ "homepage": "https://github.com/rvagg/string_decoder",
+ "keywords": [
+ "string",
+ "decoder",
+ "browser",
+ "browserify"
+ ],
+ "license": "MIT",
+ "gitHead": "d46d4fd87cf1d06e031c23f1ba170ca7d4ade9a0",
+ "bugs": {
+ "url": "https://github.com/rvagg/string_decoder/issues"
+ },
+ "_id": "string_decoder@0.10.31",
+ "_shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94",
+ "_from": "string_decoder@>=0.10.0 <0.11.0",
+ "_npmVersion": "1.4.23",
+ "_npmUser": {
+ "name": "rvagg",
+ "email": "rod@vagg.org"
+ },
+ "maintainers": [
+ {
+ "name": "substack",
+ "email": "mail@substack.net"
+ },
+ {
+ "name": "rvagg",
+ "email": "rod@vagg.org"
+ }
+ ],
+ "dist": {
+ "shasum": "62e203bc41766c6c28c9fc84301dab1c5310fa94",
+ "tarball": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/History.md
new file mode 100644
index 0000000..acc8675
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/History.md
@@ -0,0 +1,16 @@
+
+1.0.2 / 2015-10-07
+==================
+
+ * use try/catch when checking `localStorage` (#3, @kumavis)
+
+1.0.1 / 2014-11-25
+==================
+
+ * browser: use `console.warn()` for deprecation calls
+ * browser: more jsdocs
+
+1.0.0 / 2014-04-30
+==================
+
+ * initial commit
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/LICENSE
new file mode 100644
index 0000000..6a60e8c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/LICENSE
@@ -0,0 +1,24 @@
+(The MIT License)
+
+Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/README.md
new file mode 100644
index 0000000..75622fa
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/README.md
@@ -0,0 +1,53 @@
+util-deprecate
+==============
+### The Node.js `util.deprecate()` function with browser support
+
+In Node.js, this module simply re-exports the `util.deprecate()` function.
+
+In the web browser (i.e. via browserify), a browser-specific implementation
+of the `util.deprecate()` function is used.
+
+
+## API
+
+A `deprecate()` function is the only thing exposed by this module.
+
+``` javascript
+// setup:
+exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead');
+
+
+// users see:
+foo();
+// foo() is deprecated, use bar() instead
+foo();
+foo();
+```
+
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/browser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/browser.js
new file mode 100644
index 0000000..549ae2f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/browser.js
@@ -0,0 +1,67 @@
+
+/**
+ * Module exports.
+ */
+
+module.exports = deprecate;
+
+/**
+ * Mark that a method should not be used.
+ * Returns a modified function which warns once by default.
+ *
+ * If `localStorage.noDeprecation = true` is set, then it is a no-op.
+ *
+ * If `localStorage.throwDeprecation = true` is set, then deprecated functions
+ * will throw an Error when invoked.
+ *
+ * If `localStorage.traceDeprecation = true` is set, then deprecated functions
+ * will invoke `console.trace()` instead of `console.error()`.
+ *
+ * @param {Function} fn - the function to deprecate
+ * @param {String} msg - the string to print to the console when `fn` is invoked
+ * @returns {Function} a new "deprecated" version of `fn`
+ * @api public
+ */
+
+function deprecate (fn, msg) {
+ if (config('noDeprecation')) {
+ return fn;
+ }
+
+ var warned = false;
+ function deprecated() {
+ if (!warned) {
+ if (config('throwDeprecation')) {
+ throw new Error(msg);
+ } else if (config('traceDeprecation')) {
+ console.trace(msg);
+ } else {
+ console.warn(msg);
+ }
+ warned = true;
+ }
+ return fn.apply(this, arguments);
+ }
+
+ return deprecated;
+}
+
+/**
+ * Checks `localStorage` for boolean values for the given `name`.
+ *
+ * @param {String} name
+ * @returns {Boolean}
+ * @api private
+ */
+
+function config (name) {
+ // accessing global.localStorage can trigger a DOMException in sandboxed iframes
+ try {
+ if (!global.localStorage) return false;
+ } catch (_) {
+ return false;
+ }
+ var val = global.localStorage[name];
+ if (null == val) return false;
+ return String(val).toLowerCase() === 'true';
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/node.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/node.js
new file mode 100644
index 0000000..5e6fcff
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/node.js
@@ -0,0 +1,6 @@
+
+/**
+ * For Node.js, simply re-export the core `util.deprecate` function.
+ */
+
+module.exports = require('util').deprecate;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/package.json
new file mode 100644
index 0000000..5decbec
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/node_modules/util-deprecate/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "util-deprecate",
+ "version": "1.0.2",
+ "description": "The Node.js `util.deprecate()` function with browser support",
+ "main": "node.js",
+ "browser": "browser.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/TooTallNate/util-deprecate.git"
+ },
+ "keywords": [
+ "util",
+ "deprecate",
+ "browserify",
+ "browser",
+ "node"
+ ],
+ "author": {
+ "name": "Nathan Rajlich",
+ "email": "nathan@tootallnate.net",
+ "url": "http://n8.io/"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/TooTallNate/util-deprecate/issues"
+ },
+ "homepage": "https://github.com/TooTallNate/util-deprecate",
+ "gitHead": "475fb6857cd23fafff20c1be846c1350abf8e6d4",
+ "_id": "util-deprecate@1.0.2",
+ "_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf",
+ "_from": "util-deprecate@>=1.0.1 <1.1.0",
+ "_npmVersion": "2.14.4",
+ "_nodeVersion": "4.1.2",
+ "_npmUser": {
+ "name": "tootallnate",
+ "email": "nathan@tootallnate.net"
+ },
+ "maintainers": [
+ {
+ "name": "tootallnate",
+ "email": "nathan@tootallnate.net"
+ }
+ ],
+ "dist": {
+ "shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf",
+ "tarball": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/package.json
new file mode 100644
index 0000000..542aa38
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/package.json
@@ -0,0 +1,90 @@
+{
+ "name": "readable-stream",
+ "version": "2.1.5",
+ "description": "Streams3, a user-land copy of the stream library from Node.js",
+ "main": "readable.js",
+ "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": "~0.10.x",
+ "util-deprecate": "~1.0.1"
+ },
+ "devDependencies": {
+ "assert": "~1.4.0",
+ "babel-polyfill": "^6.9.1",
+ "nyc": "^6.4.0",
+ "tap": "~0.7.1",
+ "tape": "~4.5.1",
+ "zuul": "~3.10.0"
+ },
+ "scripts": {
+ "test": "tap test/parallel/*.js test/ours/*.js",
+ "browser": "npm run write-zuul && zuul --browser-retries 2 -- test/browser.js",
+ "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml",
+ "local": "zuul --local 3000 --no-coverage -- test/browser.js",
+ "cover": "nyc npm test",
+ "report": "nyc report --reporter=lcov"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/nodejs/readable-stream"
+ },
+ "keywords": [
+ "readable",
+ "stream",
+ "pipe"
+ ],
+ "browser": {
+ "util": false
+ },
+ "nyc": {
+ "include": [
+ "lib/**.js"
+ ]
+ },
+ "license": "MIT",
+ "gitHead": "758c8b3845af855fde736b6a7f58a15fba00d1e7",
+ "bugs": {
+ "url": "https://github.com/nodejs/readable-stream/issues"
+ },
+ "_id": "readable-stream@2.1.5",
+ "_shasum": "66fa8b720e1438b364681f2ad1a63c618448c9d0",
+ "_from": "readable-stream@2.1.5",
+ "_npmVersion": "3.8.6",
+ "_nodeVersion": "5.12.0",
+ "_npmUser": {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ },
+ "dist": {
+ "shasum": "66fa8b720e1438b364681f2ad1a63c618448c9d0",
+ "tarball": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "isaacs@npmjs.com"
+ },
+ {
+ "name": "tootallnate",
+ "email": "nathan@tootallnate.net"
+ },
+ {
+ "name": "rvagg",
+ "email": "rod@vagg.org"
+ },
+ {
+ "name": "cwmma",
+ "email": "calvin.metcalf@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/readable-stream-2.1.5.tgz_1471463532993_0.15824943827465177"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/passthrough.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/passthrough.js
new file mode 100644
index 0000000..27e8d8a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/passthrough.js
@@ -0,0 +1 @@
+module.exports = require("./lib/_stream_passthrough.js")
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/readable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/readable.js
new file mode 100644
index 0000000..be2688a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/readable.js
@@ -0,0 +1,16 @@
+var Stream = (function (){
+ try {
+ return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
+ } catch(_){}
+}());
+exports = module.exports = require('./lib/_stream_readable.js');
+exports.Stream = Stream || exports;
+exports.Readable = exports;
+exports.Writable = require('./lib/_stream_writable.js');
+exports.Duplex = require('./lib/_stream_duplex.js');
+exports.Transform = require('./lib/_stream_transform.js');
+exports.PassThrough = require('./lib/_stream_passthrough.js');
+
+if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
+ module.exports = Stream;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/transform.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/transform.js
new file mode 100644
index 0000000..5d482f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/transform.js
@@ -0,0 +1 @@
+module.exports = require("./lib/_stream_transform.js")
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/writable.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/writable.js
new file mode 100644
index 0000000..e1e9efd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/node_modules/readable-stream/writable.js
@@ -0,0 +1 @@
+module.exports = require("./lib/_stream_writable.js")
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/package.json
new file mode 100644
index 0000000..18f0906
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mongodb/package.json
@@ -0,0 +1,90 @@
+{
+ "name": "mongodb",
+ "version": "2.2.11",
+ "description": "The official MongoDB driver for Node.js",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/mongodb/node-mongodb-native.git"
+ },
+ "keywords": [
+ "mongodb",
+ "driver",
+ "official"
+ ],
+ "dependencies": {
+ "es6-promise": "3.2.1",
+ "mongodb-core": "2.0.13",
+ "readable-stream": "2.1.5"
+ },
+ "devDependencies": {
+ "JSONStream": "^1.0.7",
+ "betterbenchmarks": "^0.1.0",
+ "bluebird": "3.4.6",
+ "bson": "^0.5.1",
+ "cli-table": "^0.3.1",
+ "co": "4.6.0",
+ "colors": "^1.1.2",
+ "coveralls": "^2.11.6",
+ "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": "^1.0.6",
+ "nyc": "^8.1.0",
+ "optimist": "0.6.1",
+ "rimraf": "2.5.4",
+ "semver": "5.3.0",
+ "worker-farm": "^1.3.1"
+ },
+ "author": {
+ "name": "Christian Kvalheim"
+ },
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=0.10.3"
+ },
+ "bugs": {
+ "url": "https://github.com/mongodb/node-mongodb-native/issues"
+ },
+ "scripts": {
+ "test": "node test/runner.js -t functional",
+ "coverage": "nyc node test/runner.js -t functional && node_modules/.bin/nyc report --reporter=text-lcov | node_modules/.bin/coveralls"
+ },
+ "nyc": {
+ "include": [
+ "lib/**/*.js"
+ ]
+ },
+ "homepage": "https://github.com/mongodb/node-mongodb-native",
+ "gitHead": "3bf21eeeece3bc5b361732a9be28109a790673e7",
+ "_id": "mongodb@2.2.11",
+ "_shasum": "a828b036fe6a437a35e723af5f81781c4976306c",
+ "_from": "mongodb@2.2.11",
+ "_npmVersion": "3.10.8",
+ "_nodeVersion": "6.8.1",
+ "_npmUser": {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ },
+ "dist": {
+ "shasum": "a828b036fe6a437a35e723af5f81781c4976306c",
+ "tarball": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.11.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "christkv",
+ "email": "christkv@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/mongodb-2.2.11.tgz_1477061498561_0.7655699723400176"
+ },
+ "deprecated": "please upgrade to 2.2.12 or higher",
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.11.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.npmignore
new file mode 100644
index 0000000..be106ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.npmignore
@@ -0,0 +1,2 @@
+*.sw*
+node_modules/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.travis.yml
new file mode 100644
index 0000000..895dbd3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/History.md
new file mode 100644
index 0000000..87de484
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/History.md
@@ -0,0 +1,30 @@
+
+0.2.1 / 2013-03-22
+==================
+
+ * test; added for #5
+ * fix typo that breaks set #5 [Contra](https://github.com/Contra)
+
+0.2.0 / 2013-03-15
+==================
+
+ * added; adapter support for set
+ * added; adapter support for get
+ * add basic benchmarks
+ * add support for using module as a component #2 [Contra](https://github.com/Contra)
+
+0.1.1 / 2012-12-21
+==================
+
+ * added; map support
+
+0.1.0 / 2012-12-13
+==================
+
+ * added; set('array.property', val, object) support
+ * added; get('array.property', object) support
+
+0.0.1 / 2012-11-03
+==================
+
+ * initial release
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/Makefile
new file mode 100644
index 0000000..314c361
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/Makefile
@@ -0,0 +1,8 @@
+
+test:
+ @node_modules/mocha/bin/mocha -A $(T)
+
+bench:
+ node bench.js
+
+.PHONY: test
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/README.md
new file mode 100644
index 0000000..9831dd0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/README.md
@@ -0,0 +1,278 @@
+#mpath
+
+{G,S}et javascript object values using MongoDB-like path notation.
+
+###Getting
+
+```js
+var mpath = require('mpath');
+
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.get('comments.1.title', obj) // 'exciting!'
+```
+
+`mpath.get` supports array property notation as well.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.get('comments.title', obj) // ['funny', 'exciting!']
+```
+
+Array property and indexing syntax, when used together, are very powerful.
+
+```js
+var obj = {
+ array: [
+ { o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
+ , { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: 'Turkey Day' }] }}
+ , { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+}
+
+var found = mpath.get('array.o.array.x.b.1', obj);
+
+console.log(found); // prints..
+
+ [ [6, undefined]
+ , [2, undefined, undefined]
+ , [null, 1]
+ , [null]
+ , [undefined]
+ , [undefined, undefined, undefined]
+ , undefined
+ ]
+
+```
+
+#####Field selection rules:
+
+The following rules are iteratively applied to each `segment` in the passed `path`. For example:
+
+```js
+var path = 'one.two.14'; // path
+'one' // segment 0
+'two' // segment 1
+14 // segment 2
+```
+
+- 1) when value of the segment parent is not an array, return the value of `parent.segment`
+- 2) when value of the segment parent is an array
+ - a) if the segment is an integer, replace the parent array with the value at `parent[segment]`
+ - b) if not an integer, keep the array but replace each array `item` with the value returned from calling `get(remainingSegments, item)` or undefined if falsey.
+
+#####Maps
+
+`mpath.get` also accepts an optional `map` argument which receives each individual found value. The value returned from the `map` function will be used in the original found values place.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.get('comments.title', obj, function (val) {
+ return 'funny' == val
+ ? 'amusing'
+ : val;
+});
+// ['amusing', 'exciting!']
+```
+
+###Setting
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.set('comments.1.title', 'hilarious', obj)
+console.log(obj.comments[1].title) // 'hilarious'
+```
+
+`mpath.set` supports the same array property notation as `mpath.get`.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.set('comments.title', ['hilarious', 'fruity'], obj);
+
+console.log(obj); // prints..
+
+ { comments: [
+ { title: 'hilarious' },
+ { title: 'fruity' }
+ ]}
+```
+
+Array property and indexing syntax can be used together also when setting.
+
+```js
+var obj = {
+ array: [
+ { o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
+ , { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: 'Turkey Day' }] }}
+ , { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ]
+}
+
+mpath.set('array.1.o', 'this was changed', obj);
+
+console.log(require('util').inspect(obj, false, 1000)); // prints..
+
+{
+ array: [
+ { o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
+ , { o: 'this was changed' }
+ , { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+}
+
+mpath.set('array.o.array.x', 'this was changed too', obj);
+
+console.log(require('util').inspect(obj, false, 1000)); // prints..
+
+{
+ array: [
+ { o: { array: [{x: 'this was changed too'}, { y: 10, x: 'this was changed too'} ] }}
+ , { o: 'this was changed' }
+ , { o: { array: [{x: 'this was changed too'}, { x: 'this was changed too'}] }}
+ , { o: { array: [{x: 'this was changed too'}] }}
+ , { o: { array: [{x: 'this was changed too', y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+}
+```
+
+####Setting arrays
+
+By default, setting a property within an array to another array results in each element of the new array being set to the item in the destination array at the matching index. An example is helpful.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.set('comments.title', ['hilarious', 'fruity'], obj);
+
+console.log(obj); // prints..
+
+ { comments: [
+ { title: 'hilarious' },
+ { title: 'fruity' }
+ ]}
+```
+
+If we do not desire this destructuring-like assignment behavior we may instead specify the `$` operator in the path being set to force the array to be copied directly.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.set('comments.$.title', ['hilarious', 'fruity'], obj);
+
+console.log(obj); // prints..
+
+ { comments: [
+ { title: ['hilarious', 'fruity'] },
+ { title: ['hilarious', 'fruity'] }
+ ]}
+```
+
+####Field assignment rules
+
+The rules utilized mirror those used on `mpath.get`, meaning we can take values returned from `mpath.get`, update them, and reassign them using `mpath.set`. Note that setting nested arrays of arrays can get unweildy quickly. Check out the [tests](https://github.com/aheckmann/mpath/blob/master/test/index.js) for more extreme examples.
+
+#####Maps
+
+`mpath.set` also accepts an optional `map` argument which receives each individual value being set. The value returned from the `map` function will be used in the original values place.
+
+```js
+var obj = {
+ comments: [
+ { title: 'funny' },
+ { title: 'exciting!' }
+ ]
+}
+
+mpath.set('comments.title', ['hilarious', 'fruity'], obj, function (val) {
+ return val.length;
+});
+
+console.log(obj); // prints..
+
+ { comments: [
+ { title: 9 },
+ { title: 6 }
+ ]}
+```
+
+### Custom object types
+
+Sometimes you may want to enact the same functionality on custom object types that store all their real data internally, say for an ODM type object. No fear, `mpath` has you covered. Simply pass the name of the property being used to store the internal data and it will be traversed instead:
+
+```js
+var mpath = require('mpath');
+
+var obj = {
+ comments: [
+ { title: 'exciting!', _doc: { title: 'great!' }}
+ ]
+}
+
+mpath.get('comments.0.title', obj, '_doc') // 'great!'
+mpath.set('comments.0.title', 'nov 3rd', obj, '_doc')
+mpath.get('comments.0.title', obj, '_doc') // 'nov 3rd'
+mpath.get('comments.0.title', obj) // 'exciting'
+```
+
+When used with a `map`, the `map` argument comes last.
+
+```js
+mpath.get(path, obj, '_doc', map);
+mpath.set(path, val, obj, '_doc', map);
+```
+
+[LICENSE](https://github.com/aheckmann/mpath/blob/master/LICENSE)
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.js
new file mode 100644
index 0000000..7ec6a87
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.js
@@ -0,0 +1,109 @@
+
+var mpath = require('./')
+var Bench = require('benchmark');
+var sha = require('child_process').exec("git log --pretty=format:'%h' -n 1", function (err, sha) {
+ if (err) throw err;
+
+ var fs = require('fs')
+ var filename = __dirname + '/bench.out';
+ var out = fs.createWriteStream(filename, { flags: 'a', encoding: 'utf8' });
+
+ /**
+ * test doc creator
+ */
+
+ function doc () {
+ var o = { first: { second: { third: [3,{ name: 'aaron' }, 9] }}};
+ o.comments = [
+ { name: 'one' }
+ , { name: 'two', _doc: { name: '2' }}
+ , { name: 'three'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}] }}
+ ];
+ o.name = 'jiro';
+ o.array = [
+ { o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
+ , { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: {b: 'hi'}}] }}
+ , { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+ o.arr = [
+ { arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true }
+ ]
+ return o;
+ }
+
+ var o = doc();
+
+ var s = new Bench.Suite;
+ s.add('mpath.get("first", obj)', function () {
+ mpath.get('first', o);
+ })
+ s.add('mpath.get("first.second", obj)', function () {
+ mpath.get('first.second', o);
+ })
+ s.add('mpath.get("first.second.third.1.name", obj)', function () {
+ mpath.get('first.second.third.1.name', o);
+ })
+ s.add('mpath.get("comments", obj)', function () {
+ mpath.get('comments', o);
+ })
+ s.add('mpath.get("comments.1", obj)', function () {
+ mpath.get('comments.1', o);
+ })
+ s.add('mpath.get("comments.2.name", obj)', function () {
+ mpath.get('comments.2.name', o);
+ })
+ s.add('mpath.get("comments.2.comments.1.comments.0.val", obj)', function () {
+ mpath.get('comments.2.comments.1.comments.0.val', o);
+ })
+ s.add('mpath.get("comments.name", obj)', function () {
+ mpath.get('comments.name', o);
+ })
+
+ s.add('mpath.set("first", obj, val)', function () {
+ mpath.set('first', o, 1);
+ })
+ s.add('mpath.set("first.second", obj, val)', function () {
+ mpath.set('first.second', o, 1);
+ })
+ s.add('mpath.set("first.second.third.1.name", obj, val)', function () {
+ mpath.set('first.second.third.1.name', o, 1);
+ })
+ s.add('mpath.set("comments", obj, val)', function () {
+ mpath.set('comments', o, 1);
+ })
+ s.add('mpath.set("comments.1", obj, val)', function () {
+ mpath.set('comments.1', o, 1);
+ })
+ s.add('mpath.set("comments.2.name", obj, val)', function () {
+ mpath.set('comments.2.name', o, 1);
+ })
+ s.add('mpath.set("comments.2.comments.1.comments.0.val", obj, val)', function () {
+ mpath.set('comments.2.comments.1.comments.0.val', o, 1);
+ })
+ s.add('mpath.set("comments.name", obj, val)', function () {
+ mpath.set('comments.name', o, 1);
+ })
+
+ s.on('start', function () {
+ console.log('starting...');
+ out.write('*' + sha + ': ' + String(new Date()) + '\n');
+ });
+ s.on('cycle', function (e) {
+ var s = String(e.target);
+ console.log(s);
+ out.write(s + '\n');
+ })
+ s.on('complete', function () {
+ console.log('done')
+ out.end('');
+ })
+ s.run()
+})
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.log b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.log
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.log
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.out b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.out
new file mode 100644
index 0000000..40d3c31
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/bench.out
@@ -0,0 +1,69 @@
+*b566c26: Fri Mar 15 2013 14:14:04 GMT-0700 (PDT)
+mpath.get("first", obj) x 3,827,405 ops/sec ±0.91% (90 runs sampled)
+mpath.get("first.second", obj) x 4,930,222 ops/sec ±1.92% (91 runs sampled)
+mpath.get("first.second.third.1.name", obj) x 3,070,837 ops/sec ±1.45% (97 runs sampled)
+mpath.get("comments", obj) x 3,649,771 ops/sec ±1.71% (93 runs sampled)
+mpath.get("comments.1", obj) x 3,846,728 ops/sec ±0.86% (94 runs sampled)
+mpath.get("comments.2.name", obj) x 3,527,680 ops/sec ±0.95% (96 runs sampled)
+mpath.get("comments.2.comments.1.comments.0.val", obj) x 2,046,982 ops/sec ±0.80% (96 runs sampled)
+mpath.get("comments.name", obj) x 625,546 ops/sec ±2.02% (82 runs sampled)
+*e42bdb1: Fri Mar 15 2013 14:19:28 GMT-0700 (PDT)
+mpath.get("first", obj) x 3,700,783 ops/sec ±1.30% (95 runs sampled)
+mpath.get("first.second", obj) x 4,621,795 ops/sec ±0.86% (95 runs sampled)
+mpath.get("first.second.third.1.name", obj) x 3,012,671 ops/sec ±1.21% (100 runs sampled)
+mpath.get("comments", obj) x 3,677,694 ops/sec ±0.80% (96 runs sampled)
+mpath.get("comments.1", obj) x 3,798,862 ops/sec ±0.81% (91 runs sampled)
+mpath.get("comments.2.name", obj) x 3,489,356 ops/sec ±0.66% (98 runs sampled)
+mpath.get("comments.2.comments.1.comments.0.val", obj) x 2,004,076 ops/sec ±0.85% (99 runs sampled)
+mpath.get("comments.name", obj) x 613,270 ops/sec ±1.33% (83 runs sampled)
+*0521aac: Fri Mar 15 2013 16:37:16 GMT-0700 (PDT)
+mpath.get("first", obj) x 3,834,755 ops/sec ±0.70% (100 runs sampled)
+mpath.get("first.second", obj) x 4,999,965 ops/sec ±1.01% (98 runs sampled)
+mpath.get("first.second.third.1.name", obj) x 3,125,953 ops/sec ±0.97% (100 runs sampled)
+mpath.get("comments", obj) x 3,759,233 ops/sec ±0.81% (97 runs sampled)
+mpath.get("comments.1", obj) x 3,894,893 ops/sec ±0.76% (96 runs sampled)
+mpath.get("comments.2.name", obj) x 3,576,929 ops/sec ±0.68% (98 runs sampled)
+mpath.get("comments.2.comments.1.comments.0.val", obj) x 2,149,610 ops/sec ±0.67% (97 runs sampled)
+mpath.get("comments.name", obj) x 629,259 ops/sec ±1.30% (87 runs sampled)
+mpath.set("first", obj, val) x 2,869,477 ops/sec ±0.63% (97 runs sampled)
+mpath.set("first.second", obj, val) x 2,418,751 ops/sec ±0.62% (98 runs sampled)
+mpath.set("first.second.third.1.name", obj, val) x 2,313,099 ops/sec ±0.69% (94 runs sampled)
+mpath.set("comments", obj, val) x 2,680,882 ops/sec ±0.76% (99 runs sampled)
+mpath.set("comments.1", obj, val) x 2,401,829 ops/sec ±0.68% (98 runs sampled)
+mpath.set("comments.2.name", obj, val) x 2,335,081 ops/sec ±1.07% (96 runs sampled)
+mpath.set("comments.2.comments.1.comments.0.val", obj, val) x 2,245,436 ops/sec ±0.76% (92 runs sampled)
+mpath.set("comments.name", obj, val) x 2,356,278 ops/sec ±1.15% (100 runs sampled)
+*97e85d3: Fri Mar 15 2013 16:39:21 GMT-0700 (PDT)
+mpath.get("first", obj) x 3,837,614 ops/sec ±0.74% (99 runs sampled)
+mpath.get("first.second", obj) x 4,991,779 ops/sec ±1.01% (94 runs sampled)
+mpath.get("first.second.third.1.name", obj) x 3,078,455 ops/sec ±1.17% (96 runs sampled)
+mpath.get("comments", obj) x 3,770,961 ops/sec ±0.45% (101 runs sampled)
+mpath.get("comments.1", obj) x 3,832,814 ops/sec ±0.67% (92 runs sampled)
+mpath.get("comments.2.name", obj) x 3,536,436 ops/sec ±0.49% (100 runs sampled)
+mpath.get("comments.2.comments.1.comments.0.val", obj) x 2,141,947 ops/sec ±0.72% (98 runs sampled)
+mpath.get("comments.name", obj) x 667,898 ops/sec ±1.62% (85 runs sampled)
+mpath.set("first", obj, val) x 2,642,517 ops/sec ±0.72% (98 runs sampled)
+mpath.set("first.second", obj, val) x 2,502,124 ops/sec ±1.28% (99 runs sampled)
+mpath.set("first.second.third.1.name", obj, val) x 2,426,804 ops/sec ±0.55% (99 runs sampled)
+mpath.set("comments", obj, val) x 2,699,478 ops/sec ±0.85% (98 runs sampled)
+mpath.set("comments.1", obj, val) x 2,494,454 ops/sec ±1.05% (96 runs sampled)
+mpath.set("comments.2.name", obj, val) x 2,463,894 ops/sec ±0.86% (98 runs sampled)
+mpath.set("comments.2.comments.1.comments.0.val", obj, val) x 2,320,398 ops/sec ±0.82% (95 runs sampled)
+mpath.set("comments.name", obj, val) x 2,512,408 ops/sec ±0.77% (95 runs sampled)
+*2368a6d: Fri Mar 22 2013 14:07:40 GMT-0700 (PDT)
+mpath.get("first", obj) x 3,932,284 ops/sec ±0.65% (98 runs sampled)
+mpath.get("first.second", obj) x 4,982,307 ops/sec ±1.52% (91 runs sampled)
+mpath.get("first.second.third.1.name", obj) x 3,094,619 ops/sec ±1.17% (95 runs sampled)
+mpath.get("comments", obj) x 3,843,924 ops/sec ±0.76% (95 runs sampled)
+mpath.get("comments.1", obj) x 3,864,491 ops/sec ±1.03% (96 runs sampled)
+mpath.get("comments.2.name", obj) x 3,568,867 ops/sec ±0.79% (96 runs sampled)
+mpath.get("comments.2.comments.1.comments.0.val", obj) x 2,120,898 ops/sec ±0.94% (95 runs sampled)
+mpath.get("comments.name", obj) x 623,508 ops/sec ±1.95% (80 runs sampled)
+mpath.set("first", obj, val) x 2,780,551 ops/sec ±1.23% (97 runs sampled)
+mpath.set("first.second", obj, val) x 2,227,087 ops/sec ±0.59% (97 runs sampled)
+mpath.set("first.second.third.1.name", obj, val) x 2,145,494 ops/sec ±0.86% (96 runs sampled)
+mpath.set("comments", obj, val) x 2,768,894 ops/sec ±0.90% (98 runs sampled)
+mpath.set("comments.1", obj, val) x 2,202,542 ops/sec ±0.92% (95 runs sampled)
+mpath.set("comments.2.name", obj, val) x 2,169,428 ops/sec ±1.10% (96 runs sampled)
+mpath.set("comments.2.comments.1.comments.0.val", obj, val) x 2,060,389 ops/sec ±0.72% (100 runs sampled)
+mpath.set("comments.name", obj, val) x 2,128,875 ops/sec ±1.16% (97 runs sampled)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/component.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/component.json
new file mode 100644
index 0000000..53c2846
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/component.json
@@ -0,0 +1,8 @@
+{
+ "name": "mpath",
+ "version": "0.2.1",
+ "main": "lib/index.js",
+ "scripts": [
+ "lib/index.js"
+ ]
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/index.js
new file mode 100644
index 0000000..f7b65dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/index.js
@@ -0,0 +1 @@
+module.exports = exports = require('./lib');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/lib/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/lib/index.js
new file mode 100644
index 0000000..1b755b7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/lib/index.js
@@ -0,0 +1,215 @@
+/**
+ * Returns the value of object `o` at the given `path`.
+ *
+ * ####Example:
+ *
+ * var obj = {
+ * comments: [
+ * { title: 'exciting!', _doc: { title: 'great!' }}
+ * , { title: 'number dos' }
+ * ]
+ * }
+ *
+ * mpath.get('comments.0.title', o) // 'exciting!'
+ * mpath.get('comments.0.title', o, '_doc') // 'great!'
+ * mpath.get('comments.title', o) // ['exciting!', 'number dos']
+ *
+ * // summary
+ * mpath.get(path, o)
+ * mpath.get(path, o, special)
+ * mpath.get(path, o, map)
+ * mpath.get(path, o, special, map)
+ *
+ * @param {String} path
+ * @param {Object} o
+ * @param {String} [special] When this property name is present on any object in the path, walking will continue on the value of this property.
+ * @param {Function} [map] Optional function which receives each individual found value. The value returned from `map` is used in the original values place.
+ */
+
+exports.get = function (path, o, special, map) {
+ var lookup;
+
+ if ('function' == typeof special) {
+ if (special.length < 2) {
+ map = special;
+ special = undefined;
+ } else {
+ lookup = special;
+ special = undefined;
+ }
+ }
+
+ map || (map = K);
+
+ var parts = 'string' == typeof path
+ ? path.split('.')
+ : path
+
+ if (!Array.isArray(parts)) {
+ throw new TypeError('Invalid `path`. Must be either string or array');
+ }
+
+ var obj = o
+ , part;
+
+ for (var i = 0; i < parts.length; ++i) {
+ part = parts[i];
+
+ if (Array.isArray(obj) && !/^\d+$/.test(part)) {
+ // reading a property from the array items
+ var paths = parts.slice(i);
+
+ return obj.map(function (item) {
+ return item
+ ? exports.get(paths, item, special || lookup, map)
+ : map(undefined);
+ });
+ }
+
+ if (lookup) {
+ obj = lookup(obj, part);
+ } else {
+ obj = special && obj[special]
+ ? obj[special][part]
+ : obj[part];
+ }
+
+ if (!obj) return map(obj);
+ }
+
+ return map(obj);
+}
+
+/**
+ * Sets the `val` at the given `path` of object `o`.
+ *
+ * @param {String} path
+ * @param {Anything} val
+ * @param {Object} o
+ * @param {String} [special] When this property name is present on any object in the path, walking will continue on the value of this property.
+ * @param {Function} [map] Optional function which is passed each individual value before setting it. The value returned from `map` is used in the original values place.
+ */
+
+exports.set = function (path, val, o, special, map, _copying) {
+ var lookup;
+
+ if ('function' == typeof special) {
+ if (special.length < 2) {
+ map = special;
+ special = undefined;
+ } else {
+ lookup = special;
+ special = undefined;
+ }
+ }
+
+ map || (map = K);
+
+ var parts = 'string' == typeof path
+ ? path.split('.')
+ : path
+
+ if (!Array.isArray(parts)) {
+ throw new TypeError('Invalid `path`. Must be either string or array');
+ }
+
+ if (null == o) return;
+
+ // the existance of $ in a path tells us if the user desires
+ // the copying of an array instead of setting each value of
+ // the array to the one by one to matching positions of the
+ // current array.
+ var copy = _copying || /\$/.test(path)
+ , obj = o
+ , part
+
+ for (var i = 0, len = parts.length - 1; i < len; ++i) {
+ part = parts[i];
+
+ if ('$' == part) {
+ if (i == len - 1) {
+ break;
+ } else {
+ continue;
+ }
+ }
+
+ if (Array.isArray(obj) && !/^\d+$/.test(part)) {
+ var paths = parts.slice(i);
+ if (!copy && Array.isArray(val)) {
+ for (var j = 0; j < obj.length && j < val.length; ++j) {
+ // assignment of single values of array
+ exports.set(paths, val[j], obj[j], special || lookup, map, copy);
+ }
+ } else {
+ for (var j = 0; j < obj.length; ++j) {
+ // assignment of entire value
+ exports.set(paths, val, obj[j], special || lookup, map, copy);
+ }
+ }
+ return;
+ }
+
+ if (lookup) {
+ obj = lookup(obj, part);
+ } else {
+ obj = special && obj[special]
+ ? obj[special][part]
+ : obj[part];
+ }
+
+ if (!obj) return;
+ }
+
+ // process the last property of the path
+
+ part = parts[len];
+
+ // use the special property if exists
+ if (special && obj[special]) {
+ obj = obj[special];
+ }
+
+ // set the value on the last branch
+ if (Array.isArray(obj) && !/^\d+$/.test(part)) {
+ if (!copy && Array.isArray(val)) {
+ for (var item, j = 0; j < obj.length && j < val.length; ++j) {
+ item = obj[j];
+ if (item) {
+ if (lookup) {
+ lookup(item, part, map(val[j]));
+ } else {
+ if (item[special]) item = item[special];
+ item[part] = map(val[j]);
+ }
+ }
+ }
+ } else {
+ for (var j = 0; j < obj.length; ++j) {
+ item = obj[j];
+ if (item) {
+ if (lookup) {
+ lookup(item, part, map(val));
+ } else {
+ if (item[special]) item = item[special];
+ item[part] = map(val);
+ }
+ }
+ }
+ }
+ } else {
+ if (lookup) {
+ lookup(obj, part, map(val));
+ } else {
+ obj[part] = map(val);
+ }
+ }
+}
+
+/*!
+ * Returns the value passed to it.
+ */
+
+function K (v) {
+ return v;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/package.json
new file mode 100644
index 0000000..b17f0fc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "mpath",
+ "version": "0.2.1",
+ "description": "{G,S}et object values using MongoDB-like path notation",
+ "main": "index.js",
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/mpath.git"
+ },
+ "keywords": [
+ "mongodb",
+ "path",
+ "get",
+ "set"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "1.8.1",
+ "benchmark": "~1.0.0"
+ },
+ "_id": "mpath@0.2.1",
+ "dist": {
+ "shasum": "3a4e829359801de96309c27a6b2e102e89f9e96e",
+ "tarball": "https://registry.npmjs.org/mpath/-/mpath-0.2.1.tgz"
+ },
+ "_from": "mpath@0.2.1",
+ "_npmVersion": "1.2.15",
+ "_npmUser": {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "3a4e829359801de96309c27a6b2e102e89f9e96e",
+ "_resolved": "https://registry.npmjs.org/mpath/-/mpath-0.2.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/test/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/test/index.js
new file mode 100644
index 0000000..53bdbd7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpath/test/index.js
@@ -0,0 +1,1790 @@
+
+/**
+ * Test dependencies.
+ */
+
+var mpath = require('../')
+var assert = require('assert')
+
+/**
+ * logging helper
+ */
+
+function log (o) {
+ console.log();
+ console.log(require('util').inspect(o, false, 1000));
+}
+
+/**
+ * special path for override tests
+ */
+
+var special = '_doc';
+
+/**
+ * Tests
+ */
+
+describe('mpath', function(){
+
+ /**
+ * test doc creator
+ */
+
+ function doc () {
+ var o = { first: { second: { third: [3,{ name: 'aaron' }, 9] }}};
+ o.comments = [
+ { name: 'one' }
+ , { name: 'two', _doc: { name: '2' }}
+ , { name: 'three'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}] }}
+ ];
+ o.name = 'jiro';
+ o.array = [
+ { o: { array: [{x: {b: [4,6,8]}}, { y: 10} ] }}
+ , { o: { array: [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: {b: 'hi'}}] }}
+ , { o: { array: [{x: {b: null }}, { x: { b: [null, 1]}}] }}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+ o.arr = [
+ { arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true }
+ ]
+ return o;
+ }
+
+ describe('get', function(){
+ var o = doc();
+
+ it('`path` must be a string or array', function(done){
+ assert.throws(function () {
+ mpath.get({}, o);
+ }, /Must be either string or array/);
+ assert.throws(function () {
+ mpath.get(4, o);
+ }, /Must be either string or array/);
+ assert.throws(function () {
+ mpath.get(function(){}, o);
+ }, /Must be either string or array/);
+ assert.throws(function () {
+ mpath.get(/asdf/, o);
+ }, /Must be either string or array/);
+ assert.throws(function () {
+ mpath.get(Math, o);
+ }, /Must be either string or array/);
+ assert.throws(function () {
+ mpath.get(Buffer, o);
+ }, /Must be either string or array/);
+ assert.doesNotThrow(function () {
+ mpath.get('string', o);
+ });
+ assert.doesNotThrow(function () {
+ mpath.get([], o);
+ });
+ done();
+ })
+
+ describe('without `special`', function(){
+ it('works', function(done){
+ assert.equal('jiro', mpath.get('name', o));
+
+ assert.deepEqual(
+ { second: { third: [3,{ name: 'aaron' }, 9] }}
+ , mpath.get('first', o)
+ );
+
+ assert.deepEqual(
+ { third: [3,{ name: 'aaron' }, 9] }
+ , mpath.get('first.second', o)
+ );
+
+ assert.deepEqual(
+ [3,{ name: 'aaron' }, 9]
+ , mpath.get('first.second.third', o)
+ );
+
+ assert.deepEqual(
+ 3
+ , mpath.get('first.second.third.0', o)
+ );
+
+ assert.deepEqual(
+ 9
+ , mpath.get('first.second.third.2', o)
+ );
+
+ assert.deepEqual(
+ { name: 'aaron' }
+ , mpath.get('first.second.third.1', o)
+ );
+
+ assert.deepEqual(
+ 'aaron'
+ , mpath.get('first.second.third.1.name', o)
+ );
+
+ assert.deepEqual([
+ { name: 'one' }
+ , { name: 'two', _doc: { name: '2' }}
+ , { name: 'three'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}]}}],
+ mpath.get('comments', o));
+
+ assert.deepEqual({ name: 'one' }, mpath.get('comments.0', o));
+ assert.deepEqual('one', mpath.get('comments.0.name', o));
+ assert.deepEqual('two', mpath.get('comments.1.name', o));
+ assert.deepEqual('three', mpath.get('comments.2.name', o));
+
+ assert.deepEqual([{},{ comments: [{val: 'twoo'}]}]
+ , mpath.get('comments.2.comments', o));
+
+ assert.deepEqual({ comments: [{val: 'twoo'}]}
+ , mpath.get('comments.2.comments.1', o));
+
+ assert.deepEqual('twoo', mpath.get('comments.2.comments.1.comments.0.val', o));
+
+ done();
+ })
+
+ it('handles array.property dot-notation', function(done){
+ assert.deepEqual(
+ ['one', 'two', 'three']
+ , mpath.get('comments.name', o)
+ );
+ done();
+ })
+
+ it('handles array.array notation', function(done){
+ assert.deepEqual(
+ [undefined, undefined, [{}, {comments:[{val:'twoo'}]}]]
+ , mpath.get('comments.comments', o)
+ );
+ done();
+ })
+
+ it('handles prop.prop.prop.arrayProperty notation', function(done){
+ assert.deepEqual(
+ [undefined, 'aaron', undefined]
+ , mpath.get('first.second.third.name', o)
+ );
+ assert.deepEqual(
+ [1, 'aaron', 1]
+ , mpath.get('first.second.third.name', o, function (v) {
+ return undefined === v ? 1 : v;
+ })
+ );
+ done();
+ })
+
+ it('handles array.prop.array', function(done){
+ assert.deepEqual(
+ [ [{x: {b: [4,6,8]}}, { y: 10} ]
+ , [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: {b: 'hi'}}]
+ , [{x: {b: null }}, { x: { b: [null, 1]}}]
+ , [{x: null }]
+ , [{y: 3 }]
+ , [3, 0, null]
+ , undefined
+ ]
+ , mpath.get('array.o.array', o)
+ );
+ done();
+ })
+
+ it('handles array.prop.array.index', function(done){
+ assert.deepEqual(
+ [ {x: {b: [4,6,8]}}
+ , {x: {b: [1,2,3]}}
+ , {x: {b: null }}
+ , {x: null }
+ , {y: 3 }
+ , 3
+ , undefined
+ ]
+ , mpath.get('array.o.array.0', o)
+ );
+ done();
+ })
+
+ it('handles array.prop.array.index.prop', function(done){
+ assert.deepEqual(
+ [ {b: [4,6,8]}
+ , {b: [1,2,3]}
+ , {b: null }
+ , null
+ , undefined
+ , undefined
+ , undefined
+ ]
+ , mpath.get('array.o.array.0.x', o)
+ );
+ done();
+ })
+
+ it('handles array.prop.array.prop', function(done){
+ assert.deepEqual(
+ [ [undefined, 10 ]
+ , [undefined, undefined, undefined]
+ , [undefined, undefined]
+ , [undefined]
+ , [3]
+ , [undefined, undefined, undefined]
+ , undefined
+ ]
+ , mpath.get('array.o.array.y', o)
+ );
+ assert.deepEqual(
+ [ [{b: [4,6,8]}, undefined]
+ , [{b: [1,2,3]}, {z: 10 }, {b: 'hi'}]
+ , [{b: null }, { b: [null, 1]}]
+ , [null]
+ , [undefined]
+ , [undefined, undefined, undefined]
+ , undefined
+ ]
+ , mpath.get('array.o.array.x', o)
+ );
+ done();
+ })
+
+ it('handles array.prop.array.prop.prop', function(done){
+ assert.deepEqual(
+ [ [[4,6,8], undefined]
+ , [[1,2,3], undefined, 'hi']
+ , [null, [null, 1]]
+ , [null]
+ , [undefined]
+ , [undefined, undefined, undefined]
+ , undefined
+ ]
+ , mpath.get('array.o.array.x.b', o)
+ );
+ done();
+ })
+
+ it('handles array.prop.array.prop.prop.index', function(done){
+ assert.deepEqual(
+ [ [6, undefined]
+ , [2, undefined, 'i'] // undocumented feature (string indexing)
+ , [null, 1]
+ , [null]
+ , [undefined]
+ , [undefined, undefined, undefined]
+ , undefined
+ ]
+ , mpath.get('array.o.array.x.b.1', o)
+ );
+ assert.deepEqual(
+ [ [6, 0]
+ , [2, 0, 'i'] // undocumented feature (string indexing)
+ , [null, 1]
+ , [null]
+ , [0]
+ , [0, 0, 0]
+ , 0
+ ]
+ , mpath.get('array.o.array.x.b.1', o, function (v) {
+ return undefined === v ? 0 : v;
+ })
+ );
+ done();
+ })
+
+ it('handles array.index.prop.prop', function(done){
+ assert.deepEqual(
+ [{x: {b: [1,2,3]}}, { x: {z: 10 }}, { x: {b: 'hi'}}]
+ , mpath.get('array.1.o.array', o)
+ );
+ assert.deepEqual(
+ ['hi','hi','hi']
+ , mpath.get('array.1.o.array', o, function (v) {
+ if (Array.isArray(v)) {
+ return v.map(function (val) {
+ return 'hi';
+ })
+ }
+ return v;
+ })
+ );
+ done();
+ })
+
+ it('handles array.array.index', function(done){
+ assert.deepEqual(
+ [{ a: { c: 48 }}, undefined]
+ , mpath.get('arr.arr.1', o)
+ );
+ assert.deepEqual(
+ ['woot', undefined]
+ , mpath.get('arr.arr.1', o, function (v) {
+ if (v && v.a && v.a.c) return 'woot';
+ return v;
+ })
+ );
+ done();
+ })
+
+ it('handles array.array.index.prop', function(done){
+ assert.deepEqual(
+ [{ c: 48 }, 'woot']
+ , mpath.get('arr.arr.1.a', o, function (v) {
+ if (undefined === v) return 'woot';
+ return v;
+ })
+ );
+ assert.deepEqual(
+ [{ c: 48 }, undefined]
+ , mpath.get('arr.arr.1.a', o)
+ );
+ mpath.set('arr.arr.1.a', [{c:49},undefined], o)
+ assert.deepEqual(
+ [{ c: 49 }, undefined]
+ , mpath.get('arr.arr.1.a', o)
+ );
+ mpath.set('arr.arr.1.a', [{c:48},undefined], o)
+ done();
+ })
+
+ it('handles array.array.index.prop.prop', function(done){
+ assert.deepEqual(
+ [48, undefined]
+ , mpath.get('arr.arr.1.a.c', o)
+ );
+ assert.deepEqual(
+ [48, 'woot']
+ , mpath.get('arr.arr.1.a.c', o, function (v) {
+ if (undefined === v) return 'woot';
+ return v;
+ })
+ );
+ done();
+ })
+
+ })
+
+ describe('with `special`', function(){
+ describe('that is a string', function(){
+ it('works', function(done){
+ assert.equal('jiro', mpath.get('name', o, special));
+
+ assert.deepEqual(
+ { second: { third: [3,{ name: 'aaron' }, 9] }}
+ , mpath.get('first', o, special)
+ );
+
+ assert.deepEqual(
+ { third: [3,{ name: 'aaron' }, 9] }
+ , mpath.get('first.second', o, special)
+ );
+
+ assert.deepEqual(
+ [3,{ name: 'aaron' }, 9]
+ , mpath.get('first.second.third', o, special)
+ );
+
+ assert.deepEqual(
+ 3
+ , mpath.get('first.second.third.0', o, special)
+ );
+
+ assert.deepEqual(
+ 4
+ , mpath.get('first.second.third.0', o, special, function (v) {
+ return 3 === v ? 4 : v;
+ })
+ );
+
+ assert.deepEqual(
+ 9
+ , mpath.get('first.second.third.2', o, special)
+ );
+
+ assert.deepEqual(
+ { name: 'aaron' }
+ , mpath.get('first.second.third.1', o, special)
+ );
+
+ assert.deepEqual(
+ 'aaron'
+ , mpath.get('first.second.third.1.name', o, special)
+ );
+
+ assert.deepEqual([
+ { name: 'one' }
+ , { name: 'two', _doc: { name: '2' }}
+ , { name: 'three'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}]}}],
+ mpath.get('comments', o, special));
+
+ assert.deepEqual({ name: 'one' }, mpath.get('comments.0', o, special));
+ assert.deepEqual('one', mpath.get('comments.0.name', o, special));
+ assert.deepEqual('2', mpath.get('comments.1.name', o, special));
+ assert.deepEqual('3', mpath.get('comments.2.name', o, special));
+ assert.deepEqual('nice', mpath.get('comments.2.name', o, special, function (v) {
+ return '3' === v ? 'nice' : v;
+ }));
+
+ assert.deepEqual([{},{ _doc: { comments: [{ val: 2 }] }}]
+ , mpath.get('comments.2.comments', o, special));
+
+ assert.deepEqual({ _doc: { comments: [{val: 2}]}}
+ , mpath.get('comments.2.comments.1', o, special));
+
+ assert.deepEqual(2, mpath.get('comments.2.comments.1.comments.0.val', o, special));
+ done();
+ })
+
+ it('handles array.property dot-notation', function(done){
+ assert.deepEqual(
+ ['one', '2', '3']
+ , mpath.get('comments.name', o, special)
+ );
+ assert.deepEqual(
+ ['one', 2, '3']
+ , mpath.get('comments.name', o, special, function (v) {
+ return '2' === v ? 2 : v
+ })
+ );
+ done();
+ })
+
+ it('handles array.array notation', function(done){
+ assert.deepEqual(
+ [undefined, undefined, [{}, {_doc: { comments:[{val:2}]}}]]
+ , mpath.get('comments.comments', o, special)
+ );
+ done();
+ })
+
+ it('handles array.array.index.array', function(done){
+ assert.deepEqual(
+ [undefined, undefined, [{val:2}]]
+ , mpath.get('comments.comments.1.comments', o, special)
+ );
+ done();
+ })
+
+ it('handles array.array.index.array.prop', function(done){
+ assert.deepEqual(
+ [undefined, undefined, [2]]
+ , mpath.get('comments.comments.1.comments.val', o, special)
+ );
+ assert.deepEqual(
+ ['nil', 'nil', [2]]
+ , mpath.get('comments.comments.1.comments.val', o, special, function (v) {
+ return undefined === v ? 'nil' : v;
+ })
+ );
+ done();
+ })
+ })
+
+ describe('that is a function', function(){
+ var special = function (obj, key) {
+ return obj[key]
+ }
+
+ it('works', function(done){
+ assert.equal('jiro', mpath.get('name', o, special));
+
+ assert.deepEqual(
+ { second: { third: [3,{ name: 'aaron' }, 9] }}
+ , mpath.get('first', o, special)
+ );
+
+ assert.deepEqual(
+ { third: [3,{ name: 'aaron' }, 9] }
+ , mpath.get('first.second', o, special)
+ );
+
+ assert.deepEqual(
+ [3,{ name: 'aaron' }, 9]
+ , mpath.get('first.second.third', o, special)
+ );
+
+ assert.deepEqual(
+ 3
+ , mpath.get('first.second.third.0', o, special)
+ );
+
+ assert.deepEqual(
+ 4
+ , mpath.get('first.second.third.0', o, special, function (v) {
+ return 3 === v ? 4 : v;
+ })
+ );
+
+ assert.deepEqual(
+ 9
+ , mpath.get('first.second.third.2', o, special)
+ );
+
+ assert.deepEqual(
+ { name: 'aaron' }
+ , mpath.get('first.second.third.1', o, special)
+ );
+
+ assert.deepEqual(
+ 'aaron'
+ , mpath.get('first.second.third.1.name', o, special)
+ );
+
+ assert.deepEqual([
+ { name: 'one' }
+ , { name: 'two', _doc: { name: '2' }}
+ , { name: 'three'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}]}}],
+ mpath.get('comments', o, special));
+
+ assert.deepEqual({ name: 'one' }, mpath.get('comments.0', o, special));
+ assert.deepEqual('one', mpath.get('comments.0.name', o, special));
+ assert.deepEqual('two', mpath.get('comments.1.name', o, special));
+ assert.deepEqual('three', mpath.get('comments.2.name', o, special));
+ assert.deepEqual('nice', mpath.get('comments.2.name', o, special, function (v) {
+ return 'three' === v ? 'nice' : v;
+ }));
+
+ assert.deepEqual([{},{ comments: [{ val: 'twoo' }] }]
+ , mpath.get('comments.2.comments', o, special));
+
+ assert.deepEqual({ comments: [{val: 'twoo'}]}
+ , mpath.get('comments.2.comments.1', o, special));
+
+ assert.deepEqual('twoo', mpath.get('comments.2.comments.1.comments.0.val', o, special));
+
+ var overide = false;
+ assert.deepEqual('twoo', mpath.get('comments.8.comments.1.comments.0.val', o, function (obj, path) {
+ if (Array.isArray(obj) && 8 == path) {
+ overide = true;
+ return obj[2];
+ }
+ return obj[path];
+ }));
+ assert.ok(overide);
+
+ done();
+ })
+
+ it('in combination with map', function(done){
+ var special = function (obj, key) {
+ if (Array.isArray(obj)) return obj[key];
+ return obj.mpath;
+ }
+ var map = function (val) {
+ return 'convert' == val
+ ? 'mpath'
+ : val;
+ }
+ var o = { mpath: [{ mpath: 'converse' }, { mpath: 'convert' }] }
+
+ assert.equal('mpath', mpath.get('something.1.kewl', o, special, map));
+ done();
+ })
+ })
+ })
+ })
+
+ describe('set', function(){
+ describe('without `special`', function(){
+ var o = doc();
+
+ it('works', function(done){
+ mpath.set('name', 'a new val', o, function (v) {
+ return 'a new val' === v ? 'changed' : v;
+ });
+ assert.deepEqual('changed', o.name);
+
+ mpath.set('name', 'changed', o);
+ assert.deepEqual('changed', o.name);
+
+ mpath.set('first.second.third', [1,{name:'x'},9], o);
+ assert.deepEqual([1,{name:'x'},9], o.first.second.third);
+
+ mpath.set('first.second.third.1.name', 'y', o)
+ assert.deepEqual([1,{name:'y'},9], o.first.second.third);
+
+ mpath.set('comments.1.name', 'ttwwoo', o);
+ assert.deepEqual({ name: 'ttwwoo', _doc: { name: '2' }}, o.comments[1]);
+
+ mpath.set('comments.2.comments.1.comments.0.expand', 'added', o);
+ assert.deepEqual(
+ { val: 'twoo', expand: 'added'}
+ , o.comments[2].comments[1].comments[0]);
+
+ mpath.set('comments.2.comments.1.comments.2', 'added', o);
+ assert.equal(3, o.comments[2].comments[1].comments.length);
+ assert.deepEqual(
+ { val: 'twoo', expand: 'added'}
+ , o.comments[2].comments[1].comments[0]);
+ assert.deepEqual(
+ undefined
+ , o.comments[2].comments[1].comments[1]);
+ assert.deepEqual(
+ 'added'
+ , o.comments[2].comments[1].comments[2]);
+
+ done();
+ })
+
+ describe('array.path', function(){
+ describe('with single non-array value', function(){
+ it('works', function(done){
+ mpath.set('arr.yep', false, o, function (v) {
+ return false === v ? true: v;
+ });
+ assert.deepEqual([
+ { yep: true, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true }
+ ], o.arr);
+
+ mpath.set('arr.yep', false, o);
+
+ assert.deepEqual([
+ { yep: false, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: false }
+ ], o.arr);
+
+ done();
+ })
+ })
+ describe('with array of values', function(){
+ it('that are equal in length', function(done){
+ mpath.set('arr.yep', ['one',2], o, function (v) {
+ return 'one' === v ? 1 : v;
+ });
+ assert.deepEqual([
+ { yep: 1, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 2 }
+ ], o.arr);
+ mpath.set('arr.yep', ['one',2], o);
+
+ assert.deepEqual([
+ { yep: 'one', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 2 }
+ ], o.arr);
+
+ done();
+ })
+
+ it('that is less than length', function(done){
+ mpath.set('arr.yep', [47], o, function (v) {
+ return 47 === v ? 4 : v;
+ });
+ assert.deepEqual([
+ { yep: 4, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 2 }
+ ], o.arr);
+
+ mpath.set('arr.yep', [47], o);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 2 }
+ ], o.arr);
+
+ done();
+ })
+
+ it('that is greater than length', function(done){
+ mpath.set('arr.yep', [5,6,7], o, function (v) {
+ return 5 === v ? 'five' : v;
+ });
+ assert.deepEqual([
+ { yep: 'five', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 6 }
+ ], o.arr);
+
+ mpath.set('arr.yep', [5,6,7], o);
+ assert.deepEqual([
+ { yep: 5, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 6 }
+ ], o.arr);
+
+ done();
+ })
+ })
+ })
+
+ describe('array.$.path', function(){
+ describe('with single non-array value', function(){
+ it('copies the value to each item in array', function(done){
+ mpath.set('arr.$.yep', {xtra: 'double good'}, o, function (v) {
+ return v && v.xtra ? 'hi' : v;
+ });
+ assert.deepEqual([
+ { yep: 'hi', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 'hi'}
+ ], o.arr);
+
+ mpath.set('arr.$.yep', {xtra: 'double good'}, o);
+ assert.deepEqual([
+ { yep: {xtra:'double good'}, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: {xtra:'double good'}}
+ ], o.arr);
+
+ done();
+ })
+ })
+ describe('with array of values', function(){
+ it('copies the value to each item in array', function(done){
+ mpath.set('arr.$.yep', [15], o, function (v) {
+ return v.length === 1 ? [] : v;
+ });
+ assert.deepEqual([
+ { yep: [], arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: []}
+ ], o.arr);
+
+ mpath.set('arr.$.yep', [15], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: [15]}
+ ], o.arr);
+
+ done();
+ })
+ })
+ })
+
+ describe('array.index.path', function(){
+ it('works', function(done){
+ mpath.set('arr.1.yep', 0, o, function (v) {
+ return 0 === v ? 'zero' : v;
+ });
+ assert.deepEqual([
+ { yep: [15] , arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 'zero' }
+ ], o.arr);
+
+ mpath.set('arr.1.yep', 0, o);
+ assert.deepEqual([
+ { yep: [15] , arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.e', 35, o, function (v) {
+ return 35 === v ? 3 : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 47 }, e: 3}, { a: { c: 48 }, e: 3}, { d: 'yep', e: 3 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.e', 35, o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 47 }, e: 35}, { a: { c: 48 }, e: 35}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.e', ['a','b'], o, function (v) {
+ return 'a' === v ? 'x' : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 47 }, e: 'x'}, { a: { c: 48 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.e', ['a','b'], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 47 }, e: 'a'}, { a: { c: 48 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.path.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.a.b', 36, o, function (v) {
+ return 36 === v ? 3 : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 3 }, e: 'a'}, { a: { c: 48, b: 3 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.a.b', 36, o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 36 }, e: 'a'}, { a: { c: 48, b: 36 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.a.b', [1,2,3,4], o, function (v) {
+ return 2 === v ? 'two' : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 1 }, e: 'a'}, { a: { c: 48, b: 'two' }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.a.b', [1,2,3,4], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 1 }, e: 'a'}, { a: { c: 48, b: 2 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.$.path.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.$.a.b', '$', o, function (v) {
+ return '$' === v ? 'dolla billz' : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: 'dolla billz' }, e: 'a'}, { a: { c: 48, b: 'dolla billz' }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.$.a.b', '$', o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: '$' }, e: 'a'}, { a: { c: 48, b: '$' }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.$.a.b', [1], o, function (v) {
+ return Array.isArray(v) ? {} : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: {} }, e: 'a'}, { a: { c: 48, b: {} }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.0.arr.$.a.b', [1], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: { b: [1] }, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.index.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.0.a', 'single', o, function (v) {
+ return 'single' === v ? 'double' : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 'double', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.arr.0.a', 'single', o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 'single', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.arr.0.a', [4,8,15,16,23,42], o, function (v) {
+ return 4 === v ? 3 : v;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 3, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: false }
+ ], o.arr);
+
+ mpath.set('arr.arr.0.a', [4,8,15,16,23,42], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 4, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: false }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.$.index.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.$.0.a', 'singles', o, function (v) {
+ return 0;
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 0, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('arr.arr.$.0.a', 'singles', o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 'singles', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ mpath.set('$.arr.arr.0.a', 'single', o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 'single', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0 }
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.arr.$.0.a', [4,8,15,16,23,42], o, function (v) {
+ return 'nope'
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: 'nope', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0}
+ ], o.arr);
+
+ mpath.set('arr.arr.$.0.a', [4,8,15,16,23,42], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: [4,8,15,16,23,42], e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0}
+ ], o.arr);
+
+ mpath.set('arr.$.arr.0.a', [4,8,15,16,23,42,108], o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: [4,8,15,16,23,42,108], e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.path.index', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.a.7', 47, o, function (v) {
+ return 1
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,1], e: 'a'}, { a: { c: 48, b: [1], '7': 1 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0}
+ ], o.arr);
+
+ mpath.set('arr.arr.a.7', 47, o);
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,47], e: 'a'}, { a: { c: 48, b: [1], '7': 47 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ o.arr[1].arr = [{ a: [] }, { a: [] }, { a: null }];
+ mpath.set('arr.arr.a.7', [[null,46], [undefined, 'woot']], o);
+
+ var a1 = [];
+ var a2 = [];
+ a1[7] = undefined;
+ a2[7] = 'woot';
+
+ assert.deepEqual([
+ { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,null], e: 'a'}, { a: { c: 48, b: [1], '7': 46 }, e: 'b'}, { d: 'yep', e: 35 }] }
+ , { yep: 0, arr: [{a:a1},{a:a2},{a:null}] }
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('handles array.array.path', function(){
+ it('with single', function(done){
+ o.arr[1].arr = [{},{}];
+ assert.deepEqual([{},{}], o.arr[1].arr);
+ o.arr.push({ arr: 'something else' });
+ o.arr.push({ arr: ['something else'] });
+ o.arr.push({ arr: [[]] });
+ o.arr.push({ arr: [5] });
+
+ var weird = [];
+ weird.e = 'xmas';
+
+ // test
+ mpath.set('arr.arr.e', 47, o, function (v) {
+ return 'xmas'
+ });
+ assert.deepEqual([
+ { yep: [15], arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 'xmas'}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 'xmas'}
+ , { d: 'yep', e: 'xmas' }
+ ]
+ }
+ , { yep: 0, arr: [{e: 'xmas'}, {e:'xmas'}] }
+ , { arr: 'something else' }
+ , { arr: ['something else'] }
+ , { arr: [weird] }
+ , { arr: [5] }
+ ]
+ , o.arr);
+
+ weird.e = 47;
+
+ mpath.set('arr.arr.e', 47, o);
+ assert.deepEqual([
+ { yep: [15], arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 47}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 47}
+ , { d: 'yep', e: 47 }
+ ]
+ }
+ , { yep: 0, arr: [{e: 47}, {e:47}] }
+ , { arr: 'something else' }
+ , { arr: ['something else'] }
+ , { arr: [weird] }
+ , { arr: [5] }
+ ]
+ , o.arr);
+
+ done();
+ })
+ it('with arrays', function(done){
+ mpath.set('arr.arr.e', [[1,2,3],[4,5],null,[],[6], [7,8,9]], o, function (v) {
+ return 10;
+ });
+
+ var weird = [];
+ weird.e = 10;
+
+ assert.deepEqual([
+ { yep: [15], arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 10}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 10}
+ , { d: 'yep', e: 10 }
+ ]
+ }
+ , { yep: 0, arr: [{e: 10}, {e:10}] }
+ , { arr: 'something else' }
+ , { arr: ['something else'] }
+ , { arr: [weird] }
+ , { arr: [5] }
+ ]
+ , o.arr);
+
+ mpath.set('arr.arr.e', [[1,2,3],[4,5],null,[],[6], [7,8,9]], o);
+
+ weird.e = 6;
+
+ assert.deepEqual([
+ { yep: [15], arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 1}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 2}
+ , { d: 'yep', e: 3 }
+ ]
+ }
+ , { yep: 0, arr: [{e: 4}, {e:5}] }
+ , { arr: 'something else' }
+ , { arr: ['something else'] }
+ , { arr: [weird] }
+ , { arr: [5] }
+ ]
+ , o.arr);
+
+ done();
+ })
+ })
+ })
+
+ describe('with `special`', function(){
+ var o = doc();
+
+ it('works', function(done){
+ mpath.set('name', 'chan', o, special, function (v) {
+ return 'hi';
+ });
+ assert.deepEqual('hi', o.name);
+
+ mpath.set('name', 'changer', o, special);
+ assert.deepEqual('changer', o.name);
+
+ mpath.set('first.second.third', [1,{name:'y'},9], o, special);
+ assert.deepEqual([1,{name:'y'},9], o.first.second.third);
+
+ mpath.set('first.second.third.1.name', 'z', o, special)
+ assert.deepEqual([1,{name:'z'},9], o.first.second.third);
+
+ mpath.set('comments.1.name', 'ttwwoo', o, special);
+ assert.deepEqual({ name: 'two', _doc: { name: 'ttwwoo' }}, o.comments[1]);
+
+ mpath.set('comments.2.comments.1.comments.0.expander', 'adder', o, special, function (v) {
+ return 'super'
+ });
+ assert.deepEqual(
+ { val: 2, expander: 'super'}
+ , o.comments[2]._doc.comments[1]._doc.comments[0]);
+
+ mpath.set('comments.2.comments.1.comments.0.expander', 'adder', o, special);
+ assert.deepEqual(
+ { val: 2, expander: 'adder'}
+ , o.comments[2]._doc.comments[1]._doc.comments[0]);
+
+ mpath.set('comments.2.comments.1.comments.2', 'set', o, special);
+ assert.equal(3, o.comments[2]._doc.comments[1]._doc.comments.length);
+ assert.deepEqual(
+ { val: 2, expander: 'adder'}
+ , o.comments[2]._doc.comments[1]._doc.comments[0]);
+ assert.deepEqual(
+ undefined
+ , o.comments[2]._doc.comments[1]._doc.comments[1]);
+ assert.deepEqual(
+ 'set'
+ , o.comments[2]._doc.comments[1]._doc.comments[2]);
+ done();
+ })
+
+ describe('array.path', function(){
+ describe('with single non-array value', function(){
+ it('works', function(done){
+ o.arr[1]._doc = { special: true }
+
+ mpath.set('arr.yep', false, o, special, function (v) {
+ return 'yes';
+ });
+ assert.deepEqual([
+ { yep: 'yes', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: 'yes'}}
+ ], o.arr);
+
+ mpath.set('arr.yep', false, o, special);
+ assert.deepEqual([
+ { yep: false, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: false }}
+ ], o.arr);
+
+ done();
+ })
+ })
+ describe('with array of values', function(){
+ it('that are equal in length', function(done){
+ mpath.set('arr.yep', ['one',2], o, special, function (v) {
+ return 2 === v ? 20 : v;
+ });
+ assert.deepEqual([
+ { yep: 'one', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: 20}}
+ ], o.arr);
+
+ mpath.set('arr.yep', ['one',2], o, special);
+ assert.deepEqual([
+ { yep: 'one', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: 2}}
+ ], o.arr);
+
+ done();
+ })
+
+ it('that is less than length', function(done){
+ mpath.set('arr.yep', [47], o, special, function (v) {
+ return 80;
+ });
+ assert.deepEqual([
+ { yep: 80, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: 2}}
+ ], o.arr);
+
+ mpath.set('arr.yep', [47], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+ , { yep: true, _doc: { special: true, yep: 2}}
+ ], o.arr);
+
+ // add _doc to first element
+ o.arr[0]._doc = { yep: 46, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] }
+
+ mpath.set('arr.yep', [20], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }], _doc: { yep: 20, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 2}}
+ ], o.arr);
+
+ done();
+ })
+
+ it('that is greater than length', function(done){
+ mpath.set('arr.yep', [5,6,7], o, special, function () {
+ return 'x';
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }], _doc: { yep: 'x', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 'x'}}
+ ], o.arr);
+
+ mpath.set('arr.yep', [5,6,7], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }], _doc: { yep: 5, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 6}}
+ ], o.arr);
+
+ done();
+ })
+ })
+ })
+
+ describe('array.$.path', function(){
+ describe('with single non-array value', function(){
+ it('copies the value to each item in array', function(done){
+ mpath.set('arr.$.yep', {xtra: 'double good'}, o, special, function (v) {
+ return 9;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: 9, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 9}}
+ ], o.arr);
+
+ mpath.set('arr.$.yep', {xtra: 'double good'}, o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: {xtra:'double good'}, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: {xtra:'double good'}}}
+ ], o.arr);
+
+ done();
+ })
+ })
+ describe('with array of values', function(){
+ it('copies the value to each item in array', function(done){
+ mpath.set('arr.$.yep', [15], o, special, function (v) {
+ return 'array'
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: 'array', arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 'array'}}
+ ], o.arr);
+
+ mpath.set('arr.$.yep', [15], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: [15]}}
+ ], o.arr);
+
+ done();
+ })
+ })
+ })
+
+ describe('array.index.path', function(){
+ it('works', function(done){
+ mpath.set('arr.1.yep', 0, o, special, function (v) {
+ return 1;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 1}}
+ ], o.arr);
+
+ mpath.set('arr.1.yep', 0, o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.e', 35, o, special, function (v) {
+ return 30
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }, e: 30}, { a: { c: 48 }, e: 30}, { d: 'yep', e: 30 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.e', 35, o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }, e: 35}, { a: { c: 48 }, e: 35}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.e', ['a','b'], o, special, function (v) {
+ return 'a' === v ? 'A' : v;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }, e: 'A'}, { a: { c: 48 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.e', ['a','b'], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 47 }, e: 'a'}, { a: { c: 48 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.path.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.a.b', 36, o, special, function (v) {
+ return 20
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 20 }, e: 'a'}, { a: { c: 48, b: 20 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.a.b', 36, o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 36 }, e: 'a'}, { a: { c: 48, b: 36 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.a.b', [1,2,3,4], o, special, function (v) {
+ return v*2;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 2 }, e: 'a'}, { a: { c: 48, b: 4 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.a.b', [1,2,3,4], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 1 }, e: 'a'}, { a: { c: 48, b: 2 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.index.array.$.path.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.0.arr.$.a.b', '$', o, special, function (v) {
+ return 'dollaz'
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: 'dollaz' }, e: 'a'}, { a: { c: 48, b: 'dollaz' }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.$.a.b', '$', o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: '$' }, e: 'a'}, { a: { c: 48, b: '$' }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.0.arr.$.a.b', [1], o, special, function (v) {
+ return {};
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: {} }, e: 'a'}, { a: { c: 48, b: {} }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.0.arr.$.a.b', [1], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: { b: [1] }, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.index.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.0.a', 'single', o, special, function (v) {
+ return 88;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 88, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.0.a', 'single', o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 'single', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.arr.0.a', [4,8,15,16,23,42], o, special, function (v) {
+ return v*2;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 8, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.0.a', [4,8,15,16,23,42], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 4, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.$.index.path', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.$.0.a', 'singles', o, special, function (v) {
+ return v.toUpperCase();
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 'SINGLES', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.$.0.a', 'singles', o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 'singles', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('$.arr.arr.0.a', 'single', o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: 'single', e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ mpath.set('arr.arr.$.0.a', [4,8,15,16,23,42], o, special, function (v) {
+ return Array
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: Array, e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.$.0.a', [4,8,15,16,23,42], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42], e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.$.arr.0.a', [4,8,15,16,23,42,108], o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42,108], e: 'a'}, { a: { c: 48, b: [1] }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('array.array.path.index', function(){
+ it('with single value', function(done){
+ mpath.set('arr.arr.a.7', 47, o, special, function (v) {
+ return Object;
+ });
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,Object], e: 'a'}, { a: { c: 48, b: [1], '7': Object }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.a.7', 47, o, special);
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,47], e: 'a'}, { a: { c: 48, b: [1], '7': 47 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ it('with array', function(done){
+ o.arr[1]._doc.arr = [{ a: [] }, { a: [] }, { a: null }];
+ mpath.set('arr.arr.a.7', [[null,46], [undefined, 'woot']], o, special, function (v) {
+ return undefined === v ? 'nope' : v;
+ });
+
+ var a1 = [];
+ var a2 = [];
+ a1[7] = 'nope';
+ a2[7] = 'woot';
+
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,null], e: 'a'}, { a: { c: 48, b: [1], '7': 46 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { arr: [{a:a1},{a:a2},{a:null}], special: true, yep: 0}}
+ ], o.arr);
+
+ mpath.set('arr.arr.a.7', [[null,46], [undefined, 'woot']], o, special);
+
+ a1[7] = undefined;
+
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: { yep: [15], arr: [{ a: [4,8,15,16,23,42,108,null], e: 'a'}, { a: { c: 48, b: [1], '7': 46 }, e: 'b'}, { d: 'yep', e: 35 }] } }
+ , { yep: true, _doc: { arr: [{a:a1},{a:a2},{a:null}], special: true, yep: 0}}
+ ], o.arr);
+
+ done();
+ })
+ })
+
+ describe('handles array.array.path', function(){
+ it('with single', function(done){
+ o.arr[1]._doc.arr = [{},{}];
+ assert.deepEqual([{},{}], o.arr[1]._doc.arr);
+ o.arr.push({ _doc: { arr: 'something else' }});
+ o.arr.push({ _doc: { arr: ['something else'] }});
+ o.arr.push({ _doc: { arr: [[]] }});
+ o.arr.push({ _doc: { arr: [5] }});
+
+ // test
+ mpath.set('arr.arr.e', 47, o, special);
+
+ var weird = [];
+ weird.e = 47;
+
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: {
+ yep: [15]
+ , arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 47}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 47}
+ , { d: 'yep', e: 47 }
+ ]
+ }
+ }
+ , { yep: true
+ , _doc: {
+ arr: [
+ {e:47}
+ , {e:47}
+ ]
+ , special: true
+ , yep: 0
+ }
+ }
+ , { _doc: { arr: 'something else' }}
+ , { _doc: { arr: ['something else'] }}
+ , { _doc: { arr: [weird] }}
+ , { _doc: { arr: [5] }}
+ ]
+ , o.arr);
+
+ done();
+ })
+ it('with arrays', function(done){
+ mpath.set('arr.arr.e', [[1,2,3],[4,5],null,[],[6], [7,8,9]], o, special);
+
+ var weird = [];
+ weird.e = 6;
+
+ assert.deepEqual([
+ { yep: 47, arr: [{ a: { b: 47 }}, { a: { c: 48 }}, { d: 'yep' }]
+ , _doc: {
+ yep: [15]
+ , arr: [
+ { a: [4,8,15,16,23,42,108,null], e: 1}
+ , { a: { c: 48, b: [1], '7': 46 }, e: 2}
+ , { d: 'yep', e: 3 }
+ ]
+ }
+ }
+ , { yep: true
+ , _doc: {
+ arr: [
+ {e:4}
+ , {e:5}
+ ]
+ , special: true
+ , yep: 0
+ }
+ }
+ , { _doc: { arr: 'something else' }}
+ , { _doc: { arr: ['something else'] }}
+ , { _doc: { arr: [weird] }}
+ , { _doc: { arr: [5] }}
+ ]
+ , o.arr);
+
+ done();
+ })
+ })
+
+ describe('that is a function', function(){
+ describe('without map', function(){
+ it('works on array value', function(done){
+ var o = { hello: { world: [{ how: 'are' }, { you: '?' }] }};
+ var special = function (obj, key, val) {
+ if (val) {
+ obj[key] = val;
+ } else {
+ return 'thing' == key
+ ? obj.world
+ : obj[key]
+ }
+ }
+ mpath.set('hello.thing.how', 'arrrr', o, special);
+ assert.deepEqual(o, { hello: { world: [{ how: 'arrrr' }, { you: '?', how: 'arrrr' }] }});
+ done();
+ })
+ it('works on non-array value', function(done){
+ var o = { hello: { world: { how: 'are you' }}};
+ var special = function (obj, key, val) {
+ if (val) {
+ obj[key] = val;
+ } else {
+ return 'thing' == key
+ ? obj.world
+ : obj[key]
+ }
+ }
+ mpath.set('hello.thing.how', 'RU', o, special);
+ assert.deepEqual(o, { hello: { world: { how: 'RU' }}});
+ done();
+ })
+ })
+ it('works with map', function(done){
+ var o = { hello: { world: [{ how: 'are' }, { you: '?' }] }};
+ var special = function (obj, key, val) {
+ if (val) {
+ obj[key] = val;
+ } else {
+ return 'thing' == key
+ ? obj.world
+ : obj[key]
+ }
+ }
+ var map = function (val) {
+ return 'convert' == val
+ ? 'ºº'
+ : val
+ }
+ mpath.set('hello.thing.how', 'convert', o, special, map);
+ assert.deepEqual(o, { hello: { world: [{ how: 'ºº' }, { you: '?', how: 'ºº' }] }});
+ done();
+ })
+ })
+
+ })
+
+ describe('get/set integration', function(){
+ var o = doc();
+
+ it('works', function(done){
+ var vals = mpath.get('array.o.array.x.b', o);
+
+ vals[0][0][2] = 10;
+ vals[1][0][1] = 0;
+ vals[1][1] = 'Rambaldi';
+ vals[1][2] = [12,14];
+ vals[2] = [{changed:true}, [null, ['changed','to','array']]];
+
+ mpath.set('array.o.array.x.b', vals, o);
+
+ var t = [
+ { o: { array: [{x: {b: [4,6,10]}}, { y: 10} ] }}
+ , { o: { array: [{x: {b: [1,0,3]}}, { x: {b:'Rambaldi',z: 10 }}, { x: {b: [12,14]}}] }}
+ , { o: { array: [{x: {b: {changed:true}}}, { x: { b: [null, ['changed','to','array']]}}]}}
+ , { o: { array: [{x: null }] }}
+ , { o: { array: [{y: 3 }] }}
+ , { o: { array: [3, 0, null] }}
+ , { o: { name: 'ha' }}
+ ];
+ assert.deepEqual(t, o.array);
+ done();
+ })
+
+ it('array.prop', function(done){
+ mpath.set('comments.name', ['this', 'was', 'changed'], o);
+
+ assert.deepEqual([
+ { name: 'this' }
+ , { name: 'was', _doc: { name: '2' }}
+ , { name: 'changed'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: '3', comments: [{},{ _doc: { comments: [{ val: 2 }] }}] }}
+ ], o.comments);
+
+ mpath.set('comments.name', ['also', 'changed', 'this'], o, special);
+
+ assert.deepEqual([
+ { name: 'also' }
+ , { name: 'was', _doc: { name: 'changed' }}
+ , { name: 'changed'
+ , comments: [{},{ comments: [{val: 'twoo'}]}]
+ , _doc: { name: 'this', comments: [{},{ _doc: { comments: [{ val: 2 }] }}] }}
+ ], o.comments);
+
+ done();
+ })
+
+ })
+
+ describe('multiple $ use', function(){
+ var o = doc();
+ it('is ok', function(done){
+ assert.doesNotThrow(function () {
+ mpath.set('arr.$.arr.$.a', 35, o);
+ });
+ done();
+ })
+ })
+
+ it('ignores setting a nested path that doesnt exist', function(done){
+ var o = doc();
+ assert.doesNotThrow(function(){
+ mpath.set('thing.that.is.new', 10, o);
+ })
+ done();
+ })
+ })
+
+})
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.npmignore
new file mode 100644
index 0000000..e86496f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.npmignore
@@ -0,0 +1,4 @@
+*.sw*
+node_modules/
+.DS_Store
+.idea \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.travis.yml
new file mode 100644
index 0000000..d63ba09
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.8
+ - 0.10
+ - 0.11
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/History.md
new file mode 100644
index 0000000..12c0dc3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/History.md
@@ -0,0 +1,80 @@
+0.5.5 / 2014-09-19
+==================
+
+ * change `end()` semantics
+ * add `catch()` as in ES6
+
+0.5.1 / 2014-01-20
+==================
+
+ * fixed; `end` is much more consistent (especially for `then` chains)
+
+0.4.4 / 2014-01-20
+==================
+
+ * fixed; `end` is much more consistent (especially for `then` chains)
+
+0.4.3 / 2013-12-17
+==================
+
+ * fixed; non-A+ behavior on fulfill and reject [lbeschastny](https://github.com/lbeschastny)
+ * tests; simplified harness + compatible with travis + compatible with windows
+
+0.5.0 / 2013-12-14
+==================
+
+ * fixed; non-A+ behavior on fulfill and reject [lbeschastny](https://github.com/lbeschastny)
+ * tests; simplified harness + compatible with travis + compatible with windows
+
+0.4.2 / 2013-11-26
+==================
+
+ * fixed; enter the domain only if not the present domain
+ * added; `end` returns the promise
+
+0.4.1 / 2013-10-26
+==================
+
+ * Add `all`
+ * Longjohn for easier debugging
+ * can end a promise chain with an error handler
+ * Add ```chain```
+
+0.4.0 / 2013-10-24
+==================
+
+ * fixed; now plays nice with domains #3 [refack](https://github.com/refack)
+ * updated; compatibility for Promises A+ 2.0.0 [refack](https://github.com/refack)
+ * updated; guard against invalid arguments [refack](https://github.com/refack)
+
+0.3.0 / 2013-07-25
+==================
+
+ * updated; sliced to 0.0.5
+ * fixed; then is passed all fulfillment values
+ * use setImmediate if available
+ * conform to Promises A+ 1.1
+
+0.2.1 / 2013-02-09
+==================
+
+ * fixed; conformancy with A+ 1.2
+
+0.2.0 / 2013-01-09
+==================
+
+ * added; .end()
+ * fixed; only catch handler executions
+
+0.1.0 / 2013-01-08
+==================
+
+ * cleaned up API
+ * customizable event names
+ * docs
+
+0.0.1 / 2013-01-07
+==================
+
+ * original release
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/README.md
new file mode 100644
index 0000000..2906f56
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/README.md
@@ -0,0 +1,224 @@
+#mpromise
+==========
+
+[![Build Status](https://travis-ci.org/aheckmann/mpromise.png)](https://travis-ci.org/aheckmann/mpromise)
+
+A [promises/A+](https://github.com/promises-aplus/promises-spec) conformant implementation, written for [mongoose](http://mongoosejs.com).
+
+## installation
+
+```
+$ npm install mpromise
+```
+
+## docs
+
+An `mpromise` can be in any of three states, pending, fulfilled (success), or rejected (error). Once it is either fulfilled or rejected it's state can no longer be changed.
+
+The exports object is the Promise constructor.
+
+```js
+var Promise = require('mpromise');
+```
+
+The constructor accepts an optional function which is executed when the promise is first resolved (either fulfilled or rejected).
+
+```js
+var promise = new Promise(fn);
+```
+
+This is the same as passing the `fn` to `onResolve` directly.
+
+```js
+var promise = new Promise;
+promise.onResolve(function (err, args..) {
+ ...
+});
+```
+
+### Methods
+
+####fulfill
+
+Fulfilling a promise with values:
+
+```js
+var promise = new Promise;
+promise.fulfill(args...);
+```
+
+If the promise has already been fulfilled or rejected, no action is taken.
+
+####reject
+
+Rejecting a promise with a reason:
+
+```js
+var promise = new Promise;
+promise.reject(reason);
+```
+
+If the promise has already been fulfilled or rejected, no action is taken.
+
+####resolve
+
+Node.js callback style promise resolution `(err, args...)`:
+
+```js
+var promise = new Promise;
+promise.resolve([reason], [arg1, arg2, ...]);
+```
+
+If the promise has already been fulfilled or rejected, no action is taken.
+
+####onFulfill
+
+To register a function for execution when the promise is fulfilled, pass it to `onFulfill`. When executed it will receive the arguments passed to `fulfill()`.
+
+```js
+var promise = new Promise;
+promise.onFulfill(function (a, b) {
+ assert.equal(3, a + b);
+});
+promise.fulfill(1, 2);
+```
+
+The function will only be called once when the promise is fulfilled, never when rejected.
+
+Registering a function with `onFulfill` after the promise has already been fulfilled results in the immediate execution of the function with the original arguments used to fulfill the promise.
+
+```js
+var promise = new Promise;
+promise.fulfill(" :D ");
+promise.onFulfill(function (arg) {
+ console.log(arg); // logs " :D "
+})
+```
+
+####onReject
+
+To register a function for execution when the promise is rejected, pass it to `onReject`. When executed it will receive the argument passed to `reject()`.
+
+```js
+var promise = new Promise;
+promise.onReject(function (reason) {
+ assert.equal('sad', reason);
+});
+promise.reject('sad');
+```
+
+The function will only be called once when the promise is rejected, never when fulfilled.
+
+Registering a function with `onReject` after the promise has already been rejected results in the immediate execution of the function with the original argument used to reject the promise.
+
+```js
+var promise = new Promise;
+promise.reject(" :( ");
+promise.onReject(function (reason) {
+ console.log(reason); // logs " :( "
+})
+```
+
+####onResolve
+
+Allows registration of node.js style callbacks `(err, args..)` to handle either promise resolution type (fulfill or reject).
+
+```js
+// fulfillment
+var promise = new Promise;
+promise.onResolve(function (err, a, b) {
+ console.log(a + b); // logs 3
+});
+promise.fulfill(1, 2);
+
+// rejection
+var promise = new Promise;
+promise.onResolve(function (err) {
+ if (err) {
+ console.log(err.message); // logs "failed"
+ }
+});
+promise.reject(new Error('failed'));
+```
+
+####then
+
+Creates a new promise and returns it. If `onFulfill` or `onReject` are passed, they are added as SUCCESS/ERROR callbacks to this promise after the nextTick.
+
+Conforms to [promises/A+](https://github.com/promises-aplus/promises-spec) specification and passes its [tests](https://github.com/promises-aplus/promises-tests).
+
+```js
+// promise.then(onFulfill, onReject);
+
+var p = new Promise;
+
+p.then(function (arg) {
+ return arg + 1;
+}).then(function (arg) {
+ throw new Error(arg + ' is an error!');
+}).then(null, function (err) {
+ assert.ok(err instanceof Error);
+ assert.equal('2 is an error', err.message);
+});
+p.fullfill(1);
+```
+
+####end
+
+Signifies that this promise was the last in a chain of `then()s`: if a handler passed to the call to `then` which produced this promise throws, the exception be rethrown.
+You can pass an OnReject handler to `end` so that exceptions will be handled (like a final catch clause);
+This method returns it's promise for easy use with `return`.
+
+```js
+var p = new Promise;
+p.then(function(){ throw new Error('shucks') });
+setTimeout(function () {
+ p.fulfill();
+ // error was caught and swallowed by the promise returned from
+ // p.then(). we either have to always register handlers on
+ // the returned promises or we can do the following...
+}, 10);
+
+// this time we use .end() which prevents catching thrown errors
+var p = new Promise;
+setTimeout(function () {
+ p.fulfill(); // throws "shucks"
+}, 10);
+return p.then(function(){ throw new Error('shucks') }).end(); // <--
+```
+
+
+### chain
+
+Allows direct promise to promise chaining (especially useful by a outside aggregating function). It doesn't use the asynchronous `resolve` algorithm and so excepts only another Promise as it's argument.
+
+```js
+function makeMeAPromise(i) {
+ var p = new Promise;
+ p.fulfill(i);
+ return p;
+}
+
+var returnPromise = initialPromise = new Promise;
+for (i=0; i<10; ++i)
+ returnPromise = returnPromise.chain(makeMeAPromise(i));
+
+initialPromise.fulfill();
+return returnPromise;
+```
+
+###Event names
+
+If you'd like to alter this implementations event names used to signify success and failure you may do so by setting `Promise.SUCCESS` or `Promise.FAILURE` respectively.
+
+```js
+Promise.SUCCESS = 'complete';
+Promise.FAILURE = 'err';
+```
+
+###Luke, use the Source
+For more ideas read the [source](https://github.com/aheckmann/mpromise/blob/master/lib), [tests](https://github.com/aheckmann/mpromise/blob/master/test), or the [mongoose implementation](https://github.com/LearnBoost/mongoose/blob/3.6x/lib/promise.js).
+
+## license
+
+[MIT](https://github.com/aheckmann/mpromise/blob/master/LICENSE)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/lib/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/lib/promise.js
new file mode 100644
index 0000000..3cb4419
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/lib/promise.js
@@ -0,0 +1,445 @@
+'use strict';
+var util = require('util');
+var EventEmitter = require('events').EventEmitter;
+function toArray(arr, start, end) {
+ return Array.prototype.slice.call(arr, start, end)
+}
+function strongUnshift(x, arrLike) {
+ var arr = toArray(arrLike);
+ arr.unshift(x);
+ return arr;
+}
+
+
+/**
+ * MPromise constructor.
+ *
+ * _NOTE: The success and failure event names can be overridden by setting `Promise.SUCCESS` and `Promise.FAILURE` respectively._
+ *
+ * @param {Function} back a function that accepts `fn(err, ...){}` as signature
+ * @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
+ * @event `reject`: Emits when the promise is rejected (event name may be overridden)
+ * @event `fulfill`: Emits when the promise is fulfilled (event name may be overridden)
+ * @api public
+ */
+function Promise(back) {
+ this.emitter = new EventEmitter();
+ this.emitted = {};
+ this.ended = false;
+ if ('function' == typeof back) {
+ this.ended = true;
+ this.onResolve(back);
+ }
+}
+
+
+/*
+ * Module exports.
+ */
+module.exports = Promise;
+
+
+/*!
+ * event names
+ */
+Promise.SUCCESS = 'fulfill';
+Promise.FAILURE = 'reject';
+
+
+/**
+ * Adds `listener` to the `event`.
+ *
+ * If `event` is either the success or failure event and the event has already been emitted, the`listener` is called immediately and passed the results of the original emitted event.
+ *
+ * @param {String} event
+ * @param {Function} callback
+ * @return {MPromise} this
+ * @api private
+ */
+Promise.prototype.on = function (event, callback) {
+ if (this.emitted[event])
+ callback.apply(undefined, this.emitted[event]);
+ else
+ this.emitter.on(event, callback);
+
+ return this;
+};
+
+
+/**
+ * Keeps track of emitted events to run them on `on`.
+ *
+ * @api private
+ */
+Promise.prototype.safeEmit = function (event) {
+ // ensures a promise can't be fulfill() or reject() more than once
+ if (event == Promise.SUCCESS || event == Promise.FAILURE) {
+ if (this.emitted[Promise.SUCCESS] || this.emitted[Promise.FAILURE]) {
+ return this;
+ }
+ this.emitted[event] = toArray(arguments, 1);
+ }
+
+ this.emitter.emit.apply(this.emitter, arguments);
+ return this;
+};
+
+
+/**
+ * @api private
+ */
+Promise.prototype.hasRejectListeners = function () {
+ return EventEmitter.listenerCount(this.emitter, Promise.FAILURE) > 0;
+};
+
+
+/**
+ * Fulfills this promise with passed arguments.
+ *
+ * If this promise has already been fulfilled or rejected, no action is taken.
+ *
+ * @api public
+ */
+Promise.prototype.fulfill = function () {
+ return this.safeEmit.apply(this, strongUnshift(Promise.SUCCESS, arguments));
+};
+
+
+/**
+ * Rejects this promise with `reason`.
+ *
+ * If this promise has already been fulfilled or rejected, no action is taken.
+ *
+ * @api public
+ * @param {Object|String} reason
+ * @return {MPromise} this
+ */
+Promise.prototype.reject = function (reason) {
+ if (this.ended && !this.hasRejectListeners())
+ throw reason;
+ return this.safeEmit(Promise.FAILURE, reason);
+};
+
+
+/**
+ * Resolves this promise to a rejected state if `err` is passed or
+ * fulfilled state if no `err` is passed.
+ *
+ * @param {Error} [err] error or null
+ * @param {Object} [val] value to fulfill the promise with
+ * @api public
+ */
+Promise.prototype.resolve = function (err, val) {
+ if (err) return this.reject(err);
+ return this.fulfill(val);
+};
+
+
+/**
+ * Adds a listener to the SUCCESS event.
+ *
+ * @return {MPromise} this
+ * @api public
+ */
+Promise.prototype.onFulfill = function (fn) {
+ if (!fn) return this;
+ if ('function' != typeof fn) throw new TypeError("fn should be a function");
+ return this.on(Promise.SUCCESS, fn);
+};
+
+
+/**
+ * Adds a listener to the FAILURE event.
+ *
+ * @return {MPromise} this
+ * @api public
+ */
+Promise.prototype.onReject = function (fn) {
+ if (!fn) return this;
+ if ('function' != typeof fn) throw new TypeError("fn should be a function");
+ return this.on(Promise.FAILURE, fn);
+};
+
+
+/**
+ * Adds a single function as a listener to both SUCCESS and FAILURE.
+ *
+ * It will be executed with traditional node.js argument position:
+ * function (err, args...) {}
+ *
+ * Also marks the promise as `end`ed, since it's the common use-case, and yet has no
+ * side effects unless `fn` is undefined or null.
+ *
+ * @param {Function} fn
+ * @return {MPromise} this
+ */
+Promise.prototype.onResolve = function (fn) {
+ if (!fn) return this;
+ if ('function' != typeof fn) throw new TypeError("fn should be a function");
+ this.on(Promise.FAILURE, function (err) { fn.call(this, err); });
+ this.on(Promise.SUCCESS, function () { fn.apply(this, strongUnshift(null, arguments)); });
+ return this;
+};
+
+
+/**
+ * Creates a new promise and returns it. If `onFulfill` or
+ * `onReject` are passed, they are added as SUCCESS/ERROR callbacks
+ * to this promise after the next tick.
+ *
+ * Conforms to [promises/A+](https://github.com/promises-aplus/promises-spec) specification. Read for more detail how to use this method.
+ *
+ * ####Example:
+ *
+ * var p = new Promise;
+ * p.then(function (arg) {
+ * return arg + 1;
+ * }).then(function (arg) {
+ * throw new Error(arg + ' is an error!');
+ * }).then(null, function (err) {
+ * assert.ok(err instanceof Error);
+ * assert.equal('2 is an error', err.message);
+ * });
+ * p.complete(1);
+ *
+ * @see promises-A+ https://github.com/promises-aplus/promises-spec
+ * @param {Function} onFulfill
+ * @param {Function} [onReject]
+ * @return {MPromise} newPromise
+ */
+Promise.prototype.then = function (onFulfill, onReject) {
+ var newPromise = new Promise;
+
+ if ('function' == typeof onFulfill) {
+ this.onFulfill(handler(newPromise, onFulfill));
+ } else {
+ this.onFulfill(newPromise.fulfill.bind(newPromise));
+ }
+
+ if ('function' == typeof onReject) {
+ this.onReject(handler(newPromise, onReject));
+ } else {
+ this.onReject(newPromise.reject.bind(newPromise));
+ }
+
+ return newPromise;
+};
+
+
+function handler(promise, fn) {
+ function newTickHandler() {
+ var pDomain = promise.emitter.domain;
+ if (pDomain && pDomain !== process.domain) pDomain.enter();
+ try {
+ var x = fn.apply(undefined, boundHandler.args);
+ } catch (err) {
+ promise.reject(err);
+ return;
+ }
+ resolve(promise, x);
+ }
+ function boundHandler() {
+ boundHandler.args = arguments;
+ process.nextTick(newTickHandler);
+ }
+ return boundHandler;
+}
+
+
+function resolve(promise, x) {
+ function fulfillOnce() {
+ if (done++) return;
+ resolve.apply(undefined, strongUnshift(promise, arguments));
+ }
+ function rejectOnce(reason) {
+ if (done++) return;
+ promise.reject(reason);
+ }
+
+ if (promise === x) {
+ promise.reject(new TypeError("promise and x are the same"));
+ return;
+ }
+ var rest = toArray(arguments, 1);
+ var type = typeof x;
+ if ('undefined' == type || null == x || !('object' == type || 'function' == type)) {
+ promise.fulfill.apply(promise, rest);
+ return;
+ }
+
+ try {
+ var theThen = x.then;
+ } catch (err) {
+ promise.reject(err);
+ return;
+ }
+
+ if ('function' != typeof theThen) {
+ promise.fulfill.apply(promise, rest);
+ return;
+ }
+
+ var done = 0;
+ try {
+ var ret = theThen.call(x, fulfillOnce, rejectOnce);
+ return ret;
+ } catch (err) {
+ if (done++) return;
+ promise.reject(err);
+ }
+}
+
+
+/**
+ * Signifies that this promise was the last in a chain of `then()s`: if a handler passed to the call to `then` which produced this promise throws, the exception will go uncaught.
+ *
+ * ####Example:
+ *
+ * var p = new Promise;
+ * p.then(function(){ throw new Error('shucks') });
+ * setTimeout(function () {
+ * p.fulfill();
+ * // error was caught and swallowed by the promise returned from
+ * // p.then(). we either have to always register handlers on
+ * // the returned promises or we can do the following...
+ * }, 10);
+ *
+ * // this time we use .end() which prevents catching thrown errors
+ * var p = new Promise;
+ * var p2 = p.then(function(){ throw new Error('shucks') }).end(); // <--
+ * setTimeout(function () {
+ * p.fulfill(); // throws "shucks"
+ * }, 10);
+ *
+ * @api public
+ * @param {Function} [onReject]
+ * @return {MPromise} this
+ */
+Promise.prototype.end = Promise.prototype['catch'] = function (onReject) {
+ if (!onReject && !this.hasRejectListeners())
+ onReject = function idRejector(e) { throw e; };
+ this.onReject(onReject);
+ this.ended = true;
+ return this;
+};
+
+
+/**
+ * A debug utility function that adds handlers to a promise that will log some output to the `console`
+ *
+ * ####Example:
+ *
+ * var p = new Promise;
+ * p.then(function(){ throw new Error('shucks') });
+ * setTimeout(function () {
+ * p.fulfill();
+ * // error was caught and swallowed by the promise returned from
+ * // p.then(). we either have to always register handlers on
+ * // the returned promises or we can do the following...
+ * }, 10);
+ *
+ * // this time we use .end() which prevents catching thrown errors
+ * var p = new Promise;
+ * var p2 = p.then(function(){ throw new Error('shucks') }).end(); // <--
+ * setTimeout(function () {
+ * p.fulfill(); // throws "shucks"
+ * }, 10);
+ *
+ * @api public
+ * @param {MPromise} p
+ * @param {String} name
+ * @return {MPromise} this
+ */
+Promise.trace = function (p, name) {
+ p.then(
+ function () {
+ console.log("%s fulfill %j", name, toArray(arguments));
+ },
+ function () {
+ console.log("%s reject %j", name, toArray(arguments));
+ }
+ )
+};
+
+
+Promise.prototype.chain = function (p2) {
+ var p1 = this;
+ p1.onFulfill(p2.fulfill.bind(p2));
+ p1.onReject(p2.reject.bind(p2));
+ return p2;
+};
+
+
+Promise.prototype.all = function (promiseOfArr) {
+ var pRet = new Promise;
+ this.then(promiseOfArr).then(
+ function (promiseArr) {
+ var count = 0;
+ var ret = [];
+ var errSentinel;
+ if (!promiseArr.length) pRet.resolve();
+ promiseArr.forEach(function (promise, index) {
+ if (errSentinel) return;
+ count++;
+ promise.then(
+ function (val) {
+ if (errSentinel) return;
+ ret[index] = val;
+ --count;
+ if (count == 0) pRet.fulfill(ret);
+ },
+ function (err) {
+ if (errSentinel) return;
+ errSentinel = err;
+ pRet.reject(err);
+ }
+ );
+ });
+ return pRet;
+ }
+ , pRet.reject.bind(pRet)
+ );
+ return pRet;
+};
+
+
+Promise.hook = function (arr) {
+ var p1 = new Promise;
+ var pFinal = new Promise;
+ var signalP = function () {
+ --count;
+ if (count == 0)
+ pFinal.fulfill();
+ return pFinal;
+ };
+ var count = 1;
+ var ps = p1;
+ arr.forEach(function (hook) {
+ ps = ps.then(
+ function () {
+ var p = new Promise;
+ count++;
+ hook(p.resolve.bind(p), signalP);
+ return p;
+ }
+ )
+ });
+ ps = ps.then(signalP);
+ p1.resolve();
+ return ps;
+};
+
+
+/* This is for the A+ tests, but it's very useful as well */
+Promise.fulfilled = function fulfilled() { var p = new Promise; p.fulfill.apply(p, arguments); return p; };
+Promise.rejected = function rejected(reason) { return new Promise().reject(reason); };
+Promise.deferred = function deferred() {
+ var p = new Promise;
+ return {
+ promise: p,
+ reject: p.reject.bind(p),
+ resolve: p.fulfill.bind(p),
+ callback: p.resolve.bind(p)
+ }
+};
+/* End A+ tests adapter bit */
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/package.json
new file mode 100644
index 0000000..8e56fe4
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/package.json
@@ -0,0 +1,65 @@
+{
+ "name": "mpromise",
+ "version": "0.5.5",
+ "description": "Promises A+ conformant implementation",
+ "main": "lib/promise.js",
+ "scripts": {
+ "test": "mocha"
+ },
+ "devDependencies": {
+ "promises-aplus-tests": "2.1.0",
+ "mocha": "1.21.4"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/aheckmann/mpromise"
+ },
+ "keywords": [
+ "promise",
+ "mongoose",
+ "aplus",
+ "a+",
+ "plus"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "contributors": [
+ {
+ "name": "Refael Ackermann",
+ "email": "refack@gmail",
+ "url": "http://node.org.il/"
+ }
+ ],
+ "license": "MIT",
+ "gitHead": "c8842ff1065e9fceef0eef7e97bdb291b7c2550e",
+ "bugs": {
+ "url": "https://github.com/aheckmann/mpromise/issues"
+ },
+ "homepage": "https://github.com/aheckmann/mpromise",
+ "_id": "mpromise@0.5.5",
+ "_shasum": "f5b24259d763acc2257b0a0c8c6d866fd51732e6",
+ "_from": "mpromise@0.5.5",
+ "_npmVersion": "2.0.0-beta.2",
+ "_npmUser": {
+ "name": "refack",
+ "email": "refael@empeeric.com"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ {
+ "name": "refack",
+ "email": "refael@empeeric.com"
+ }
+ ],
+ "dist": {
+ "shasum": "f5b24259d763acc2257b0a0c8c6d866fd51732e6",
+ "tarball": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.domain.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.domain.test.js
new file mode 100644
index 0000000..a6a6be7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.domain.test.js
@@ -0,0 +1,28 @@
+var Promise = require('../')
+ , Domain = require('domain').Domain
+ , assert = require('assert');
+
+
+describe("domains", function () {
+ it("exceptions should not breakout of domain boundaries", function (done) {
+ if (process.version.indexOf('v0.10') != 0) return done();
+ var d = new Domain;
+ d.on('error', function (err) {
+ assert.equal(err.message, 'gaga');
+ done()
+ });
+
+ var p = new Promise();
+ d.run(function () {
+ p.then(
+ function () {}
+ ).then(
+ function () { throw new Error('gaga'); }
+ ).end();
+ });
+
+ process.nextTick(function () {
+ p.fulfill();
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.test.js
new file mode 100644
index 0000000..bf3044d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promise.test.js
@@ -0,0 +1,554 @@
+/*global describe,it */
+/**
+ * Module dependencies.
+ */
+
+var assert = require('assert');
+var MPromise = require('../');
+
+/**
+ * Test.
+ */
+
+describe('promise', function () {
+ it('events fire right after fulfill()', function (done) {
+ var promise = new MPromise()
+ , called = 0;
+
+ promise.on('fulfill', function (a, b) {
+ assert.equal(a, '1');
+ assert.equal(b, '2');
+ called++;
+ });
+
+ promise.fulfill('1', '2');
+
+ promise.on('fulfill', function (a, b) {
+ assert.equal(a, '1');
+ assert.equal(b, '2');
+ called++;
+ });
+
+ assert.equal(2, called);
+ done();
+ });
+
+ it('events fire right after reject()', function (done) {
+ var promise = new MPromise()
+ , called = 0;
+
+ promise.on('reject', function (err) {
+ assert.ok(err instanceof Error);
+ called++;
+ });
+
+ promise.reject(new Error('booyah'));
+
+ promise.on('reject', function (err) {
+ assert.ok(err instanceof Error);
+ called++;
+ });
+
+ assert.equal(2, called);
+ done()
+ });
+
+ describe('onResolve()', function () {
+ it('from constructor works', function (done) {
+ var called = 0;
+
+ var promise = new MPromise(function (err) {
+ assert.ok(err instanceof Error);
+ called++;
+ });
+
+ promise.reject(new Error('dawg'));
+
+ assert.equal(1, called);
+ done();
+ });
+
+ it('after fulfill()', function (done) {
+ var promise = new MPromise()
+ , called = 0;
+
+ promise.fulfill('woot');
+
+ promise.onResolve(function (err, data) {
+ assert.equal(data, 'woot');
+ called++;
+ });
+
+ promise.onResolve(function (err) {
+ assert.strictEqual(err, null);
+ called++;
+ });
+
+ assert.equal(2, called);
+ done();
+ })
+ });
+
+ describe('onFulfill shortcut', function () {
+ it('works', function (done) {
+ var promise = new MPromise()
+ , called = 0;
+
+ promise.onFulfill(function (woot) {
+ assert.strictEqual(woot, undefined);
+ called++;
+ });
+
+ promise.fulfill();
+
+ assert.equal(1, called);
+ done();
+ });
+ });
+
+ describe('onReject shortcut', function () {
+ it('works', function (done) {
+ var promise = new MPromise()
+ , called = 0;
+
+ promise.onReject(function (err) {
+ assert.ok(err instanceof Error);
+ called++;
+ });
+
+ promise.reject(new Error);
+ assert.equal(1, called);
+ done();
+ })
+ });
+
+ describe('return values', function () {
+ it('on()', function (done) {
+ var promise = new MPromise();
+ assert.ok(promise.on('jump', function () {}) instanceof MPromise);
+ done()
+ });
+
+ it('onFulfill()', function (done) {
+ var promise = new MPromise();
+ assert.ok(promise.onFulfill(function () {}) instanceof MPromise);
+ done();
+ });
+ it('onReject()', function (done) {
+ var promise = new MPromise();
+ assert.ok(promise.onReject(function () {}) instanceof MPromise);
+ done();
+ });
+ it('onResolve()', function (done) {
+ var promise = new MPromise();
+ assert.ok(promise.onResolve(function () {}) instanceof MPromise);
+ done();
+ })
+ });
+
+ describe('casting errors', function () {
+ describe('reject()', function () {
+ it('does not cast arguments to Error', function (done) {
+ var p = new MPromise(function (err) {
+ assert.equal(3, err);
+ done();
+ });
+
+ p.reject(3);
+ })
+ })
+ });
+
+ describe('then', function () {
+ describe('catching', function () {
+ it('should not catch returned promise fulfillments', function (done) {
+ var errorSentinal
+ , p = new MPromise;
+ p.then(function () { throw errorSentinal = new Error("boo!") });
+
+ p.fulfill();
+ done();
+ });
+
+
+ it('should not catch returned promise fulfillments even async', function (done) {
+ var errorSentinal
+ , p = new MPromise;
+ p.then(function () { throw errorSentinal = new Error("boo!") });
+
+ setTimeout(function () {
+ p.fulfill();
+ done();
+ }, 10);
+ });
+
+
+ it('can be disabled using .end()', function (done) {
+ if (process.version.indexOf('v0.8') == 0) return done();
+ var errorSentinal
+ , overTimeout
+ , domain = require('domain').create();
+
+ domain.once('error', function (err) {
+ assert(err, errorSentinal);
+ clearTimeout(overTimeout);
+ done()
+ });
+
+ domain.run(function () {
+ var p = new MPromise;
+ var p2 = p.then(function () {
+ throw errorSentinal = new Error('shucks')
+ });
+ p2.end();
+
+ p.fulfill();
+ });
+ overTimeout = setTimeout(function () { done(new Error('error was swallowed')); }, 10);
+ });
+
+
+ it('can be disabled using .end() even when async', function (done) {
+ if (process.version.indexOf('v0.10') != 0) return done();
+ var errorSentinal
+ , overTimeout
+ , domain = require('domain').create();
+
+ domain.on('error', function (err) {
+ assert(err, errorSentinal);
+ clearTimeout(overTimeout);
+ done()
+ });
+
+ domain.run(function () {
+ var p = new MPromise;
+ var p2 = p.then(function () {
+ throw errorSentinal = new Error("boo!")
+ });
+ p2.end();
+
+ setTimeout(function () {p.fulfill();}, 10);
+ });
+ overTimeout = setTimeout(function () { done(new Error('error was swallowed')); }, 20);
+ });
+
+
+ it('can be handled using .end() so no throwing', function (done) {
+ var errorSentinal
+ , overTimeout
+ , domain = require('domain').create();
+
+ domain.run(function () {
+ var p = new MPromise;
+ var p2 = p.then(function () {
+ throw errorSentinal = new Error("boo!")
+ });
+ p2.end(function (err) {
+ assert.equal(err, errorSentinal);
+ clearTimeout(overTimeout);
+ done()
+ });
+
+ setTimeout(function () {p.fulfill();}, 10);
+ });
+ overTimeout = setTimeout(function () { done(new Error('error was swallowed')); }, 20);
+ });
+
+ });
+
+ it('persistent', function (done) {
+ var p = new MPromise;
+ v = null;
+
+ function ensure(val) {
+ v = v || val;
+ assert.equal(v, val);
+ }
+
+ function guard() {
+ throw new Error('onReject should not be called');
+ }
+
+ p.then(ensure, guard).end();
+
+ p.fulfill('foo');
+ p.fulfill('bar');
+ p.reject(new Error('baz'));
+
+ p.then(ensure, guard).end();
+
+ setTimeout(done, 0);
+ });
+
+
+ it('accepts multiple completion values', function (done) {
+ var p = new MPromise;
+
+ p.then(function (a, b) {
+ assert.equal(2, arguments.length);
+ assert.equal('hi', a);
+ assert.equal(4, b);
+ done();
+ }, done).end();
+
+ p.fulfill('hi', 4);
+ })
+ });
+
+ describe('fulfill values and splats', function () {
+ it('should handle multiple values', function (done) {
+ var p = new MPromise;
+ p.onFulfill(function (a, b, c) {
+ assert.equal('a', a);
+ assert.equal('b', b);
+ assert.equal('c', c);
+ done();
+ });
+ p.fulfill('a', 'b', 'c');
+ });
+
+ it('should handle multiple values from a then', function (done) {
+ MPromise.fulfilled().then(
+ function () {
+ return MPromise.fulfilled().then(
+ function () {
+ var p = new MPromise;
+ p.fulfill('a', 'b', 'c');
+ return p;
+ }
+ );
+ }
+ ).onFulfill(
+ function (a, b, c) {
+ assert.equal('a', a);
+ assert.equal('b', b);
+ assert.equal('c', c);
+ done();
+ }
+ ).end()
+ });
+
+ it('should work with `fulfilled` convenience method', function (done) {
+ MPromise.fulfilled('a', 'b', 'c').then(function (a, b, c) {
+ assert.equal('a', a);
+ assert.equal('b', b);
+ assert.equal('c', c);
+ done();
+ })
+ });
+ });
+
+
+ describe('end', function () {
+ it("should return the promise", function (done) {
+ var p = new MPromise;
+ var p1 = p.end();
+ assert.equal(p, p1);
+ done();
+ });
+
+
+ it("should throw for chain", function (done) {
+ var p = new MPromise;
+ p.then().then().then().then().end();
+ try {
+ p.reject('bad');
+ } catch (e) {
+ done();
+ }
+ });
+
+
+ it("should not throw for chain with reject handler", function (done) {
+ var p = new MPromise;
+ p.then().then().then().then().end(function () {
+ done();
+ });
+ try {
+ p.reject('bad');
+ } catch (e) {
+ done(e);
+ }
+ });
+ });
+
+
+ describe('chain', function () {
+ it('should propagate fulfillment', function (done) {
+ var varSentinel = {a: 'a'};
+ var p1 = new MPromise;
+ p1.chain(new MPromise(function (err, doc) {
+ assert.equal(doc, varSentinel);
+ done();
+ }));
+ p1.fulfill(varSentinel);
+ });
+
+
+ it('should propagate rejection', function (done) {
+ var e = new Error("gaga");
+ var p1 = new MPromise;
+ p1.chain(new MPromise(function (err) {
+ assert.equal(err, e);
+ done();
+ }));
+ p1.reject(e);
+ });
+
+
+ it('should propagate resolution err', function (done) {
+ var e = new Error("gaga");
+ var p1 = new MPromise;
+ p1.chain(new MPromise(function (err) {
+ assert.equal(err, e);
+ done();
+ }));
+ p1.resolve(e);
+ });
+
+
+ it('should propagate resolution val', function (done) {
+ var varSentinel = {a: 'a'};
+ var p1 = new MPromise;
+ p1.chain(new MPromise(function (err, val) {
+ assert.equal(val, varSentinel);
+ done();
+ }));
+ p1.resolve(null, varSentinel);
+ })
+ });
+
+
+ describe("all", function () {
+ it("works", function (done) {
+ var count = 0;
+ var p = new MPromise;
+ var p2 = p.all(function () {
+ return [
+ (function () {
+ var p = new MPromise();
+ count++;
+ p.resolve();
+ return p;
+ })()
+ , (function () {
+ var p = new MPromise();
+ count++;
+ p.resolve();
+ return p;
+ })()
+ ];
+ });
+ p2.then(function () {
+ assert.equal(count, 2);
+ done();
+ });
+ p.resolve();
+ });
+
+
+ it("handles rejects", function (done) {
+ var count = 0;
+ var p = new MPromise;
+ var p2 = p.all(function () {
+ return [
+ (function () {
+ var p = new MPromise();
+ count++;
+ p.resolve();
+ return p;
+ })()
+ , (function () {
+ count++;
+ throw new Error("gaga");
+ })()
+ ];
+ });
+ p2.onReject(function (err) {
+ assert(err.message, "gaga");
+ assert.equal(count, 2);
+ done();
+ });
+ p.resolve();
+ });
+ });
+
+
+ describe("deferred", function () {
+ it("works", function (done) {
+ var d = MPromise.deferred();
+ assert.ok(d.promise instanceof MPromise);
+ assert.ok(d.reject instanceof Function);
+ assert.ok(d.resolve instanceof Function);
+ assert.ok(d.callback instanceof Function);
+ done();
+ });
+ });
+
+
+ describe("hook", function () {
+ it("works", function (done) {
+ var run = 0;
+ var l1 = function (ser, par) {
+ run++;
+ ser();
+ par();
+ };
+ MPromise.hook([l1, l1, l1]).then(function () {
+ assert(run, 3);
+ done();
+ })
+
+ });
+
+
+ it("works with async serial hooks", function (done) {
+ this.timeout(800);
+ var run = 0;
+ var l1 = function (ser, par) {
+ run++;
+ setTimeout(function () {ser();}, 200);
+ par();
+ };
+ MPromise.hook([l1, l1, l1]).then(function () {
+ assert(run, 3);
+ done();
+ })
+ });
+
+
+ it("works with async parallel hooks", function (done) {
+ this.timeout(400);
+ var run = 0;
+ var l1 = function (ser, par) {
+ run++;
+ ser();
+ setTimeout(function () {par();}, 200);
+ };
+ MPromise.hook([l1, l1, l1]).then(function () {
+ assert(run, 3);
+ done();
+ })
+ });
+
+
+ it("catches errors in hook logic", function (done) {
+ var run = 0;
+ var l1 = function (ser, par) {
+ run++;
+ ser();
+ par();
+ };
+ var l2 = function (ser, par) {
+ run++;
+ ser();
+ par();
+ throw new Error("err")
+ };
+ MPromise.hook([l1, l2, l1]).end(function (err) {
+ assert(run, 2);
+ done();
+ });
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promises.Aplus.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promises.Aplus.js
new file mode 100644
index 0000000..d30bb32
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mpromise/test/promises.Aplus.js
@@ -0,0 +1,15 @@
+/**
+ * Module dependencies.
+ */
+var Promise = require('../lib/promise');
+var aplus = require('promises-aplus-tests');
+
+// tests
+describe("run A+ suite", function () {
+ aplus.mocha({
+ fulfilled: Promise.fulfilled,
+ rejected: Promise.rejected,
+ deferred: Promise.deferred
+ });
+});
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.npmignore
new file mode 100644
index 0000000..5a14ae1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.npmignore
@@ -0,0 +1,3 @@
+*.sw*
+node_modules/
+coverage/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.travis.yml
new file mode 100644
index 0000000..54f54a5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/.travis.yml
@@ -0,0 +1,8 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.12"
+ - "4"
+ - "5"
+services:
+ - mongodb
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/History.md
new file mode 100644
index 0000000..1b9f1de
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/History.md
@@ -0,0 +1,265 @@
+2.0.0 / 2016-09-25
+==================
+ * added; support for mongodb driver 2.0 streams
+
+1.12.0 / 2016-09-25
+===================
+ * added; `retainKeyOrder` option re: Automattic/mongoose#4542
+
+1.11.0 / 2016-06-04
+===================
+ * added; `.minDistance()` helper and minDistance for `.near()` Automattic/mongoose#4179
+
+1.10.1 / 2016-04-26
+===================
+ * fixed; ensure conditions is an object before assigning #75
+
+1.10.0 / 2016-03-16
+==================
+
+ * updated; bluebird to latest 2.10.2 version #74 [matskiv](https://github.com/matskiv)
+
+1.9.0 / 2016-03-15
+==================
+ * added; `.eq` as a shortcut for `.equals` #72 [Fonger](https://github.com/Fonger)
+ * added; ability to use array syntax for sort re: https://jira.mongodb.org/browse/NODE-578 #67
+
+1.8.0 / 2016-03-01
+==================
+ * fixed; dont throw an error if count used with sort or select Automattic/mongoose#3914
+
+1.7.0 / 2016-02-23
+==================
+ * fixed; don't treat objects with a length property as argument objects #70
+ * added; `.findCursor()` method #69 [nswbmw](https://github.com/nswbmw)
+ * added; `_compiledUpdate` property #68 [nswbmw](https://github.com/nswbmw)
+
+1.6.2 / 2015-07-12
+==================
+
+ * fixed; support exec cb being called synchronously #66
+
+1.6.1 / 2015-06-16
+==================
+
+ * fixed; do not treat $meta projection as inclusive [vkarpov15](https://github.com/vkarpov15)
+
+1.6.0 / 2015-05-27
+==================
+
+ * update dependencies #65 [bachp](https://github.com/bachp)
+
+1.5.0 / 2015-03-31
+==================
+
+ * fixed; debug output
+ * fixed; allow hint usage with count #61 [trueinsider](https://github.com/trueinsider)
+
+1.4.0 / 2015-03-29
+==================
+
+ * added; object support to slice() #60 [vkarpov15](https://github.com/vkarpov15)
+ * debug; improved output #57 [flyvictor](https://github.com/flyvictor)
+
+1.3.0 / 2014-11-06
+==================
+
+ * added; setTraceFunction() #53 from [jlai](https://github.com/jlai)
+
+1.2.1 / 2014-09-26
+==================
+
+ * fixed; distinct assignment in toConstructor() #51 from [esco](https://github.com/esco)
+
+1.2.0 / 2014-09-18
+==================
+
+ * added; stream() support for find()
+
+1.1.0 / 2014-09-15
+==================
+
+ * add #then for co / koa support
+ * start checking code coverage
+
+1.0.0 / 2014-07-07
+==================
+
+ * Remove broken require() calls until they're actually implemented #48 [vkarpov15](https://github.com/vkarpov15)
+
+0.9.0 / 2014-05-22
+==================
+
+ * added; thunk() support
+ * release 0.8.0
+
+0.8.0 / 2014-05-15
+==================
+
+ * added; support for maxTimeMS #44 [yoitsro](https://github.com/yoitsro)
+ * updated; devDependency (driver to 1.4.4)
+
+0.7.0 / 2014-05-02
+==================
+
+ * fixed; pass $maxDistance in $near object as described in docs #43 [vkarpov15](https://github.com/vkarpov15)
+ * fixed; cloning buffers #42 [gjohnson](https://github.com/gjohnson)
+ * tests; a little bit more `mongodb` agnostic #34 [refack](https://github.com/refack)
+
+0.6.0 / 2014-04-01
+==================
+
+ * fixed; Allow $meta args in sort() so text search sorting works #37 [vkarpov15](https://github.com/vkarpov15)
+
+0.5.3 / 2014-02-22
+==================
+
+ * fixed; cloning mongodb.Binary
+
+0.5.2 / 2014-01-30
+==================
+
+ * fixed; cloning ObjectId constructors
+ * fixed; cloning of ReadPreferences #30 [ashtuchkin](https://github.com/ashtuchkin)
+ * tests; use specific mongodb version #29 [AvianFlu](https://github.com/AvianFlu)
+ * tests; remove dependency on ObjectId #28 [refack](https://github.com/refack)
+ * tests; add failing ReadPref test
+
+0.5.1 / 2014-01-17
+==================
+
+ * added; deprecation notice to tags parameter #27 [ashtuchkin](https://github.com/ashtuchkin)
+ * readme; add links
+
+0.5.0 / 2014-01-16
+==================
+
+ * removed; mongodb driver dependency #26 [ashtuchkin](https://github.com/ashtuchkin)
+ * removed; first class support of read preference tags #26 (still supported though) [ashtuchkin](https://github.com/ashtuchkin)
+ * added; better ObjectId clone support
+ * fixed; cloning objects that have no constructor #21
+ * docs; cleaned up [ashtuchkin](https://github.com/ashtuchkin)
+
+0.4.2 / 2014-01-08
+==================
+
+ * updated; debug module 0.7.4 [refack](https://github.com/refack)
+
+0.4.1 / 2014-01-07
+==================
+
+ * fixed; inclusive/exclusive logic
+
+0.4.0 / 2014-01-06
+==================
+
+ * added; selected()
+ * added; selectedInclusively()
+ * added; selectedExclusively()
+
+0.3.3 / 2013-11-14
+==================
+
+ * Fix Mongo DB Dependency #20 [rschmukler](https://github.com/rschmukler)
+
+0.3.2 / 2013-09-06
+==================
+
+ * added; geometry support for near()
+
+0.3.1 / 2013-08-22
+==================
+
+ * fixed; update retains key order #19
+
+0.3.0 / 2013-08-22
+==================
+
+ * less hardcoded isNode env detection #18 [vshulyak](https://github.com/vshulyak)
+ * added; validation of findAndModify varients
+ * clone update doc before execution
+ * stricter env checks
+
+0.2.7 / 2013-08-2
+==================
+
+ * Now support GeoJSON point values for Query#near
+
+0.2.6 / 2013-07-30
+==================
+
+ * internally, 'asc' and 'desc' for sorts are now converted into 1 and -1, respectively
+
+0.2.5 / 2013-07-30
+==================
+
+ * updated docs
+ * changed internal representation of `sort` to use objects instead of arrays
+
+0.2.4 / 2013-07-25
+==================
+
+ * updated; sliced to 0.0.5
+
+0.2.3 / 2013-07-09
+==================
+
+ * now using a callback in collection.find instead of directly calling toArray() on the cursor [ebensing](https://github.com/ebensing)
+
+0.2.2 / 2013-07-09
+==================
+
+ * now exposing mongodb export to allow for better testing [ebensing](https://github.com/ebensing)
+
+0.2.1 / 2013-07-08
+==================
+
+ * select no longer accepts arrays as parameters [ebensing](https://github.com/ebensing)
+
+0.2.0 / 2013-07-05
+==================
+
+ * use $geoWithin by default
+
+0.1.2 / 2013-07-02
+==================
+
+ * added use$geoWithin flag [ebensing](https://github.com/ebensing)
+ * fix read preferences typo [ebensing](https://github.com/ebensing)
+ * fix reference to old param name in exists() [ebensing](https://github.com/ebensing)
+
+0.1.1 / 2013-06-24
+==================
+
+ * fixed; $intersects -> $geoIntersects #14 [ebensing](https://github.com/ebensing)
+ * fixed; Retain key order when copying objects #15 [ebensing](https://github.com/ebensing)
+ * bump mongodb dev dep
+
+0.1.0 / 2013-05-06
+==================
+
+ * findAndModify; return the query
+ * move mquery.proto.canMerge to mquery.canMerge
+ * overwrite option now works with non-empty objects
+ * use strict mode
+ * validate count options
+ * validate distinct options
+ * add aggregate to base collection methods
+ * clone merge arguments
+ * clone merged update arguments
+ * move subclass to mquery.prototype.toConstructor
+ * fixed; maxScan casing
+ * use regexp-clone
+ * added; geometry/intersects support
+ * support $and
+ * near: do not use "radius"
+ * callbacks always fire on next turn of loop
+ * defined collection interface
+ * remove time from tests
+ * clarify goals
+ * updated docs;
+
+0.0.1 / 2012-12-15
+==================
+
+ * initial release
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/Makefile
new file mode 100644
index 0000000..dbb2831
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/Makefile
@@ -0,0 +1,22 @@
+
+test:
+ @NODE_ENV=test ./node_modules/.bin/mocha $(T) $(TESTS)
+
+test-cov:
+ @NODE_ENV=test node \
+ node_modules/.bin/istanbul cover \
+ ./node_modules/.bin/_mocha \
+ -- -u exports \
+
+open-cov:
+ open coverage/lcov-report/index.html
+
+test-travis:
+ @NODE_ENV=test node \
+ node_modules/.bin/istanbul cover \
+ ./node_modules/.bin/_mocha \
+ --report lcovonly \
+ -- -u exports \
+ --bail
+
+.PHONY: test test-cov open-cov test-travis
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/README.md
new file mode 100644
index 0000000..f9a06f0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/README.md
@@ -0,0 +1,1219 @@
+#mquery
+
+`mquery` is a fluent mongodb query builder designed to run in multiple environments. As of v0.1, `mquery` runs on `Node.js` only with support for the MongoDB shell and browser environments planned for upcoming releases.
+
+##Features
+
+ - fluent query builder api
+ - custom base query support
+ - MongoDB 2.4 geoJSON support
+ - method + option combinations validation
+ - node.js driver compatibility
+ - environment detection
+ - [debug](https://github.com/visionmedia/debug) support
+ - separated collection implementations for maximum flexibility
+
+[![Build Status](https://travis-ci.org/aheckmann/mquery.png)](https://travis-ci.org/aheckmann/mquery)
+
+##Use
+
+```js
+require('mongodb').connect(uri, function (err, db) {
+ if (err) return handleError(err);
+
+ // get a collection
+ var collection = db.collection('artists');
+
+ // pass it to the constructor
+ mquery(collection).find({..}, callback);
+
+ // or pass it to the collection method
+ mquery().find({..}).collection(collection).exec(callback)
+
+ // or better yet, create a custom query constructor that has it always set
+ var Artist = mquery(collection).toConstructor();
+ Artist().find(..).where(..).exec(callback)
+})
+```
+
+`mquery` requires a collection object to work with. In the example above we just pass the collection object created using the official [MongoDB driver](https://github.com/mongodb/node-mongodb-native).
+
+
+##Fluent API
+
+- [find](#find)
+- [findOne](#findOne)
+- [count](#count)
+- [remove](#remove)
+- [update](#update)
+- [findOneAndUpdate](#findoneandupdate)
+- [findOneAndRemove](#findoneandremove)
+- [distinct](#distinct)
+- [exec](#exec)
+- [stream](#stream)
+- [all](#all)
+- [and](#and)
+- [box](#box)
+- [circle](#circle)
+- [elemMatch](#elemmatch)
+- [equals](#equals)
+- [exists](#exists)
+- [geometry](#geometry)
+- [gt](#gt)
+- [gte](#gte)
+- [in](#in)
+- [intersects](#intersects)
+- [lt](#lt)
+- [lte](#lte)
+- [maxDistance](#maxdistance)
+- [mod](#mod)
+- [ne](#ne)
+- [nin](#nin)
+- [nor](#nor)
+- [near](#near)
+- [or](#or)
+- [polygon](#polygon)
+- [regex](#regex)
+- [select](#select)
+- [selected](#selected)
+- [selectedInclusively](#selectedinclusively)
+- [selectedExclusively](#selectedexclusively)
+- [size](#size)
+- [slice](#slice)
+- [within](#within)
+- [where](#where)
+- [$where](#where-1)
+- [batchSize](#batchsize)
+- [comment](#comment)
+- [hint](#hint)
+- [limit](#limit)
+- [maxScan](#maxscan)
+- [maxTime](#maxtime)
+- [skip](#skip)
+- [sort](#sort)
+- [read](#read)
+- [slaveOk](#slaveok)
+- [snapshot](#snapshot)
+- [tailable](#tailable)
+
+## Helpers
+
+- [collection](#collection)
+- [then](#then)
+- [thunk](#thunk)
+- [merge](#mergeobject)
+- [setOptions](#setoptionsoptions)
+- [setTraceFunction](#settracefunctionfunc)
+- [mquery.setGlobalTraceFunction](#mquerysetglobaltracefunctionfunc)
+- [mquery.canMerge](#mquerycanmerge)
+- [mquery.use$geoWithin](#mqueryusegeowithin)
+
+###find()
+
+Declares this query a _find_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
+
+```js
+mquery().find()
+mquery().find(match)
+mquery().find(callback)
+mquery().find(match, function (err, docs) {
+ assert(Array.isArray(docs));
+})
+```
+
+###findOne()
+
+Declares this query a _findOne_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
+
+```js
+mquery().findOne()
+mquery().findOne(match)
+mquery().findOne(callback)
+mquery().findOne(match, function (err, doc) {
+ if (doc) {
+ // the document may not be found
+ console.log(doc);
+ }
+})
+```
+
+###count()
+
+Declares this query a _count_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
+
+```js
+mquery().count()
+mquery().count(match)
+mquery().count(callback)
+mquery().count(match, function (err, number){
+ console.log('we found %d matching documents', number);
+})
+```
+
+###remove()
+
+Declares this query a _remove_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
+
+```js
+mquery().remove()
+mquery().remove(match)
+mquery().remove(callback)
+mquery().remove(match, function (err){})
+```
+
+###update()
+
+Declares this query an _update_ query. Optionally pass an update document, match clause, options or callback. If a callback is passed, the query is executed. To force execution without passing a callback, run `update(true)`.
+
+```js
+mquery().update()
+mquery().update(match, updateDocument)
+mquery().update(match, updateDocument, options)
+
+// the following all execute the command
+mquery().update(callback)
+mquery().update({$set: updateDocument, callback)
+mquery().update(match, updateDocument, callback)
+mquery().update(match, updateDocument, options, function (err, result){})
+mquery().update(true) // executes (unsafe write)
+```
+
+#####the update document
+
+All paths passed that are not `$atomic` operations will become `$set` ops. For example:
+
+```js
+mquery(collection).where({ _id: id }).update({ title: 'words' }, callback)
+```
+
+becomes
+
+```js
+collection.update({ _id: id }, { $set: { title: 'words' }}, callback)
+```
+
+This behavior can be overridden using the `overwrite` option (see below).
+
+#####options
+
+Options are passed to the `setOptions()` method.
+
+- overwrite
+
+Passing an empty object `{ }` as the update document will result in a no-op unless the `overwrite` option is passed. Without the `overwrite` option, the update operation will be ignored and the callback executed without sending the command to MongoDB to prevent accidently overwritting documents in the collection.
+
+```js
+var q = mquery(collection).where({ _id: id }).setOptions({ overwrite: true });
+q.update({ }, callback); // overwrite with an empty doc
+```
+
+The `overwrite` option isn't just for empty objects, it also provides a means to override the default `$set` conversion and send the update document as is.
+
+```js
+// create a base query
+var base = mquery({ _id: 108 }).collection(collection).toConstructor();
+
+base().findOne(function (err, doc) {
+ console.log(doc); // { _id: 108, name: 'cajon' })
+
+ base().setOptions({ overwrite: true }).update({ changed: true }, function (err) {
+ base.findOne(function (err, doc) {
+ console.log(doc); // { _id: 108, changed: true }) - the doc was overwritten
+ });
+ });
+})
+```
+
+- multi
+
+Updates only modify a single document by default. To update multiple documents, set the `multi` option to `true`.
+
+```js
+mquery()
+ .collection(coll)
+ .update({ name: /^match/ }, { $addToSet: { arr: 4 }}, { multi: true }, callback)
+
+// another way of doing it
+mquery({ name: /^match/ })
+ .collection(coll)
+ .setOptions({ multi: true })
+ .update({ $addToSet: { arr: 4 }}, callback)
+
+// update multiple documents with an empty doc
+var q = mquery(collection).where({ name: /^match/ });
+q.setOptions({ multi: true, overwrite: true })
+q.update({ });
+q.update(function (err, result) {
+ console.log(arguments);
+});
+```
+
+###findOneAndUpdate()
+
+Declares this query a _findAndModify_ with update query. Optionally pass a match clause, update document, options, or callback. If a callback is passed, the query is executed.
+
+When executed, the first matching document (if found) is modified according to the update document and passed back to the callback.
+
+#####options
+
+Options are passed to the `setOptions()` method.
+
+- `new`: boolean - true to return the modified document rather than the original. defaults to true
+- `upsert`: boolean - creates the object if it doesn't exist. defaults to false
+- `sort`: if multiple docs are found by the match condition, sets the sort order to choose which doc to update
+
+```js
+query.findOneAndUpdate()
+query.findOneAndUpdate(updateDocument)
+query.findOneAndUpdate(match, updateDocument)
+query.findOneAndUpdate(match, updateDocument, options)
+
+// the following all execute the command
+query.findOneAndUpdate(callback)
+query.findOneAndUpdate(updateDocument, callback)
+query.findOneAndUpdate(match, updateDocument, callback)
+query.findOneAndUpdate(match, updateDocument, options, function (err, doc) {
+ if (doc) {
+ // the document may not be found
+ console.log(doc);
+ }
+})
+ ```
+
+###findOneAndRemove()
+
+Declares this query a _findAndModify_ with remove query. Optionally pass a match clause, options, or callback. If a callback is passed, the query is executed.
+
+When executed, the first matching document (if found) is modified according to the update document, removed from the collection and passed to the callback.
+
+#####options
+
+Options are passed to the `setOptions()` method.
+
+- `sort`: if multiple docs are found by the condition, sets the sort order to choose which doc to modify and remove
+
+```js
+A.where().findOneAndRemove()
+A.where().findOneAndRemove(match)
+A.where().findOneAndRemove(match, options)
+
+// the following all execute the command
+A.where().findOneAndRemove(callback)
+A.where().findOneAndRemove(match, callback)
+A.where().findOneAndRemove(match, options, function (err, doc) {
+ if (doc) {
+ // the document may not be found
+ console.log(doc);
+ }
+})
+ ```
+
+###distinct()
+
+Declares this query a _distinct_ query. Optionally pass the distinct field, a match clause or callback. If a callback is passed the query is executed.
+
+```js
+mquery().distinct()
+mquery().distinct(match)
+mquery().distinct(match, field)
+mquery().distinct(field)
+
+// the following all execute the command
+mquery().distinct(callback)
+mquery().distinct(field, callback)
+mquery().distinct(match, callback)
+mquery().distinct(match, field, function (err, result) {
+ console.log(result);
+})
+```
+
+###exec()
+
+Executes the query.
+
+```js
+mquery().findOne().where('route').intersects(polygon).exec(function (err, docs){})
+```
+
+###stream()
+
+Executes the query and returns a stream.
+
+```js
+var stream = mquery().find().stream(options);
+stream.on('data', cb);
+stream.on('close', fn);
+```
+
+Note: this only works with `find()` operations.
+
+Note: returns the stream object directly from the node-mongodb-native driver. (currently streams1 type stream). Any options will be passed along to the [driver method](http://mongodb.github.io/node-mongodb-native/api-generated/cursor.html#stream).
+
+-------------
+
+###all()
+
+Specifies an `$all` query condition
+
+```js
+mquery().where('permission').all(['read', 'write'])
+```
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/all/)
+
+###and()
+
+Specifies arguments for an `$and` condition
+
+```js
+mquery().and([{ color: 'green' }, { status: 'ok' }])
+```
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/and/)
+
+###box()
+
+Specifies a `$box` condition
+
+```js
+var lowerLeft = [40.73083, -73.99756]
+var upperRight= [40.741404, -73.988135]
+
+mquery().where('location').within().box(lowerLeft, upperRight)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/box/)
+
+###circle()
+
+Specifies a `$center` or `$centerSphere` condition.
+
+```js
+var area = { center: [50, 50], radius: 10, unique: true }
+query.where('loc').within().circle(area)
+query.circle('loc', area);
+
+// for spherical calculations
+var area = { center: [50, 50], radius: 10, unique: true, spherical: true }
+query.where('loc').within().circle(area)
+query.circle('loc', area);
+```
+
+- [MongoDB Documentation - center](http://docs.mongodb.org/manual/reference/operator/center/)
+- [MongoDB Documentation - centerSphere](http://docs.mongodb.org/manual/reference/operator/centerSphere/)
+
+###elemMatch()
+
+Specifies an `$elemMatch` condition
+
+```js
+query.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}})
+
+query.elemMatch('comment', function (elem) {
+ elem.where('author').equals('autobot');
+ elem.where('votes').gte(5);
+})
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/elemMatch/)
+
+###equals()
+
+Specifies the complementary comparison value for the path specified with `where()`.
+
+```js
+mquery().where('age').equals(49);
+
+// is the same as
+
+mquery().where({ 'age': 49 });
+```
+
+###exists()
+
+Specifies an `$exists` condition
+
+```js
+// { name: { $exists: true }}
+mquery().where('name').exists()
+mquery().where('name').exists(true)
+mquery().exists('name')
+
+// { name: { $exists: false }}
+mquery().where('name').exists(false);
+mquery().exists('name', false);
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/exists/)
+
+###geometry()
+
+Specifies a `$geometry` condition
+
+```js
+var polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
+query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
+
+// or
+var polyB = [[ 0, 0 ], [ 1, 1 ]]
+query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
+
+// or
+var polyC = [ 0, 0 ]
+query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
+
+// or
+query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })
+
+// or
+query.where('loc').near().geometry({ type: 'Point', coordinates: [3,5] })
+```
+
+`geometry()` **must** come after `intersects()`, `within()`, or `near()`.
+
+The `object` argument must contain `type` and `coordinates` properties.
+
+- type `String`
+- coordinates `Array`
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/geometry/)
+
+###gt()
+
+Specifies a `$gt` query condition.
+
+```js
+mquery().where('clicks').gt(999)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/gt/)
+
+###gte()
+
+Specifies a `$gte` query condition.
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/gte/)
+
+```js
+mquery().where('clicks').gte(1000)
+```
+
+###in()
+
+Specifies an `$in` query condition.
+
+```js
+mquery().where('author_id').in([3, 48901, 761])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/in/)
+
+###intersects()
+
+Declares an `$geoIntersects` query for `geometry()`.
+
+```js
+query.where('path').intersects().geometry({
+ type: 'LineString'
+ , coordinates: [[180.0, 11.0], [180, 9.0]]
+})
+
+// geometry arguments are supported
+query.where('path').intersects({
+ type: 'LineString'
+ , coordinates: [[180.0, 11.0], [180, 9.0]]
+})
+```
+
+**Must** be used after `where()`.
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/geoIntersects/)
+
+###lt()
+
+Specifies a `$lt` query condition.
+
+```js
+mquery().where('clicks').lt(50)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/lt/)
+
+###lte()
+
+Specifies a `$lte` query condition.
+
+```js
+mquery().where('clicks').lte(49)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/lte/)
+
+###maxDistance()
+
+Specifies a `$maxDistance` query condition.
+
+```js
+mquery().where('location').near({ center: [139, 74.3] }).maxDistance(5)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/maxDistance/)
+
+###mod()
+
+Specifies a `$mod` condition
+
+```js
+mquery().where('count').mod(2, 0)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/mod/)
+
+###ne()
+
+Specifies a `$ne` query condition.
+
+```js
+mquery().where('status').ne('ok')
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/ne/)
+
+###nin()
+
+Specifies an `$nin` query condition.
+
+```js
+mquery().where('author_id').nin([3, 48901, 761])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/nin/)
+
+###nor()
+
+Specifies arguments for an `$nor` condition.
+
+```js
+mquery().nor([{ color: 'green' }, { status: 'ok' }])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/nor/)
+
+###near()
+
+Specifies arguments for a `$near` or `$nearSphere` condition.
+
+These operators return documents sorted by distance.
+
+####Example
+
+```js
+query.where('loc').near({ center: [10, 10] });
+query.where('loc').near({ center: [10, 10], maxDistance: 5 });
+query.near('loc', { center: [10, 10], maxDistance: 5 });
+
+// GeoJSON
+query.where('loc').near({ center: { type: 'Point', coordinates: [10, 10] }});
+query.where('loc').near({ center: { type: 'Point', coordinates: [10, 10] }, maxDistance: 5, spherical: true });
+query.where('loc').near().geometry({ type: 'Point', coordinates: [10, 10] });
+
+// For a $nearSphere condition, pass the `spherical` option.
+query.near({ center: [10, 10], maxDistance: 5, spherical: true });
+```
+
+[MongoDB Documentation](http://www.mongodb.org/display/DOCS/Geospatial+Indexing)
+
+###or()
+
+Specifies arguments for an `$or` condition.
+
+```js
+mquery().or([{ color: 'red' }, { status: 'emergency' }])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/or/)
+
+###polygon()
+
+Specifies a `$polygon` condition
+
+```js
+mquery().where('loc').within().polygon([10,20], [13, 25], [7,15])
+mquery().polygon('loc', [10,20], [13, 25], [7,15])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/polygon/)
+
+###regex()
+
+Specifies a `$regex` query condition.
+
+```js
+mquery().where('name').regex(/^sixstepsrecords/)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/regex/)
+
+###select()
+
+Specifies which document fields to include or exclude
+
+```js
+// 1 means include, 0 means exclude
+mquery().select({ name: 1, address: 1, _id: 0 })
+
+// or
+
+mquery().select('name address -_id')
+```
+
+#####String syntax
+
+When passing a string, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included.
+
+```js
+// include a and b, exclude c
+query.select('a b -c');
+
+// or you may use object notation, useful when
+// you have keys already prefixed with a "-"
+query.select({a: 1, b: 1, c: 0});
+```
+
+_Cannot be used with `distinct()`._
+
+###selected()
+
+Determines if the query has selected any fields.
+
+```js
+var query = mquery();
+query.selected() // false
+query.select('-name');
+query.selected() // true
+```
+
+###selectedInclusively()
+
+Determines if the query has selected any fields inclusively.
+
+```js
+var query = mquery().select('name');
+query.selectedInclusively() // true
+
+var query = mquery();
+query.selected() // false
+query.select('-name');
+query.selectedInclusively() // false
+query.selectedExclusively() // true
+```
+
+###selectedExclusively()
+
+Determines if the query has selected any fields exclusively.
+
+```js
+var query = mquery().select('-name');
+query.selectedExclusively() // true
+
+var query = mquery();
+query.selected() // false
+query.select('name');
+query.selectedExclusively() // false
+query.selectedInclusively() // true
+```
+
+###size()
+
+Specifies a `$size` query condition.
+
+```js
+mquery().where('someArray').size(6)
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/size/)
+
+###slice()
+
+Specifies a `$slice` projection for a `path`
+
+```js
+mquery().where('comments').slice(5)
+mquery().where('comments').slice(-5)
+mquery().where('comments').slice([-10, 5])
+```
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/projection/slice/)
+
+###within()
+
+Sets a `$geoWithin` or `$within` argument for geo-spatial queries.
+
+```js
+mquery().within().box()
+mquery().within().circle()
+mquery().within().geometry()
+
+mquery().where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
+mquery().where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
+mquery().where('loc').within({ polygon: [[],[],[],[]] });
+
+mquery().where('loc').within([], [], []) // polygon
+mquery().where('loc').within([], []) // box
+mquery().where('loc').within({ type: 'LineString', coordinates: [...] }); // geometry
+```
+
+As of mquery 2.0, `$geoWithin` is used by default. This impacts you if running MongoDB < 2.4. To alter this behavior, see [mquery.use$geoWithin](#mqueryusegeowithin).
+
+**Must** be used after `where()`.
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/reference/operator/geoWithin/)
+
+###where()
+
+Specifies a `path` for use with chaining
+
+```js
+// instead of writing:
+mquery().find({age: {$gte: 21, $lte: 65}});
+
+// we can instead write:
+mquery().where('age').gte(21).lte(65);
+
+// passing query conditions is permitted too
+mquery().find().where({ name: 'vonderful' })
+
+// chaining
+mquery()
+.where('age').gte(21).lte(65)
+.where({ 'name': /^vonderful/i })
+.where('friends').slice(10)
+.exec(callback)
+```
+
+###$where()
+
+Specifies a `$where` condition.
+
+Use `$where` when you need to select documents using a JavaScript expression.
+
+```js
+query.$where('this.comments.length > 10 || this.name.length > 5').exec(callback)
+
+query.$where(function () {
+ return this.comments.length > 10 || this.name.length > 5;
+})
+```
+
+Only use `$where` when you have a condition that cannot be met using other MongoDB operators like `$lt`. Be sure to read about all of [its caveats](http://docs.mongodb.org/manual/reference/operator/where/) before using.
+
+-----------
+
+###batchSize()
+
+Specifies the batchSize option.
+
+```js
+query.batchSize(100)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/cursor.batchSize/)
+
+###comment()
+
+Specifies the comment option.
+
+```js
+query.comment('login query');
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/)
+
+###hint()
+
+Sets query hints.
+
+```js
+mquery().hint({ indexA: 1, indexB: -1 })
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/hint/)
+
+###limit()
+
+Specifies the limit option.
+
+```js
+query.limit(20)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/cursor.limit/)
+
+###maxScan()
+
+Specifies the maxScan option.
+
+```js
+query.maxScan(100)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/maxScan/)
+
+###maxTime()
+
+Specifies the maxTimeMS option.
+
+```js
+query.maxTime(100)
+```
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/cursor.maxTimeMS/)
+
+
+###skip()
+
+Specifies the skip option.
+
+```js
+query.skip(100).limit(20)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/cursor.skip/)
+
+###sort()
+
+Sets the query sort order.
+
+If an object is passed, key values allowed are `asc`, `desc`, `ascending`, `descending`, `1`, and `-1`.
+
+If a string is passed, it must be a space delimited list of path names. The sort order of each path is ascending unless the path name is prefixed with `-` which will be treated as descending.
+
+```js
+// these are equivalent
+query.sort({ field: 'asc', test: -1 });
+query.sort('field -test');
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/cursor.sort/)
+
+###read()
+
+Sets the readPreference option for the query.
+
+```js
+mquery().read('primary')
+mquery().read('p') // same as primary
+
+mquery().read('primaryPreferred')
+mquery().read('pp') // same as primaryPreferred
+
+mquery().read('secondary')
+mquery().read('s') // same as secondary
+
+mquery().read('secondaryPreferred')
+mquery().read('sp') // same as secondaryPreferred
+
+mquery().read('nearest')
+mquery().read('n') // same as nearest
+```
+
+#####Preferences:
+
+- `primary` - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.
+- `secondary` - Read from secondary if available, otherwise error.
+- `primaryPreferred` - Read from primary if available, otherwise a secondary.
+- `secondaryPreferred` - Read from a secondary if available, otherwise read from the primary.
+- `nearest` - All operations read from among the nearest candidates, but unlike other modes, this option will include both the primary and all secondaries in the random selection.
+
+Aliases
+
+- `p` primary
+- `pp` primaryPreferred
+- `s` secondary
+- `sp` secondaryPreferred
+- `n` nearest
+
+#####Preference Tags:
+
+To keep the separation of concerns between `mquery` and your driver
+clean, `mquery#read()` no longer handles specifying a second `tags` argument as of version 0.5.
+If you need to specify tags, pass any non-string argument as the first argument.
+`mquery` will pass this argument untouched to your collections methods later.
+For example:
+
+```js
+// example of specifying tags using the Node.js driver
+var ReadPref = require('mongodb').ReadPreference;
+var preference = new ReadPref('secondary', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }]);
+mquery(..).read(preference).exec();
+```
+
+Read more about how to use read preferences [here](http://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
+
+###slaveOk()
+
+Sets the slaveOk option. `true` allows reading from secondaries.
+
+**deprecated** use [read()](#read) preferences instead if on mongodb >= 2.2
+
+```js
+query.slaveOk() // true
+query.slaveOk(true)
+query.slaveOk(false)
+```
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/method/rs.slaveOk/)
+
+###snapshot()
+
+Specifies this query as a snapshot query.
+
+```js
+mquery().snapshot() // true
+mquery().snapshot(true)
+mquery().snapshot(false)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/snapshot/)
+
+###tailable()
+
+Sets tailable option.
+
+```js
+mquery().tailable() <== true
+mquery().tailable(true)
+mquery().tailable(false)
+```
+
+_Cannot be used with `distinct()`._
+
+[MongoDB Documentation](http://docs.mongodb.org/manual/tutorial/create-tailable-cursor/)
+
+##Helpers
+
+###collection()
+
+Sets the querys collection.
+
+```js
+mquery().collection(aCollection)
+```
+
+###then()
+
+Executes the query and returns a promise which will be resolved with the query results or rejected if the query responds with an error.
+
+```js
+mquery().find(..).then(success, error);
+```
+
+This is very useful when combined with [co](https://github.com/visionmedia/co) or [koa](https://github.com/koajs/koa), which automatically resolve promise-like objects for you.
+
+```js
+co(function*(){
+ var doc = yield mquery().findOne({ _id: 499 });
+ console.log(doc); // { _id: 499, name: 'amazing', .. }
+})();
+```
+
+_NOTE_:
+The returned promise is a [bluebird](https://github.com/petkaantonov/bluebird/) promise but this is customizable. If you want to
+use your favorite promise library, simply set `mquery.Promise = YourPromiseConstructor`.
+Your `Promise` must be [promises A+](http://promisesaplus.com/) compliant.
+
+###thunk()
+
+Returns a thunk which when called runs the query's `exec` method passing the results to the callback.
+
+```js
+var thunk = mquery(collection).find({..}).thunk();
+
+thunk(function(err, results) {
+
+})
+```
+
+###merge(object)
+
+Merges other mquery or match condition objects into this one. When an muery instance is passed, its match conditions, field selection and options are merged.
+
+```js
+var drum = mquery({ type: 'drum' }).collection(instruments);
+var redDrum = mqery({ color: 'red' }).merge(drum);
+redDrum.count(function (err, n) {
+ console.log('there are %d red drums', n);
+})
+```
+
+Internally uses `mquery.canMerge` to determine validity.
+
+###setOptions(options)
+
+Sets query options.
+
+```js
+mquery().setOptions({ collection: coll, limit: 20 })
+```
+
+#####options
+
+- [tailable](#tailable) *
+- [sort](#sort) *
+- [limit](#limit) *
+- [skip](#skip) *
+- [maxScan](#maxscan) *
+- [maxTime](#maxtime) *
+- [batchSize](#batchSize) *
+- [comment](#comment) *
+- [snapshot](#snapshot) *
+- [hint](#hint) *
+- [slaveOk](#slaveOk) *
+- [safe](http://docs.mongodb.org/manual/reference/write-concern/): Boolean - passed through to the collection. Setting to `true` is equivalent to `{ w: 1 }`
+- [collection](#collection): the collection to query against
+
+_* denotes a query helper method is also available_
+
+###setTraceFunction(func)
+
+Set a function to trace this query. Useful for profiling or logging.
+
+```js
+function traceFunction (method, queryInfo, query) {
+ console.log('starting ' + method + ' query');
+
+ return function (err, result, millis) {
+ console.log('finished ' + method + ' query in ' + millis + 'ms');
+ };
+}
+
+mquery().setTraceFunction(traceFunction).findOne({name: 'Joe'}, cb);
+```
+
+The trace function is passed (method, queryInfo, query)
+
+- method is the name of the method being called (e.g. findOne)
+- queryInfo contains information about the query:
+ - conditions: query conditions/criteria
+ - options: options such as sort, fields, etc
+ - doc: document being updated
+- query is the query object
+
+The trace function should return a callback function which accepts:
+- err: error, if any
+- result: result, if any
+- millis: time spent waiting for query result
+
+NOTE: stream requests are not traced.
+
+###mquery.setGlobalTraceFunction(func)
+
+Similar to `setTraceFunction()` but automatically applied to all queries.
+
+```js
+mquery.setTraceFunction(traceFunction);
+```
+
+###mquery.canMerge(conditions)
+
+Determines if `conditions` can be merged using `mquery().merge()`.
+
+```js
+var query = mquery({ type: 'drum' });
+var okToMerge = mquery.canMerge(anObject)
+if (okToMerge) {
+ query.merge(anObject);
+}
+```
+
+##mquery.use$geoWithin
+
+MongoDB 2.4 introduced the `$geoWithin` operator which replaces and is 100% backward compatible with `$within`. As of mquery 0.2, we default to using `$geoWithin` for all `within()` calls.
+
+If you are running MongoDB < 2.4 this will be problematic. To force `mquery` to be backward compatible and always use `$within`, set the `mquery.use$geoWithin` flag to `false`.
+
+```js
+mquery.use$geoWithin = false;
+```
+
+##Custom Base Queries
+
+Often times we want custom base queries that encapsulate predefined criteria. With `mquery` this is easy. First create the query you want to reuse and call its `toConstructor()` method which returns a new subclass of `mquery` that retains all options and criteria of the original.
+
+```js
+var greatMovies = mquery(movieCollection).where('rating').gte(4.5).toConstructor();
+
+// use it!
+greatMovies().count(function (err, n) {
+ console.log('There are %d great movies', n);
+});
+
+greatMovies().where({ name: /^Life/ }).select('name').find(function (err, docs) {
+ console.log(docs);
+});
+```
+
+##Validation
+
+Method and options combinations are checked for validity at runtime to prevent creation of invalid query constructs. For example, a `distinct` query does not support specifying options like `hint` or field selection. In this case an error will be thrown so you can catch these mistakes in development.
+
+##Debug support
+
+Debug mode is provided through the use of the [debug](https://github.com/visionmedia/debug) module. To enable:
+
+ DEBUG=mquery node yourprogram.js
+
+Read the debug module documentation for more details.
+
+## General compatibility
+
+#### ObjectIds
+
+`mquery` clones query arguments before passing them to a `collection` method for execution.
+This prevents accidental side-affects to the objects you pass.
+To clone `ObjectIds` we need to make some assumptions.
+
+First, to check if an object is an `ObjectId`, we check its constructors name. If it matches either
+`ObjectId` or `ObjectID` we clone it.
+
+To clone `ObjectIds`, we call its optional `clone` method. If a `clone` method does not exist, we fall
+back to calling `new obj.constructor(obj.id)`. We assume, for compatibility with the
+Node.js driver, that the `ObjectId` instance has a public `id` property and that
+when creating an `ObjectId` instance we can pass that `id` as an argument.
+
+#### Read Preferences
+
+`mquery` supports specifying [Read Preferences]() to control from which MongoDB node your query will read.
+The Read Preferences spec also support specifying tags. To pass tags, some
+drivers (Node.js driver) require passing a special constructor that handles both the read preference and its tags.
+If you need to specify tags, pass an instance of your drivers ReadPreference constructor or roll your own. `mquery` will store whatever you provide and pass later to your collection during execution.
+
+##Future goals
+
+ - mongo shell compatibility
+ - browser compatibility
+
+## Installation
+
+ $ npm install mquery
+
+## License
+
+[MIT](https://github.com/aheckmann/mquery/blob/master/LICENSE)
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/collection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/collection.js
new file mode 100644
index 0000000..bce3c38
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/collection.js
@@ -0,0 +1,42 @@
+'use strict';
+
+/**
+ * methods a collection must implement
+ */
+
+var methods = [
+ 'find'
+ , 'findOne'
+ , 'update'
+ , 'remove'
+ , 'count'
+ , 'distinct'
+ , 'findAndModify'
+ , 'aggregate'
+ , 'findStream'
+];
+
+/**
+ * Collection base class from which implementations inherit
+ */
+
+function Collection () {}
+
+for (var i = 0, len = methods.length; i < len; ++i) {
+ var method = methods[i];
+ Collection.prototype[method] = notImplemented(method);
+}
+
+module.exports = exports = Collection;
+Collection.methods = methods;
+
+/**
+ * creates a function which throws an implementation error
+ */
+
+function notImplemented (method) {
+ return function () {
+ throw new Error('collection.' + method + ' not implemented');
+ }
+}
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/index.js
new file mode 100644
index 0000000..e3cf44d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+var env = require('../env')
+
+if ('unknown' == env.type) {
+ throw new Error('Unknown environment')
+}
+
+module.exports =
+ env.isNode ? require('./node') :
+ env.isMongo ? require('./collection') :
+ require('./collection');
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/node.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/node.js
new file mode 100644
index 0000000..7ba04cf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/collection/node.js
@@ -0,0 +1,108 @@
+'use strict';
+
+/**
+ * Module dependencies
+ */
+
+var Collection = require('./collection');
+var utils = require('../utils');
+
+function NodeCollection (col) {
+ this.collection = col;
+ this.collectionName = col.collectionName;
+}
+
+/**
+ * inherit from collection base class
+ */
+
+utils.inherits(NodeCollection, Collection);
+
+/**
+ * find(match, options, function(err, docs))
+ */
+
+NodeCollection.prototype.find = function (match, options, cb) {
+ this.collection.find(match, options, function (err, cursor) {
+ if (err) return cb(err);
+
+ cursor.toArray(cb);
+ });
+}
+
+/**
+ * findOne(match, options, function(err, doc))
+ */
+
+NodeCollection.prototype.findOne = function (match, options, cb) {
+ this.collection.findOne(match, options, cb);
+}
+
+/**
+ * count(match, options, function(err, count))
+ */
+
+NodeCollection.prototype.count = function (match, options, cb) {
+ this.collection.count(match, options, cb);
+}
+
+/**
+ * distinct(prop, match, options, function(err, count))
+ */
+
+NodeCollection.prototype.distinct = function (prop, match, options, cb) {
+ this.collection.distinct(prop, match, options, cb);
+}
+
+/**
+ * update(match, update, options, function(err[, result]))
+ */
+
+NodeCollection.prototype.update = function (match, update, options, cb) {
+ this.collection.update(match, update, options, cb);
+}
+
+/**
+ * remove(match, options, function(err[, result])
+ */
+
+NodeCollection.prototype.remove = function (match, options, cb) {
+ this.collection.remove(match, options, cb);
+}
+
+/**
+ * findAndModify(match, update, options, function(err, doc))
+ */
+
+NodeCollection.prototype.findAndModify = function (match, update, options, cb) {
+ var sort = Array.isArray(options.sort) ? options.sort : [];
+ this.collection.findAndModify(match, sort, update, options, cb);
+}
+
+/**
+ * var stream = findStream(match, findOptions, streamOptions)
+ */
+
+NodeCollection.prototype.findStream = function(match, findOptions, streamOptions) {
+ return this.collection.find(match, findOptions);
+}
+
+/**
+ * var cursor = findCursor(match, findOptions)
+ */
+
+NodeCollection.prototype.findCursor = function(match, findOptions) {
+ return this.collection.find(match, findOptions);
+}
+
+/**
+ * aggregation(operators..., function(err, doc))
+ * TODO
+ */
+
+/**
+ * Expose
+ */
+
+module.exports = exports = NodeCollection;
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/env.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/env.js
new file mode 100644
index 0000000..3313b46
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/env.js
@@ -0,0 +1,22 @@
+'use strict';
+
+exports.isNode = 'undefined' != typeof process
+ && 'object' == typeof module
+ && 'object' == typeof global
+ && 'function' == typeof Buffer
+ && process.argv
+
+exports.isMongo = !exports.isNode
+ && 'function' == typeof printjson
+ && 'function' == typeof ObjectId
+ && 'function' == typeof rs
+ && 'function' == typeof sh;
+
+exports.isBrowser = !exports.isNode
+ && !exports.isMongo
+ && 'undefined' != typeof window;
+
+exports.type = exports.isNode ? 'node'
+ : exports.isMongo ? 'mongo'
+ : exports.isBrowser ? 'browser'
+ : 'unknown'
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/mquery.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/mquery.js
new file mode 100644
index 0000000..63d2c51
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/mquery.js
@@ -0,0 +1,2728 @@
+'use strict';
+
+/**
+ * Dependencies
+ */
+
+var slice = require('sliced')
+var assert = require('assert')
+var util = require('util')
+var utils = require('./utils')
+var debug = require('debug')('mquery');
+
+/**
+ * Query constructor used for building queries.
+ *
+ * ####Example:
+ *
+ * var query = new Query({ name: 'mquery' });
+ * query.setOptions({ collection: moduleCollection })
+ * query.where('age').gte(21).exec(callback);
+ *
+ * @param {Object} [criteria]
+ * @param {Object} [options]
+ * @api public
+ */
+
+function Query (criteria, options) {
+ if (!(this instanceof Query))
+ return new Query(criteria, options);
+
+ var proto = this.constructor.prototype;
+
+ this.op = proto.op || undefined;
+
+ this.options = {};
+ this.setOptions(proto.options);
+
+ this._conditions = proto._conditions
+ ? utils.clone(proto._conditions, { retainKeyOrder: this.options.retainKeyOrder })
+ : {};
+
+ this._fields = proto._fields
+ ? utils.clone(proto._fields, { retainKeyOrder: this.options.retainKeyOrder })
+ : undefined;
+
+ this._update = proto._update
+ ? utils.clone(proto._update, { retainKeyOrder: this.options.retainKeyOrder })
+ : undefined;
+
+ this._path = proto._path || undefined;
+ this._distinct = proto._distinct || undefined;
+ this._collection = proto._collection || undefined;
+ this._traceFunction = proto._traceFunction || undefined;
+
+ if (options) {
+ this.setOptions(options);
+ }
+
+ if (criteria) {
+ if (criteria.find && criteria.remove && criteria.update) {
+ // quack quack!
+ this.collection(criteria);
+ } else {
+ this.find(criteria);
+ }
+ }
+}
+
+/**
+ * This is a parameter that the user can set which determines if mquery
+ * uses $within or $geoWithin for queries. It defaults to true which
+ * means $geoWithin will be used. If using MongoDB < 2.4 you should
+ * set this to false.
+ *
+ * @api public
+ * @property use$geoWithin
+ */
+
+var $withinCmd = '$geoWithin';
+Object.defineProperty(Query, 'use$geoWithin', {
+ get: function ( ) { return $withinCmd == '$geoWithin' }
+ , set: function (v) {
+ if (true === v) {
+ // mongodb >= 2.4
+ $withinCmd = '$geoWithin';
+ } else {
+ $withinCmd = '$within';
+ }
+ }
+});
+
+/**
+ * Converts this query to a constructor function with all arguments and options retained.
+ *
+ * ####Example
+ *
+ * // Create a query that will read documents with a "video" category from
+ * // `aCollection` on the primary node in the replica-set unless it is down,
+ * // in which case we'll read from a secondary node.
+ * var query = mquery({ category: 'video' })
+ * query.setOptions({ collection: aCollection, read: 'primaryPreferred' });
+ *
+ * // create a constructor based off these settings
+ * var Video = query.toConstructor();
+ *
+ * // Video is now a subclass of mquery() and works the same way but with the
+ * // default query parameters and options set.
+ *
+ * // run a query with the previous settings but filter for movies with names
+ * // that start with "Life".
+ * Video().where({ name: /^Life/ }).exec(cb);
+ *
+ * @return {Query} new Query
+ * @api public
+ */
+
+Query.prototype.toConstructor = function toConstructor () {
+ function CustomQuery (criteria, options) {
+ if (!(this instanceof CustomQuery))
+ return new CustomQuery(criteria, options);
+ Query.call(this, criteria, options);
+ }
+
+ utils.inherits(CustomQuery, Query);
+
+ // set inherited defaults
+ var p = CustomQuery.prototype;
+
+ p.options = {};
+ p.setOptions(this.options);
+
+ p.op = this.op;
+ p._conditions = utils.clone(this._conditions, { retainKeyOrder: this.options.retainKeyOrder });
+ p._fields = utils.clone(this._fields, { retainKeyOrder: this.options.retainKeyOrder });
+ p._update = utils.clone(this._update, { retainKeyOrder: this.options.retainKeyOrder });
+ p._path = this._path;
+ p._distinct = this._distinct;
+ p._collection = this._collection;
+ p._traceFunction = this._traceFunction;
+
+ return CustomQuery;
+}
+
+/**
+ * Sets query options.
+ *
+ * ####Options:
+ *
+ * - [tailable](http://www.mongodb.org/display/DOCS/Tailable+Cursors) *
+ * - [sort](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsort(\)%7D%7D) *
+ * - [limit](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D) *
+ * - [skip](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D) *
+ * - [maxScan](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24maxScan) *
+ * - [maxTime](http://docs.mongodb.org/manual/reference/operator/meta/maxTimeMS/#op._S_maxTimeMS) *
+ * - [batchSize](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D) *
+ * - [comment](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment) *
+ * - [snapshot](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D) *
+ * - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint) *
+ * - [slaveOk](http://docs.mongodb.org/manual/applications/replication/#read-preference) *
+ * - [safe](http://www.mongodb.org/display/DOCS/getLastError+Command)
+ * - collection the collection to query against
+ *
+ * _* denotes a query helper method is also available_
+ *
+ * @param {Object} options
+ * @api public
+ */
+
+Query.prototype.setOptions = function (options) {
+ if (!(options && utils.isObject(options)))
+ return this;
+
+ // set arbitrary options
+ var methods = utils.keys(options)
+ , method
+
+ for (var i = 0; i < methods.length; ++i) {
+ method = methods[i];
+
+ // use methods if exist (safer option manipulation)
+ if ('function' == typeof this[method]) {
+ var args = utils.isArray(options[method])
+ ? options[method]
+ : [options[method]];
+ this[method].apply(this, args)
+ } else {
+ this.options[method] = options[method];
+ }
+ }
+
+ return this;
+}
+
+/**
+ * Sets this Querys collection.
+ *
+ * @param {Collection} coll
+ * @return {Query} this
+ */
+
+Query.prototype.collection = function collection (coll) {
+ this._collection = new Query.Collection(coll);
+
+ return this;
+}
+
+/**
+ * Specifies a `$where` condition
+ *
+ * Use `$where` when you need to select documents using a JavaScript expression.
+ *
+ * ####Example
+ *
+ * query.$where('this.comments.length > 10 || this.name.length > 5')
+ *
+ * query.$where(function () {
+ * return this.comments.length > 10 || this.name.length > 5;
+ * })
+ *
+ * @param {String|Function} js javascript string or function
+ * @return {Query} this
+ * @memberOf Query
+ * @method $where
+ * @api public
+ */
+
+Query.prototype.$where = function (js) {
+ this._conditions.$where = js;
+ return this;
+}
+
+/**
+ * Specifies a `path` for use with chaining.
+ *
+ * ####Example
+ *
+ * // instead of writing:
+ * User.find({age: {$gte: 21, $lte: 65}}, callback);
+ *
+ * // we can instead write:
+ * User.where('age').gte(21).lte(65);
+ *
+ * // passing query conditions is permitted
+ * User.find().where({ name: 'vonderful' })
+ *
+ * // chaining
+ * User
+ * .where('age').gte(21).lte(65)
+ * .where('name', /^vonderful/i)
+ * .where('friends').slice(10)
+ * .exec(callback)
+ *
+ * @param {String} [path]
+ * @param {Object} [val]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.where = function () {
+ if (!arguments.length) return this;
+ if (!this.op) this.op = 'find';
+
+ var type = typeof arguments[0];
+
+ if ('string' == type) {
+ this._path = arguments[0];
+
+ if (2 === arguments.length) {
+ this._conditions[this._path] = arguments[1];
+ }
+
+ return this;
+ }
+
+ if ('object' == type && !Array.isArray(arguments[0])) {
+ return this.merge(arguments[0]);
+ }
+
+ throw new TypeError('path must be a string or object');
+}
+
+/**
+ * Specifies the complementary comparison value for paths specified with `where()`
+ *
+ * ####Example
+ *
+ * User.where('age').equals(49);
+ *
+ * // is the same as
+ *
+ * User.where('age', 49);
+ *
+ * @param {Object} val
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.equals = function equals (val) {
+ this._ensurePath('equals');
+ var path = this._path;
+ this._conditions[path] = val;
+ return this;
+}
+
+/**
+ * Specifies the complementary comparison value for paths specified with `where()`
+ * This is alias of `equals`
+ *
+ * ####Example
+ *
+ * User.where('age').eq(49);
+ *
+ * // is the same as
+ *
+ * User.shere('age').equals(49);
+ *
+ * // is the same as
+ *
+ * User.where('age', 49);
+ *
+ * @param {Object} val
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.eq = function eq (val) {
+ this._ensurePath('eq');
+ var path = this._path;
+ this._conditions[path] = val;
+ return this;
+}
+
+/**
+ * Specifies arguments for an `$or` condition.
+ *
+ * ####Example
+ *
+ * query.or([{ color: 'red' }, { status: 'emergency' }])
+ *
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.or = function or (array) {
+ var or = this._conditions.$or || (this._conditions.$or = []);
+ if (!utils.isArray(array)) array = [array];
+ or.push.apply(or, array);
+ return this;
+}
+
+/**
+ * Specifies arguments for a `$nor` condition.
+ *
+ * ####Example
+ *
+ * query.nor([{ color: 'green' }, { status: 'ok' }])
+ *
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.nor = function nor (array) {
+ var nor = this._conditions.$nor || (this._conditions.$nor = []);
+ if (!utils.isArray(array)) array = [array];
+ nor.push.apply(nor, array);
+ return this;
+}
+
+/**
+ * Specifies arguments for a `$and` condition.
+ *
+ * ####Example
+ *
+ * query.and([{ color: 'green' }, { status: 'ok' }])
+ *
+ * @see $and http://docs.mongodb.org/manual/reference/operator/and/
+ * @param {Array} array array of conditions
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.and = function and (array) {
+ var and = this._conditions.$and || (this._conditions.$and = []);
+ if (!Array.isArray(array)) array = [array];
+ and.push.apply(and, array);
+ return this;
+}
+
+/**
+ * Specifies a $gt query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * ####Example
+ *
+ * Thing.find().where('age').gt(21)
+ *
+ * // or
+ * Thing.find().gt('age', 21)
+ *
+ * @method gt
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $gte query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method gte
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $lt query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method lt
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $lte query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method lte
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $ne query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method ne
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $in query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method in
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $nin query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method nin
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies an $all query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method all
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $size query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method size
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $regex query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method regex
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/**
+ * Specifies a $maxDistance query condition.
+ *
+ * When called with one argument, the most recent path passed to `where()` is used.
+ *
+ * @method maxDistance
+ * @memberOf Query
+ * @param {String} [path]
+ * @param {Number} val
+ * @api public
+ */
+
+/*!
+ * gt, gte, lt, lte, ne, in, nin, all, regex, size, maxDistance
+ *
+ * Thing.where('type').nin(array)
+ */
+
+'gt gte lt lte ne in nin all regex size maxDistance minDistance'.split(' ').forEach(function ($conditional) {
+ Query.prototype[$conditional] = function () {
+ var path, val;
+
+ if (1 === arguments.length) {
+ this._ensurePath($conditional);
+ val = arguments[0];
+ path = this._path;
+ } else {
+ val = arguments[1];
+ path = arguments[0];
+ }
+
+ var conds = this._conditions[path] === null || typeof this._conditions[path] === 'object' ?
+ this._conditions[path] :
+ (this._conditions[path] = {});
+ conds['$' + $conditional] = val;
+ return this;
+ };
+})
+
+/**
+ * Specifies a `$mod` condition
+ *
+ * @param {String} [path]
+ * @param {Number} val
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.mod = function () {
+ var val, path;
+
+ if (1 === arguments.length) {
+ this._ensurePath('mod')
+ val = arguments[0];
+ path = this._path;
+ } else if (2 === arguments.length && !utils.isArray(arguments[1])) {
+ this._ensurePath('mod')
+ val = slice(arguments);
+ path = this._path;
+ } else if (3 === arguments.length) {
+ val = slice(arguments, 1);
+ path = arguments[0];
+ } else {
+ val = arguments[1];
+ path = arguments[0];
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds.$mod = val;
+ return this;
+}
+
+/**
+ * Specifies an `$exists` condition
+ *
+ * ####Example
+ *
+ * // { name: { $exists: true }}
+ * Thing.where('name').exists()
+ * Thing.where('name').exists(true)
+ * Thing.find().exists('name')
+ *
+ * // { name: { $exists: false }}
+ * Thing.where('name').exists(false);
+ * Thing.find().exists('name', false);
+ *
+ * @param {String} [path]
+ * @param {Number} val
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.exists = function () {
+ var path, val;
+
+ if (0 === arguments.length) {
+ this._ensurePath('exists');
+ path = this._path;
+ val = true;
+ } else if (1 === arguments.length) {
+ if ('boolean' === typeof arguments[0]) {
+ this._ensurePath('exists');
+ path = this._path;
+ val = arguments[0];
+ } else {
+ path = arguments[0];
+ val = true;
+ }
+ } else if (2 === arguments.length) {
+ path = arguments[0];
+ val = arguments[1];
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds.$exists = val;
+ return this;
+}
+
+/**
+ * Specifies an `$elemMatch` condition
+ *
+ * ####Example
+ *
+ * query.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}})
+ *
+ * query.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}})
+ *
+ * query.elemMatch('comment', function (elem) {
+ * elem.where('author').equals('autobot');
+ * elem.where('votes').gte(5);
+ * })
+ *
+ * query.where('comment').elemMatch(function (elem) {
+ * elem.where({ author: 'autobot' });
+ * elem.where('votes').gte(5);
+ * })
+ *
+ * @param {String|Object|Function} path
+ * @param {Object|Function} criteria
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.elemMatch = function () {
+ if (null == arguments[0])
+ throw new TypeError("Invalid argument");
+
+ var fn, path, criteria;
+
+ if ('function' === typeof arguments[0]) {
+ this._ensurePath('elemMatch');
+ path = this._path;
+ fn = arguments[0];
+ } else if (utils.isObject(arguments[0])) {
+ this._ensurePath('elemMatch');
+ path = this._path;
+ criteria = arguments[0];
+ } else if ('function' === typeof arguments[1]) {
+ path = arguments[0];
+ fn = arguments[1];
+ } else if (arguments[1] && utils.isObject(arguments[1])) {
+ path = arguments[0];
+ criteria = arguments[1];
+ } else {
+ throw new TypeError("Invalid argument");
+ }
+
+ if (fn) {
+ criteria = new Query;
+ fn(criteria);
+ criteria = criteria._conditions;
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds.$elemMatch = criteria;
+ return this;
+}
+
+// Spatial queries
+
+/**
+ * Sugar for geo-spatial queries.
+ *
+ * ####Example
+ *
+ * query.within().box()
+ * query.within().circle()
+ * query.within().geometry()
+ *
+ * query.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
+ * query.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
+ * query.where('loc').within({ polygon: [[],[],[],[]] });
+ *
+ * query.where('loc').within([], [], []) // polygon
+ * query.where('loc').within([], []) // box
+ * query.where('loc').within({ type: 'LineString', coordinates: [...] }); // geometry
+ *
+ * ####NOTE:
+ *
+ * Must be used after `where()`.
+ *
+ * @memberOf Query
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.within = function within () {
+ // opinionated, must be used after where
+ this._ensurePath('within');
+ this._geoComparison = $withinCmd;
+
+ if (0 === arguments.length) {
+ return this;
+ }
+
+ if (2 === arguments.length) {
+ return this.box.apply(this, arguments);
+ } else if (2 < arguments.length) {
+ return this.polygon.apply(this, arguments);
+ }
+
+ var area = arguments[0];
+
+ if (!area)
+ throw new TypeError('Invalid argument');
+
+ if (area.center)
+ return this.circle(area);
+
+ if (area.box)
+ return this.box.apply(this, area.box);
+
+ if (area.polygon)
+ return this.polygon.apply(this, area.polygon);
+
+ if (area.type && area.coordinates)
+ return this.geometry(area);
+
+ throw new TypeError('Invalid argument');
+}
+
+/**
+ * Specifies a $box condition
+ *
+ * ####Example
+ *
+ * var lowerLeft = [40.73083, -73.99756]
+ * var upperRight= [40.741404, -73.988135]
+ *
+ * query.where('loc').within().box(lowerLeft, upperRight)
+ * query.box('loc', lowerLeft, upperRight )
+ *
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @see Query#within #query_Query-within
+ * @param {String} path
+ * @param {Object} val
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.box = function () {
+ var path, box;
+
+ if (3 === arguments.length) {
+ // box('loc', [], [])
+ path = arguments[0];
+ box = [arguments[1], arguments[2]];
+ } else if (2 === arguments.length) {
+ // box([], [])
+ this._ensurePath('box');
+ path = this._path;
+ box = [arguments[0], arguments[1]];
+ } else {
+ throw new TypeError("Invalid argument");
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds[this._geoComparison || $withinCmd] = { '$box': box };
+ return this;
+}
+
+/**
+ * Specifies a $polygon condition
+ *
+ * ####Example
+ *
+ * query.where('loc').within().polygon([10,20], [13, 25], [7,15])
+ * query.polygon('loc', [10,20], [13, 25], [7,15])
+ *
+ * @param {String|Array} [path]
+ * @param {Array|Object} [val]
+ * @return {Query} this
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+Query.prototype.polygon = function () {
+ var val, path;
+
+ if ('string' == typeof arguments[0]) {
+ // polygon('loc', [],[],[])
+ path = arguments[0];
+ val = slice(arguments, 1);
+ } else {
+ // polygon([],[],[])
+ this._ensurePath('polygon');
+ path = this._path;
+ val = slice(arguments);
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds[this._geoComparison || $withinCmd] = { '$polygon': val };
+ return this;
+}
+
+/**
+ * Specifies a $center or $centerSphere condition.
+ *
+ * ####Example
+ *
+ * var area = { center: [50, 50], radius: 10, unique: true }
+ * query.where('loc').within().circle(area)
+ * query.center('loc', area);
+ *
+ * // for spherical calculations
+ * var area = { center: [50, 50], radius: 10, unique: true, spherical: true }
+ * query.where('loc').within().circle(area)
+ * query.center('loc', area);
+ *
+ * @param {String} [path]
+ * @param {Object} area
+ * @return {Query} this
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+Query.prototype.circle = function () {
+ var path, val;
+
+ if (1 === arguments.length) {
+ this._ensurePath('circle');
+ path = this._path;
+ val = arguments[0];
+ } else if (2 === arguments.length) {
+ path = arguments[0];
+ val = arguments[1];
+ } else {
+ throw new TypeError("Invalid argument");
+ }
+
+ if (!('radius' in val && val.center))
+ throw new Error('center and radius are required');
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+
+ var type = val.spherical
+ ? '$centerSphere'
+ : '$center';
+
+ var wKey = this._geoComparison || $withinCmd;
+ conds[wKey] = {};
+ conds[wKey][type] = [val.center, val.radius];
+
+ if ('unique' in val)
+ conds[wKey].$uniqueDocs = !! val.unique;
+
+ return this;
+}
+
+/**
+ * Specifies a `$near` or `$nearSphere` condition
+ *
+ * These operators return documents sorted by distance.
+ *
+ * ####Example
+ *
+ * query.where('loc').near({ center: [10, 10] });
+ * query.where('loc').near({ center: [10, 10], maxDistance: 5 });
+ * query.where('loc').near({ center: [10, 10], maxDistance: 5, spherical: true });
+ * query.near('loc', { center: [10, 10], maxDistance: 5 });
+ * query.near({ center: { type: 'Point', coordinates: [..] }})
+ * query.near().geometry({ type: 'Point', coordinates: [..] })
+ *
+ * @param {String} [path]
+ * @param {Object} val
+ * @return {Query} this
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @api public
+ */
+
+Query.prototype.near = function near () {
+ var path, val;
+
+ this._geoComparison = '$near';
+
+ if (0 === arguments.length) {
+ return this;
+ } else if (1 === arguments.length) {
+ this._ensurePath('near');
+ path = this._path;
+ val = arguments[0];
+ } else if (2 === arguments.length) {
+ path = arguments[0];
+ val = arguments[1];
+ } else {
+ throw new TypeError("Invalid argument");
+ }
+
+ if (!val.center) {
+ throw new Error('center is required');
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+
+ var type = val.spherical
+ ? '$nearSphere'
+ : '$near';
+
+ // center could be a GeoJSON object or an Array
+ if (Array.isArray(val.center)) {
+ conds[type] = val.center;
+
+ var radius = 'maxDistance' in val
+ ? val.maxDistance
+ : null;
+
+ if (null != radius) {
+ conds.$maxDistance = radius;
+ }
+ if (null != val.minDistance) {
+ conds.$minDistance = val.minDistance;
+ }
+ } else {
+ // GeoJSON?
+ if (val.center.type != 'Point' || !Array.isArray(val.center.coordinates)) {
+ throw new Error(util.format("Invalid GeoJSON specified for %s", type));
+ }
+ conds[type] = { $geometry : val.center };
+
+ // MongoDB 2.6 insists on maxDistance being in $near / $nearSphere
+ if ('maxDistance' in val) {
+ conds[type]['$maxDistance'] = val.maxDistance;
+ }
+ if ('minDistance' in val) {
+ conds[type]['$minDistance'] = val.minDistance;
+ }
+ }
+
+ return this;
+}
+
+/**
+ * Declares an intersects query for `geometry()`.
+ *
+ * ####Example
+ *
+ * query.where('path').intersects().geometry({
+ * type: 'LineString'
+ * , coordinates: [[180.0, 11.0], [180, 9.0]]
+ * })
+ *
+ * query.where('path').intersects({
+ * type: 'LineString'
+ * , coordinates: [[180.0, 11.0], [180, 9.0]]
+ * })
+ *
+ * @param {Object} [arg]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.intersects = function intersects () {
+ // opinionated, must be used after where
+ this._ensurePath('intersects');
+
+ this._geoComparison = '$geoIntersects';
+
+ if (0 === arguments.length) {
+ return this;
+ }
+
+ var area = arguments[0];
+
+ if (null != area && area.type && area.coordinates)
+ return this.geometry(area);
+
+ throw new TypeError('Invalid argument');
+}
+
+/**
+ * Specifies a `$geometry` condition
+ *
+ * ####Example
+ *
+ * var polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
+ * query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
+ *
+ * // or
+ * var polyB = [[ 0, 0 ], [ 1, 1 ]]
+ * query.where('loc').within().geometry({ type: 'LineString', coordinates: polyB })
+ *
+ * // or
+ * var polyC = [ 0, 0 ]
+ * query.where('loc').within().geometry({ type: 'Point', coordinates: polyC })
+ *
+ * // or
+ * query.where('loc').intersects().geometry({ type: 'Point', coordinates: polyC })
+ *
+ * ####NOTE:
+ *
+ * `geometry()` **must** come after either `intersects()` or `within()`.
+ *
+ * The `object` argument must contain `type` and `coordinates` properties.
+ * - type {String}
+ * - coordinates {Array}
+ *
+ * The most recent path passed to `where()` is used.
+ *
+ * @param {Object} object Must contain a `type` property which is a String and a `coordinates` property which is an Array. See the examples.
+ * @return {Query} this
+ * @see http://docs.mongodb.org/manual/release-notes/2.4/#new-geospatial-indexes-with-geojson-and-improved-spherical-geometry
+ * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
+ * @see $geometry http://docs.mongodb.org/manual/reference/operator/geometry/
+ * @api public
+ */
+
+Query.prototype.geometry = function geometry () {
+ if (!('$within' == this._geoComparison ||
+ '$geoWithin' == this._geoComparison ||
+ '$near' == this._geoComparison ||
+ '$geoIntersects' == this._geoComparison)) {
+ throw new Error('geometry() must come after `within()`, `intersects()`, or `near()');
+ }
+
+ var val, path;
+
+ if (1 === arguments.length) {
+ this._ensurePath('geometry');
+ path = this._path;
+ val = arguments[0];
+ } else {
+ throw new TypeError("Invalid argument");
+ }
+
+ if (!(val.type && Array.isArray(val.coordinates))) {
+ throw new TypeError('Invalid argument');
+ }
+
+ var conds = this._conditions[path] || (this._conditions[path] = {});
+ conds[this._geoComparison] = { $geometry: val };
+
+ return this;
+}
+
+// end spatial
+
+/**
+ * Specifies which document fields to include or exclude
+ *
+ * ####String syntax
+ *
+ * When passing a string, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included.
+ *
+ * ####Example
+ *
+ * // include a and b, exclude c
+ * query.select('a b -c');
+ *
+ * // or you may use object notation, useful when
+ * // you have keys already prefixed with a "-"
+ * query.select({a: 1, b: 1, c: 0});
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @param {Object|String} arg
+ * @return {Query} this
+ * @see SchemaType
+ * @api public
+ */
+
+Query.prototype.select = function select () {
+ var arg = arguments[0];
+ if (!arg) return this;
+
+ if (arguments.length !== 1) {
+ throw new Error("Invalid select: select only takes 1 argument");
+ }
+
+ this._validate('select');
+
+ var fields = this._fields || (this._fields = {});
+ var type = typeof arg;
+
+ if (('string' == type || utils.isArgumentsObject(arg)) &&
+ 'number' == typeof arg.length) {
+ if ('string' == type)
+ arg = arg.split(/\s+/);
+
+ for (var i = 0, len = arg.length; i < len; ++i) {
+ var field = arg[i];
+ if (!field) continue;
+ var include = '-' == field[0] ? 0 : 1;
+ if (include === 0) field = field.substring(1);
+ fields[field] = include;
+ }
+
+ return this;
+ }
+
+ if (utils.isObject(arg) && !Array.isArray(arg)) {
+ var keys = utils.keys(arg);
+ for (var i = 0; i < keys.length; ++i) {
+ fields[keys[i]] = arg[keys[i]];
+ }
+ return this;
+ }
+
+ throw new TypeError('Invalid select() argument. Must be string or object.');
+}
+
+/**
+ * Specifies a $slice condition for a `path`
+ *
+ * ####Example
+ *
+ * query.slice('comments', 5)
+ * query.slice('comments', -5)
+ * query.slice('comments', [10, 5])
+ * query.where('comments').slice(5)
+ * query.where('comments').slice([-10, 5])
+ *
+ * @param {String} [path]
+ * @param {Number} val number/range of elements to slice
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/Retrieving+a+Subset+of+Fields#RetrievingaSubsetofFields-RetrievingaSubrangeofArrayElements
+ * @api public
+ */
+
+Query.prototype.slice = function () {
+ if (0 === arguments.length)
+ return this;
+
+ this._validate('slice');
+
+ var path, val;
+
+ if (1 === arguments.length) {
+ var arg = arguments[0];
+ if (typeof arg === 'object' && !Array.isArray(arg)) {
+ var keys = Object.keys(arg);
+ var numKeys = keys.length;
+ for (var i = 0; i < numKeys; ++i) {
+ this.slice(keys[i], arg[keys[i]]);
+ }
+ return this;
+ }
+ this._ensurePath('slice');
+ path = this._path;
+ val = arguments[0];
+ } else if (2 === arguments.length) {
+ if ('number' === typeof arguments[0]) {
+ this._ensurePath('slice');
+ path = this._path;
+ val = slice(arguments);
+ } else {
+ path = arguments[0];
+ val = arguments[1];
+ }
+ } else if (3 === arguments.length) {
+ path = arguments[0];
+ val = slice(arguments, 1);
+ }
+
+ var myFields = this._fields || (this._fields = {});
+ myFields[path] = { '$slice': val };
+ return this;
+}
+
+/**
+ * Sets the sort order
+ *
+ * If an object is passed, values allowed are 'asc', 'desc', 'ascending', 'descending', 1, and -1.
+ *
+ * If a string is passed, it must be a space delimited list of path names. The sort order of each path is ascending unless the path name is prefixed with `-` which will be treated as descending.
+ *
+ * ####Example
+ *
+ * // these are equivalent
+ * query.sort({ field: 'asc', test: -1 });
+ * query.sort('field -test');
+ * query.sort([['field', 1], ['test', -1]]);
+ *
+ * ####Note
+ *
+ * - The array syntax `.sort([['field', 1], ['test', -1]])` can only be used with [mongodb driver >= 2.0.46](https://github.com/mongodb/node-mongodb-native/blob/2.1/HISTORY.md#2046-2015-10-15).
+ * - Cannot be used with `distinct()`
+ *
+ * @param {Object|String|Array} arg
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.sort = function (arg) {
+ if (!arg) return this;
+ var len;
+
+ this._validate('sort');
+
+ var type = typeof arg;
+
+ // .sort([['field', 1], ['test', -1]])
+ if (Array.isArray(arg)) {
+ len = arg.length;
+ for (var i = 0; i < arg.length; ++i) {
+ _pushArr(this.options, arg[i][0], arg[i][1]);
+ }
+ return this;
+ }
+
+ // .sort('field -test')
+ if (1 === arguments.length && 'string' == type) {
+ arg = arg.split(/\s+/);
+ len = arg.length;
+ for (var i = 0; i < len; ++i) {
+ var field = arg[i];
+ if (!field) continue;
+ var ascend = '-' == field[0] ? -1 : 1;
+ if (ascend === -1) field = field.substring(1);
+ push(this.options, field, ascend);
+ }
+
+ return this;
+ }
+
+ // .sort({ field: 1, test: -1 })
+ if (utils.isObject(arg)) {
+ var keys = utils.keys(arg);
+ for (var i = 0; i < keys.length; ++i) {
+ var field = keys[i];
+ push(this.options, field, arg[field]);
+ }
+
+ return this;
+ }
+
+ throw new TypeError('Invalid sort() argument. Must be a string, object, or array.');
+}
+
+/*!
+ * @ignore
+ */
+
+function push (opts, field, value) {
+ if (Array.isArray(opts.sort)) {
+ throw new TypeError("Can't mix sort syntaxes. Use either array or object:" +
+ "\n- `.sort([['field', 1], ['test', -1]])`" +
+ "\n- `.sort({ field: 1, test: -1 })`");
+ }
+
+ if (value && value.$meta) {
+ var s = opts.sort || (opts.sort = {});
+ s[field] = { $meta : value.$meta };
+ return;
+ }
+
+ var val = String(value || 1).toLowerCase();
+ if (!/^(?:ascending|asc|descending|desc|1|-1)$/.test(val)) {
+ if (utils.isArray(value)) value = '['+value+']';
+ throw new TypeError('Invalid sort value: {' + field + ': ' + value + ' }');
+ }
+ // store `sort` in a sane format
+ var s = opts.sort || (opts.sort = {});
+ var valueStr = value.toString()
+ .replace("asc", "1")
+ .replace("ascending", "1")
+ .replace("desc", "-1")
+ .replace("descending", "-1");
+ s[field] = parseInt(valueStr, 10);
+}
+
+function _pushArr (opts, field, value) {
+ opts.sort = opts.sort || [];
+ if (!Array.isArray(opts.sort)) {
+ throw new TypeError("Can't mix sort syntaxes. Use either array or object:" +
+ "\n- `.sort([['field', 1], ['test', -1]])`" +
+ "\n- `.sort({ field: 1, test: -1 })`");
+ }
+ var valueStr = value.toString()
+ .replace("asc", "1")
+ .replace("ascending", "1")
+ .replace("desc", "-1")
+ .replace("descending", "-1");
+ opts.sort.push([field, value]);
+}
+
+/**
+ * Specifies the limit option.
+ *
+ * ####Example
+ *
+ * query.limit(20)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method limit
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Blimit%28%29%7D%7D
+ * @api public
+ */
+/**
+ * Specifies the skip option.
+ *
+ * ####Example
+ *
+ * query.skip(100).limit(20)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method skip
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bskip%28%29%7D%7D
+ * @api public
+ */
+/**
+ * Specifies the maxScan option.
+ *
+ * ####Example
+ *
+ * query.maxScan(100)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method maxScan
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24maxScan
+ * @api public
+ */
+/**
+ * Specifies the batchSize option.
+ *
+ * ####Example
+ *
+ * query.batchSize(100)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method batchSize
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7BbatchSize%28%29%7D%7D
+ * @api public
+ */
+/**
+ * Specifies the `comment` option.
+ *
+ * ####Example
+ *
+ * query.comment('login query')
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @method comment
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24comment
+ * @api public
+ */
+
+/*!
+ * limit, skip, maxScan, batchSize, comment
+ *
+ * Sets these associated options.
+ *
+ * query.comment('feed query');
+ */
+
+;['limit', 'skip', 'maxScan', 'batchSize', 'comment'].forEach(function (method) {
+ Query.prototype[method] = function (v) {
+ this._validate(method);
+ this.options[method] = v;
+ return this;
+ };
+})
+
+/**
+ * Specifies the maxTimeMS option.
+ *
+ * ####Example
+ *
+ * query.maxTime(100)
+ *
+ * @method maxTime
+ * @memberOf Query
+ * @param {Number} val
+ * @see mongodb http://docs.mongodb.org/manual/reference/operator/meta/maxTimeMS/#op._S_maxTimeMS
+ * @api public
+ */
+
+Query.prototype.maxTime = function (v) {
+ this._validate('maxTime');
+ this.options.maxTimeMS = v;
+ return this;
+};
+
+/**
+ * Specifies this query as a `snapshot` query.
+ *
+ * ####Example
+ *
+ * mquery().snapshot() // true
+ * mquery().snapshot(true)
+ * mquery().snapshot(false)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%7B%7Bsnapshot%28%29%7D%7D
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.snapshot = function () {
+ this._validate('snapshot');
+
+ this.options.snapshot = arguments.length
+ ? !! arguments[0]
+ : true
+
+ return this;
+}
+
+/**
+ * Sets query hints.
+ *
+ * ####Example
+ *
+ * query.hint({ indexA: 1, indexB: -1})
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @param {Object} val a hint object
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint
+ * @api public
+ */
+
+Query.prototype.hint = function () {
+ if (0 === arguments.length) return this;
+
+ this._validate('hint');
+
+ var arg = arguments[0];
+ if (utils.isObject(arg)) {
+ var hint = this.options.hint || (this.options.hint = {});
+
+ // must keep object keys in order so don't use Object.keys()
+ for (var k in arg) {
+ hint[k] = arg[k];
+ }
+
+ return this;
+ }
+
+ throw new TypeError('Invalid hint. ' + arg);
+}
+
+/**
+ * Sets the slaveOk option. _Deprecated_ in MongoDB 2.2 in favor of read preferences.
+ *
+ * ####Example:
+ *
+ * query.slaveOk() // true
+ * query.slaveOk(true)
+ * query.slaveOk(false)
+ *
+ * @deprecated use read() preferences instead if on mongodb >= 2.2
+ * @param {Boolean} v defaults to true
+ * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
+ * @see read()
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.slaveOk = function (v) {
+ this.options.slaveOk = arguments.length ? !!v : true;
+ return this;
+}
+
+/**
+ * Sets the readPreference option for the query.
+ *
+ * ####Example:
+ *
+ * new Query().read('primary')
+ * new Query().read('p') // same as primary
+ *
+ * new Query().read('primaryPreferred')
+ * new Query().read('pp') // same as primaryPreferred
+ *
+ * new Query().read('secondary')
+ * new Query().read('s') // same as secondary
+ *
+ * new Query().read('secondaryPreferred')
+ * new Query().read('sp') // same as secondaryPreferred
+ *
+ * new Query().read('nearest')
+ * new Query().read('n') // same as nearest
+ *
+ * // you can also use mongodb.ReadPreference class to also specify tags
+ * new Query().read(mongodb.ReadPreference('secondary', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }]))
+ *
+ * ####Preferences:
+ *
+ * primary - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.
+ * secondary Read from secondary if available, otherwise error.
+ * primaryPreferred Read from primary if available, otherwise a secondary.
+ * secondaryPreferred Read from a secondary if available, otherwise read from the primary.
+ * nearest All operations read from among the nearest candidates, but unlike other modes, this option will include both the primary and all secondaries in the random selection.
+ *
+ * Aliases
+ *
+ * p primary
+ * pp primaryPreferred
+ * s secondary
+ * sp secondaryPreferred
+ * n nearest
+ *
+ * Read more about how to use read preferences [here](http://docs.mongodb.org/manual/applications/replication/#read-preference) and [here](http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences).
+ *
+ * @param {String|ReadPreference} pref one of the listed preference options or their aliases
+ * @see mongodb http://docs.mongodb.org/manual/applications/replication/#read-preference
+ * @see driver http://mongodb.github.com/node-mongodb-native/driver-articles/anintroductionto1_1and2_2.html#read-preferences
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.read = function (pref) {
+ if (arguments.length > 1 && !Query.prototype.read.deprecationWarningIssued) {
+ console.error("Deprecation warning: 'tags' argument is not supported anymore in Query.read() method. Please use mongodb.ReadPreference object instead.");
+ Query.prototype.read.deprecationWarningIssued = true;
+ }
+ this.options.readPreference = utils.readPref(pref);
+ return this;
+}
+
+/**
+ * Sets tailable option.
+ *
+ * ####Example
+ *
+ * query.tailable() <== true
+ * query.tailable(true)
+ * query.tailable(false)
+ *
+ * ####Note
+ *
+ * Cannot be used with `distinct()`
+ *
+ * @param {Boolean} v defaults to true
+ * @see mongodb http://www.mongodb.org/display/DOCS/Tailable+Cursors
+ * @api public
+ */
+
+Query.prototype.tailable = function () {
+ this._validate('tailable');
+
+ this.options.tailable = arguments.length
+ ? !! arguments[0]
+ : true;
+
+ return this;
+}
+
+/**
+ * Merges another Query or conditions object into this one.
+ *
+ * When a Query is passed, conditions, field selection and options are merged.
+ *
+ * @param {Query|Object} source
+ * @return {Query} this
+ */
+
+Query.prototype.merge = function (source) {
+ if (!source)
+ return this;
+
+ if (!Query.canMerge(source))
+ throw new TypeError('Invalid argument. Expected instanceof mquery or plain object');
+
+ if (source instanceof Query) {
+ // if source has a feature, apply it to ourselves
+
+ if (source._conditions) {
+ utils.merge(this._conditions, source._conditions);
+ }
+
+ if (source._fields) {
+ this._fields || (this._fields = {});
+ utils.merge(this._fields, source._fields);
+ }
+
+ if (source.options) {
+ this.options || (this.options = {});
+ utils.merge(this.options, source.options);
+ }
+
+ if (source._update) {
+ this._update || (this._update = {});
+ utils.mergeClone(this._update, source._update);
+ }
+
+ if (source._distinct) {
+ this._distinct = source._distinct;
+ }
+
+ return this;
+ }
+
+ // plain object
+ utils.merge(this._conditions, source);
+
+ return this;
+}
+
+/**
+ * Finds documents.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example
+ *
+ * query.find()
+ * query.find(callback)
+ * query.find({ name: 'Burning Lights' }, callback)
+ *
+ * @param {Object} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.find = function (criteria, callback) {
+ this.op = 'find';
+
+ if ('function' === typeof criteria) {
+ callback = criteria;
+ criteria = undefined;
+ } else if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ if (!callback) return this;
+
+ var self = this
+ , conds = this._conditions
+ , options = this._optionsForExec()
+
+ options.fields = this._fieldsForExec()
+
+ debug('find', this._collection.collectionName, conds, options);
+ callback = this._wrapCallback('find', callback, {
+ conditions: conds
+ , options: options
+ });
+
+ this._collection.find(conds, options, utils.tick(callback));
+ return this;
+}
+
+/**
+ * Returns the query cursor
+ *
+ * ####Examples
+ *
+ * query.find().cursor();
+ * query.cursor({ name: 'Burning Lights' });
+ *
+ * @param {Object} [criteria] mongodb selector
+ * @return {Object} cursor
+ * @api public
+ */
+
+Query.prototype.cursor = function cursor (criteria) {
+ if (this.op) {
+ if (this.op !== 'find') {
+ throw new TypeError(".cursor only support .find method");
+ }
+ } else {
+ this.find(criteria);
+ }
+
+ var conds = this._conditions
+ , options = this._optionsForExec()
+
+ options.fields = this._fieldsForExec()
+
+ debug('findCursor', this._collection.collectionName, conds, options);
+ return this._collection.findCursor(conds, options);
+}
+
+/**
+ * Executes the query as a findOne() operation.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example
+ *
+ * query.findOne().where('name', /^Burning/);
+ *
+ * query.findOne({ name: /^Burning/ })
+ *
+ * query.findOne({ name: /^Burning/ }, callback); // executes
+ *
+ * query.findOne(function (err, doc) {
+ * if (err) return handleError(err);
+ * if (doc) {
+ * // doc may be null if no document matched
+ *
+ * }
+ * });
+ *
+ * @param {Object|Query} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.findOne = function (criteria, callback) {
+ this.op = 'findOne';
+
+ if ('function' === typeof criteria) {
+ callback = criteria;
+ criteria = undefined;
+ } else if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ if (!callback) return this;
+
+ var self = this
+ , conds = this._conditions
+ , options = this._optionsForExec()
+
+ options.fields = this._fieldsForExec();
+
+ debug('findOne', this._collection.collectionName, conds, options);
+ callback = this._wrapCallback('findOne', callback, {
+ conditions: conds
+ , options: options
+ });
+
+ this._collection.findOne(conds, options, utils.tick(callback));
+
+ return this;
+}
+
+/**
+ * Exectues the query as a count() operation.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example
+ *
+ * query.count().where('color', 'black').exec(callback);
+ *
+ * query.count({ color: 'black' }).count(callback)
+ *
+ * query.count({ color: 'black' }, callback)
+ *
+ * query.where('color', 'black').count(function (err, count) {
+ * if (err) return handleError(err);
+ * console.log('there are %d kittens', count);
+ * })
+ *
+ * @param {Object} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Count
+ * @api public
+ */
+
+Query.prototype.count = function (criteria, callback) {
+ this.op = 'count';
+ this._validate();
+
+ if ('function' === typeof criteria) {
+ callback = criteria;
+ criteria = undefined;
+ } else if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ if (!callback) return this;
+
+ var conds = this._conditions
+ , options = this._optionsForExec()
+
+ debug('count', this._collection.collectionName, conds, options);
+ callback = this._wrapCallback('count', callback, {
+ conditions: conds
+ , options: options
+ });
+
+ this._collection.count(conds, options, utils.tick(callback));
+ return this;
+}
+
+/**
+ * Declares or executes a distinct() operation.
+ *
+ * Passing a `callback` executes the query.
+ *
+ * ####Example
+ *
+ * distinct(criteria, field, fn)
+ * distinct(criteria, field)
+ * distinct(field, fn)
+ * distinct(field)
+ * distinct(fn)
+ * distinct()
+ *
+ * @param {Object|Query} [criteria]
+ * @param {String} [field]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct
+ * @api public
+ */
+
+Query.prototype.distinct = function (criteria, field, callback) {
+ this.op = 'distinct';
+ this._validate();
+
+ if (!callback) {
+ switch (typeof field) {
+ case 'function':
+ callback = field;
+ if ('string' == typeof criteria) {
+ field = criteria;
+ criteria = undefined;
+ }
+ break;
+ case 'undefined':
+ case 'string':
+ break;
+ default:
+ throw new TypeError('Invalid `field` argument. Must be string or function')
+ break;
+ }
+
+ switch (typeof criteria) {
+ case 'function':
+ callback = criteria;
+ criteria = field = undefined;
+ break;
+ case 'string':
+ field = criteria;
+ criteria = undefined;
+ break;
+ }
+ }
+
+ if ('string' == typeof field) {
+ this._distinct = field;
+ }
+
+ if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ if (!callback) {
+ return this;
+ }
+
+ if (!this._distinct) {
+ throw new Error('No value for `distinct` has been declared');
+ }
+
+ var conds = this._conditions
+ , options = this._optionsForExec()
+
+ debug('distinct', this._collection.collectionName, conds, options);
+ callback = this._wrapCallback('distinct', callback, {
+ conditions: conds
+ , options: options
+ });
+
+ this._collection.distinct(this._distinct, conds, options, utils.tick(callback));
+
+ return this;
+}
+
+/**
+ * Declare and/or execute this query as an update() operation.
+ *
+ * _All paths passed that are not $atomic operations will become $set ops._
+ *
+ * ####Example
+ *
+ * mquery({ _id: id }).update({ title: 'words' }, ...)
+ *
+ * becomes
+ *
+ * collection.update({ _id: id }, { $set: { title: 'words' }}, ...)
+ *
+ * ####Note
+ *
+ * Passing an empty object `{}` as the doc will result in a no-op unless the `overwrite` option is passed. Without the `overwrite` option set, the update operation will be ignored and the callback executed without sending the command to MongoDB so as to prevent accidently overwritting documents in the collection.
+ *
+ * ####Note
+ *
+ * The operation is only executed when a callback is passed. To force execution without a callback (which would be an unsafe write), we must first call update() and then execute it by using the `exec()` method.
+ *
+ * var q = mquery(collection).where({ _id: id });
+ * q.update({ $set: { name: 'bob' }}).update(); // not executed
+ *
+ * var q = mquery(collection).where({ _id: id });
+ * q.update({ $set: { name: 'bob' }}).exec(); // executed as unsafe
+ *
+ * // keys that are not $atomic ops become $set.
+ * // this executes the same command as the previous example.
+ * q.update({ name: 'bob' }).where({ _id: id }).exec();
+ *
+ * var q = mquery(collection).update(); // not executed
+ *
+ * // overwriting with empty docs
+ * var q.where({ _id: id }).setOptions({ overwrite: true })
+ * q.update({ }, callback); // executes
+ *
+ * // multi update with overwrite to empty doc
+ * var q = mquery(collection).where({ _id: id });
+ * q.setOptions({ multi: true, overwrite: true })
+ * q.update({ });
+ * q.update(callback); // executed
+ *
+ * // multi updates
+ * mquery()
+ * .collection(coll)
+ * .update({ name: /^match/ }, { $set: { arr: [] }}, { multi: true }, callback)
+ * // more multi updates
+ * mquery({ })
+ * .collection(coll)
+ * .setOptions({ multi: true })
+ * .update({ $set: { arr: [] }}, callback)
+ *
+ * // single update by default
+ * mquery({ email: 'address@example.com' })
+ * .collection(coll)
+ * .update({ $inc: { counter: 1 }}, callback)
+ *
+ * // summary
+ * update(criteria, doc, opts, cb) // executes
+ * update(criteria, doc, opts)
+ * update(criteria, doc, cb) // executes
+ * update(criteria, doc)
+ * update(doc, cb) // executes
+ * update(doc)
+ * update(cb) // executes
+ * update(true) // executes (unsafe write)
+ * update()
+ *
+ * @param {Object} [criteria]
+ * @param {Object} [doc] the update command
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.update = function update (criteria, doc, options, callback) {
+ this.op = 'update';
+ var force;
+
+ switch (arguments.length) {
+ case 3:
+ if ('function' == typeof options) {
+ callback = options;
+ options = undefined;
+ }
+ break;
+ case 2:
+ if ('function' == typeof doc) {
+ callback = doc;
+ doc = criteria;
+ criteria = undefined;
+ }
+ break;
+ case 1:
+ switch (typeof criteria) {
+ case 'function':
+ callback = criteria;
+ criteria = options = doc = undefined;
+ break;
+ case 'boolean':
+ // execution with no callback (unsafe write)
+ force = criteria;
+ criteria = undefined;
+ break;
+ default:
+ doc = criteria;
+ criteria = options = undefined;
+ break;
+ }
+ }
+
+ if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ if (doc) {
+ this._mergeUpdate(doc);
+ }
+
+ if (utils.isObject(options)) {
+ // { overwrite: true }
+ this.setOptions(options);
+ }
+
+ // we are done if we don't have callback and they are
+ // not forcing an unsafe write.
+ if (!(force || callback))
+ return this;
+
+ if (!this._update ||
+ !this.options.overwrite && 0 === utils.keys(this._update).length) {
+ callback && utils.soon(callback.bind(null, null, 0));
+ return this;
+ }
+
+ options = this._optionsForExec();
+ if (!callback) options.safe = false;
+
+ var criteria = this._conditions;
+ doc = this._updateForExec();
+
+ debug('update', this._collection.collectionName, criteria, doc, options);
+ callback = this._wrapCallback('update', callback, {
+ conditions: criteria
+ , doc: doc
+ , options: options
+ });
+
+ this._collection.update(criteria, doc, options, utils.tick(callback));
+
+ return this;
+}
+
+/**
+ * Declare and/or execute this query as a remove() operation.
+ *
+ * ####Example
+ *
+ * mquery(collection).remove({ artist: 'Anne Murray' }, callback)
+ *
+ * ####Note
+ *
+ * The operation is only executed when a callback is passed. To force execution without a callback (which would be an unsafe write), we must first call remove() and then execute it by using the `exec()` method.
+ *
+ * // not executed
+ * var query = mquery(collection).remove({ name: 'Anne Murray' })
+ *
+ * // executed
+ * mquery(collection).remove({ name: 'Anne Murray' }, callback)
+ * mquery(collection).remove({ name: 'Anne Murray' }).remove(callback)
+ *
+ * // executed without a callback (unsafe write)
+ * query.exec()
+ *
+ * // summary
+ * query.remove(conds, fn); // executes
+ * query.remove(conds)
+ * query.remove(fn) // executes
+ * query.remove()
+ *
+ * @param {Object|Query} [criteria] mongodb selector
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.remove = function (criteria, callback) {
+ this.op = 'remove';
+ var force;
+
+ if ('function' === typeof criteria) {
+ callback = criteria;
+ criteria = undefined;
+ } else if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ } else if (true === criteria) {
+ force = criteria;
+ criteria = undefined;
+ }
+
+ if (!(force || callback))
+ return this;
+
+ var options = this._optionsForExec()
+ if (!callback) options.safe = false;
+
+ var conds = this._conditions;
+
+ debug('remove', this._collection.collectionName, conds, options);
+ callback = this._wrapCallback('remove', callback, {
+ conditions: conds
+ , options: options
+ });
+
+ this._collection.remove(conds, options, utils.tick(callback));
+
+ return this;
+}
+
+/**
+ * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) update command.
+ *
+ * Finds a matching document, updates it according to the `update` arg, passing any `options`, and returns the found document (if any) to the callback. The query executes immediately if `callback` is passed.
+ *
+ * ####Available options
+ *
+ * - `new`: bool - true to return the modified document rather than the original. defaults to true
+ * - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ *
+ * ####Examples
+ *
+ * query.findOneAndUpdate(conditions, update, options, callback) // executes
+ * query.findOneAndUpdate(conditions, update, options) // returns Query
+ * query.findOneAndUpdate(conditions, update, callback) // executes
+ * query.findOneAndUpdate(conditions, update) // returns Query
+ * query.findOneAndUpdate(update, callback) // returns Query
+ * query.findOneAndUpdate(update) // returns Query
+ * query.findOneAndUpdate(callback) // executes
+ * query.findOneAndUpdate() // returns Query
+ *
+ * @param {Object|Query} [query]
+ * @param {Object} [doc]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @return {Query} this
+ * @api public
+ */
+
+Query.prototype.findOneAndUpdate = function (criteria, doc, options, callback) {
+ this.op = 'findOneAndUpdate';
+ this._validate();
+
+ switch (arguments.length) {
+ case 3:
+ if ('function' == typeof options) {
+ callback = options;
+ options = {};
+ }
+ break;
+ case 2:
+ if ('function' == typeof doc) {
+ callback = doc;
+ doc = criteria;
+ criteria = undefined;
+ }
+ options = undefined;
+ break;
+ case 1:
+ if ('function' == typeof criteria) {
+ callback = criteria;
+ criteria = options = doc = undefined;
+ } else {
+ doc = criteria;
+ criteria = options = undefined;
+ }
+ }
+
+ if (Query.canMerge(criteria)) {
+ this.merge(criteria);
+ }
+
+ // apply doc
+ if (doc) {
+ this._mergeUpdate(doc);
+ }
+
+ options && this.setOptions(options);
+
+ if (!callback) return this;
+ return this._findAndModify('update', callback);
+}
+
+/**
+ * Issues a mongodb [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) remove command.
+ *
+ * Finds a matching document, removes it, passing the found document (if any) to the callback. Executes immediately if `callback` is passed.
+ *
+ * ####Available options
+ *
+ * - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
+ *
+ * ####Examples
+ *
+ * A.where().findOneAndRemove(conditions, options, callback) // executes
+ * A.where().findOneAndRemove(conditions, options) // return Query
+ * A.where().findOneAndRemove(conditions, callback) // executes
+ * A.where().findOneAndRemove(conditions) // returns Query
+ * A.where().findOneAndRemove(callback) // executes
+ * A.where().findOneAndRemove() // returns Query
+ *
+ * @param {Object} [conditions]
+ * @param {Object} [options]
+ * @param {Function} [callback]
+ * @return {Query} this
+ * @see mongodb http://www.mongodb.org/display/DOCS/findAndModify+Command
+ * @api public
+ */
+
+Query.prototype.findOneAndRemove = function (conditions, options, callback) {
+ this.op = 'findOneAndRemove';
+ this._validate();
+
+ if ('function' == typeof options) {
+ callback = options;
+ options = undefined;
+ } else if ('function' == typeof conditions) {
+ callback = conditions;
+ conditions = undefined;
+ }
+
+ // apply conditions
+ if (Query.canMerge(conditions)) {
+ this.merge(conditions);
+ }
+
+ // apply options
+ options && this.setOptions(options);
+
+ if (!callback) return this;
+
+ return this._findAndModify('remove', callback);
+}
+
+/**
+ * _findAndModify
+ *
+ * @param {String} type - either "remove" or "update"
+ * @param {Function} callback
+ * @api private
+ */
+
+Query.prototype._findAndModify = function (type, callback) {
+ assert.equal('function', typeof callback);
+
+ var opts = this._optionsForExec()
+ , self = this
+ , fields
+ , sort
+ , doc
+
+ if ('remove' == type) {
+ opts.remove = true;
+ } else {
+ if (!('new' in opts)) opts.new = true;
+ if (!('upsert' in opts)) opts.upsert = false;
+
+ doc = this._updateForExec()
+ if (!doc) {
+ if (opts.upsert) {
+ // still need to do the upsert to empty doc
+ doc = { $set: {} };
+ } else {
+ return this.findOne(callback);
+ }
+ }
+ }
+
+ var fields = this._fieldsForExec();
+ if (fields) {
+ opts.fields = fields;
+ }
+
+ var conds = this._conditions;
+
+ debug('findAndModify', this._collection.collectionName, conds, doc, opts);
+ callback = this._wrapCallback('findAndModify', callback, {
+ conditions: conds
+ , doc: doc
+ , options: opts
+ });
+
+ this._collection
+ .findAndModify(conds, doc, opts, utils.tick(callback));
+
+ return this;
+}
+
+/**
+ * Wrap callback to add tracing
+ *
+ * @param {Function} callback
+ * @param {Object} [queryInfo]
+ * @api private
+ */
+Query.prototype._wrapCallback = function (method, callback, queryInfo) {
+ var traceFunction = this._traceFunction || Query.traceFunction;
+
+ if (traceFunction) {
+ queryInfo.collectionName = this._collection.collectionName;
+
+ var traceCallback = traceFunction &&
+ traceFunction.call(null, method, queryInfo, this);
+
+ var startTime = new Date().getTime();
+
+ return function wrapperCallback (err, result) {
+ if (traceCallback) {
+ var millis = new Date().getTime() - startTime;
+ traceCallback.call(null, err, result, millis);
+ }
+
+ if (callback) {
+ callback.apply(null, arguments);
+ }
+ };
+ }
+
+ return callback;
+}
+
+/**
+ * Add trace function that gets called when the query is executed.
+ * The function will be called with (method, queryInfo, query) and
+ * should return a callback function which will be called
+ * with (err, result, millis) when the query is complete.
+ *
+ * queryInfo is an object containing: {
+ * collectionName: <name of the collection>,
+ * conditions: <query criteria>,
+ * options: <comment, fields, readPreference, etc>,
+ * doc: [document to update, if applicable]
+ * }
+ *
+ * NOTE: Does not trace stream queries.
+ *
+ * @param {Function} traceFunction
+ * @return {Query} this
+ * @api public
+ */
+Query.prototype.setTraceFunction = function (traceFunction) {
+ this._traceFunction = traceFunction;
+ return this;
+}
+
+/**
+ * Executes the query
+ *
+ * ####Examples
+ *
+ * query.exec();
+ * query.exec(callback);
+ * query.exec('update');
+ * query.exec('find', callback);
+ *
+ * @param {String|Function} [operation]
+ * @param {Function} [callback]
+ * @api public
+ */
+
+Query.prototype.exec = function exec (op, callback) {
+ switch (typeof op) {
+ case 'function':
+ callback = op;
+ op = null;
+ break;
+ case 'string':
+ this.op = op;
+ break;
+ }
+
+ assert.ok(this.op, "Missing query type: (find, update, etc)");
+
+ if ('update' == this.op || 'remove' == this.op) {
+ callback || (callback = true);
+ }
+
+ var self = this;
+
+ if ('function' == typeof callback) {
+ this[this.op](callback);
+ } else {
+ return new Query.Promise(function(success, error) {
+ self[self.op](function(err, val) {
+ if (err) error(err);
+ else success(val);
+ self = success = error = null;
+ });
+ });
+ }
+}
+
+/**
+ * Returns a thunk which when called runs this.exec()
+ *
+ * The thunk receives a callback function which will be
+ * passed to `this.exec()`
+ *
+ * @return {Function}
+ * @api public
+ */
+
+Query.prototype.thunk = function() {
+ var self = this;
+ return function(cb) {
+ self.exec(cb);
+ }
+}
+
+/**
+ * Executes the query returning a `Promise` which will be
+ * resolved with either the doc(s) or rejected with the error.
+ *
+ * @param {Function} [resolve]
+ * @param {Function} [reject]
+ * @return {Promise}
+ * @api public
+ */
+
+Query.prototype.then = function(resolve, reject) {
+ var self = this;
+ var promise = new Query.Promise(function(success, error) {
+ self.exec(function(err, val) {
+ if (err) error(err);
+ else success(val);
+ self = success = error = null;
+ });
+ });
+ return promise.then(resolve, reject);
+}
+
+/**
+ * Returns a stream for the given find query.
+ *
+ * @throws Error if operation is not a find
+ * @returns {Stream} Node 0.8 style
+ */
+
+Query.prototype.stream = function(streamOptions) {
+ if ('find' != this.op)
+ throw new Error('stream() is only available for find');
+
+ var conds = this._conditions;
+
+ var options = this._optionsForExec()
+ options.fields = this._fieldsForExec()
+
+ debug('stream', this._collection.collectionName, conds, options, streamOptions);
+
+ return this._collection.findStream(conds, options, streamOptions);
+}
+
+/**
+ * Determines if field selection has been made.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+Query.prototype.selected = function selected () {
+ return !! (this._fields && Object.keys(this._fields).length > 0);
+}
+
+/**
+ * Determines if inclusive field selection has been made.
+ *
+ * query.selectedInclusively() // false
+ * query.select('name')
+ * query.selectedInclusively() // true
+ * query.selectedExlusively() // false
+ *
+ * @returns {Boolean}
+ */
+
+Query.prototype.selectedInclusively = function selectedInclusively () {
+ if (!this._fields) return false;
+
+ var keys = Object.keys(this._fields);
+ if (0 === keys.length) return false;
+
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (0 === this._fields[key]) return false;
+ if (this._fields[key] &&
+ typeof this._fields[key] === 'object' &&
+ this._fields[key].$meta) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Determines if exclusive field selection has been made.
+ *
+ * query.selectedExlusively() // false
+ * query.select('-name')
+ * query.selectedExlusively() // true
+ * query.selectedInclusively() // false
+ *
+ * @returns {Boolean}
+ */
+
+Query.prototype.selectedExclusively = function selectedExclusively () {
+ if (!this._fields) return false;
+
+ var keys = Object.keys(this._fields);
+ if (0 === keys.length) return false;
+
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (0 === this._fields[key]) return true;
+ }
+
+ return false;
+}
+
+/**
+ * Merges `doc` with the current update object.
+ *
+ * @param {Object} doc
+ */
+
+Query.prototype._mergeUpdate = function (doc) {
+ if (!this._update) this._update = {};
+ if (doc instanceof Query) {
+ if (doc._update) {
+ utils.mergeClone(this._update, doc._update);
+ }
+ } else {
+ utils.mergeClone(this._update, doc);
+ }
+}
+
+/**
+ * Returns default options.
+ *
+ * @return {Object}
+ * @api private
+ */
+
+Query.prototype._optionsForExec = function () {
+ var options = utils.clone(this.options, { retainKeyOrder: true });
+ return options;
+}
+
+/**
+ * Returns fields selection for this query.
+ *
+ * @return {Object}
+ * @api private
+ */
+
+Query.prototype._fieldsForExec = function () {
+ return utils.clone(this._fields, { retainKeyOrder: true });
+}
+
+/**
+ * Return an update document with corrected $set operations.
+ *
+ * @api private
+ */
+
+Query.prototype._updateForExec = function () {
+ var update = utils.clone(this._update, { retainKeyOrder: true })
+ , ops = utils.keys(update)
+ , i = ops.length
+ , ret = {}
+ , hasKeys
+ , val
+
+ while (i--) {
+ var op = ops[i];
+
+ if (this.options.overwrite) {
+ ret[op] = update[op];
+ continue;
+ }
+
+ if ('$' !== op[0]) {
+ // fix up $set sugar
+ if (!ret.$set) {
+ if (update.$set) {
+ ret.$set = update.$set;
+ } else {
+ ret.$set = {};
+ }
+ }
+ ret.$set[op] = update[op];
+ ops.splice(i, 1);
+ if (!~ops.indexOf('$set')) ops.push('$set');
+ } else if ('$set' === op) {
+ if (!ret.$set) {
+ ret[op] = update[op];
+ }
+ } else {
+ ret[op] = update[op];
+ }
+ }
+
+ this._compiledUpdate = ret;
+ return ret;
+}
+
+/**
+ * Make sure _path is set.
+ *
+ * @parmam {String} method
+ */
+
+Query.prototype._ensurePath = function (method) {
+ if (!this._path) {
+ var msg = method + '() must be used after where() '
+ + 'when called with these arguments'
+ throw new Error(msg);
+ }
+}
+
+/*!
+ * Permissions
+ */
+
+Query.permissions = require('./permissions');
+
+Query._isPermitted = function (a, b) {
+ var denied = Query.permissions[b];
+ if (!denied) return true;
+ return true !== denied[a];
+}
+
+Query.prototype._validate = function (action) {
+ var fail;
+ var validator;
+
+ if (undefined === action) {
+
+ validator = Query.permissions[this.op];
+ if ('function' != typeof validator) return true;
+
+ fail = validator(this);
+
+ } else if (!Query._isPermitted(action, this.op)) {
+ fail = action;
+ }
+
+ if (fail) {
+ throw new Error(fail + ' cannot be used with ' + this.op);
+ }
+}
+
+/**
+ * Determines if `conds` can be merged using `mquery().merge()`
+ *
+ * @param {Object} conds
+ * @return {Boolean}
+ */
+
+Query.canMerge = function (conds) {
+ return conds instanceof Query || utils.isObject(conds);
+}
+
+/**
+ * Set a trace function that will get called whenever a
+ * query is executed.
+ *
+ * See `setTraceFunction()` for details.
+ *
+ * @param {Object} conds
+ * @return {Boolean}
+ */
+Query.setGlobalTraceFunction = function (traceFunction) {
+ Query.traceFunction = traceFunction;
+}
+
+/*!
+ * Exports.
+ */
+
+Query.utils = utils;
+Query.env = require('./env')
+Query.Collection = require('./collection');
+Query.BaseCollection = require('./collection/collection');
+Query.Promise = require('bluebird');
+module.exports = exports = Query;
+
+// TODO
+// test utils
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/permissions.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/permissions.js
new file mode 100644
index 0000000..d46f7ae
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/permissions.js
@@ -0,0 +1,88 @@
+'use strict';
+
+var denied = exports;
+
+denied.distinct = function (self) {
+ if (self._fields && Object.keys(self._fields).length > 0) {
+ return 'field selection and slice'
+ }
+
+ var keys = Object.keys(denied.distinct);
+ var err;
+
+ keys.every(function (option) {
+ if (self.options[option]) {
+ err = option;
+ return false;
+ }
+ return true;
+ });
+
+ return err;
+};
+denied.distinct.select =
+denied.distinct.slice =
+denied.distinct.sort =
+denied.distinct.limit =
+denied.distinct.skip =
+denied.distinct.batchSize =
+denied.distinct.comment =
+denied.distinct.maxScan =
+denied.distinct.snapshot =
+denied.distinct.hint =
+denied.distinct.tailable = true;
+
+
+// aggregation integration
+
+
+denied.findOneAndUpdate =
+denied.findOneAndRemove = function (self) {
+ var keys = Object.keys(denied.findOneAndUpdate);
+ var err;
+
+ keys.every(function (option) {
+ if (self.options[option]) {
+ err = option;
+ return false;
+ }
+ return true;
+ });
+
+ return err;
+}
+denied.findOneAndUpdate.limit =
+denied.findOneAndUpdate.skip =
+denied.findOneAndUpdate.batchSize =
+denied.findOneAndUpdate.maxScan =
+denied.findOneAndUpdate.snapshot =
+denied.findOneAndUpdate.hint =
+denied.findOneAndUpdate.tailable =
+denied.findOneAndUpdate.comment = true;
+
+
+denied.count = function (self) {
+ if (self._fields && Object.keys(self._fields).length > 0) {
+ return 'field selection and slice'
+ }
+
+ var keys = Object.keys(denied.count);
+ var err;
+
+ keys.every(function (option) {
+ if (self.options[option]) {
+ err = option;
+ return false;
+ }
+ return true;
+ });
+
+ return err;
+}
+
+denied.count.slice =
+denied.count.batchSize =
+denied.count.comment =
+denied.count.maxScan =
+denied.count.snapshot =
+denied.count.tailable = true;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/utils.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/utils.js
new file mode 100644
index 0000000..f0337b6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/lib/utils.js
@@ -0,0 +1,342 @@
+'use strict';
+
+/*!
+ * Module dependencies.
+ */
+
+var RegExpClone = require('regexp-clone')
+
+/**
+ * Clones objects
+ *
+ * @param {Object} obj the object to clone
+ * @param {Object} options
+ * @return {Object} the cloned object
+ * @api private
+ */
+
+var clone = exports.clone = function clone (obj, options) {
+ if (obj === undefined || obj === null)
+ return obj;
+
+ if (Array.isArray(obj))
+ return exports.cloneArray(obj, options);
+
+ if (obj.constructor) {
+ if (/ObjectI[dD]$/.test(obj.constructor.name)) {
+ return 'function' == typeof obj.clone
+ ? obj.clone()
+ : new obj.constructor(obj.id);
+ }
+
+ if ('ReadPreference' === obj._type && obj.isValid && obj.toObject) {
+ return 'function' == typeof obj.clone
+ ? obj.clone()
+ : new obj.constructor(obj.mode, clone(obj.tags, options));
+ }
+
+ if ('Binary' == obj._bsontype && obj.buffer && obj.value) {
+ return 'function' == typeof obj.clone
+ ? obj.clone()
+ : new obj.constructor(obj.value(true), obj.sub_type);
+ }
+
+ if ('Date' === obj.constructor.name || 'Function' === obj.constructor.name)
+ return new obj.constructor(+obj);
+
+ if ('RegExp' === obj.constructor.name)
+ return RegExpClone(obj);
+
+ if ('Buffer' === obj.constructor.name)
+ return exports.cloneBuffer(obj);
+ }
+
+ if (isObject(obj))
+ return exports.cloneObject(obj, options);
+
+ if (obj.valueOf)
+ return obj.valueOf();
+};
+
+/*!
+ * ignore
+ */
+
+var cloneObject = exports.cloneObject = function cloneObject (obj, options) {
+ var retainKeyOrder = options && options.retainKeyOrder
+ , minimize = options && options.minimize
+ , ret = {}
+ , hasKeys
+ , keys
+ , val
+ , k
+ , i
+
+ if (retainKeyOrder) {
+ for (k in obj) {
+ val = clone(obj[k], options);
+
+ if (!minimize || ('undefined' !== typeof val)) {
+ hasKeys || (hasKeys = true);
+ ret[k] = val;
+ }
+ }
+ } else {
+ // faster
+
+ keys = Object.keys(obj);
+ i = keys.length;
+
+ while (i--) {
+ k = keys[i];
+ val = clone(obj[k], options);
+
+ if (!minimize || ('undefined' !== typeof val)) {
+ if (!hasKeys) hasKeys = true;
+ ret[k] = val;
+ }
+ }
+ }
+
+ return minimize
+ ? hasKeys && ret
+ : ret;
+};
+
+var cloneArray = exports.cloneArray = function cloneArray (arr, options) {
+ var ret = [];
+ for (var i = 0, l = arr.length; i < l; i++)
+ ret.push(clone(arr[i], options));
+ return ret;
+};
+
+/**
+ * process.nextTick helper.
+ *
+ * Wraps the given `callback` in a try/catch. If an error is
+ * caught it will be thrown on nextTick.
+ *
+ * node-mongodb-native had a habit of state corruption when
+ * an error was immediately thrown from within a collection
+ * method (find, update, etc) callback.
+ *
+ * @param {Function} [callback]
+ * @api private
+ */
+
+var tick = exports.tick = function tick (callback) {
+ if ('function' !== typeof callback) return;
+ return function () {
+ // callbacks should always be fired on the next
+ // turn of the event loop. A side benefit is
+ // errors thrown from executing the callback
+ // will not cause drivers state to be corrupted
+ // which has historically been a problem.
+ var args = arguments;
+ soon(function(){
+ callback.apply(this, args);
+ });
+ }
+}
+
+/**
+ * Merges `from` into `to` without overwriting existing properties.
+ *
+ * @param {Object} to
+ * @param {Object} from
+ * @api private
+ */
+
+var merge = exports.merge = function merge (to, from) {
+ var keys = Object.keys(from)
+ , i = keys.length
+ , key
+
+ while (i--) {
+ key = keys[i];
+ if ('undefined' === typeof to[key]) {
+ to[key] = from[key];
+ } else {
+ if (exports.isObject(from[key])) {
+ merge(to[key], from[key]);
+ } else {
+ to[key] = from[key];
+ }
+ }
+ }
+}
+
+/**
+ * Same as merge but clones the assigned values.
+ *
+ * @param {Object} to
+ * @param {Object} from
+ * @api private
+ */
+
+var mergeClone = exports.mergeClone = function mergeClone (to, from) {
+ var keys = Object.keys(from)
+ , i = keys.length
+ , key
+
+ while (i--) {
+ key = keys[i];
+ if ('undefined' === typeof to[key]) {
+ // make sure to retain key order here because of a bug handling the $each
+ // operator in mongodb 2.4.4
+ to[key] = clone(from[key], { retainKeyOrder : 1});
+ } else {
+ if (exports.isObject(from[key])) {
+ mergeClone(to[key], from[key]);
+ } else {
+ // make sure to retain key order here because of a bug handling the
+ // $each operator in mongodb 2.4.4
+ to[key] = clone(from[key], { retainKeyOrder : 1});
+ }
+ }
+ }
+}
+
+/**
+ * Read pref helper (mongo 2.2 drivers support this)
+ *
+ * Allows using aliases instead of full preference names:
+ *
+ * p primary
+ * pp primaryPreferred
+ * s secondary
+ * sp secondaryPreferred
+ * n nearest
+ *
+ * @param {String} pref
+ */
+
+exports.readPref = function readPref (pref) {
+ switch (pref) {
+ case 'p':
+ pref = 'primary';
+ break;
+ case 'pp':
+ pref = 'primaryPreferred';
+ break;
+ case 's':
+ pref = 'secondary';
+ break;
+ case 'sp':
+ pref = 'secondaryPreferred';
+ break;
+ case 'n':
+ pref = 'nearest';
+ break;
+ }
+
+ return pref;
+}
+
+/**
+ * Object.prototype.toString.call helper
+ */
+
+var _toString = Object.prototype.toString;
+var toString = exports.toString = function (arg) {
+ return _toString.call(arg);
+}
+
+/**
+ * Determines if `arg` is an object.
+ *
+ * @param {Object|Array|String|Function|RegExp|any} arg
+ * @return {Boolean}
+ */
+
+var isObject = exports.isObject = function (arg) {
+ return '[object Object]' == exports.toString(arg);
+}
+
+/**
+ * Determines if `arg` is an array.
+ *
+ * @param {Object}
+ * @return {Boolean}
+ * @see nodejs utils
+ */
+
+var isArray = exports.isArray = function (arg) {
+ return Array.isArray(arg) ||
+ 'object' == typeof arg && '[object Array]' == exports.toString(arg);
+}
+
+/**
+ * Object.keys helper
+ */
+
+exports.keys = Object.keys || function (obj) {
+ var keys = [];
+ for (var k in obj) if (obj.hasOwnProperty(k)) {
+ keys.push(k);
+ }
+ return keys;
+}
+
+/**
+ * Basic Object.create polyfill.
+ * Only one argument is supported.
+ *
+ * Based on https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create
+ */
+
+exports.create = 'function' == typeof Object.create
+ ? Object.create
+ : create;
+
+function create (proto) {
+ if (arguments.length > 1) {
+ throw new Error("Adding properties is not supported")
+ }
+
+ function F () {}
+ F.prototype = proto;
+ return new F;
+}
+
+/**
+ * inheritance
+ */
+
+exports.inherits = function (ctor, superCtor) {
+ ctor.prototype = exports.create(superCtor.prototype);
+ ctor.prototype.constructor = ctor;
+}
+
+/**
+ * nextTick helper
+ * compat with node 0.10 which behaves differently than previous versions
+ */
+
+var soon = exports.soon = 'function' == typeof setImmediate
+ ? setImmediate
+ : process.nextTick;
+
+/**
+ * Clones the contents of a buffer.
+ *
+ * @param {Buffer} buff
+ * @return {Buffer}
+ */
+
+exports.cloneBuffer = function (buff) {
+ var dupe = new Buffer(buff.length);
+ buff.copy(dupe, 0, 0, buff.length);
+ return dupe;
+};
+
+/**
+ * Check if this object is an arguments object
+ *
+ * @param {Any} v
+ * @return {Boolean}
+ */
+
+exports.isArgumentsObject = function(v) {
+ return Object.prototype.toString.call(v) === '[object Arguments]';
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/LICENSE
new file mode 100644
index 0000000..4182a1e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2013-2015 Petka Antonov
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/README.md
new file mode 100644
index 0000000..e1447bf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/README.md
@@ -0,0 +1,679 @@
+<a href="http://promisesaplus.com/">
+ <img src="http://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo"
+ title="Promises/A+ 1.1 compliant" align="right" />
+</a>
+[![Build Status](https://travis-ci.org/petkaantonov/bluebird.svg?branch=master)](https://travis-ci.org/petkaantonov/bluebird)
+[![coverage-98%](http://img.shields.io/badge/coverage-98%-brightgreen.svg?style=flat)](http://petkaantonov.github.io/bluebird/coverage/debug/index.html)
+
+**Got a question?** Join us on [stackoverflow](http://stackoverflow.com/questions/tagged/bluebird), the [mailing list](https://groups.google.com/forum/#!forum/bluebird-js) or chat on [IRC](https://webchat.freenode.net/?channels=#promises)
+
+# Introduction
+
+Bluebird is a fully featured [promise](#what-are-promises-and-why-should-i-use-them) library with focus on innovative features and performance
+
+
+
+# Topics
+
+- [Features](#features)
+- [Quick start](#quick-start)
+- [API Reference and examples](API.md)
+- [Support](#support)
+- [What are promises and why should I use them?](#what-are-promises-and-why-should-i-use-them)
+- [Questions and issues](#questions-and-issues)
+- [Error handling](#error-handling)
+- [Development](#development)
+ - [Testing](#testing)
+ - [Benchmarking](#benchmarks)
+ - [Custom builds](#custom-builds)
+ - [For library authors](#for-library-authors)
+- [What is the sync build?](#what-is-the-sync-build)
+- [License](#license)
+- [Snippets for common problems](https://github.com/petkaantonov/bluebird/wiki/Snippets)
+- [Promise anti-patterns](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns)
+- [Changelog](changelog.md)
+- [Optimization guide](#optimization-guide)
+
+# Features
+<img src="http://petkaantonov.github.io/bluebird/logo.png" alt="bluebird logo" align="right" />
+
+- [Promises A+](http://promisesaplus.com)
+- [Synchronous inspection](API.md#synchronous-inspection)
+- [Concurrency coordination](API.md#collections)
+- [Promisification on steroids](API.md#promisification)
+- [Resource management through a parallel of python `with`/C# `using`](API.md#resource-management)
+- [Cancellation and timeouts](API.md#cancellation)
+- [Parallel for C# `async` and `await`](API.md#generators)
+- Mind blowing utilities such as
+ - [`.bind()`](API.md#binddynamic-thisarg---promise)
+ - [`.call()`](API.md#callstring-propertyname--dynamic-arg---promise)
+ - [`Promise.join()`](API.md#promisejoinpromisethenablevalue-promises-function-handler---promise)
+ - [And](API.md#core) [much](API.md#timers) [more](API.md#utility)!
+- [Practical debugging solutions and sane defaults](#error-handling)
+- [Sick performance](benchmark/)
+
+<hr>
+
+# Quick start
+
+## Node.js
+
+ npm install bluebird
+
+Then:
+
+```js
+var Promise = require("bluebird");
+```
+
+## Browsers
+
+There are many ways to use bluebird in browsers:
+
+- Direct downloads
+ - Full build [bluebird.js](https://cdn.jsdelivr.net/bluebird/latest/bluebird.js)
+ - Full build minified [bluebird.min.js](https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js)
+ - Core build [bluebird.core.js](https://cdn.jsdelivr.net/bluebird/latest/bluebird.core.js)
+ - Core build minified [bluebird.core.min.js](https://cdn.jsdelivr.net/bluebird/latest/bluebird.core.min.js)
+- You may use browserify on the main export
+- You may use the [bower](http://bower.io) package.
+
+When using script tags the global variables `Promise` and `P` (alias for `Promise`) become available.
+
+A [minimal bluebird browser build](#custom-builds) is &asymp;38.92KB minified*, 11.65KB gzipped and has no external dependencies.
+
+*Google Closure Compiler using Simple.
+
+#### Browser support
+
+Browsers that [implement ECMA-262, edition 3](http://en.wikipedia.org/wiki/Ecmascript#Implementations) and later are supported.
+
+[![Selenium Test Status](https://saucelabs.com/browser-matrix/petka_antonov.svg)](https://saucelabs.com/u/petka_antonov)
+
+**Note** that in ECMA-262, edition 3 (IE7, IE8 etc.) it is not possible to use methods that have keyword names like `.catch` and `.finally`. The [API documentation](API.md) always lists a compatible alternative name that you can use if you need to support these browsers. For example `.catch` is replaced with `.caught` and `.finally` with `.lastly`.
+
+Also, [long stack trace](API.md#promiselongstacktraces---void) support is only available in Chrome, Firefox and Internet Explorer 10+.
+
+After quick start, see [API Reference and examples](API.md)
+
+<hr>
+
+# Support
+
+- Mailing list: [bluebird-js@googlegroups.com](https://groups.google.com/forum/#!forum/bluebird-js)
+- IRC: #promises @freenode
+- StackOverflow: [bluebird tag](http://stackoverflow.com/questions/tagged/bluebird)
+- Bugs and feature requests: [github issue tracker](https://github.com/petkaantonov/bluebird/issues?state=open)
+
+<hr>
+
+# What are promises and why should I use them?
+
+You should use promises to turn this:
+
+```js
+fs.readFile("file.json", function(err, val) {
+ if( err ) {
+ console.error("unable to read file");
+ }
+ else {
+ try {
+ val = JSON.parse(val);
+ console.log(val.success);
+ }
+ catch( e ) {
+ console.error("invalid json in file");
+ }
+ }
+});
+```
+
+Into this:
+
+```js
+fs.readFileAsync("file.json").then(JSON.parse).then(function(val) {
+ console.log(val.success);
+})
+.catch(SyntaxError, function(e) {
+ console.error("invalid json in file");
+})
+.catch(function(e) {
+ console.error("unable to read file");
+});
+```
+
+*If you are wondering "there is no `readFileAsync` method on `fs` that returns a promise", see [promisification](API.md#promisification)*
+
+Actually you might notice the latter has a lot in common with code that would do the same using synchronous I/O:
+
+```js
+try {
+ var val = JSON.parse(fs.readFileSync("file.json"));
+ console.log(val.success);
+}
+//Syntax actually not supported in JS but drives the point
+catch(SyntaxError e) {
+ console.error("invalid json in file");
+}
+catch(Error e) {
+ console.error("unable to read file");
+}
+```
+
+And that is the point - being able to have something that is a lot like `return` and `throw` in synchronous code.
+
+You can also use promises to improve code that was written with callback helpers:
+
+
+```js
+//Copyright Plato http://stackoverflow.com/a/19385911/995876
+//CC BY-SA 2.5
+mapSeries(URLs, function (URL, done) {
+ var options = {};
+ needle.get(URL, options, function (error, response, body) {
+ if (error) {
+ return done(error);
+ }
+ try {
+ var ret = JSON.parse(body);
+ return done(null, ret);
+ }
+ catch (e) {
+ done(e);
+ }
+ });
+}, function (err, results) {
+ if (err) {
+ console.log(err);
+ } else {
+ console.log('All Needle requests successful');
+ // results is a 1 to 1 mapping in order of URLs > needle.body
+ processAndSaveAllInDB(results, function (err) {
+ if (err) {
+ return done(err);
+ }
+ console.log('All Needle requests saved');
+ done(null);
+ });
+ }
+});
+```
+
+Is more pleasing to the eye when done with promises:
+
+```js
+Promise.promisifyAll(needle);
+var options = {};
+
+var current = Promise.resolve();
+Promise.map(URLs, function(URL) {
+ current = current.then(function () {
+ return needle.getAsync(URL, options);
+ });
+ return current;
+}).map(function(responseAndBody){
+ return JSON.parse(responseAndBody[1]);
+}).then(function (results) {
+ return processAndSaveAllInDB(results);
+}).then(function(){
+ console.log('All Needle requests saved');
+}).catch(function (e) {
+ console.log(e);
+});
+```
+
+Also promises don't just give you correspondences for synchronous features but can also be used as limited event emitters or callback aggregators.
+
+More reading:
+
+ - [Promise nuggets](https://promise-nuggets.github.io/)
+ - [Why I am switching to promises](http://spion.github.io/posts/why-i-am-switching-to-promises.html)
+ - [What is the the point of promises](http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/#toc_1)
+ - [Snippets for common problems](https://github.com/petkaantonov/bluebird/wiki/Snippets)
+ - [Promise anti-patterns](https://github.com/petkaantonov/bluebird/wiki/Promise-anti-patterns)
+
+# Questions and issues
+
+The [github issue tracker](https://github.com/petkaantonov/bluebird/issues) is **_only_** for bug reports and feature requests. Anything else, such as questions for help in using the library, should be posted in [StackOverflow](http://stackoverflow.com/questions/tagged/bluebird) under tags `promise` and `bluebird`.
+
+# Error handling
+
+This is a problem every promise library needs to handle in some way. Unhandled rejections/exceptions don't really have a good agreed-on asynchronous correspondence. The problem is that it is impossible to predict the future and know if a rejected promise will eventually be handled.
+
+There are two common pragmatic attempts at solving the problem that promise libraries do.
+
+The more popular one is to have the user explicitly communicate that they are done and any unhandled rejections should be thrown, like so:
+
+```js
+download().then(...).then(...).done();
+```
+
+For handling this problem, in my opinion, this is completely unacceptable and pointless. The user must remember to explicitly call `.done` and that cannot be justified when the problem is forgetting to create an error handler in the first place.
+
+The second approach, which is what bluebird by default takes, is to call a registered handler if a rejection is unhandled by the start of a second turn. The default handler is to write the stack trace to `stderr` or `console.error` in browsers. This is close to what happens with synchronous code - your code doesn't work as expected and you open console and see a stack trace. Nice.
+
+Of course this is not perfect, if your code for some reason needs to swoop in and attach error handler to some promise after the promise has been hanging around a while then you will see annoying messages. In that case you can use the `.done()` method to signal that any hanging exceptions should be thrown.
+
+If you want to override the default handler for these possibly unhandled rejections, you can pass yours like so:
+
+```js
+Promise.onPossiblyUnhandledRejection(function(error){
+ throw error;
+});
+```
+
+If you want to also enable long stack traces, call:
+
+```js
+Promise.longStackTraces();
+```
+
+right after the library is loaded.
+
+In node.js use the environment flag `BLUEBIRD_DEBUG`:
+
+```
+BLUEBIRD_DEBUG=1 node server.js
+```
+
+to enable long stack traces in all instances of bluebird.
+
+Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, even after using every trick to optimize them.
+
+Long stack traces are enabled by default in the debug build.
+
+#### Expected and unexpected errors
+
+A practical problem with Promises/A+ is that it models Javascript `try-catch` too closely for its own good. Therefore by default promises inherit `try-catch` warts such as the inability to specify the error types that the catch block is eligible for. It is an anti-pattern in every other language to use catch-all handlers because they swallow exceptions that you might not know about.
+
+Now, Javascript does have a perfectly fine and working way of creating error type hierarchies. It is still quite awkward to use them with the built-in `try-catch` however:
+
+```js
+try {
+ //code
+}
+catch(e) {
+ if( e instanceof WhatIWantError) {
+ //handle
+ }
+ else {
+ throw e;
+ }
+}
+```
+
+Without such checking, unexpected errors would be silently swallowed. However, with promises, bluebird brings the future (hopefully) here now and extends the `.catch` to [accept potential error type eligibility](API.md#catchfunction-errorclass-function-handler---promise).
+
+For instance here it is expected that some evil or incompetent entity will try to crash our server from `SyntaxError` by providing syntactically invalid JSON:
+
+```js
+getJSONFromSomewhere().then(function(jsonString) {
+ return JSON.parse(jsonString);
+}).then(function(object) {
+ console.log("it was valid json: ", object);
+}).catch(SyntaxError, function(e){
+ console.log("don't be evil");
+});
+```
+
+Here any kind of unexpected error will be automatically reported on `stderr` along with a stack trace because we only register a handler for the expected `SyntaxError`.
+
+Ok, so, that's pretty neat. But actually not many libraries define error types and it is in fact a complete ghetto out there with ad hoc strings being attached as some arbitrary property name like `.name`, `.type`, `.code`, not having any property at all or even throwing strings as errors and so on. So how can we still listen for expected errors?
+
+Bluebird defines a special error type `OperationalError` (you can get a reference from `Promise.OperationalError`). This type of error is given as rejection reason by promisified methods when
+their underlying library gives an untyped, but expected error. Primitives such as strings, and error objects that are directly created like `new Error("database didn't respond")` are considered untyped.
+
+Example of such library is the node core library `fs`. So if we promisify it, we can catch just the errors we want pretty easily and have programmer errors be redirected to unhandled rejection handler so that we notice them:
+
+```js
+//Read more about promisification in the API Reference:
+//API.md
+var fs = Promise.promisifyAll(require("fs"));
+
+fs.readFileAsync("myfile.json").then(JSON.parse).then(function (json) {
+ console.log("Successful json");
+}).catch(SyntaxError, function (e) {
+ console.error("file contains invalid json");
+}).catch(Promise.OperationalError, function (e) {
+ console.error("unable to read file, because: ", e.message);
+});
+```
+
+The last `catch` handler is only invoked when the `fs` module explicitly used the `err` argument convention of async callbacks to inform of an expected error. The `OperationalError` instance will contain the original error in its `.cause` property but it does have a direct copy of the `.message` and `.stack` too. In this code any unexpected error - be it in our code or the `fs` module - would not be caught by these handlers and therefore not swallowed.
+
+Since a `catch` handler typed to `Promise.OperationalError` is expected to be used very often, it has a neat shorthand:
+
+```js
+.error(function (e) {
+ console.error("unable to read file, because: ", e.message);
+});
+```
+
+See [API documentation for `.error()`](API.md#error-rejectedhandler----promise)
+
+Finally, Bluebird also supports predicate-based filters. If you pass a
+predicate function instead of an error type, the predicate will receive
+the error as an argument. The return result will be used to determine whether
+the error handler should be called.
+
+Predicates should allow for very fine grained control over caught errors:
+pattern matching, error typesets with set operations and many other techniques
+can be implemented on top of them.
+
+Example of using a predicate-based filter:
+
+```js
+var Promise = require("bluebird");
+var request = Promise.promisify(require("request"));
+
+function clientError(e) {
+ return e.code >= 400 && e.code < 500;
+}
+
+request("http://www.google.com").then(function(contents){
+ console.log(contents);
+}).catch(clientError, function(e){
+ //A client error like 400 Bad Request happened
+});
+```
+
+**Danger:** The JavaScript language allows throwing primitive values like strings. Throwing primitives can lead to worse or no stack traces. Primitives [are not exceptions](http://www.devthought.com/2011/12/22/a-string-is-not-an-error/). You should consider always throwing Error objects when handling exceptions.
+
+<hr>
+
+#### How do long stack traces differ from e.g. Q?
+
+Bluebird attempts to have more elaborate traces. Consider:
+
+```js
+Error.stackTraceLimit = 25;
+Q.longStackSupport = true;
+Q().then(function outer() {
+ return Q().then(function inner() {
+ return Q().then(function evenMoreInner() {
+ a.b.c.d();
+ }).catch(function catcher(e){
+ console.error(e.stack);
+ });
+ })
+});
+```
+
+You will see
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:7:13)
+ From previous event:
+ at inner (<anonymous>:6:20)
+
+Compare to:
+
+```js
+Error.stackTraceLimit = 25;
+Promise.longStackTraces();
+Promise.resolve().then(function outer() {
+ return Promise.resolve().then(function inner() {
+ return Promise.resolve().then(function evenMoreInner() {
+ a.b.c.d();
+ }).catch(function catcher(e){
+ console.error(e.stack);
+ });
+ });
+});
+```
+
+ ReferenceError: a is not defined
+ at evenMoreInner (<anonymous>:7:13)
+ From previous event:
+ at inner (<anonymous>:6:36)
+ From previous event:
+ at outer (<anonymous>:5:32)
+ From previous event:
+ at <anonymous>:4:21
+ at Object.InjectedScript._evaluateOn (<anonymous>:572:39)
+ at Object.InjectedScript._evaluateAndWrap (<anonymous>:531:52)
+ at Object.InjectedScript.evaluate (<anonymous>:450:21)
+
+
+A better and more practical example of the differences can be seen in gorgikosev's [debuggability competition](https://github.com/spion/async-compare#debuggability).
+
+<hr>
+
+# Development
+
+For development tasks such as running benchmarks or testing, you need to clone the repository and install dev-dependencies.
+
+Install [node](http://nodejs.org/) and [npm](https://npmjs.org/)
+
+ git clone git@github.com:petkaantonov/bluebird.git
+ cd bluebird
+ npm install
+
+## Testing
+
+To run all tests, run
+
+ node tools/test
+
+If you need to run generator tests run the `tool/test.js` script with `--harmony` argument and node 0.11+:
+
+ node-dev --harmony tools/test
+
+You may specify an individual test file to run with the `--run` script flag:
+
+ node tools/test --run=cancel.js
+
+
+This enables output from the test and may give a better idea where the test is failing. The parameter to `--run` can be any file name located in `test/mocha` folder.
+
+#### Testing in browsers
+
+To run the test in a browser instead of node, pass the flag `--browser` to the test tool
+
+ node tools/test --run=cancel.js --browser
+
+This will automatically create a server (default port 9999) and open it in your default browser once the tests have been compiled.
+
+Keep the test tab active because some tests are timing-sensitive and will fail if the browser is throttling timeouts. Chrome will do this for example when the tab is not active.
+
+#### Supported options by the test tool
+
+The value of boolean flags is determined by presence, if you want to pass false value for a boolean flag, use the `no-`-prefix e.g. `--no-browser`.
+
+ - `--run=String` - Which tests to run (or compile when testing in browser). Default `"all"`. Can also be a glob string (relative to ./test/mocha folder).
+ - `--cover=String`. Create code coverage using the String as istanbul reporter. Coverage is created in the ./coverage folder. No coverage is created by default, default reporter is `"html"` (use `--cover` to use default reporter).
+ - `--browser` - Whether to compile tests for browsers. Default `false`.
+ - `--port=Number` - Port where local server is hosted when testing in browser. Default `9999`
+ - `--execute-browser-tests` - Whether to execute the compiled tests for browser when using `--browser`. Default `true`.
+ - `--open-browser` - Whether to open the default browser when executing browser tests. Default `true`.
+ - `--fake-timers` - Whether to use fake timers (`setTimeout` etc) when running tests in node. Default `true`.
+ - `--js-hint` - Whether to run JSHint on source files. Default `true`.
+ - `--saucelabs` - Whether to create a tunnel to sauce labs and run tests in their VMs instead of your browser when compiling tests for browser. Default `false`.
+
+## Benchmarks
+
+To run a benchmark, run the given command for a benchmark while on the project root. Requires bash (on windows the mingw32 that comes with git works fine too).
+
+Node 0.11.2+ is required to run the generator examples.
+
+### 1\. DoxBee sequential
+
+Currently the most relevant benchmark is @gorkikosev's benchmark in the article [Analysis of generators and other async patterns in node](http://spion.github.io/posts/analysis-generators-and-other-async-patterns-node.html). The benchmark emulates a situation where n amount of users are making a request in parallel to execute some mixed async/sync action. The benchmark has been modified to include a warm-up phase to minimize any JITing during timed sections.
+
+Command: `bench doxbee`
+
+### 2\. Made-up parallel
+
+This made-up scenario runs 15 shimmed queries in parallel.
+
+Command: `bench parallel`
+
+## Custom builds
+
+Custom builds for browsers are supported through a command-line utility.
+
+
+<table>
+ <caption>The following features can be disabled</caption>
+ <thead>
+ <tr>
+ <th>Feature(s)</th>
+ <th>Command line identifier</th>
+ </tr>
+ </thead>
+ <tbody>
+
+ <tr><td><a href="API.md#any---promise"><code>.any</code></a> and <a href="API.md#promiseanyarraydynamicpromise-values---promise"><code>Promise.any</code></a></td><td><code>any</code></td></tr>
+ <tr><td><a href="API.md#race---promise"><code>.race</code></a> and <a href="API.md#promiseracearraypromise-promises---promise"><code>Promise.race</code></a></td><td><code>race</code></td></tr>
+ <tr><td><a href="API.md#callstring-propertyname--dynamic-arg---promise"><code>.call</code></a> and <a href="API.md#getstring-propertyname---promise"><code>.get</code></a></td><td><code>call_get</code></td></tr>
+ <tr><td><a href="API.md#filterfunction-filterer---promise"><code>.filter</code></a> and <a href="API.md#promisefilterarraydynamicpromise-values-function-filterer---promise"><code>Promise.filter</code></a></td><td><code>filter</code></td></tr>
+ <tr><td><a href="API.md#mapfunction-mapper---promise"><code>.map</code></a> and <a href="API.md#promisemaparraydynamicpromise-values-function-mapper---promise"><code>Promise.map</code></a></td><td><code>map</code></td></tr>
+ <tr><td><a href="API.md#reducefunction-reducer--dynamic-initialvalue---promise"><code>.reduce</code></a> and <a href="API.md#promisereducearraydynamicpromise-values-function-reducer--dynamic-initialvalue---promise"><code>Promise.reduce</code></a></td><td><code>reduce</code></td></tr>
+ <tr><td><a href="API.md#props---promise"><code>.props</code></a> and <a href="API.md#promisepropsobjectpromise-object---promise"><code>Promise.props</code></a></td><td><code>props</code></td></tr>
+ <tr><td><a href="API.md#settle---promise"><code>.settle</code></a> and <a href="API.md#promisesettlearraydynamicpromise-values---promise"><code>Promise.settle</code></a></td><td><code>settle</code></td></tr>
+ <tr><td><a href="API.md#someint-count---promise"><code>.some</code></a> and <a href="API.md#promisesomearraydynamicpromise-values-int-count---promise"><code>Promise.some</code></a></td><td><code>some</code></td></tr>
+ <tr><td><a href="API.md#nodeifyfunction-callback---promise"><code>.nodeify</code></a></td><td><code>nodeify</code></td></tr>
+ <tr><td><a href="API.md#promisecoroutinegeneratorfunction-generatorfunction---function"><code>Promise.coroutine</code></a> and <a href="API.md#promisespawngeneratorfunction-generatorfunction---promise"><code>Promise.spawn</code></a></td><td><code>generators</code></td></tr>
+ <tr><td><a href="API.md#progression">Progression</a></td><td><code>progress</code></td></tr>
+ <tr><td><a href="API.md#promisification">Promisification</a></td><td><code>promisify</code></td></tr>
+ <tr><td><a href="API.md#cancellation">Cancellation</a></td><td><code>cancel</code></td></tr>
+ <tr><td><a href="API.md#timers">Timers</a></td><td><code>timers</code></td></tr>
+ <tr><td><a href="API.md#resource-management">Resource management</a></td><td><code>using</code></td></tr>
+
+ </tbody>
+</table>
+
+
+Make sure you have cloned the repo somewhere and did `npm install` successfully.
+
+After that you can run:
+
+ node tools/build --features="core"
+
+
+The above builds the most minimal build you can get. You can add more features separated by spaces from the above list:
+
+ node tools/build --features="core filter map reduce"
+
+The custom build file will be found from `/js/browser/bluebird.js`. It will have a comment that lists the disabled and enabled features.
+
+Note that the build leaves the `/js/main` etc folders with same features so if you use the folder for node.js at the same time, don't forget to build
+a full version afterwards (after having taken a copy of the bluebird.js somewhere):
+
+ node tools/build --debug --main --zalgo --browser --minify
+
+#### Supported options by the build tool
+
+The value of boolean flags is determined by presence, if you want to pass false value for a boolean flag, use the `no-`-prefix e.g. `--no-debug`.
+
+ - `--main` - Whether to build the main build. The main build is placed at `js/main` directory. Default `false`.
+ - `--debug` - Whether to build the debug build. The debug build is placed at `js/debug` directory. Default `false`.
+ - `--zalgo` - Whether to build the zalgo build. The zalgo build is placed at `js/zalgo` directory. Default `false`.
+ - `--browser` - Whether to compile the browser build. The browser build file is placed at `js/browser/bluebird.js` Default `false`.
+ - `--minify` - Whether to minify the compiled browser build. The minified browser build file is placed at `js/browser/bluebird.min.js` Default `true`.
+ - `--features=String` - See [custom builds](#custom-builds)
+
+<hr>
+
+## For library authors
+
+Building a library that depends on bluebird? You should know about a few features.
+
+If your library needs to do something obtrusive like adding or modifying methods on the `Promise` prototype, uses long stack traces or uses a custom unhandled rejection handler then... that's totally ok as long as you don't use `require("bluebird")`. Instead you should create a file
+that creates an isolated copy. For example, creating a file called `bluebird-extended.js` that contains:
+
+```js
+ //NOTE the function call right after
+module.exports = require("bluebird/js/main/promise")();
+```
+
+Your library can then use `var Promise = require("bluebird-extended");` and do whatever it wants with it. Then if the application or other library uses their own bluebird promises they will all play well together because of Promises/A+ thenable assimilation magic.
+
+You should also know about [`.nodeify()`](API.md#nodeifyfunction-callback---promise) which makes it easy to provide a dual callback/promise API.
+
+<hr>
+
+## What is the sync build?
+
+You may now use sync build by:
+
+ var Promise = require("bluebird/zalgo");
+
+The sync build is provided to see how forced asynchronity affects benchmarks. It should not be used in real code due to the implied hazards.
+
+The normal async build gives Promises/A+ guarantees about asynchronous resolution of promises. Some people think this affects performance or just plain love their code having a possibility
+of stack overflow errors and non-deterministic behavior.
+
+The sync build skips the async call trampoline completely, e.g code like:
+
+ async.invoke( this.fn, this, val );
+
+Appears as this in the sync build:
+
+ this.fn(val);
+
+This should pressure the CPU slightly less and thus the sync build should perform better. Indeed it does, but only marginally. The biggest performance boosts are from writing efficient Javascript, not from compromising determinism.
+
+Note that while some benchmarks are waiting for the next event tick, the CPU is actually not in use during that time. So the resulting benchmark result is not completely accurate because on node.js you only care about how much the CPU is taxed. Any time spent on CPU is time the whole process (or server) is paralyzed. And it is not graceful like it would be with threads.
+
+
+```js
+var cache = new Map(); //ES6 Map or DataStructures/Map or whatever...
+function getResult(url) {
+ var resolver = Promise.pending();
+ if (cache.has(url)) {
+ resolver.resolve(cache.get(url));
+ }
+ else {
+ http.get(url, function(err, content) {
+ if (err) resolver.reject(err);
+ else {
+ cache.set(url, content);
+ resolver.resolve(content);
+ }
+ });
+ }
+ return resolver.promise;
+}
+
+
+
+//The result of console.log is truly random without async guarantees
+function guessWhatItPrints( url ) {
+ var i = 3;
+ getResult(url).then(function(){
+ i = 4;
+ });
+ console.log(i);
+}
+```
+
+# Optimization guide
+
+Articles about optimization will be periodically posted in [the wiki section](https://github.com/petkaantonov/bluebird/wiki), polishing edits are welcome.
+
+A single cohesive guide compiled from the articles will probably be done eventually.
+
+# License
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Petka Antonov
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/changelog.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/changelog.md
new file mode 100644
index 0000000..5f6e348
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/changelog.md
@@ -0,0 +1,1723 @@
+## 2.10.2 (2015-10-01)
+
+Features:
+
+ - `.timeout()` now takes a custom error object as second argument
+
+## 2.10.1 (2015-09-21)
+
+ - Fix error "Cannot promisify an API that has normal methods with 'Async'-suffix" when promisifying certain objects with a custom promisifier
+
+## 2.10.0 (2015-09-08)
+
+Features:
+
+ - `Promise.using` can now take the promises-for-resources as an array ([#733](.)).
+ - Browser builds for minimal core are now hosted on CDN ([#724](.)).
+
+Bugfixes:
+
+ - Disabling debug mode with `BLUEBIRD_DEBUG=0` environment variable now works ([#719](.)).
+ - Fix unhandled rejection reporting when passing rejected promise to `.return()` ([#721](.)).
+ - Fix unbound promise's then handlers being called with wrong `this` value ([#738](.)).
+
+## 2.9.34 (2015-07-15)
+
+Bugfixes:
+
+- Correct domain for .map, .each, .filter, .reduce callbacks ([#701](.)).
+ - Preserve bound-with-promise promises across the entire chain ([#702](.)).
+
+## 2.9.33 (2015-07-09)
+
+Bugfixes:
+
+ - Methods on `Function.prototype` are no longer promisified ([#680](.)).
+
+## 2.9.32 (2015-07-03)
+
+Bugfixes:
+
+ - Fix `.return(primitiveValue)` returning a wrapped version of the primitive value when a Node.js domain is active ([#689](.)).
+
+## 2.9.31 (2015-07-03)
+
+Bugfixes:
+
+ - Fix Promises/A+ compliance issue regarding circular thenables: the correct behavior is to go into an infinite loop instead of warning with an error (Fixes [#682](.)).
+ - Fix "(node) warning: possible EventEmitter memory leak detected" ([#661](.)).
+ - Fix callbacks sometimes being called with a wrong node.js domain ([#664](.)).
+ - Fix callbacks sometimes not being called at all in iOS 8.1 WebApp mode ([#666](.), [#687](.)).
+
+## 2.9.30 (2015-06-14)
+
+Bugfixes:
+
+ - Fix regression with `promisifyAll` not promisifying certain methods
+
+## 2.9.29 (2015-06-14)
+
+Bugfixes:
+
+ - Improve `promisifyAll` detection of functions that are class constructors. Fixes mongodb 2.x promisification.
+
+## 2.9.28 (2015-06-14)
+
+Bugfixes:
+
+ - Fix handled rejection being reported as unhandled in certain scenarios when using [.all](.) or [Promise.join](.) ([#645](.))
+ - Fix custom scheduler not being called in Google Chrome when long stack traces are enabled ([#650](.))
+
+## 2.9.27 (2015-05-30)
+
+Bugfixes:
+
+ - Fix `sinon.useFakeTimers()` breaking scheduler ([#631](.))
+
+Misc:
+
+ - Add nw testing facilities (`node tools/test --nw`)
+
+## 2.9.26 (2015-05-25)
+
+Bugfixes:
+
+ - Fix crash in NW [#624](.)
+ - Fix [`.return()`](.) not supporting `undefined` as return value [#627](.)
+
+## 2.9.25 (2015-04-28)
+
+Bugfixes:
+
+ - Fix crash in node 0.8
+
+## 2.9.24 (2015-04-02)
+
+Bugfixes:
+
+ - Fix not being able to load multiple bluebird copies introduced in 2.9.22 ([#559](.), [#561](.), [#560](.)).
+
+## 2.9.23 (2015-04-02)
+
+Bugfixes:
+
+ - Fix node.js domain propagation ([#521](.)).
+
+## 2.9.22 (2015-04-02)
+
+ - Fix `.promisify` crashing in phantom JS ([#556](.))
+
+## 2.9.21 (2015-03-30)
+
+ - Fix error object's `'stack'`' overwriting causing an error when its defined to be a setter that throws an error ([#552](.)).
+
+## 2.9.20 (2015-03-29)
+
+Bugfixes:
+
+ - Fix regression where there is a long delay between calling `.cancel()` and promise actually getting cancelled in Chrome when long stack traces are enabled
+
+## 2.9.19 (2015-03-29)
+
+Bugfixes:
+
+ - Fix crashing in Chrome when long stack traces are disabled
+
+## 2.9.18 (2015-03-29)
+
+Bugfixes:
+
+ - Fix settlePromises using trampoline
+
+## 2.9.17 (2015-03-29)
+
+
+Bugfixes:
+
+ - Fix Chrome DevTools async stack traceability ([#542](.)).
+
+## 2.9.16 (2015-03-28)
+
+Features:
+
+ - Use setImmediate if available
+
+## 2.9.15 (2015-03-26)
+
+Features:
+
+ - Added `.asCallback` alias for `.nodeify`.
+
+Bugfixes:
+
+ - Don't always use nextTick, but try to pick up setImmediate or setTimeout in NW. Fixes [#534](.), [#525](.)
+ - Make progress a core feature. Fixes [#535](.) Note that progress has been removed in 3.x - this is only a fix necessary for 2.x custom builds.
+
+## 2.9.14 (2015-03-12)
+
+Bugfixes:
+
+ - Always use process.nextTick. Fixes [#525](.)
+
+## 2.9.13 (2015-02-27)
+
+Bugfixes:
+
+ - Fix .each, .filter, .reduce and .map callbacks being called synchornously if the input is immediate. ([#513](.))
+
+## 2.9.12 (2015-02-19)
+
+Bugfixes:
+
+ - Fix memory leak introduced in 2.9.0 ([#502](.))
+
+## 2.9.11 (2015-02-19)
+
+Bugfixes:
+
+ - Fix [#503](.)
+
+## 2.9.10 (2015-02-18)
+
+Bugfixes:
+
+ - Fix [#501](.)
+
+## 2.9.9 (2015-02-12)
+
+Bugfixes:
+
+ - Fix `TypeError: Cannot assign to read only property 'length'` when jsdom has declared a read-only length for all objects to inherit.
+
+## 2.9.8 (2015-02-10)
+
+Bugfixes:
+
+ - Fix regression introduced in 2.9.7 where promisify didn't properly dynamically look up methods on `this`
+
+## 2.9.7 (2015-02-08)
+
+Bugfixes:
+
+ - Fix `promisify` not retaining custom properties of the function. This enables promisifying the `"request"` module's export function and its methods at the same time.
+ - Fix `promisifyAll` methods being dependent on `this` when they are not originally dependent on `this`. This enables e.g. passing promisified `fs` functions directly as callbacks without having to bind them to `fs`.
+ - Fix `process.nextTick` being used over `setImmediate` in node.
+
+## 2.9.6 (2015-02-02)
+
+Bugfixes:
+
+ - Node environment detection can no longer be fooled
+
+## 2.9.5 (2015-02-02)
+
+Misc:
+
+ - Warn when [`.then()`](.) is passed non-functions
+
+## 2.9.4 (2015-01-30)
+
+Bugfixes:
+
+ - Fix [.timeout()](.) not calling `clearTimeout` with the proper handle in node causing the process to wait for unneeded timeout. This was a regression introduced in 2.9.1.
+
+## 2.9.3 (2015-01-27)
+
+Bugfixes:
+
+ - Fix node-webkit compatibility issue ([#467](https://github.com/petkaantonov/bluebird/pull/467))
+ - Fix long stack trace support in recent firefox versions
+
+## 2.9.2 (2015-01-26)
+
+Bugfixes:
+
+ - Fix critical bug regarding to using promisifyAll in browser that was introduced in 2.9.0 ([#466](https://github.com/petkaantonov/bluebird/issues/466)).
+
+Misc:
+
+ - Add `"browser"` entry point to package.json
+
+## 2.9.1 (2015-01-24)
+
+Features:
+
+ - If a bound promise is returned by the callback to [`Promise.method`](#promisemethodfunction-fn---function) and [`Promise.try`](#promisetryfunction-fn--arraydynamicdynamic-arguments--dynamic-ctx----promise), the returned promise will be bound to the same value
+
+## 2.9.0 (2015-01-24)
+
+Features:
+
+ - Add [`Promise.fromNode`](API.md#promisefromnodefunction-resolver---promise)
+ - Add new paramter `value` for [`Promise.bind`](API.md#promisebinddynamic-thisarg--dynamic-value---promise)
+
+Bugfixes:
+
+ - Fix several issues with [`cancellation`](API.md#cancellation) and [`.bind()`](API.md#binddynamic-thisarg---promise) interoperation when `thisArg` is a promise or thenable
+ - Fix promises created in [`disposers`](API#disposerfunction-disposer---disposer) not having proper long stack trace context
+ - Fix [`Promise.join`](API.md#promisejoinpromisethenablevalue-promises-function-handler---promise) sometimes passing the passed in callback function as the last argument to itself.
+
+Misc:
+
+ - Reduce minified full browser build file size by not including unused code generation functionality.
+ - Major internal refactoring related to testing code and source code file layout
+
+## 2.8.2 (2015-01-20)
+
+Features:
+
+ - [Global rejection events](https://github.com/petkaantonov/bluebird/blob/master/API.md#global-rejection-events) are now fired both as DOM3 events and as legacy events in browsers
+
+## 2.8.1 (2015-01-20)
+
+Bugfixes:
+
+ - Fix long stack trace stiching consistency when rejected from thenables
+
+## 2.8.0 (2015-01-19)
+
+Features:
+
+ - Major debuggability improvements:
+ - Long stack traces have been re-designed. They are now much more readable,
+ succint, relevant and consistent across bluebird features.
+ - Long stack traces are supported now in IE10+
+
+## 2.7.1 (2015-01-15)
+
+Bugfixes:
+
+ - Fix [#447](https://github.com/petkaantonov/bluebird/issues/447)
+
+## 2.7.0 (2015-01-15)
+
+Features:
+
+ - Added more context to stack traces originating from coroutines ([#421](https://github.com/petkaantonov/bluebird/issues/421))
+ - Implemented [global rejection events](https://github.com/petkaantonov/bluebird/blob/master/API.md#global-rejection-events) ([#428](https://github.com/petkaantonov/bluebird/issues/428), [#357](https://github.com/petkaantonov/bluebird/issues/357))
+ - [Custom promisifiers](https://github.com/petkaantonov/bluebird/blob/master/API.md#option-promisifier) are now passed the default promisifier which can be used to add enhancements on top of normal node promisification
+ - [Promisification filters](https://github.com/petkaantonov/bluebird/blob/master/API.md#option-filter) are now passed `passesDefaultFilter` boolean
+
+Bugfixes:
+
+ - Fix `.noConflict()` call signature ([#446]())
+ - Fix `Promise.method`ified functions being called with `undefined` when they were called with no arguments
+
+## 2.6.4 (2015-01-12)
+
+Bugfixes:
+
+ - `OperationalErrors` thrown by promisified functions retain custom properties, such as `.code` and `.path`.
+
+## 2.6.3 (2015-01-12)
+
+Bugfixes:
+
+ - Fix [#429](https://github.com/petkaantonov/bluebird/issues/429)
+ - Fix [#432](https://github.com/petkaantonov/bluebird/issues/432)
+ - Fix [#433](https://github.com/petkaantonov/bluebird/issues/433)
+
+## 2.6.2 (2015-01-07)
+
+Bugfixes:
+
+ - Fix [#426](https://github.com/petkaantonov/bluebird/issues/426)
+
+## 2.6.1 (2015-01-07)
+
+Bugfixes:
+
+ - Fixed built browser files not being included in the git tag release for bower
+
+## 2.6.0 (2015-01-06)
+
+Features:
+
+ - Significantly improve parallel promise performance and memory usage (+50% faster, -50% less memory)
+
+
+## 2.5.3 (2014-12-30)
+
+## 2.5.2 (2014-12-29)
+
+Bugfixes:
+
+ - Fix bug where already resolved promise gets attached more handlers while calling its handlers resulting in some handlers not being called
+ - Fix bug where then handlers are not called in the same order as they would run if Promises/A+ 2.3.2 was implemented as adoption
+ - Fix bug where using `Object.create(null)` as a rejection reason would crash bluebird
+
+## 2.5.1 (2014-12-29)
+
+Bugfixes:
+
+ - Fix `.finally` throwing null error when it is derived from a promise that is resolved with a promise that is resolved with a promise
+
+## 2.5.0 (2014-12-28)
+
+Features:
+
+ - [`.get`](#API.md#https://github.com/petkaantonov/bluebird/blob/master/API.md#getstring-propertyname---promise) now supports negative indexing.
+
+Bugfixes:
+
+ - Fix bug with `Promise.method` wrapped function returning a promise that never resolves if the function returns a promise that is resolved with another promise
+ - Fix bug with `Promise.delay` never resolving if the value is a promise that is resolved with another promise
+
+## 2.4.3 (2014-12-28)
+
+Bugfixes:
+
+ - Fix memory leak as described in [this Promises/A+ spec issue](https://github.com/promises-aplus/promises-spec/issues/179).
+
+## 2.4.2 (2014-12-21)
+
+Bugfixes:
+
+ - Fix bug where spread rejected handler is ignored in case of rejection
+ - Fix synchronous scheduler passed to `setScheduler` causing infinite loop
+
+## 2.4.1 (2014-12-20)
+
+Features:
+
+ - Error messages now have links to wiki pages for additional information
+ - Promises now clean up all references (to handlers, child promises etc) as soon as possible.
+
+## 2.4.0 (2014-12-18)
+
+Features:
+
+ - Better filtering of bluebird internal calls in long stack traces, especially when using minified file in browsers
+ - Small performance improvements for all collection methods
+ - Promises now delete references to handlers attached to them as soon as possible
+ - Additional stack traces are now output on stderr/`console.warn` for errors that are thrown in the process/window from rejected `.done()` promises. See [#411](https://github.com/petkaantonov/bluebird/issues/411)
+
+## 2.3.11 (2014-10-31)
+
+Bugfixes:
+
+ - Fix [#371](https://github.com/petkaantonov/bluebird/issues/371), [#373](https://github.com/petkaantonov/bluebird/issues/373)
+
+
+## 2.3.10 (2014-10-28)
+
+Features:
+
+ - `Promise.method` no longer wraps primitive errors
+ - `Promise.try` no longer wraps primitive errors
+
+## 2.3.7 (2014-10-25)
+
+Bugfixes:
+
+ - Fix [#359](https://github.com/petkaantonov/bluebird/issues/359), [#362](https://github.com/petkaantonov/bluebird/issues/362) and [#364](https://github.com/petkaantonov/bluebird/issues/364)
+
+## 2.3.6 (2014-10-15)
+
+Features:
+
+ - Implement [`.reflect()`](API.md#reflect---promisepromiseinspection)
+
+## 2.3.5 (2014-10-06)
+
+Bugfixes:
+
+ - Fix issue when promisifying methods whose names contain the string 'args'
+
+## 2.3.4 (2014-09-27)
+
+ - `P` alias was not declared inside WebWorkers
+
+## 2.3.3 (2014-09-27)
+
+Bugfixes:
+
+ - Fix [#318](https://github.com/petkaantonov/bluebird/issues/318), [#314](https://github.com/petkaantonov/bluebird/issues/#314)
+
+## 2.3.2 (2014-08-25)
+
+Bugfixes:
+
+ - `P` alias for `Promise` now exists in global scope when using browser builds without a module loader, fixing an issue with firefox extensions
+
+## 2.3.1 (2014-08-23)
+
+Features:
+
+ - `.using` can now be used with disposers created from different bluebird copy
+
+## 2.3.0 (2014-08-13)
+
+Features:
+
+ - [`.bind()`](API.md#binddynamic-thisarg---promise) and [`Promise.bind()`](API.md#promisebinddynamic-thisarg---promise) now await for the resolution of the `thisArg` if it's a promise or a thenable
+
+Bugfixes:
+
+ - Fix [#276](https://github.com/petkaantonov/bluebird/issues/276)
+
+## 2.2.2 (2014-07-14)
+
+ - Fix [#259](https://github.com/petkaantonov/bluebird/issues/259)
+
+## 2.2.1 (2014-07-07)
+
+ - Fix multiline error messages only showing the first line
+
+## 2.2.0 (2014-07-07)
+
+Bugfixes:
+
+ - `.any` and `.some` now consistently reject with RangeError when input array contains too few promises
+ - Fix iteration bug with `.reduce` when input array contains already fulfilled promises
+
+## 2.1.3 (2014-06-18)
+
+Bugfixes:
+
+ - Fix [#235](https://github.com/petkaantonov/bluebird/issues/235)
+
+## 2.1.2 (2014-06-15)
+
+Bugfixes:
+
+ - Fix [#232](https://github.com/petkaantonov/bluebird/issues/232)
+
+## 2.1.1 (2014-06-11)
+
+## 2.1.0 (2014-06-11)
+
+Features:
+
+ - Add [`promisifier`](API.md#option-promisifier) option to `Promise.promisifyAll()`
+ - Improve performance of `.props()` and collection methods when used with immediate values
+
+
+Bugfixes:
+
+ - Fix a bug where .reduce calls the callback for an already visited item
+ - Fix a bug where stack trace limit is calculated to be too small, which resulted in too short stack traces
+
+<sub>Add undocumented experimental `yieldHandler` option to `Promise.coroutine`</sub>
+
+## 2.0.7 (2014-06-08)
+## 2.0.6 (2014-06-07)
+## 2.0.5 (2014-06-05)
+## 2.0.4 (2014-06-05)
+## 2.0.3 (2014-06-05)
+## 2.0.2 (2014-06-04)
+## 2.0.1 (2014-06-04)
+
+## 2.0.0 (2014-06-04)
+
+#What's new in 2.0
+
+- [Resource management](API.md#resource-management) - never leak resources again
+- [Promisification](API.md#promisification) on steroids - entire modules can now be promisified with one line of code
+- [`.map()`](API.md#mapfunction-mapper--object-options---promise), [`.each()`](API.md#eachfunction-iterator---promise), [`.filter()`](API.md#filterfunction-filterer--object-options---promise), [`.reduce()`](API.md#reducefunction-reducer--dynamic-initialvalue---promise) reimagined from simple sugar to powerful concurrency coordination tools
+- [API Documentation](API.md) has been reorganized and more elaborate examples added
+- Deprecated [progression](#progression-migration) and [deferreds](#deferred-migration)
+- Improved performance and readability
+
+Features:
+
+- Added [`using()`](API.md#promiseusingpromisedisposer-promise-promisedisposer-promise--function-handler---promise) and [`disposer()`](API.md#disposerfunction-disposer---disposer)
+- [`.map()`](API.md#mapfunction-mapper--object-options---promise) now calls the handler as soon as items in the input array become fulfilled
+- Added a concurrency option to [`.map()`](API.md#mapfunction-mapper--object-options---promise)
+- [`.filter()`](API.md#filterfunction-filterer--object-options---promise) now calls the handler as soon as items in the input array become fulfilled
+- Added a concurrency option to [`.filter()`](API.md#filterfunction-filterer--object-options---promise)
+- [`.reduce()`](API.md#reducefunction-reducer--dynamic-initialvalue---promise) now calls the handler as soon as items in the input array become fulfilled, but in-order
+- Added [`.each()`](API.md#eachfunction-iterator---promise)
+- [`Promise.resolve()`](API.md#promiseresolvedynamic-value---promise) behaves like `Promise.cast`. `Promise.cast` deprecated.
+- [Synchronous inspection](API.md#synchronous-inspection): Removed `.inspect()`, added [`.value()`](API.md#value---dynamic) and [`.reason()`](API.md#reason---dynamic)
+- [`Promise.join()`](API.md#promisejoinpromisethenablevalue-promises-function-handler---promise) now takes a function as the last argument
+- Added [`Promise.setScheduler()`](API.md#promisesetschedulerfunction-scheduler---void)
+- [`.cancel()`](API.md#cancelerror-reason---promise) supports a custom cancellation reason
+- [`.timeout()`](API.md#timeoutint-ms--string-message---promise) now cancels the promise instead of rejecting it
+- [`.nodeify()`](API.md#nodeifyfunction-callback--object-options---promise) now supports passing multiple success results when mapping promises to nodebacks
+- Added `suffix` and `filter` options to [`Promise.promisifyAll()`](API.md#promisepromisifyallobject-target--object-options---object)
+
+Breaking changes:
+
+- Sparse array holes are not skipped by collection methods but treated as existing elements with `undefined` value
+- `.map()` and `.filter()` do not call the given mapper or filterer function in any specific order
+- Removed the `.inspect()` method
+- Yielding an array from a coroutine is not supported by default. You can use [`coroutine.addYieldHandler()`](API.md#promisecoroutineaddyieldhandlerfunction-handler---void) to configure the old behavior (or any behavior you want).
+- [`.any()`](API.md#any---promise) and [`.some()`](API.md#someint-count---promise) no longer use an array as the rejection reason. [`AggregateError`](API.md#aggregateerror) is used instead.
+
+
+## 1.2.4 (2014-04-27)
+
+Bugfixes:
+
+ - Fix promisifyAll causing a syntax error when a method name is not a valid identifier
+ - Fix syntax error when es5.js is used in strict mode
+
+## 1.2.3 (2014-04-17)
+
+Bugfixes:
+
+ - Fix [#179](https://github.com/petkaantonov/bluebird/issues/179)
+
+## 1.2.2 (2014-04-09)
+
+Bugfixes:
+
+ - Promisified methods from promisifyAll no longer call the original method when it is overriden
+ - Nodeify doesn't pass second argument to the callback if the promise is fulfilled with `undefined`
+
+## 1.2.1 (2014-03-31)
+
+Bugfixes:
+
+ - Fix [#168](https://github.com/petkaantonov/bluebird/issues/168)
+
+## 1.2.0 (2014-03-29)
+
+Features:
+
+ - New method: [`.value()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#value---dynamic)
+ - New method: [`.reason()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#reason---dynamic)
+ - New method: [`Promise.onUnhandledRejectionHandled()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#promiseonunhandledrejectionhandledfunction-handler---undefined)
+ - `Promise.map()`, `.map()`, `Promise.filter()` and `.filter()` start calling their callbacks as soon as possible while retaining a correct order. See [`8085922f`](https://github.com/petkaantonov/bluebird/commit/8085922fb95a9987fda0cf2337598ab4a98dc315).
+
+Bugfixes:
+
+ - Fix [#165](https://github.com/petkaantonov/bluebird/issues/165)
+ - Fix [#166](https://github.com/petkaantonov/bluebird/issues/166)
+
+## 1.1.1 (2014-03-18)
+
+Bugfixes:
+
+ - [#138](https://github.com/petkaantonov/bluebird/issues/138)
+ - [#144](https://github.com/petkaantonov/bluebird/issues/144)
+ - [#148](https://github.com/petkaantonov/bluebird/issues/148)
+ - [#151](https://github.com/petkaantonov/bluebird/issues/151)
+
+## 1.1.0 (2014-03-08)
+
+Features:
+
+ - Implement [`Promise.prototype.tap()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#tapfunction-handler---promise)
+ - Implement [`Promise.coroutine.addYieldHandler()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisecoroutineaddyieldhandlerfunction-handler---void)
+ - Deprecate `Promise.prototype.spawn`
+
+Bugfixes:
+
+ - Fix already rejected promises being reported as unhandled when handled through collection methods
+ - Fix browserisfy crashing from checking `process.version.indexOf`
+
+## 1.0.8 (2014-03-03)
+
+Bugfixes:
+
+ - Fix active domain being lost across asynchronous boundaries in Node.JS 10.xx
+
+## 1.0.7 (2014-02-25)
+
+Bugfixes:
+
+ - Fix handled errors being reported
+
+## 1.0.6 (2014-02-17)
+
+Bugfixes:
+
+ - Fix bug with unhandled rejections not being reported
+ when using `Promise.try` or `Promise.method` without
+ attaching further handlers
+
+## 1.0.5 (2014-02-15)
+
+Features:
+
+ - Node.js performance: promisified functions try to check amount of passed arguments in most optimal order
+ - Node.js promisified functions will have same `.length` as the original function minus one (for the callback parameter)
+
+## 1.0.4 (2014-02-09)
+
+Features:
+
+ - Possibly unhandled rejection handler will always get a stack trace, even if the rejection or thrown error was not an error
+ - Unhandled rejections are tracked per promise, not per error. So if you create multiple branches from a single ancestor and that ancestor gets rejected, each branch with no error handler with the end will cause a possibly unhandled rejection handler invocation
+
+Bugfixes:
+
+ - Fix unhandled non-writable objects or primitives not reported by possibly unhandled rejection handler
+
+## 1.0.3 (2014-02-05)
+
+Bugfixes:
+
+ - [#93](https://github.com/petkaantonov/bluebird/issues/88)
+
+## 1.0.2 (2014-02-04)
+
+Features:
+
+ - Significantly improve performance of foreign bluebird thenables
+
+Bugfixes:
+
+ - [#88](https://github.com/petkaantonov/bluebird/issues/88)
+
+## 1.0.1 (2014-01-28)
+
+Features:
+
+ - Error objects that have property `.isAsync = true` will now be caught by `.error()`
+
+Bugfixes:
+
+ - Fix TypeError and RangeError shims not working without `new` operator
+
+## 1.0.0 (2014-01-12)
+
+Features:
+
+ - `.filter`, `.map`, and `.reduce` no longer skip sparse array holes. This is a backwards incompatible change.
+ - Like `.map` and `.filter`, `.reduce` now allows returning promises and thenables from the iteration function.
+
+Bugfixes:
+
+ - [#58](https://github.com/petkaantonov/bluebird/issues/58)
+ - [#61](https://github.com/petkaantonov/bluebird/issues/61)
+ - [#64](https://github.com/petkaantonov/bluebird/issues/64)
+ - [#60](https://github.com/petkaantonov/bluebird/issues/60)
+
+## 0.11.6-1 (2013-12-29)
+
+## 0.11.6-0 (2013-12-29)
+
+Features:
+
+ - You may now return promises and thenables from the filterer function used in `Promise.filter` and `Promise.prototype.filter`.
+
+ - `.error()` now catches additional sources of rejections:
+
+ - Rejections originating from `Promise.reject`
+
+ - Rejections originating from thenables using
+ the `reject` callback
+
+ - Rejections originating from promisified callbacks
+ which use the `errback` argument
+
+ - Rejections originating from `new Promise` constructor
+ where the `reject` callback is called explicitly
+
+ - Rejections originating from `PromiseResolver` where
+ `.reject()` method is called explicitly
+
+Bugfixes:
+
+ - Fix `captureStackTrace` being called when it was `null`
+ - Fix `Promise.map` not unwrapping thenables
+
+## 0.11.5-1 (2013-12-15)
+
+## 0.11.5-0 (2013-12-03)
+
+Features:
+
+ - Improve performance of collection methods
+ - Improve performance of promise chains
+
+## 0.11.4-1 (2013-12-02)
+
+## 0.11.4-0 (2013-12-02)
+
+Bugfixes:
+
+ - Fix `Promise.some` behavior with arguments like negative integers, 0...
+ - Fix stack traces of synchronously throwing promisified functions'
+
+## 0.11.3-0 (2013-12-02)
+
+Features:
+
+ - Improve performance of generators
+
+Bugfixes:
+
+ - Fix critical bug with collection methods.
+
+## 0.11.2-0 (2013-12-02)
+
+Features:
+
+ - Improve performance of all collection methods
+
+## 0.11.1-0 (2013-12-02)
+
+Features:
+
+- Improve overall performance.
+- Improve performance of promisified functions.
+- Improve performance of catch filters.
+- Improve performance of .finally.
+
+Bugfixes:
+
+- Fix `.finally()` rejecting if passed non-function. It will now ignore non-functions like `.then`.
+- Fix `.finally()` not converting thenables returned from the handler to promises.
+- `.spread()` now rejects if the ultimate value given to it is not spreadable.
+
+## 0.11.0-0 (2013-12-02)
+
+Features:
+
+ - Improve overall performance when not using `.bind()` or cancellation.
+ - Promises are now not cancellable by default. This is backwards incompatible change - see [`.cancellable()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#cancellable---promise)
+ - [`Promise.delay`](https://github.com/petkaantonov/bluebird/blob/master/API.md#promisedelaydynamic-value-int-ms---promise)
+ - [`.delay()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#delayint-ms---promise)
+ - [`.timeout()`](https://github.com/petkaantonov/bluebird/blob/master/API.md#timeoutint-ms--string-message---promise)
+
+## 0.10.14-0 (2013-12-01)
+
+Bugfixes:
+
+ - Fix race condition when mixing 3rd party asynchrony.
+
+## 0.10.13-1 (2013-11-30)
+
+## 0.10.13-0 (2013-11-30)
+
+Bugfixes:
+
+ - Fix another bug with progression.
+
+## 0.10.12-0 (2013-11-30)
+
+Bugfixes:
+
+ - Fix bug with progression.
+
+## 0.10.11-4 (2013-11-29)
+
+## 0.10.11-2 (2013-11-29)
+
+Bugfixes:
+
+ - Fix `.race()` not propagating bound values.
+
+## 0.10.11-1 (2013-11-29)
+
+Features:
+
+ - Improve performance of `Promise.race`
+
+## 0.10.11-0 (2013-11-29)
+
+Bugfixes:
+
+ - Fixed `Promise.promisifyAll` invoking property accessors. Only data properties with function values are considered.
+
+## 0.10.10-0 (2013-11-28)
+
+Features:
+
+ - Disable long stack traces in browsers by default. Call `Promise.longStackTraces()` to enable them.
+
+## 0.10.9-1 (2013-11-27)
+
+Bugfixes:
+
+ - Fail early when `new Promise` is constructed incorrectly
+
+## 0.10.9-0 (2013-11-27)
+
+Bugfixes:
+
+ - Promise.props now takes a [thenable-for-collection](https://github.com/petkaantonov/bluebird/blob/f41edac61b7c421608ff439bb5a09b7cffeadcf9/test/mocha/props.js#L197-L217)
+ - All promise collection methods now reject when a promise-or-thenable-for-collection turns out not to give a collection
+
+## 0.10.8-0 (2013-11-25)
+
+Features:
+
+ - All static collection methods take thenable-for-collection
+
+## 0.10.7-0 (2013-11-25)
+
+Features:
+
+ - throw TypeError when thenable resolves with itself
+ - Make .race() and Promise.race() forever pending on empty collections
+
+## 0.10.6-0 (2013-11-25)
+
+Bugfixes:
+
+ - Promise.resolve and PromiseResolver.resolve follow thenables too.
+
+## 0.10.5-0 (2013-11-24)
+
+Bugfixes:
+
+ - Fix infinite loop when thenable resolves with itself
+
+## 0.10.4-1 (2013-11-24)
+
+Bugfixes:
+
+ - Fix a file missing from build. (Critical fix)
+
+## 0.10.4-0 (2013-11-24)
+
+Features:
+
+ - Remove dependency of es5-shim and es5-sham when using ES3.
+
+## 0.10.3-0 (2013-11-24)
+
+Features:
+
+ - Improve performance of `Promise.method`
+
+## 0.10.2-1 (2013-11-24)
+
+Features:
+
+ - Rename PromiseResolver#asCallback to PromiseResolver#callback
+
+## 0.10.2-0 (2013-11-24)
+
+Features:
+
+ - Remove memoization of thenables
+
+## 0.10.1-0 (2013-11-21)
+
+Features:
+
+ - Add methods `Promise.resolve()`, `Promise.reject()`, `Promise.defer()` and `.resolve()`.
+
+## 0.10.0-1 (2013-11-17)
+
+## 0.10.0-0 (2013-11-17)
+
+Features:
+
+ - Implement `Promise.method()`
+ - Implement `.return()`
+ - Implement `.throw()`
+
+Bugfixes:
+
+ - Fix promises being able to use themselves as resolution or follower value
+
+## 0.9.11-1 (2013-11-14)
+
+Features:
+
+ - Implicit `Promise.all()` when yielding an array from generators
+
+## 0.9.11-0 (2013-11-13)
+
+Bugfixes:
+
+ - Fix `.spread` not unwrapping thenables
+
+## 0.9.10-2 (2013-11-13)
+
+Features:
+
+ - Improve performance of promisified functions on V8
+
+Bugfixes:
+
+ - Report unhandled rejections even when long stack traces are disabled
+ - Fix `.error()` showing up in stack traces
+
+## 0.9.10-1 (2013-11-05)
+
+Bugfixes:
+
+ - Catch filter method calls showing in stack traces
+
+## 0.9.10-0 (2013-11-05)
+
+Bugfixes:
+
+ - Support primitives in catch filters
+
+## 0.9.9-0 (2013-11-05)
+
+Features:
+
+ - Add `Promise.race()` and `.race()`
+
+## 0.9.8-0 (2013-11-01)
+
+Bugfixes:
+
+ - Fix bug with `Promise.try` not unwrapping returned promises and thenables
+
+## 0.9.7-0 (2013-10-29)
+
+Bugfixes:
+
+ - Fix bug with build files containing duplicated code for promise.js
+
+## 0.9.6-0 (2013-10-28)
+
+Features:
+
+ - Improve output of reporting unhandled non-errors
+ - Implement RejectionError wrapping and `.error()` method
+
+## 0.9.5-0 (2013-10-27)
+
+Features:
+
+ - Allow fresh copies of the library to be made
+
+## 0.9.4-1 (2013-10-27)
+
+## 0.9.4-0 (2013-10-27)
+
+Bugfixes:
+
+ - Rollback non-working multiple fresh copies feature
+
+## 0.9.3-0 (2013-10-27)
+
+Features:
+
+ - Allow fresh copies of the library to be made
+ - Add more components to customized builds
+
+## 0.9.2-1 (2013-10-25)
+
+## 0.9.2-0 (2013-10-25)
+
+Features:
+
+ - Allow custom builds
+
+## 0.9.1-1 (2013-10-22)
+
+Bugfixes:
+
+ - Fix unhandled rethrown exceptions not reported
+
+## 0.9.1-0 (2013-10-22)
+
+Features:
+
+ - Improve performance of `Promise.try`
+ - Extend `Promise.try` to accept arguments and ctx to make it more usable in promisification of synchronous functions.
+
+## 0.9.0-0 (2013-10-18)
+
+Features:
+
+ - Implement `.bind` and `Promise.bind`
+
+Bugfixes:
+
+ - Fix `.some()` when argument is a pending promise that later resolves to an array
+
+## 0.8.5-1 (2013-10-17)
+
+Features:
+
+ - Enable process wide long stack traces through BLUEBIRD_DEBUG environment variable
+
+## 0.8.5-0 (2013-10-16)
+
+Features:
+
+ - Improve performance of all collection methods
+
+Bugfixes:
+
+ - Fix .finally passing the value to handlers
+ - Remove kew from benchmarks due to bugs in the library breaking the benchmark
+ - Fix some bluebird library calls potentially appearing in stack traces
+
+## 0.8.4-1 (2013-10-15)
+
+Bugfixes:
+
+ - Fix .pending() call showing in long stack traces
+
+## 0.8.4-0 (2013-10-15)
+
+Bugfixes:
+
+ - Fix PromiseArray and its sub-classes swallowing possibly unhandled rejections
+
+## 0.8.3-3 (2013-10-14)
+
+Bugfixes:
+
+ - Fix AMD-declaration using named module.
+
+## 0.8.3-2 (2013-10-14)
+
+Features:
+
+ - The mortals that can handle it may now release Zalgo by `require("bluebird/zalgo");`
+
+## 0.8.3-1 (2013-10-14)
+
+Bugfixes:
+
+ - Fix memory leak when using the same promise to attach handlers over and over again
+
+## 0.8.3-0 (2013-10-13)
+
+Features:
+
+ - Add `Promise.props()` and `Promise.prototype.props()`. They work like `.all()` for object properties.
+
+Bugfixes:
+
+ - Fix bug with .some returning garbage when sparse arrays have rejections
+
+## 0.8.2-2 (2013-10-13)
+
+Features:
+
+ - Improve performance of `.reduce()` when `initialValue` can be synchronously cast to a value
+
+## 0.8.2-1 (2013-10-12)
+
+Bugfixes:
+
+ - Fix .npmignore having irrelevant files
+
+## 0.8.2-0 (2013-10-12)
+
+Features:
+
+ - Improve performance of `.some()`
+
+## 0.8.1-0 (2013-10-11)
+
+Bugfixes:
+
+ - Remove uses of dynamic evaluation (`new Function`, `eval` etc) when strictly not necessary. Use feature detection to use static evaluation to avoid errors when dynamic evaluation is prohibited.
+
+## 0.8.0-3 (2013-10-10)
+
+Features:
+
+ - Add `.asCallback` property to `PromiseResolver`s
+
+## 0.8.0-2 (2013-10-10)
+
+## 0.8.0-1 (2013-10-09)
+
+Features:
+
+ - Improve overall performance. Be able to sustain infinite recursion when using promises.
+
+## 0.8.0-0 (2013-10-09)
+
+Bugfixes:
+
+ - Fix stackoverflow error when function calls itself "synchronously" from a promise handler
+
+## 0.7.12-2 (2013-10-09)
+
+Bugfixes:
+
+ - Fix safari 6 not using `MutationObserver` as a scheduler
+ - Fix process exceptions interfering with internal queue flushing
+
+## 0.7.12-1 (2013-10-09)
+
+Bugfixes:
+
+ - Don't try to detect if generators are available to allow shims to be used
+
+## 0.7.12-0 (2013-10-08)
+
+Features:
+
+ - Promisification now consider all functions on the object and its prototype chain
+ - Individual promisifcation uses current `this` if no explicit receiver is given
+ - Give better stack traces when promisified callbacks throw or errback primitives such as strings by wrapping them in an `Error` object.
+
+Bugfixes:
+
+ - Fix runtime APIs throwing synchronous errors
+
+## 0.7.11-0 (2013-10-08)
+
+Features:
+
+ - Deprecate `Promise.promisify(Object target)` in favor of `Promise.promisifyAll(Object target)` to avoid confusion with function objects
+ - Coroutines now throw error when a non-promise is `yielded`
+
+## 0.7.10-1 (2013-10-05)
+
+Features:
+
+ - Make tests pass Internet Explorer 8
+
+## 0.7.10-0 (2013-10-05)
+
+Features:
+
+ - Create browser tests
+
+## 0.7.9-1 (2013-10-03)
+
+Bugfixes:
+
+ - Fix promise cast bug when thenable fulfills using itself as the fulfillment value
+
+## 0.7.9-0 (2013-10-03)
+
+Features:
+
+ - More performance improvements when long stack traces are enabled
+
+## 0.7.8-1 (2013-10-02)
+
+Features:
+
+ - Performance improvements when long stack traces are enabled
+
+## 0.7.8-0 (2013-10-02)
+
+Bugfixes:
+
+ - Fix promisified methods not turning synchronous exceptions into rejections
+
+## 0.7.7-1 (2013-10-02)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.7-0 (2013-10-01)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.6-0 (2013-09-29)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.5-0 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.4-1 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.4-0 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.3-1 (2013-09-28)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.3-0 (2013-09-27)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.2-0 (2013-09-27)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-5 (2013-09-26)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-4 (2013-09-25)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-3 (2013-09-25)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-2 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-1 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.1-0 (2013-09-24)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.0-1 (2013-09-23)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.7.0-0 (2013-09-23)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-2 (2013-09-20)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-1 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.5-0 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.4-1 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.4-0 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-4 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-3 (2013-09-18)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-2 (2013-09-16)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-1 (2013-09-16)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.3-0 (2013-09-15)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.2-1 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.2-0 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.1-0 (2013-09-14)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.6.0-0 (2013-09-13)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-6 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-5 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-4 (2013-09-12)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-3 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-2 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-1 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.9-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.8-1 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.8-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.7-0 (2013-09-11)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.6-1 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.6-0 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.5-1 (2013-09-10)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.5-0 (2013-09-09)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.4-1 (2013-09-08)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.4-0 (2013-09-08)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.3-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.2-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.1-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.5.0-0 (2013-09-07)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.4.0-0 (2013-09-06)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.3.0-1 (2013-09-06)
+
+Features:
+
+ - feature
+
+Bugfixes:
+
+ - bugfix
+
+## 0.3.0 (2013-09-06)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.js
new file mode 100644
index 0000000..58a08a3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.js
@@ -0,0 +1,4887 @@
+/* @preserve
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013-2015 Petka Antonov
+ *
+ * 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.
+ *
+ */
+/**
+ * bluebird build version 2.10.2
+ * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, cancel, using, filter, any, each, timers
+*/
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise) {
+var SomePromiseArray = Promise._SomePromiseArray;
+function any(promises) {
+ var ret = new SomePromiseArray(promises);
+ var promise = ret.promise();
+ ret.setHowMany(1);
+ ret.setUnwrap();
+ ret.init();
+ return promise;
+}
+
+Promise.any = function (promises) {
+ return any(promises);
+};
+
+Promise.prototype.any = function () {
+ return any(this);
+};
+
+};
+
+},{}],2:[function(_dereq_,module,exports){
+"use strict";
+var firstLineError;
+try {throw new Error(); } catch (e) {firstLineError = e;}
+var schedule = _dereq_("./schedule.js");
+var Queue = _dereq_("./queue.js");
+var util = _dereq_("./util.js");
+
+function Async() {
+ this._isTickUsed = false;
+ this._lateQueue = new Queue(16);
+ this._normalQueue = new Queue(16);
+ this._trampolineEnabled = true;
+ var self = this;
+ this.drainQueues = function () {
+ self._drainQueues();
+ };
+ this._schedule =
+ schedule.isStatic ? schedule(this.drainQueues) : schedule;
+}
+
+Async.prototype.disableTrampolineIfNecessary = function() {
+ if (util.hasDevTools) {
+ this._trampolineEnabled = false;
+ }
+};
+
+Async.prototype.enableTrampoline = function() {
+ if (!this._trampolineEnabled) {
+ this._trampolineEnabled = true;
+ this._schedule = function(fn) {
+ setTimeout(fn, 0);
+ };
+ }
+};
+
+Async.prototype.haveItemsQueued = function () {
+ return this._normalQueue.length() > 0;
+};
+
+Async.prototype.throwLater = function(fn, arg) {
+ if (arguments.length === 1) {
+ arg = fn;
+ fn = function () { throw arg; };
+ }
+ if (typeof setTimeout !== "undefined") {
+ setTimeout(function() {
+ fn(arg);
+ }, 0);
+ } else try {
+ this._schedule(function() {
+ fn(arg);
+ });
+ } catch (e) {
+ throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
+ }
+};
+
+function AsyncInvokeLater(fn, receiver, arg) {
+ this._lateQueue.push(fn, receiver, arg);
+ this._queueTick();
+}
+
+function AsyncInvoke(fn, receiver, arg) {
+ this._normalQueue.push(fn, receiver, arg);
+ this._queueTick();
+}
+
+function AsyncSettlePromises(promise) {
+ this._normalQueue._pushOne(promise);
+ this._queueTick();
+}
+
+if (!util.hasDevTools) {
+ Async.prototype.invokeLater = AsyncInvokeLater;
+ Async.prototype.invoke = AsyncInvoke;
+ Async.prototype.settlePromises = AsyncSettlePromises;
+} else {
+ if (schedule.isStatic) {
+ schedule = function(fn) { setTimeout(fn, 0); };
+ }
+ Async.prototype.invokeLater = function (fn, receiver, arg) {
+ if (this._trampolineEnabled) {
+ AsyncInvokeLater.call(this, fn, receiver, arg);
+ } else {
+ this._schedule(function() {
+ setTimeout(function() {
+ fn.call(receiver, arg);
+ }, 100);
+ });
+ }
+ };
+
+ Async.prototype.invoke = function (fn, receiver, arg) {
+ if (this._trampolineEnabled) {
+ AsyncInvoke.call(this, fn, receiver, arg);
+ } else {
+ this._schedule(function() {
+ fn.call(receiver, arg);
+ });
+ }
+ };
+
+ Async.prototype.settlePromises = function(promise) {
+ if (this._trampolineEnabled) {
+ AsyncSettlePromises.call(this, promise);
+ } else {
+ this._schedule(function() {
+ promise._settlePromises();
+ });
+ }
+ };
+}
+
+Async.prototype.invokeFirst = function (fn, receiver, arg) {
+ this._normalQueue.unshift(fn, receiver, arg);
+ this._queueTick();
+};
+
+Async.prototype._drainQueue = function(queue) {
+ while (queue.length() > 0) {
+ var fn = queue.shift();
+ if (typeof fn !== "function") {
+ fn._settlePromises();
+ continue;
+ }
+ var receiver = queue.shift();
+ var arg = queue.shift();
+ fn.call(receiver, arg);
+ }
+};
+
+Async.prototype._drainQueues = function () {
+ this._drainQueue(this._normalQueue);
+ this._reset();
+ this._drainQueue(this._lateQueue);
+};
+
+Async.prototype._queueTick = function () {
+ if (!this._isTickUsed) {
+ this._isTickUsed = true;
+ this._schedule(this.drainQueues);
+ }
+};
+
+Async.prototype._reset = function () {
+ this._isTickUsed = false;
+};
+
+module.exports = new Async();
+module.exports.firstLineError = firstLineError;
+
+},{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
+var rejectThis = function(_, e) {
+ this._reject(e);
+};
+
+var targetRejected = function(e, context) {
+ context.promiseRejectionQueued = true;
+ context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
+};
+
+var bindingResolved = function(thisArg, context) {
+ if (this._isPending()) {
+ this._resolveCallback(context.target);
+ }
+};
+
+var bindingRejected = function(e, context) {
+ if (!context.promiseRejectionQueued) this._reject(e);
+};
+
+Promise.prototype.bind = function (thisArg) {
+ var maybePromise = tryConvertToPromise(thisArg);
+ var ret = new Promise(INTERNAL);
+ ret._propagateFrom(this, 1);
+ var target = this._target();
+
+ ret._setBoundTo(maybePromise);
+ if (maybePromise instanceof Promise) {
+ var context = {
+ promiseRejectionQueued: false,
+ promise: ret,
+ target: target,
+ bindingPromise: maybePromise
+ };
+ target._then(INTERNAL, targetRejected, ret._progress, ret, context);
+ maybePromise._then(
+ bindingResolved, bindingRejected, ret._progress, ret, context);
+ } else {
+ ret._resolveCallback(target);
+ }
+ return ret;
+};
+
+Promise.prototype._setBoundTo = function (obj) {
+ if (obj !== undefined) {
+ this._bitField = this._bitField | 131072;
+ this._boundTo = obj;
+ } else {
+ this._bitField = this._bitField & (~131072);
+ }
+};
+
+Promise.prototype._isBound = function () {
+ return (this._bitField & 131072) === 131072;
+};
+
+Promise.bind = function (thisArg, value) {
+ var maybePromise = tryConvertToPromise(thisArg);
+ var ret = new Promise(INTERNAL);
+
+ ret._setBoundTo(maybePromise);
+ if (maybePromise instanceof Promise) {
+ maybePromise._then(function() {
+ ret._resolveCallback(value);
+ }, ret._reject, ret._progress, ret, null);
+ } else {
+ ret._resolveCallback(value);
+ }
+ return ret;
+};
+};
+
+},{}],4:[function(_dereq_,module,exports){
+"use strict";
+var old;
+if (typeof Promise !== "undefined") old = Promise;
+function noConflict() {
+ try { if (Promise === bluebird) Promise = old; }
+ catch (e) {}
+ return bluebird;
+}
+var bluebird = _dereq_("./promise.js")();
+bluebird.noConflict = noConflict;
+module.exports = bluebird;
+
+},{"./promise.js":23}],5:[function(_dereq_,module,exports){
+"use strict";
+var cr = Object.create;
+if (cr) {
+ var callerCache = cr(null);
+ var getterCache = cr(null);
+ callerCache[" size"] = getterCache[" size"] = 0;
+}
+
+module.exports = function(Promise) {
+var util = _dereq_("./util.js");
+var canEvaluate = util.canEvaluate;
+var isIdentifier = util.isIdentifier;
+
+var getMethodCaller;
+var getGetter;
+if (!true) {
+var makeMethodCaller = function (methodName) {
+ return new Function("ensureMethod", " \n\
+ return function(obj) { \n\
+ 'use strict' \n\
+ var len = this.length; \n\
+ ensureMethod(obj, 'methodName'); \n\
+ switch(len) { \n\
+ case 1: return obj.methodName(this[0]); \n\
+ case 2: return obj.methodName(this[0], this[1]); \n\
+ case 3: return obj.methodName(this[0], this[1], this[2]); \n\
+ case 0: return obj.methodName(); \n\
+ default: \n\
+ return obj.methodName.apply(obj, this); \n\
+ } \n\
+ }; \n\
+ ".replace(/methodName/g, methodName))(ensureMethod);
+};
+
+var makeGetter = function (propertyName) {
+ return new Function("obj", " \n\
+ 'use strict'; \n\
+ return obj.propertyName; \n\
+ ".replace("propertyName", propertyName));
+};
+
+var getCompiled = function(name, compiler, cache) {
+ var ret = cache[name];
+ if (typeof ret !== "function") {
+ if (!isIdentifier(name)) {
+ return null;
+ }
+ ret = compiler(name);
+ cache[name] = ret;
+ cache[" size"]++;
+ if (cache[" size"] > 512) {
+ var keys = Object.keys(cache);
+ for (var i = 0; i < 256; ++i) delete cache[keys[i]];
+ cache[" size"] = keys.length - 256;
+ }
+ }
+ return ret;
+};
+
+getMethodCaller = function(name) {
+ return getCompiled(name, makeMethodCaller, callerCache);
+};
+
+getGetter = function(name) {
+ return getCompiled(name, makeGetter, getterCache);
+};
+}
+
+function ensureMethod(obj, methodName) {
+ var fn;
+ if (obj != null) fn = obj[methodName];
+ if (typeof fn !== "function") {
+ var message = "Object " + util.classString(obj) + " has no method '" +
+ util.toString(methodName) + "'";
+ throw new Promise.TypeError(message);
+ }
+ return fn;
+}
+
+function caller(obj) {
+ var methodName = this.pop();
+ var fn = ensureMethod(obj, methodName);
+ return fn.apply(obj, this);
+}
+Promise.prototype.call = function (methodName) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ if (!true) {
+ if (canEvaluate) {
+ var maybeCaller = getMethodCaller(methodName);
+ if (maybeCaller !== null) {
+ return this._then(
+ maybeCaller, undefined, undefined, args, undefined);
+ }
+ }
+ }
+ args.push(methodName);
+ return this._then(caller, undefined, undefined, args, undefined);
+};
+
+function namedGetter(obj) {
+ return obj[this];
+}
+function indexedGetter(obj) {
+ var index = +this;
+ if (index < 0) index = Math.max(0, index + obj.length);
+ return obj[index];
+}
+Promise.prototype.get = function (propertyName) {
+ var isIndex = (typeof propertyName === "number");
+ var getter;
+ if (!isIndex) {
+ if (canEvaluate) {
+ var maybeGetter = getGetter(propertyName);
+ getter = maybeGetter !== null ? maybeGetter : namedGetter;
+ } else {
+ getter = namedGetter;
+ }
+ } else {
+ getter = indexedGetter;
+ }
+ return this._then(getter, undefined, undefined, propertyName, undefined);
+};
+};
+
+},{"./util.js":38}],6:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise) {
+var errors = _dereq_("./errors.js");
+var async = _dereq_("./async.js");
+var CancellationError = errors.CancellationError;
+
+Promise.prototype._cancel = function (reason) {
+ if (!this.isCancellable()) return this;
+ var parent;
+ var promiseToReject = this;
+ while ((parent = promiseToReject._cancellationParent) !== undefined &&
+ parent.isCancellable()) {
+ promiseToReject = parent;
+ }
+ this._unsetCancellable();
+ promiseToReject._target()._rejectCallback(reason, false, true);
+};
+
+Promise.prototype.cancel = function (reason) {
+ if (!this.isCancellable()) return this;
+ if (reason === undefined) reason = new CancellationError();
+ async.invokeLater(this._cancel, this, reason);
+ return this;
+};
+
+Promise.prototype.cancellable = function () {
+ if (this._cancellable()) return this;
+ async.enableTrampoline();
+ this._setCancellable();
+ this._cancellationParent = undefined;
+ return this;
+};
+
+Promise.prototype.uncancellable = function () {
+ var ret = this.then();
+ ret._unsetCancellable();
+ return ret;
+};
+
+Promise.prototype.fork = function (didFulfill, didReject, didProgress) {
+ var ret = this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+
+ ret._setCancellable();
+ ret._cancellationParent = undefined;
+ return ret;
+};
+};
+
+},{"./async.js":2,"./errors.js":13}],7:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function() {
+var async = _dereq_("./async.js");
+var util = _dereq_("./util.js");
+var bluebirdFramePattern =
+ /[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/;
+var stackFramePattern = null;
+var formatStack = null;
+var indentStackFrames = false;
+var warn;
+
+function CapturedTrace(parent) {
+ this._parent = parent;
+ var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
+ captureStackTrace(this, CapturedTrace);
+ if (length > 32) this.uncycle();
+}
+util.inherits(CapturedTrace, Error);
+
+CapturedTrace.prototype.uncycle = function() {
+ var length = this._length;
+ if (length < 2) return;
+ var nodes = [];
+ var stackToIndex = {};
+
+ for (var i = 0, node = this; node !== undefined; ++i) {
+ nodes.push(node);
+ node = node._parent;
+ }
+ length = this._length = i;
+ for (var i = length - 1; i >= 0; --i) {
+ var stack = nodes[i].stack;
+ if (stackToIndex[stack] === undefined) {
+ stackToIndex[stack] = i;
+ }
+ }
+ for (var i = 0; i < length; ++i) {
+ var currentStack = nodes[i].stack;
+ var index = stackToIndex[currentStack];
+ if (index !== undefined && index !== i) {
+ if (index > 0) {
+ nodes[index - 1]._parent = undefined;
+ nodes[index - 1]._length = 1;
+ }
+ nodes[i]._parent = undefined;
+ nodes[i]._length = 1;
+ var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
+
+ if (index < length - 1) {
+ cycleEdgeNode._parent = nodes[index + 1];
+ cycleEdgeNode._parent.uncycle();
+ cycleEdgeNode._length =
+ cycleEdgeNode._parent._length + 1;
+ } else {
+ cycleEdgeNode._parent = undefined;
+ cycleEdgeNode._length = 1;
+ }
+ var currentChildLength = cycleEdgeNode._length + 1;
+ for (var j = i - 2; j >= 0; --j) {
+ nodes[j]._length = currentChildLength;
+ currentChildLength++;
+ }
+ return;
+ }
+ }
+};
+
+CapturedTrace.prototype.parent = function() {
+ return this._parent;
+};
+
+CapturedTrace.prototype.hasParent = function() {
+ return this._parent !== undefined;
+};
+
+CapturedTrace.prototype.attachExtraTrace = function(error) {
+ if (error.__stackCleaned__) return;
+ this.uncycle();
+ var parsed = CapturedTrace.parseStackAndMessage(error);
+ var message = parsed.message;
+ var stacks = [parsed.stack];
+
+ var trace = this;
+ while (trace !== undefined) {
+ stacks.push(cleanStack(trace.stack.split("\n")));
+ trace = trace._parent;
+ }
+ removeCommonRoots(stacks);
+ removeDuplicateOrEmptyJumps(stacks);
+ util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
+ util.notEnumerableProp(error, "__stackCleaned__", true);
+};
+
+function reconstructStack(message, stacks) {
+ for (var i = 0; i < stacks.length - 1; ++i) {
+ stacks[i].push("From previous event:");
+ stacks[i] = stacks[i].join("\n");
+ }
+ if (i < stacks.length) {
+ stacks[i] = stacks[i].join("\n");
+ }
+ return message + "\n" + stacks.join("\n");
+}
+
+function removeDuplicateOrEmptyJumps(stacks) {
+ for (var i = 0; i < stacks.length; ++i) {
+ if (stacks[i].length === 0 ||
+ ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
+ stacks.splice(i, 1);
+ i--;
+ }
+ }
+}
+
+function removeCommonRoots(stacks) {
+ var current = stacks[0];
+ for (var i = 1; i < stacks.length; ++i) {
+ var prev = stacks[i];
+ var currentLastIndex = current.length - 1;
+ var currentLastLine = current[currentLastIndex];
+ var commonRootMeetPoint = -1;
+
+ for (var j = prev.length - 1; j >= 0; --j) {
+ if (prev[j] === currentLastLine) {
+ commonRootMeetPoint = j;
+ break;
+ }
+ }
+
+ for (var j = commonRootMeetPoint; j >= 0; --j) {
+ var line = prev[j];
+ if (current[currentLastIndex] === line) {
+ current.pop();
+ currentLastIndex--;
+ } else {
+ break;
+ }
+ }
+ current = prev;
+ }
+}
+
+function cleanStack(stack) {
+ var ret = [];
+ for (var i = 0; i < stack.length; ++i) {
+ var line = stack[i];
+ var isTraceLine = stackFramePattern.test(line) ||
+ " (No stack trace)" === line;
+ var isInternalFrame = isTraceLine && shouldIgnore(line);
+ if (isTraceLine && !isInternalFrame) {
+ if (indentStackFrames && line.charAt(0) !== " ") {
+ line = " " + line;
+ }
+ ret.push(line);
+ }
+ }
+ return ret;
+}
+
+function stackFramesAsArray(error) {
+ var stack = error.stack.replace(/\s+$/g, "").split("\n");
+ for (var i = 0; i < stack.length; ++i) {
+ var line = stack[i];
+ if (" (No stack trace)" === line || stackFramePattern.test(line)) {
+ break;
+ }
+ }
+ if (i > 0) {
+ stack = stack.slice(i);
+ }
+ return stack;
+}
+
+CapturedTrace.parseStackAndMessage = function(error) {
+ var stack = error.stack;
+ var message = error.toString();
+ stack = typeof stack === "string" && stack.length > 0
+ ? stackFramesAsArray(error) : [" (No stack trace)"];
+ return {
+ message: message,
+ stack: cleanStack(stack)
+ };
+};
+
+CapturedTrace.formatAndLogError = function(error, title) {
+ if (typeof console !== "undefined") {
+ var message;
+ if (typeof error === "object" || typeof error === "function") {
+ var stack = error.stack;
+ message = title + formatStack(stack, error);
+ } else {
+ message = title + String(error);
+ }
+ if (typeof warn === "function") {
+ warn(message);
+ } else if (typeof console.log === "function" ||
+ typeof console.log === "object") {
+ console.log(message);
+ }
+ }
+};
+
+CapturedTrace.unhandledRejection = function (reason) {
+ CapturedTrace.formatAndLogError(reason, "^--- With additional stack trace: ");
+};
+
+CapturedTrace.isSupported = function () {
+ return typeof captureStackTrace === "function";
+};
+
+CapturedTrace.fireRejectionEvent =
+function(name, localHandler, reason, promise) {
+ var localEventFired = false;
+ try {
+ if (typeof localHandler === "function") {
+ localEventFired = true;
+ if (name === "rejectionHandled") {
+ localHandler(promise);
+ } else {
+ localHandler(reason, promise);
+ }
+ }
+ } catch (e) {
+ async.throwLater(e);
+ }
+
+ var globalEventFired = false;
+ try {
+ globalEventFired = fireGlobalEvent(name, reason, promise);
+ } catch (e) {
+ globalEventFired = true;
+ async.throwLater(e);
+ }
+
+ var domEventFired = false;
+ if (fireDomEvent) {
+ try {
+ domEventFired = fireDomEvent(name.toLowerCase(), {
+ reason: reason,
+ promise: promise
+ });
+ } catch (e) {
+ domEventFired = true;
+ async.throwLater(e);
+ }
+ }
+
+ if (!globalEventFired && !localEventFired && !domEventFired &&
+ name === "unhandledRejection") {
+ CapturedTrace.formatAndLogError(reason, "Unhandled rejection ");
+ }
+};
+
+function formatNonError(obj) {
+ var str;
+ if (typeof obj === "function") {
+ str = "[function " +
+ (obj.name || "anonymous") +
+ "]";
+ } else {
+ str = obj.toString();
+ var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
+ if (ruselessToString.test(str)) {
+ try {
+ var newStr = JSON.stringify(obj);
+ str = newStr;
+ }
+ catch(e) {
+
+ }
+ }
+ if (str.length === 0) {
+ str = "(empty array)";
+ }
+ }
+ return ("(<" + snip(str) + ">, no stack trace)");
+}
+
+function snip(str) {
+ var maxChars = 41;
+ if (str.length < maxChars) {
+ return str;
+ }
+ return str.substr(0, maxChars - 3) + "...";
+}
+
+var shouldIgnore = function() { return false; };
+var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
+function parseLineInfo(line) {
+ var matches = line.match(parseLineInfoRegex);
+ if (matches) {
+ return {
+ fileName: matches[1],
+ line: parseInt(matches[2], 10)
+ };
+ }
+}
+CapturedTrace.setBounds = function(firstLineError, lastLineError) {
+ if (!CapturedTrace.isSupported()) return;
+ var firstStackLines = firstLineError.stack.split("\n");
+ var lastStackLines = lastLineError.stack.split("\n");
+ var firstIndex = -1;
+ var lastIndex = -1;
+ var firstFileName;
+ var lastFileName;
+ for (var i = 0; i < firstStackLines.length; ++i) {
+ var result = parseLineInfo(firstStackLines[i]);
+ if (result) {
+ firstFileName = result.fileName;
+ firstIndex = result.line;
+ break;
+ }
+ }
+ for (var i = 0; i < lastStackLines.length; ++i) {
+ var result = parseLineInfo(lastStackLines[i]);
+ if (result) {
+ lastFileName = result.fileName;
+ lastIndex = result.line;
+ break;
+ }
+ }
+ if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
+ firstFileName !== lastFileName || firstIndex >= lastIndex) {
+ return;
+ }
+
+ shouldIgnore = function(line) {
+ if (bluebirdFramePattern.test(line)) return true;
+ var info = parseLineInfo(line);
+ if (info) {
+ if (info.fileName === firstFileName &&
+ (firstIndex <= info.line && info.line <= lastIndex)) {
+ return true;
+ }
+ }
+ return false;
+ };
+};
+
+var captureStackTrace = (function stackDetection() {
+ var v8stackFramePattern = /^\s*at\s*/;
+ var v8stackFormatter = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if (error.name !== undefined &&
+ error.message !== undefined) {
+ return error.toString();
+ }
+ return formatNonError(error);
+ };
+
+ if (typeof Error.stackTraceLimit === "number" &&
+ typeof Error.captureStackTrace === "function") {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ stackFramePattern = v8stackFramePattern;
+ formatStack = v8stackFormatter;
+ var captureStackTrace = Error.captureStackTrace;
+
+ shouldIgnore = function(line) {
+ return bluebirdFramePattern.test(line);
+ };
+ return function(receiver, ignoreUntil) {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ captureStackTrace(receiver, ignoreUntil);
+ Error.stackTraceLimit = Error.stackTraceLimit - 6;
+ };
+ }
+ var err = new Error();
+
+ if (typeof err.stack === "string" &&
+ err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
+ stackFramePattern = /@/;
+ formatStack = v8stackFormatter;
+ indentStackFrames = true;
+ return function captureStackTrace(o) {
+ o.stack = new Error().stack;
+ };
+ }
+
+ var hasStackAfterThrow;
+ try { throw new Error(); }
+ catch(e) {
+ hasStackAfterThrow = ("stack" in e);
+ }
+ if (!("stack" in err) && hasStackAfterThrow &&
+ typeof Error.stackTraceLimit === "number") {
+ stackFramePattern = v8stackFramePattern;
+ formatStack = v8stackFormatter;
+ return function captureStackTrace(o) {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ try { throw new Error(); }
+ catch(e) { o.stack = e.stack; }
+ Error.stackTraceLimit = Error.stackTraceLimit - 6;
+ };
+ }
+
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if ((typeof error === "object" ||
+ typeof error === "function") &&
+ error.name !== undefined &&
+ error.message !== undefined) {
+ return error.toString();
+ }
+ return formatNonError(error);
+ };
+
+ return null;
+
+})([]);
+
+var fireDomEvent;
+var fireGlobalEvent = (function() {
+ if (util.isNode) {
+ return function(name, reason, promise) {
+ if (name === "rejectionHandled") {
+ return process.emit(name, promise);
+ } else {
+ return process.emit(name, reason, promise);
+ }
+ };
+ } else {
+ var customEventWorks = false;
+ var anyEventWorks = true;
+ try {
+ var ev = new self.CustomEvent("test");
+ customEventWorks = ev instanceof CustomEvent;
+ } catch (e) {}
+ if (!customEventWorks) {
+ try {
+ var event = document.createEvent("CustomEvent");
+ event.initCustomEvent("testingtheevent", false, true, {});
+ self.dispatchEvent(event);
+ } catch (e) {
+ anyEventWorks = false;
+ }
+ }
+ if (anyEventWorks) {
+ fireDomEvent = function(type, detail) {
+ var event;
+ if (customEventWorks) {
+ event = new self.CustomEvent(type, {
+ detail: detail,
+ bubbles: false,
+ cancelable: true
+ });
+ } else if (self.dispatchEvent) {
+ event = document.createEvent("CustomEvent");
+ event.initCustomEvent(type, false, true, detail);
+ }
+
+ return event ? !self.dispatchEvent(event) : false;
+ };
+ }
+
+ var toWindowMethodNameMap = {};
+ toWindowMethodNameMap["unhandledRejection"] = ("on" +
+ "unhandledRejection").toLowerCase();
+ toWindowMethodNameMap["rejectionHandled"] = ("on" +
+ "rejectionHandled").toLowerCase();
+
+ return function(name, reason, promise) {
+ var methodName = toWindowMethodNameMap[name];
+ var method = self[methodName];
+ if (!method) return false;
+ if (name === "rejectionHandled") {
+ method.call(self, promise);
+ } else {
+ method.call(self, reason, promise);
+ }
+ return true;
+ };
+ }
+})();
+
+if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
+ warn = function (message) {
+ console.warn(message);
+ };
+ if (util.isNode && process.stderr.isTTY) {
+ warn = function(message) {
+ process.stderr.write("\u001b[31m" + message + "\u001b[39m\n");
+ };
+ } else if (!util.isNode && typeof (new Error().stack) === "string") {
+ warn = function(message) {
+ console.warn("%c" + message, "color: red");
+ };
+ }
+}
+
+return CapturedTrace;
+};
+
+},{"./async.js":2,"./util.js":38}],8:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(NEXT_FILTER) {
+var util = _dereq_("./util.js");
+var errors = _dereq_("./errors.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var keys = _dereq_("./es5.js").keys;
+var TypeError = errors.TypeError;
+
+function CatchFilter(instances, callback, promise) {
+ this._instances = instances;
+ this._callback = callback;
+ this._promise = promise;
+}
+
+function safePredicate(predicate, e) {
+ var safeObject = {};
+ var retfilter = tryCatch(predicate).call(safeObject, e);
+
+ if (retfilter === errorObj) return retfilter;
+
+ var safeKeys = keys(safeObject);
+ if (safeKeys.length) {
+ errorObj.e = new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a");
+ return errorObj;
+ }
+ return retfilter;
+}
+
+CatchFilter.prototype.doFilter = function (e) {
+ var cb = this._callback;
+ var promise = this._promise;
+ var boundTo = promise._boundValue();
+ for (var i = 0, len = this._instances.length; i < len; ++i) {
+ var item = this._instances[i];
+ var itemIsErrorType = item === Error ||
+ (item != null && item.prototype instanceof Error);
+
+ if (itemIsErrorType && e instanceof item) {
+ var ret = tryCatch(cb).call(boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ } else if (typeof item === "function" && !itemIsErrorType) {
+ var shouldHandle = safePredicate(item, e);
+ if (shouldHandle === errorObj) {
+ e = errorObj.e;
+ break;
+ } else if (shouldHandle) {
+ var ret = tryCatch(cb).call(boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ }
+ }
+ }
+ NEXT_FILTER.e = e;
+ return NEXT_FILTER;
+};
+
+return CatchFilter;
+};
+
+},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, CapturedTrace, isDebugging) {
+var contextStack = [];
+function Context() {
+ this._trace = new CapturedTrace(peekContext());
+}
+Context.prototype._pushContext = function () {
+ if (!isDebugging()) return;
+ if (this._trace !== undefined) {
+ contextStack.push(this._trace);
+ }
+};
+
+Context.prototype._popContext = function () {
+ if (!isDebugging()) return;
+ if (this._trace !== undefined) {
+ contextStack.pop();
+ }
+};
+
+function createContext() {
+ if (isDebugging()) return new Context();
+}
+
+function peekContext() {
+ var lastIndex = contextStack.length - 1;
+ if (lastIndex >= 0) {
+ return contextStack[lastIndex];
+ }
+ return undefined;
+}
+
+Promise.prototype._peekContext = peekContext;
+Promise.prototype._pushContext = Context.prototype._pushContext;
+Promise.prototype._popContext = Context.prototype._popContext;
+
+return createContext;
+};
+
+},{}],10:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, CapturedTrace) {
+var getDomain = Promise._getDomain;
+var async = _dereq_("./async.js");
+var Warning = _dereq_("./errors.js").Warning;
+var util = _dereq_("./util.js");
+var canAttachTrace = util.canAttachTrace;
+var unhandledRejectionHandled;
+var possiblyUnhandledRejection;
+var debugging = false || (util.isNode &&
+ (!!process.env["BLUEBIRD_DEBUG"] ||
+ process.env["NODE_ENV"] === "development"));
+
+if (util.isNode && process.env["BLUEBIRD_DEBUG"] == 0) debugging = false;
+
+if (debugging) {
+ async.disableTrampolineIfNecessary();
+}
+
+Promise.prototype._ignoreRejections = function() {
+ this._unsetRejectionIsUnhandled();
+ this._bitField = this._bitField | 16777216;
+};
+
+Promise.prototype._ensurePossibleRejectionHandled = function () {
+ if ((this._bitField & 16777216) !== 0) return;
+ this._setRejectionIsUnhandled();
+ async.invokeLater(this._notifyUnhandledRejection, this, undefined);
+};
+
+Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
+ CapturedTrace.fireRejectionEvent("rejectionHandled",
+ unhandledRejectionHandled, undefined, this);
+};
+
+Promise.prototype._notifyUnhandledRejection = function () {
+ if (this._isRejectionUnhandled()) {
+ var reason = this._getCarriedStackTrace() || this._settledValue;
+ this._setUnhandledRejectionIsNotified();
+ CapturedTrace.fireRejectionEvent("unhandledRejection",
+ possiblyUnhandledRejection, reason, this);
+ }
+};
+
+Promise.prototype._setUnhandledRejectionIsNotified = function () {
+ this._bitField = this._bitField | 524288;
+};
+
+Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
+ this._bitField = this._bitField & (~524288);
+};
+
+Promise.prototype._isUnhandledRejectionNotified = function () {
+ return (this._bitField & 524288) > 0;
+};
+
+Promise.prototype._setRejectionIsUnhandled = function () {
+ this._bitField = this._bitField | 2097152;
+};
+
+Promise.prototype._unsetRejectionIsUnhandled = function () {
+ this._bitField = this._bitField & (~2097152);
+ if (this._isUnhandledRejectionNotified()) {
+ this._unsetUnhandledRejectionIsNotified();
+ this._notifyUnhandledRejectionIsHandled();
+ }
+};
+
+Promise.prototype._isRejectionUnhandled = function () {
+ return (this._bitField & 2097152) > 0;
+};
+
+Promise.prototype._setCarriedStackTrace = function (capturedTrace) {
+ this._bitField = this._bitField | 1048576;
+ this._fulfillmentHandler0 = capturedTrace;
+};
+
+Promise.prototype._isCarryingStackTrace = function () {
+ return (this._bitField & 1048576) > 0;
+};
+
+Promise.prototype._getCarriedStackTrace = function () {
+ return this._isCarryingStackTrace()
+ ? this._fulfillmentHandler0
+ : undefined;
+};
+
+Promise.prototype._captureStackTrace = function () {
+ if (debugging) {
+ this._trace = new CapturedTrace(this._peekContext());
+ }
+ return this;
+};
+
+Promise.prototype._attachExtraTrace = function (error, ignoreSelf) {
+ if (debugging && canAttachTrace(error)) {
+ var trace = this._trace;
+ if (trace !== undefined) {
+ if (ignoreSelf) trace = trace._parent;
+ }
+ if (trace !== undefined) {
+ trace.attachExtraTrace(error);
+ } else if (!error.__stackCleaned__) {
+ var parsed = CapturedTrace.parseStackAndMessage(error);
+ util.notEnumerableProp(error, "stack",
+ parsed.message + "\n" + parsed.stack.join("\n"));
+ util.notEnumerableProp(error, "__stackCleaned__", true);
+ }
+ }
+};
+
+Promise.prototype._warn = function(message) {
+ var warning = new Warning(message);
+ var ctx = this._peekContext();
+ if (ctx) {
+ ctx.attachExtraTrace(warning);
+ } else {
+ var parsed = CapturedTrace.parseStackAndMessage(warning);
+ warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
+ }
+ CapturedTrace.formatAndLogError(warning, "");
+};
+
+Promise.onPossiblyUnhandledRejection = function (fn) {
+ var domain = getDomain();
+ possiblyUnhandledRejection =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
+};
+
+Promise.onUnhandledRejectionHandled = function (fn) {
+ var domain = getDomain();
+ unhandledRejectionHandled =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
+};
+
+Promise.longStackTraces = function () {
+ if (async.haveItemsQueued() &&
+ debugging === false
+ ) {
+ throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/DT1qyG\u000a");
+ }
+ debugging = CapturedTrace.isSupported();
+ if (debugging) {
+ async.disableTrampolineIfNecessary();
+ }
+};
+
+Promise.hasLongStackTraces = function () {
+ return debugging && CapturedTrace.isSupported();
+};
+
+if (!CapturedTrace.isSupported()) {
+ Promise.longStackTraces = function(){};
+ debugging = false;
+}
+
+return function() {
+ return debugging;
+};
+};
+
+},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(_dereq_,module,exports){
+"use strict";
+var util = _dereq_("./util.js");
+var isPrimitive = util.isPrimitive;
+
+module.exports = function(Promise) {
+var returner = function () {
+ return this;
+};
+var thrower = function () {
+ throw this;
+};
+var returnUndefined = function() {};
+var throwUndefined = function() {
+ throw undefined;
+};
+
+var wrapper = function (value, action) {
+ if (action === 1) {
+ return function () {
+ throw value;
+ };
+ } else if (action === 2) {
+ return function () {
+ return value;
+ };
+ }
+};
+
+
+Promise.prototype["return"] =
+Promise.prototype.thenReturn = function (value) {
+ if (value === undefined) return this.then(returnUndefined);
+
+ if (isPrimitive(value)) {
+ return this._then(
+ wrapper(value, 2),
+ undefined,
+ undefined,
+ undefined,
+ undefined
+ );
+ } else if (value instanceof Promise) {
+ value._ignoreRejections();
+ }
+ return this._then(returner, undefined, undefined, value, undefined);
+};
+
+Promise.prototype["throw"] =
+Promise.prototype.thenThrow = function (reason) {
+ if (reason === undefined) return this.then(throwUndefined);
+
+ if (isPrimitive(reason)) {
+ return this._then(
+ wrapper(reason, 1),
+ undefined,
+ undefined,
+ undefined,
+ undefined
+ );
+ }
+ return this._then(thrower, undefined, undefined, reason, undefined);
+};
+};
+
+},{"./util.js":38}],12:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var PromiseReduce = Promise.reduce;
+
+Promise.prototype.each = function (fn) {
+ return PromiseReduce(this, fn, null, INTERNAL);
+};
+
+Promise.each = function (promises, fn) {
+ return PromiseReduce(promises, fn, null, INTERNAL);
+};
+};
+
+},{}],13:[function(_dereq_,module,exports){
+"use strict";
+var es5 = _dereq_("./es5.js");
+var Objectfreeze = es5.freeze;
+var util = _dereq_("./util.js");
+var inherits = util.inherits;
+var notEnumerableProp = util.notEnumerableProp;
+
+function subError(nameProperty, defaultMessage) {
+ function SubError(message) {
+ if (!(this instanceof SubError)) return new SubError(message);
+ notEnumerableProp(this, "message",
+ typeof message === "string" ? message : defaultMessage);
+ notEnumerableProp(this, "name", nameProperty);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ Error.call(this);
+ }
+ }
+ inherits(SubError, Error);
+ return SubError;
+}
+
+var _TypeError, _RangeError;
+var Warning = subError("Warning", "warning");
+var CancellationError = subError("CancellationError", "cancellation error");
+var TimeoutError = subError("TimeoutError", "timeout error");
+var AggregateError = subError("AggregateError", "aggregate error");
+try {
+ _TypeError = TypeError;
+ _RangeError = RangeError;
+} catch(e) {
+ _TypeError = subError("TypeError", "type error");
+ _RangeError = subError("RangeError", "range error");
+}
+
+var methods = ("join pop push shift unshift slice filter forEach some " +
+ "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
+
+for (var i = 0; i < methods.length; ++i) {
+ if (typeof Array.prototype[methods[i]] === "function") {
+ AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
+ }
+}
+
+es5.defineProperty(AggregateError.prototype, "length", {
+ value: 0,
+ configurable: false,
+ writable: true,
+ enumerable: true
+});
+AggregateError.prototype["isOperational"] = true;
+var level = 0;
+AggregateError.prototype.toString = function() {
+ var indent = Array(level * 4 + 1).join(" ");
+ var ret = "\n" + indent + "AggregateError of:" + "\n";
+ level++;
+ indent = Array(level * 4 + 1).join(" ");
+ for (var i = 0; i < this.length; ++i) {
+ var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
+ var lines = str.split("\n");
+ for (var j = 0; j < lines.length; ++j) {
+ lines[j] = indent + lines[j];
+ }
+ str = lines.join("\n");
+ ret += str + "\n";
+ }
+ level--;
+ return ret;
+};
+
+function OperationalError(message) {
+ if (!(this instanceof OperationalError))
+ return new OperationalError(message);
+ notEnumerableProp(this, "name", "OperationalError");
+ notEnumerableProp(this, "message", message);
+ this.cause = message;
+ this["isOperational"] = true;
+
+ if (message instanceof Error) {
+ notEnumerableProp(this, "message", message.message);
+ notEnumerableProp(this, "stack", message.stack);
+ } else if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
+}
+inherits(OperationalError, Error);
+
+var errorTypes = Error["__BluebirdErrorTypes__"];
+if (!errorTypes) {
+ errorTypes = Objectfreeze({
+ CancellationError: CancellationError,
+ TimeoutError: TimeoutError,
+ OperationalError: OperationalError,
+ RejectionError: OperationalError,
+ AggregateError: AggregateError
+ });
+ notEnumerableProp(Error, "__BluebirdErrorTypes__", errorTypes);
+}
+
+module.exports = {
+ Error: Error,
+ TypeError: _TypeError,
+ RangeError: _RangeError,
+ CancellationError: errorTypes.CancellationError,
+ OperationalError: errorTypes.OperationalError,
+ TimeoutError: errorTypes.TimeoutError,
+ AggregateError: errorTypes.AggregateError,
+ Warning: Warning
+};
+
+},{"./es5.js":14,"./util.js":38}],14:[function(_dereq_,module,exports){
+var isES5 = (function(){
+ "use strict";
+ return this === undefined;
+})();
+
+if (isES5) {
+ module.exports = {
+ freeze: Object.freeze,
+ defineProperty: Object.defineProperty,
+ getDescriptor: Object.getOwnPropertyDescriptor,
+ keys: Object.keys,
+ names: Object.getOwnPropertyNames,
+ getPrototypeOf: Object.getPrototypeOf,
+ isArray: Array.isArray,
+ isES5: isES5,
+ propertyIsWritable: function(obj, prop) {
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
+ return !!(!descriptor || descriptor.writable || descriptor.set);
+ }
+ };
+} else {
+ var has = {}.hasOwnProperty;
+ var str = {}.toString;
+ var proto = {}.constructor.prototype;
+
+ var ObjectKeys = function (o) {
+ var ret = [];
+ for (var key in o) {
+ if (has.call(o, key)) {
+ ret.push(key);
+ }
+ }
+ return ret;
+ };
+
+ var ObjectGetDescriptor = function(o, key) {
+ return {value: o[key]};
+ };
+
+ var ObjectDefineProperty = function (o, key, desc) {
+ o[key] = desc.value;
+ return o;
+ };
+
+ var ObjectFreeze = function (obj) {
+ return obj;
+ };
+
+ var ObjectGetPrototypeOf = function (obj) {
+ try {
+ return Object(obj).constructor.prototype;
+ }
+ catch (e) {
+ return proto;
+ }
+ };
+
+ var ArrayIsArray = function (obj) {
+ try {
+ return str.call(obj) === "[object Array]";
+ }
+ catch(e) {
+ return false;
+ }
+ };
+
+ module.exports = {
+ isArray: ArrayIsArray,
+ keys: ObjectKeys,
+ names: ObjectKeys,
+ defineProperty: ObjectDefineProperty,
+ getDescriptor: ObjectGetDescriptor,
+ freeze: ObjectFreeze,
+ getPrototypeOf: ObjectGetPrototypeOf,
+ isES5: isES5,
+ propertyIsWritable: function() {
+ return true;
+ }
+ };
+}
+
+},{}],15:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var PromiseMap = Promise.map;
+
+Promise.prototype.filter = function (fn, options) {
+ return PromiseMap(this, fn, options, INTERNAL);
+};
+
+Promise.filter = function (promises, fn, options) {
+ return PromiseMap(promises, fn, options, INTERNAL);
+};
+};
+
+},{}],16:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, NEXT_FILTER, tryConvertToPromise) {
+var util = _dereq_("./util.js");
+var isPrimitive = util.isPrimitive;
+var thrower = util.thrower;
+
+function returnThis() {
+ return this;
+}
+function throwThis() {
+ throw this;
+}
+function return$(r) {
+ return function() {
+ return r;
+ };
+}
+function throw$(r) {
+ return function() {
+ throw r;
+ };
+}
+function promisedFinally(ret, reasonOrValue, isFulfilled) {
+ var then;
+ if (isPrimitive(reasonOrValue)) {
+ then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue);
+ } else {
+ then = isFulfilled ? returnThis : throwThis;
+ }
+ return ret._then(then, thrower, undefined, reasonOrValue, undefined);
+}
+
+function finallyHandler(reasonOrValue) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundValue())
+ : handler();
+
+ if (ret !== undefined) {
+ var maybePromise = tryConvertToPromise(ret, promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ return promisedFinally(maybePromise, reasonOrValue,
+ promise.isFulfilled());
+ }
+ }
+
+ if (promise.isRejected()) {
+ NEXT_FILTER.e = reasonOrValue;
+ return NEXT_FILTER;
+ } else {
+ return reasonOrValue;
+ }
+}
+
+function tapHandler(value) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundValue(), value)
+ : handler(value);
+
+ if (ret !== undefined) {
+ var maybePromise = tryConvertToPromise(ret, promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ return promisedFinally(maybePromise, value, true);
+ }
+ }
+ return value;
+}
+
+Promise.prototype._passThroughHandler = function (handler, isFinally) {
+ if (typeof handler !== "function") return this.then();
+
+ var promiseAndHandler = {
+ promise: this,
+ handler: handler
+ };
+
+ return this._then(
+ isFinally ? finallyHandler : tapHandler,
+ isFinally ? finallyHandler : undefined, undefined,
+ promiseAndHandler, undefined);
+};
+
+Promise.prototype.lastly =
+Promise.prototype["finally"] = function (handler) {
+ return this._passThroughHandler(handler, true);
+};
+
+Promise.prototype.tap = function (handler) {
+ return this._passThroughHandler(handler, false);
+};
+};
+
+},{"./util.js":38}],17:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise,
+ apiRejection,
+ INTERNAL,
+ tryConvertToPromise) {
+var errors = _dereq_("./errors.js");
+var TypeError = errors.TypeError;
+var util = _dereq_("./util.js");
+var errorObj = util.errorObj;
+var tryCatch = util.tryCatch;
+var yieldHandlers = [];
+
+function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
+ for (var i = 0; i < yieldHandlers.length; ++i) {
+ traceParent._pushContext();
+ var result = tryCatch(yieldHandlers[i])(value);
+ traceParent._popContext();
+ if (result === errorObj) {
+ traceParent._pushContext();
+ var ret = Promise.reject(errorObj.e);
+ traceParent._popContext();
+ return ret;
+ }
+ var maybePromise = tryConvertToPromise(result, traceParent);
+ if (maybePromise instanceof Promise) return maybePromise;
+ }
+ return null;
+}
+
+function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
+ var promise = this._promise = new Promise(INTERNAL);
+ promise._captureStackTrace();
+ this._stack = stack;
+ this._generatorFunction = generatorFunction;
+ this._receiver = receiver;
+ this._generator = undefined;
+ this._yieldHandlers = typeof yieldHandler === "function"
+ ? [yieldHandler].concat(yieldHandlers)
+ : yieldHandlers;
+}
+
+PromiseSpawn.prototype.promise = function () {
+ return this._promise;
+};
+
+PromiseSpawn.prototype._run = function () {
+ this._generator = this._generatorFunction.call(this._receiver);
+ this._receiver =
+ this._generatorFunction = undefined;
+ this._next(undefined);
+};
+
+PromiseSpawn.prototype._continue = function (result) {
+ if (result === errorObj) {
+ return this._promise._rejectCallback(result.e, false, true);
+ }
+
+ var value = result.value;
+ if (result.done === true) {
+ this._promise._resolveCallback(value);
+ } else {
+ var maybePromise = tryConvertToPromise(value, this._promise);
+ if (!(maybePromise instanceof Promise)) {
+ maybePromise =
+ promiseFromYieldHandler(maybePromise,
+ this._yieldHandlers,
+ this._promise);
+ if (maybePromise === null) {
+ this._throw(
+ new TypeError(
+ "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/4Y4pDk\u000a\u000a".replace("%s", value) +
+ "From coroutine:\u000a" +
+ this._stack.split("\n").slice(1, -7).join("\n")
+ )
+ );
+ return;
+ }
+ }
+ maybePromise._then(
+ this._next,
+ this._throw,
+ undefined,
+ this,
+ null
+ );
+ }
+};
+
+PromiseSpawn.prototype._throw = function (reason) {
+ this._promise._attachExtraTrace(reason);
+ this._promise._pushContext();
+ var result = tryCatch(this._generator["throw"])
+ .call(this._generator, reason);
+ this._promise._popContext();
+ this._continue(result);
+};
+
+PromiseSpawn.prototype._next = function (value) {
+ this._promise._pushContext();
+ var result = tryCatch(this._generator.next).call(this._generator, value);
+ this._promise._popContext();
+ this._continue(result);
+};
+
+Promise.coroutine = function (generatorFunction, options) {
+ if (typeof generatorFunction !== "function") {
+ throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
+ }
+ var yieldHandler = Object(options).yieldHandler;
+ var PromiseSpawn$ = PromiseSpawn;
+ var stack = new Error().stack;
+ return function () {
+ var generator = generatorFunction.apply(this, arguments);
+ var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
+ stack);
+ spawn._generator = generator;
+ spawn._next(undefined);
+ return spawn.promise();
+ };
+};
+
+Promise.coroutine.addYieldHandler = function(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ yieldHandlers.push(fn);
+};
+
+Promise.spawn = function (generatorFunction) {
+ if (typeof generatorFunction !== "function") {
+ return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
+ }
+ var spawn = new PromiseSpawn(generatorFunction, this);
+ var ret = spawn.promise();
+ spawn._run(Promise.spawn);
+ return ret;
+};
+};
+
+},{"./errors.js":13,"./util.js":38}],18:[function(_dereq_,module,exports){
+"use strict";
+module.exports =
+function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
+var util = _dereq_("./util.js");
+var canEvaluate = util.canEvaluate;
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var reject;
+
+if (!true) {
+if (canEvaluate) {
+ var thenCallback = function(i) {
+ return new Function("value", "holder", " \n\
+ 'use strict'; \n\
+ holder.pIndex = value; \n\
+ holder.checkFulfillment(this); \n\
+ ".replace(/Index/g, i));
+ };
+
+ var caller = function(count) {
+ var values = [];
+ for (var i = 1; i <= count; ++i) values.push("holder.p" + i);
+ return new Function("holder", " \n\
+ 'use strict'; \n\
+ var callback = holder.fn; \n\
+ return callback(values); \n\
+ ".replace(/values/g, values.join(", ")));
+ };
+ var thenCallbacks = [];
+ var callers = [undefined];
+ for (var i = 1; i <= 5; ++i) {
+ thenCallbacks.push(thenCallback(i));
+ callers.push(caller(i));
+ }
+
+ var Holder = function(total, fn) {
+ this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null;
+ this.fn = fn;
+ this.total = total;
+ this.now = 0;
+ };
+
+ Holder.prototype.callers = callers;
+ Holder.prototype.checkFulfillment = function(promise) {
+ var now = this.now;
+ now++;
+ var total = this.total;
+ if (now >= total) {
+ var handler = this.callers[total];
+ promise._pushContext();
+ var ret = tryCatch(handler)(this);
+ promise._popContext();
+ if (ret === errorObj) {
+ promise._rejectCallback(ret.e, false, true);
+ } else {
+ promise._resolveCallback(ret);
+ }
+ } else {
+ this.now = now;
+ }
+ };
+
+ var reject = function (reason) {
+ this._reject(reason);
+ };
+}
+}
+
+Promise.join = function () {
+ var last = arguments.length - 1;
+ var fn;
+ if (last > 0 && typeof arguments[last] === "function") {
+ fn = arguments[last];
+ if (!true) {
+ if (last < 6 && canEvaluate) {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ var holder = new Holder(last, fn);
+ var callbacks = thenCallbacks;
+ for (var i = 0; i < last; ++i) {
+ var maybePromise = tryConvertToPromise(arguments[i], ret);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ maybePromise._then(callbacks[i], reject,
+ undefined, ret, holder);
+ } else if (maybePromise._isFulfilled()) {
+ callbacks[i].call(ret,
+ maybePromise._value(), holder);
+ } else {
+ ret._reject(maybePromise._reason());
+ }
+ } else {
+ callbacks[i].call(ret, maybePromise, holder);
+ }
+ }
+ return ret;
+ }
+ }
+ }
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ if (fn) args.pop();
+ var ret = new PromiseArray(args).promise();
+ return fn !== undefined ? ret.spread(fn) : ret;
+};
+
+};
+
+},{"./util.js":38}],19:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise,
+ PromiseArray,
+ apiRejection,
+ tryConvertToPromise,
+ INTERNAL) {
+var getDomain = Promise._getDomain;
+var async = _dereq_("./async.js");
+var util = _dereq_("./util.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var PENDING = {};
+var EMPTY_ARRAY = [];
+
+function MappingPromiseArray(promises, fn, limit, _filter) {
+ this.constructor$(promises);
+ this._promise._captureStackTrace();
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
+ this._preservedValues = _filter === INTERNAL
+ ? new Array(this.length())
+ : null;
+ this._limit = limit;
+ this._inFlight = 0;
+ this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
+ async.invoke(init, this, undefined);
+}
+util.inherits(MappingPromiseArray, PromiseArray);
+function init() {this._init$(undefined, -2);}
+
+MappingPromiseArray.prototype._init = function () {};
+
+MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var values = this._values;
+ var length = this.length();
+ var preservedValues = this._preservedValues;
+ var limit = this._limit;
+ if (values[index] === PENDING) {
+ values[index] = value;
+ if (limit >= 1) {
+ this._inFlight--;
+ this._drainQueue();
+ if (this._isResolved()) return;
+ }
+ } else {
+ if (limit >= 1 && this._inFlight >= limit) {
+ values[index] = value;
+ this._queue.push(index);
+ return;
+ }
+ if (preservedValues !== null) preservedValues[index] = value;
+
+ var callback = this._callback;
+ var receiver = this._promise._boundValue();
+ this._promise._pushContext();
+ var ret = tryCatch(callback).call(receiver, value, index, length);
+ this._promise._popContext();
+ if (ret === errorObj) return this._reject(ret.e);
+
+ var maybePromise = tryConvertToPromise(ret, this._promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ if (limit >= 1) this._inFlight++;
+ values[index] = PENDING;
+ return maybePromise._proxyPromiseArray(this, index);
+ } else if (maybePromise._isFulfilled()) {
+ ret = maybePromise._value();
+ } else {
+ return this._reject(maybePromise._reason());
+ }
+ }
+ values[index] = ret;
+ }
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= length) {
+ if (preservedValues !== null) {
+ this._filter(values, preservedValues);
+ } else {
+ this._resolve(values);
+ }
+
+ }
+};
+
+MappingPromiseArray.prototype._drainQueue = function () {
+ var queue = this._queue;
+ var limit = this._limit;
+ var values = this._values;
+ while (queue.length > 0 && this._inFlight < limit) {
+ if (this._isResolved()) return;
+ var index = queue.pop();
+ this._promiseFulfilled(values[index], index);
+ }
+};
+
+MappingPromiseArray.prototype._filter = function (booleans, values) {
+ var len = values.length;
+ var ret = new Array(len);
+ var j = 0;
+ for (var i = 0; i < len; ++i) {
+ if (booleans[i]) ret[j++] = values[i];
+ }
+ ret.length = j;
+ this._resolve(ret);
+};
+
+MappingPromiseArray.prototype.preservedValues = function () {
+ return this._preservedValues;
+};
+
+function map(promises, fn, options, _filter) {
+ var limit = typeof options === "object" && options !== null
+ ? options.concurrency
+ : 0;
+ limit = typeof limit === "number" &&
+ isFinite(limit) && limit >= 1 ? limit : 0;
+ return new MappingPromiseArray(promises, fn, limit, _filter);
+}
+
+Promise.prototype.map = function (fn, options) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+
+ return map(this, fn, options, null).promise();
+};
+
+Promise.map = function (promises, fn, options, _filter) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ return map(promises, fn, options, _filter).promise();
+};
+
+
+};
+
+},{"./async.js":2,"./util.js":38}],20:[function(_dereq_,module,exports){
+"use strict";
+module.exports =
+function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
+var util = _dereq_("./util.js");
+var tryCatch = util.tryCatch;
+
+Promise.method = function (fn) {
+ if (typeof fn !== "function") {
+ throw new Promise.TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ return function () {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._pushContext();
+ var value = tryCatch(fn).apply(this, arguments);
+ ret._popContext();
+ ret._resolveFromSyncValue(value);
+ return ret;
+ };
+};
+
+Promise.attempt = Promise["try"] = function (fn, args, ctx) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._pushContext();
+ var value = util.isArray(args)
+ ? tryCatch(fn).apply(ctx, args)
+ : tryCatch(fn).call(ctx, args);
+ ret._popContext();
+ ret._resolveFromSyncValue(value);
+ return ret;
+};
+
+Promise.prototype._resolveFromSyncValue = function (value) {
+ if (value === util.errorObj) {
+ this._rejectCallback(value.e, false, true);
+ } else {
+ this._resolveCallback(value, true);
+ }
+};
+};
+
+},{"./util.js":38}],21:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise) {
+var util = _dereq_("./util.js");
+var async = _dereq_("./async.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+
+function spreadAdapter(val, nodeback) {
+ var promise = this;
+ if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
+ var ret =
+ tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+
+function successAdapter(val, nodeback) {
+ var promise = this;
+ var receiver = promise._boundValue();
+ var ret = val === undefined
+ ? tryCatch(nodeback).call(receiver, null)
+ : tryCatch(nodeback).call(receiver, null, val);
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+function errorAdapter(reason, nodeback) {
+ var promise = this;
+ if (!reason) {
+ var target = promise._target();
+ var newReason = target._getCarriedStackTrace();
+ newReason.cause = reason;
+ reason = newReason;
+ }
+ var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+
+Promise.prototype.asCallback =
+Promise.prototype.nodeify = function (nodeback, options) {
+ if (typeof nodeback == "function") {
+ var adapter = successAdapter;
+ if (options !== undefined && Object(options).spread) {
+ adapter = spreadAdapter;
+ }
+ this._then(
+ adapter,
+ errorAdapter,
+ undefined,
+ this,
+ nodeback
+ );
+ }
+ return this;
+};
+};
+
+},{"./async.js":2,"./util.js":38}],22:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var util = _dereq_("./util.js");
+var async = _dereq_("./async.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+
+Promise.prototype.progressed = function (handler) {
+ return this._then(undefined, undefined, handler, undefined, undefined);
+};
+
+Promise.prototype._progress = function (progressValue) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._target()._progressUnchecked(progressValue);
+
+};
+
+Promise.prototype._progressHandlerAt = function (index) {
+ return index === 0
+ ? this._progressHandler0
+ : this[(index << 2) + index - 5 + 2];
+};
+
+Promise.prototype._doProgressWith = function (progression) {
+ var progressValue = progression.value;
+ var handler = progression.handler;
+ var promise = progression.promise;
+ var receiver = progression.receiver;
+
+ var ret = tryCatch(handler).call(receiver, progressValue);
+ if (ret === errorObj) {
+ if (ret.e != null &&
+ ret.e.name !== "StopProgressPropagation") {
+ var trace = util.canAttachTrace(ret.e)
+ ? ret.e : new Error(util.toString(ret.e));
+ promise._attachExtraTrace(trace);
+ promise._progress(ret.e);
+ }
+ } else if (ret instanceof Promise) {
+ ret._then(promise._progress, null, null, promise, undefined);
+ } else {
+ promise._progress(ret);
+ }
+};
+
+
+Promise.prototype._progressUnchecked = function (progressValue) {
+ var len = this._length();
+ var progress = this._progress;
+ for (var i = 0; i < len; i++) {
+ var handler = this._progressHandlerAt(i);
+ var promise = this._promiseAt(i);
+ if (!(promise instanceof Promise)) {
+ var receiver = this._receiverAt(i);
+ if (typeof handler === "function") {
+ handler.call(receiver, progressValue, promise);
+ } else if (receiver instanceof PromiseArray &&
+ !receiver._isResolved()) {
+ receiver._promiseProgressed(progressValue, promise);
+ }
+ continue;
+ }
+
+ if (typeof handler === "function") {
+ async.invoke(this._doProgressWith, this, {
+ handler: handler,
+ promise: promise,
+ receiver: this._receiverAt(i),
+ value: progressValue
+ });
+ } else {
+ async.invoke(progress, promise, progressValue);
+ }
+ }
+};
+};
+
+},{"./async.js":2,"./util.js":38}],23:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function() {
+var makeSelfResolutionError = function () {
+ return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/LhFpo0\u000a");
+};
+var reflect = function() {
+ return new Promise.PromiseInspection(this._target());
+};
+var apiRejection = function(msg) {
+ return Promise.reject(new TypeError(msg));
+};
+
+var util = _dereq_("./util.js");
+
+var getDomain;
+if (util.isNode) {
+ getDomain = function() {
+ var ret = process.domain;
+ if (ret === undefined) ret = null;
+ return ret;
+ };
+} else {
+ getDomain = function() {
+ return null;
+ };
+}
+util.notEnumerableProp(Promise, "_getDomain", getDomain);
+
+var UNDEFINED_BINDING = {};
+var async = _dereq_("./async.js");
+var errors = _dereq_("./errors.js");
+var TypeError = Promise.TypeError = errors.TypeError;
+Promise.RangeError = errors.RangeError;
+Promise.CancellationError = errors.CancellationError;
+Promise.TimeoutError = errors.TimeoutError;
+Promise.OperationalError = errors.OperationalError;
+Promise.RejectionError = errors.OperationalError;
+Promise.AggregateError = errors.AggregateError;
+var INTERNAL = function(){};
+var APPLY = {};
+var NEXT_FILTER = {e: null};
+var tryConvertToPromise = _dereq_("./thenables.js")(Promise, INTERNAL);
+var PromiseArray =
+ _dereq_("./promise_array.js")(Promise, INTERNAL,
+ tryConvertToPromise, apiRejection);
+var CapturedTrace = _dereq_("./captured_trace.js")();
+var isDebugging = _dereq_("./debuggability.js")(Promise, CapturedTrace);
+ /*jshint unused:false*/
+var createContext =
+ _dereq_("./context.js")(Promise, CapturedTrace, isDebugging);
+var CatchFilter = _dereq_("./catch_filter.js")(NEXT_FILTER);
+var PromiseResolver = _dereq_("./promise_resolver.js");
+var nodebackForPromise = PromiseResolver._nodebackForPromise;
+var errorObj = util.errorObj;
+var tryCatch = util.tryCatch;
+function Promise(resolver) {
+ if (typeof resolver !== "function") {
+ throw new TypeError("the promise constructor requires a resolver function\u000a\u000a See http://goo.gl/EC22Yn\u000a");
+ }
+ if (this.constructor !== Promise) {
+ throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/KsIlge\u000a");
+ }
+ this._bitField = 0;
+ this._fulfillmentHandler0 = undefined;
+ this._rejectionHandler0 = undefined;
+ this._progressHandler0 = undefined;
+ this._promise0 = undefined;
+ this._receiver0 = undefined;
+ this._settledValue = undefined;
+ if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
+}
+
+Promise.prototype.toString = function () {
+ return "[object Promise]";
+};
+
+Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
+ var len = arguments.length;
+ if (len > 1) {
+ var catchInstances = new Array(len - 1),
+ j = 0, i;
+ for (i = 0; i < len - 1; ++i) {
+ var item = arguments[i];
+ if (typeof item === "function") {
+ catchInstances[j++] = item;
+ } else {
+ return Promise.reject(
+ new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a"));
+ }
+ }
+ catchInstances.length = j;
+ fn = arguments[i];
+ var catchFilter = new CatchFilter(catchInstances, fn, this);
+ return this._then(undefined, catchFilter.doFilter, undefined,
+ catchFilter, undefined);
+ }
+ return this._then(undefined, fn, undefined, undefined, undefined);
+};
+
+Promise.prototype.reflect = function () {
+ return this._then(reflect, reflect, undefined, this, undefined);
+};
+
+Promise.prototype.then = function (didFulfill, didReject, didProgress) {
+ if (isDebugging() && arguments.length > 0 &&
+ typeof didFulfill !== "function" &&
+ typeof didReject !== "function") {
+ var msg = ".then() only accepts functions but was passed: " +
+ util.classString(didFulfill);
+ if (arguments.length > 1) {
+ msg += ", " + util.classString(didReject);
+ }
+ this._warn(msg);
+ }
+ return this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+};
+
+Promise.prototype.done = function (didFulfill, didReject, didProgress) {
+ var promise = this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+ promise._setIsFinal();
+};
+
+Promise.prototype.spread = function (didFulfill, didReject) {
+ return this.all()._then(didFulfill, didReject, undefined, APPLY, undefined);
+};
+
+Promise.prototype.isCancellable = function () {
+ return !this.isResolved() &&
+ this._cancellable();
+};
+
+Promise.prototype.toJSON = function () {
+ var ret = {
+ isFulfilled: false,
+ isRejected: false,
+ fulfillmentValue: undefined,
+ rejectionReason: undefined
+ };
+ if (this.isFulfilled()) {
+ ret.fulfillmentValue = this.value();
+ ret.isFulfilled = true;
+ } else if (this.isRejected()) {
+ ret.rejectionReason = this.reason();
+ ret.isRejected = true;
+ }
+ return ret;
+};
+
+Promise.prototype.all = function () {
+ return new PromiseArray(this).promise();
+};
+
+Promise.prototype.error = function (fn) {
+ return this.caught(util.originatesFromRejection, fn);
+};
+
+Promise.is = function (val) {
+ return val instanceof Promise;
+};
+
+Promise.fromNode = function(fn) {
+ var ret = new Promise(INTERNAL);
+ var result = tryCatch(fn)(nodebackForPromise(ret));
+ if (result === errorObj) {
+ ret._rejectCallback(result.e, true, true);
+ }
+ return ret;
+};
+
+Promise.all = function (promises) {
+ return new PromiseArray(promises).promise();
+};
+
+Promise.defer = Promise.pending = function () {
+ var promise = new Promise(INTERNAL);
+ return new PromiseResolver(promise);
+};
+
+Promise.cast = function (obj) {
+ var ret = tryConvertToPromise(obj);
+ if (!(ret instanceof Promise)) {
+ var val = ret;
+ ret = new Promise(INTERNAL);
+ ret._fulfillUnchecked(val);
+ }
+ return ret;
+};
+
+Promise.resolve = Promise.fulfilled = Promise.cast;
+
+Promise.reject = Promise.rejected = function (reason) {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._rejectCallback(reason, true);
+ return ret;
+};
+
+Promise.setScheduler = function(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ var prev = async._schedule;
+ async._schedule = fn;
+ return prev;
+};
+
+Promise.prototype._then = function (
+ didFulfill,
+ didReject,
+ didProgress,
+ receiver,
+ internalData
+) {
+ var haveInternalData = internalData !== undefined;
+ var ret = haveInternalData ? internalData : new Promise(INTERNAL);
+
+ if (!haveInternalData) {
+ ret._propagateFrom(this, 4 | 1);
+ ret._captureStackTrace();
+ }
+
+ var target = this._target();
+ if (target !== this) {
+ if (receiver === undefined) receiver = this._boundTo;
+ if (!haveInternalData) ret._setIsMigrated();
+ }
+
+ var callbackIndex = target._addCallbacks(didFulfill,
+ didReject,
+ didProgress,
+ ret,
+ receiver,
+ getDomain());
+
+ if (target._isResolved() && !target._isSettlePromisesQueued()) {
+ async.invoke(
+ target._settlePromiseAtPostResolution, target, callbackIndex);
+ }
+
+ return ret;
+};
+
+Promise.prototype._settlePromiseAtPostResolution = function (index) {
+ if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
+ this._settlePromiseAt(index);
+};
+
+Promise.prototype._length = function () {
+ return this._bitField & 131071;
+};
+
+Promise.prototype._isFollowingOrFulfilledOrRejected = function () {
+ return (this._bitField & 939524096) > 0;
+};
+
+Promise.prototype._isFollowing = function () {
+ return (this._bitField & 536870912) === 536870912;
+};
+
+Promise.prototype._setLength = function (len) {
+ this._bitField = (this._bitField & -131072) |
+ (len & 131071);
+};
+
+Promise.prototype._setFulfilled = function () {
+ this._bitField = this._bitField | 268435456;
+};
+
+Promise.prototype._setRejected = function () {
+ this._bitField = this._bitField | 134217728;
+};
+
+Promise.prototype._setFollowing = function () {
+ this._bitField = this._bitField | 536870912;
+};
+
+Promise.prototype._setIsFinal = function () {
+ this._bitField = this._bitField | 33554432;
+};
+
+Promise.prototype._isFinal = function () {
+ return (this._bitField & 33554432) > 0;
+};
+
+Promise.prototype._cancellable = function () {
+ return (this._bitField & 67108864) > 0;
+};
+
+Promise.prototype._setCancellable = function () {
+ this._bitField = this._bitField | 67108864;
+};
+
+Promise.prototype._unsetCancellable = function () {
+ this._bitField = this._bitField & (~67108864);
+};
+
+Promise.prototype._setIsMigrated = function () {
+ this._bitField = this._bitField | 4194304;
+};
+
+Promise.prototype._unsetIsMigrated = function () {
+ this._bitField = this._bitField & (~4194304);
+};
+
+Promise.prototype._isMigrated = function () {
+ return (this._bitField & 4194304) > 0;
+};
+
+Promise.prototype._receiverAt = function (index) {
+ var ret = index === 0
+ ? this._receiver0
+ : this[
+ index * 5 - 5 + 4];
+ if (ret === UNDEFINED_BINDING) {
+ return undefined;
+ } else if (ret === undefined && this._isBound()) {
+ return this._boundValue();
+ }
+ return ret;
+};
+
+Promise.prototype._promiseAt = function (index) {
+ return index === 0
+ ? this._promise0
+ : this[index * 5 - 5 + 3];
+};
+
+Promise.prototype._fulfillmentHandlerAt = function (index) {
+ return index === 0
+ ? this._fulfillmentHandler0
+ : this[index * 5 - 5 + 0];
+};
+
+Promise.prototype._rejectionHandlerAt = function (index) {
+ return index === 0
+ ? this._rejectionHandler0
+ : this[index * 5 - 5 + 1];
+};
+
+Promise.prototype._boundValue = function() {
+ var ret = this._boundTo;
+ if (ret !== undefined) {
+ if (ret instanceof Promise) {
+ if (ret.isFulfilled()) {
+ return ret.value();
+ } else {
+ return undefined;
+ }
+ }
+ }
+ return ret;
+};
+
+Promise.prototype._migrateCallbacks = function (follower, index) {
+ var fulfill = follower._fulfillmentHandlerAt(index);
+ var reject = follower._rejectionHandlerAt(index);
+ var progress = follower._progressHandlerAt(index);
+ var promise = follower._promiseAt(index);
+ var receiver = follower._receiverAt(index);
+ if (promise instanceof Promise) promise._setIsMigrated();
+ if (receiver === undefined) receiver = UNDEFINED_BINDING;
+ this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
+};
+
+Promise.prototype._addCallbacks = function (
+ fulfill,
+ reject,
+ progress,
+ promise,
+ receiver,
+ domain
+) {
+ var index = this._length();
+
+ if (index >= 131071 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+
+ if (index === 0) {
+ this._promise0 = promise;
+ if (receiver !== undefined) this._receiver0 = receiver;
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this._rejectionHandler0 =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this._progressHandler0 =
+ domain === null ? progress : domain.bind(progress);
+ }
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] = promise;
+ this[base + 4] = receiver;
+ if (typeof fulfill === "function") {
+ this[base + 0] =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this[base + 1] =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this[base + 2] =
+ domain === null ? progress : domain.bind(progress);
+ }
+ }
+ this._setLength(index + 1);
+ return index;
+};
+
+Promise.prototype._setProxyHandlers = function (receiver, promiseSlotValue) {
+ var index = this._length();
+
+ if (index >= 131071 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+ if (index === 0) {
+ this._promise0 = promiseSlotValue;
+ this._receiver0 = receiver;
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] = promiseSlotValue;
+ this[base + 4] = receiver;
+ }
+ this._setLength(index + 1);
+};
+
+Promise.prototype._proxyPromiseArray = function (promiseArray, index) {
+ this._setProxyHandlers(promiseArray, index);
+};
+
+Promise.prototype._resolveCallback = function(value, shouldBind) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ if (value === this)
+ return this._rejectCallback(makeSelfResolutionError(), false, true);
+ var maybePromise = tryConvertToPromise(value, this);
+ if (!(maybePromise instanceof Promise)) return this._fulfill(value);
+
+ var propagationFlags = 1 | (shouldBind ? 4 : 0);
+ this._propagateFrom(maybePromise, propagationFlags);
+ var promise = maybePromise._target();
+ if (promise._isPending()) {
+ var len = this._length();
+ for (var i = 0; i < len; ++i) {
+ promise._migrateCallbacks(this, i);
+ }
+ this._setFollowing();
+ this._setLength(0);
+ this._setFollowee(promise);
+ } else if (promise._isFulfilled()) {
+ this._fulfillUnchecked(promise._value());
+ } else {
+ this._rejectUnchecked(promise._reason(),
+ promise._getCarriedStackTrace());
+ }
+};
+
+Promise.prototype._rejectCallback =
+function(reason, synchronous, shouldNotMarkOriginatingFromRejection) {
+ if (!shouldNotMarkOriginatingFromRejection) {
+ util.markAsOriginatingFromRejection(reason);
+ }
+ var trace = util.ensureErrorObject(reason);
+ var hasStack = trace === reason;
+ this._attachExtraTrace(trace, synchronous ? hasStack : false);
+ this._reject(reason, hasStack ? undefined : trace);
+};
+
+Promise.prototype._resolveFromResolver = function (resolver) {
+ var promise = this;
+ this._captureStackTrace();
+ this._pushContext();
+ var synchronous = true;
+ var r = tryCatch(resolver)(function(value) {
+ if (promise === null) return;
+ promise._resolveCallback(value);
+ promise = null;
+ }, function (reason) {
+ if (promise === null) return;
+ promise._rejectCallback(reason, synchronous);
+ promise = null;
+ });
+ synchronous = false;
+ this._popContext();
+
+ if (r !== undefined && r === errorObj && promise !== null) {
+ promise._rejectCallback(r.e, true, true);
+ promise = null;
+ }
+};
+
+Promise.prototype._settlePromiseFromHandler = function (
+ handler, receiver, value, promise
+) {
+ if (promise._isRejected()) return;
+ promise._pushContext();
+ var x;
+ if (receiver === APPLY && !this._isRejected()) {
+ x = tryCatch(handler).apply(this._boundValue(), value);
+ } else {
+ x = tryCatch(handler).call(receiver, value);
+ }
+ promise._popContext();
+
+ if (x === errorObj || x === promise || x === NEXT_FILTER) {
+ var err = x === promise ? makeSelfResolutionError() : x.e;
+ promise._rejectCallback(err, false, true);
+ } else {
+ promise._resolveCallback(x);
+ }
+};
+
+Promise.prototype._target = function() {
+ var ret = this;
+ while (ret._isFollowing()) ret = ret._followee();
+ return ret;
+};
+
+Promise.prototype._followee = function() {
+ return this._rejectionHandler0;
+};
+
+Promise.prototype._setFollowee = function(promise) {
+ this._rejectionHandler0 = promise;
+};
+
+Promise.prototype._cleanValues = function () {
+ if (this._cancellable()) {
+ this._cancellationParent = undefined;
+ }
+};
+
+Promise.prototype._propagateFrom = function (parent, flags) {
+ if ((flags & 1) > 0 && parent._cancellable()) {
+ this._setCancellable();
+ this._cancellationParent = parent;
+ }
+ if ((flags & 4) > 0 && parent._isBound()) {
+ this._setBoundTo(parent._boundTo);
+ }
+};
+
+Promise.prototype._fulfill = function (value) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._fulfillUnchecked(value);
+};
+
+Promise.prototype._reject = function (reason, carriedStackTrace) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._rejectUnchecked(reason, carriedStackTrace);
+};
+
+Promise.prototype._settlePromiseAt = function (index) {
+ var promise = this._promiseAt(index);
+ var isPromise = promise instanceof Promise;
+
+ if (isPromise && promise._isMigrated()) {
+ promise._unsetIsMigrated();
+ return async.invoke(this._settlePromiseAt, this, index);
+ }
+ var handler = this._isFulfilled()
+ ? this._fulfillmentHandlerAt(index)
+ : this._rejectionHandlerAt(index);
+
+ var carriedStackTrace =
+ this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
+ var value = this._settledValue;
+ var receiver = this._receiverAt(index);
+ this._clearCallbackDataAtIndex(index);
+
+ if (typeof handler === "function") {
+ if (!isPromise) {
+ handler.call(receiver, value, promise);
+ } else {
+ this._settlePromiseFromHandler(handler, receiver, value, promise);
+ }
+ } else if (receiver instanceof PromiseArray) {
+ if (!receiver._isResolved()) {
+ if (this._isFulfilled()) {
+ receiver._promiseFulfilled(value, promise);
+ }
+ else {
+ receiver._promiseRejected(value, promise);
+ }
+ }
+ } else if (isPromise) {
+ if (this._isFulfilled()) {
+ promise._fulfill(value);
+ } else {
+ promise._reject(value, carriedStackTrace);
+ }
+ }
+
+ if (index >= 4 && (index & 31) === 4)
+ async.invokeLater(this._setLength, this, 0);
+};
+
+Promise.prototype._clearCallbackDataAtIndex = function(index) {
+ if (index === 0) {
+ if (!this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 = undefined;
+ }
+ this._rejectionHandler0 =
+ this._progressHandler0 =
+ this._receiver0 =
+ this._promise0 = undefined;
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] =
+ this[base + 4] =
+ this[base + 0] =
+ this[base + 1] =
+ this[base + 2] = undefined;
+ }
+};
+
+Promise.prototype._isSettlePromisesQueued = function () {
+ return (this._bitField &
+ -1073741824) === -1073741824;
+};
+
+Promise.prototype._setSettlePromisesQueued = function () {
+ this._bitField = this._bitField | -1073741824;
+};
+
+Promise.prototype._unsetSettlePromisesQueued = function () {
+ this._bitField = this._bitField & (~-1073741824);
+};
+
+Promise.prototype._queueSettlePromises = function() {
+ async.settlePromises(this);
+ this._setSettlePromisesQueued();
+};
+
+Promise.prototype._fulfillUnchecked = function (value) {
+ if (value === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err, undefined);
+ }
+ this._setFulfilled();
+ this._settledValue = value;
+ this._cleanValues();
+
+ if (this._length() > 0) {
+ this._queueSettlePromises();
+ }
+};
+
+Promise.prototype._rejectUncheckedCheckError = function (reason) {
+ var trace = util.ensureErrorObject(reason);
+ this._rejectUnchecked(reason, trace === reason ? undefined : trace);
+};
+
+Promise.prototype._rejectUnchecked = function (reason, trace) {
+ if (reason === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err);
+ }
+ this._setRejected();
+ this._settledValue = reason;
+ this._cleanValues();
+
+ if (this._isFinal()) {
+ async.throwLater(function(e) {
+ if ("stack" in e) {
+ async.invokeFirst(
+ CapturedTrace.unhandledRejection, undefined, e);
+ }
+ throw e;
+ }, trace === undefined ? reason : trace);
+ return;
+ }
+
+ if (trace !== undefined && trace !== reason) {
+ this._setCarriedStackTrace(trace);
+ }
+
+ if (this._length() > 0) {
+ this._queueSettlePromises();
+ } else {
+ this._ensurePossibleRejectionHandled();
+ }
+};
+
+Promise.prototype._settlePromises = function () {
+ this._unsetSettlePromisesQueued();
+ var len = this._length();
+ for (var i = 0; i < len; i++) {
+ this._settlePromiseAt(i);
+ }
+};
+
+util.notEnumerableProp(Promise,
+ "_makeSelfResolutionError",
+ makeSelfResolutionError);
+
+_dereq_("./progress.js")(Promise, PromiseArray);
+_dereq_("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
+_dereq_("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
+_dereq_("./finally.js")(Promise, NEXT_FILTER, tryConvertToPromise);
+_dereq_("./direct_resolve.js")(Promise);
+_dereq_("./synchronous_inspection.js")(Promise);
+_dereq_("./join.js")(Promise, PromiseArray, tryConvertToPromise, INTERNAL);
+Promise.Promise = Promise;
+_dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
+_dereq_('./cancel.js')(Promise);
+_dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext);
+_dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise);
+_dereq_('./nodeify.js')(Promise);
+_dereq_('./call_get.js')(Promise);
+_dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
+_dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
+_dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
+_dereq_('./settle.js')(Promise, PromiseArray);
+_dereq_('./some.js')(Promise, PromiseArray, apiRejection);
+_dereq_('./promisify.js')(Promise, INTERNAL);
+_dereq_('./any.js')(Promise);
+_dereq_('./each.js')(Promise, INTERNAL);
+_dereq_('./timers.js')(Promise, INTERNAL);
+_dereq_('./filter.js')(Promise, INTERNAL);
+
+ util.toFastProperties(Promise);
+ util.toFastProperties(Promise.prototype);
+ function fillTypes(value) {
+ var p = new Promise(INTERNAL);
+ p._fulfillmentHandler0 = value;
+ p._rejectionHandler0 = value;
+ p._progressHandler0 = value;
+ p._promise0 = value;
+ p._receiver0 = value;
+ p._settledValue = value;
+ }
+ // Complete slack tracking, opt out of field-type tracking and
+ // stabilize map
+ fillTypes({a: 1});
+ fillTypes({b: 2});
+ fillTypes({c: 3});
+ fillTypes(1);
+ fillTypes(function(){});
+ fillTypes(undefined);
+ fillTypes(false);
+ fillTypes(new Promise(INTERNAL));
+ CapturedTrace.setBounds(async.firstLineError, util.lastLineError);
+ return Promise;
+
+};
+
+},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL, tryConvertToPromise,
+ apiRejection) {
+var util = _dereq_("./util.js");
+var isArray = util.isArray;
+
+function toResolutionValue(val) {
+ switch(val) {
+ case -2: return [];
+ case -3: return {};
+ }
+}
+
+function PromiseArray(values) {
+ var promise = this._promise = new Promise(INTERNAL);
+ var parent;
+ if (values instanceof Promise) {
+ parent = values;
+ promise._propagateFrom(parent, 1 | 4);
+ }
+ this._values = values;
+ this._length = 0;
+ this._totalResolved = 0;
+ this._init(undefined, -2);
+}
+PromiseArray.prototype.length = function () {
+ return this._length;
+};
+
+PromiseArray.prototype.promise = function () {
+ return this._promise;
+};
+
+PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
+ var values = tryConvertToPromise(this._values, this._promise);
+ if (values instanceof Promise) {
+ values = values._target();
+ this._values = values;
+ if (values._isFulfilled()) {
+ values = values._value();
+ if (!isArray(values)) {
+ var err = new Promise.TypeError("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
+ this.__hardReject__(err);
+ return;
+ }
+ } else if (values._isPending()) {
+ values._then(
+ init,
+ this._reject,
+ undefined,
+ this,
+ resolveValueIfEmpty
+ );
+ return;
+ } else {
+ this._reject(values._reason());
+ return;
+ }
+ } else if (!isArray(values)) {
+ this._promise._reject(apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a")._reason());
+ return;
+ }
+
+ if (values.length === 0) {
+ if (resolveValueIfEmpty === -5) {
+ this._resolveEmptyArray();
+ }
+ else {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ }
+ return;
+ }
+ var len = this.getActualLength(values.length);
+ this._length = len;
+ this._values = this.shouldCopyValues() ? new Array(len) : this._values;
+ var promise = this._promise;
+ for (var i = 0; i < len; ++i) {
+ var isResolved = this._isResolved();
+ var maybePromise = tryConvertToPromise(values[i], promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (isResolved) {
+ maybePromise._ignoreRejections();
+ } else if (maybePromise._isPending()) {
+ maybePromise._proxyPromiseArray(this, i);
+ } else if (maybePromise._isFulfilled()) {
+ this._promiseFulfilled(maybePromise._value(), i);
+ } else {
+ this._promiseRejected(maybePromise._reason(), i);
+ }
+ } else if (!isResolved) {
+ this._promiseFulfilled(maybePromise, i);
+ }
+ }
+};
+
+PromiseArray.prototype._isResolved = function () {
+ return this._values === null;
+};
+
+PromiseArray.prototype._resolve = function (value) {
+ this._values = null;
+ this._promise._fulfill(value);
+};
+
+PromiseArray.prototype.__hardReject__ =
+PromiseArray.prototype._reject = function (reason) {
+ this._values = null;
+ this._promise._rejectCallback(reason, false, true);
+};
+
+PromiseArray.prototype._promiseProgressed = function (progressValue, index) {
+ this._promise._progress({
+ index: index,
+ value: progressValue
+ });
+};
+
+
+PromiseArray.prototype._promiseFulfilled = function (value, index) {
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+PromiseArray.prototype._promiseRejected = function (reason, index) {
+ this._totalResolved++;
+ this._reject(reason);
+};
+
+PromiseArray.prototype.shouldCopyValues = function () {
+ return true;
+};
+
+PromiseArray.prototype.getActualLength = function (len) {
+ return len;
+};
+
+return PromiseArray;
+};
+
+},{"./util.js":38}],25:[function(_dereq_,module,exports){
+"use strict";
+var util = _dereq_("./util.js");
+var maybeWrapAsError = util.maybeWrapAsError;
+var errors = _dereq_("./errors.js");
+var TimeoutError = errors.TimeoutError;
+var OperationalError = errors.OperationalError;
+var haveGetters = util.haveGetters;
+var es5 = _dereq_("./es5.js");
+
+function isUntypedError(obj) {
+ return obj instanceof Error &&
+ es5.getPrototypeOf(obj) === Error.prototype;
+}
+
+var rErrorKey = /^(?:name|message|stack|cause)$/;
+function wrapAsOperationalError(obj) {
+ var ret;
+ if (isUntypedError(obj)) {
+ ret = new OperationalError(obj);
+ ret.name = obj.name;
+ ret.message = obj.message;
+ ret.stack = obj.stack;
+ var keys = es5.keys(obj);
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (!rErrorKey.test(key)) {
+ ret[key] = obj[key];
+ }
+ }
+ return ret;
+ }
+ util.markAsOriginatingFromRejection(obj);
+ return obj;
+}
+
+function nodebackForPromise(promise) {
+ return function(err, value) {
+ if (promise === null) return;
+
+ if (err) {
+ var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ } else if (arguments.length > 2) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ promise._fulfill(args);
+ } else {
+ promise._fulfill(value);
+ }
+
+ promise = null;
+ };
+}
+
+
+var PromiseResolver;
+if (!haveGetters) {
+ PromiseResolver = function (promise) {
+ this.promise = promise;
+ this.asCallback = nodebackForPromise(promise);
+ this.callback = this.asCallback;
+ };
+}
+else {
+ PromiseResolver = function (promise) {
+ this.promise = promise;
+ };
+}
+if (haveGetters) {
+ var prop = {
+ get: function() {
+ return nodebackForPromise(this.promise);
+ }
+ };
+ es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
+ es5.defineProperty(PromiseResolver.prototype, "callback", prop);
+}
+
+PromiseResolver._nodebackForPromise = nodebackForPromise;
+
+PromiseResolver.prototype.toString = function () {
+ return "[object PromiseResolver]";
+};
+
+PromiseResolver.prototype.resolve =
+PromiseResolver.prototype.fulfill = function (value) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._resolveCallback(value);
+};
+
+PromiseResolver.prototype.reject = function (reason) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._rejectCallback(reason);
+};
+
+PromiseResolver.prototype.progress = function (value) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._progress(value);
+};
+
+PromiseResolver.prototype.cancel = function (err) {
+ this.promise.cancel(err);
+};
+
+PromiseResolver.prototype.timeout = function () {
+ this.reject(new TimeoutError("timeout"));
+};
+
+PromiseResolver.prototype.isResolved = function () {
+ return this.promise.isResolved();
+};
+
+PromiseResolver.prototype.toJSON = function () {
+ return this.promise.toJSON();
+};
+
+module.exports = PromiseResolver;
+
+},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var THIS = {};
+var util = _dereq_("./util.js");
+var nodebackForPromise = _dereq_("./promise_resolver.js")
+ ._nodebackForPromise;
+var withAppended = util.withAppended;
+var maybeWrapAsError = util.maybeWrapAsError;
+var canEvaluate = util.canEvaluate;
+var TypeError = _dereq_("./errors").TypeError;
+var defaultSuffix = "Async";
+var defaultPromisified = {__isPromisified__: true};
+var noCopyProps = [
+ "arity", "length",
+ "name",
+ "arguments",
+ "caller",
+ "callee",
+ "prototype",
+ "__isPromisified__"
+];
+var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
+
+var defaultFilter = function(name) {
+ return util.isIdentifier(name) &&
+ name.charAt(0) !== "_" &&
+ name !== "constructor";
+};
+
+function propsFilter(key) {
+ return !noCopyPropsPattern.test(key);
+}
+
+function isPromisified(fn) {
+ try {
+ return fn.__isPromisified__ === true;
+ }
+ catch (e) {
+ return false;
+ }
+}
+
+function hasPromisified(obj, key, suffix) {
+ var val = util.getDataPropertyOrDefault(obj, key + suffix,
+ defaultPromisified);
+ return val ? isPromisified(val) : false;
+}
+function checkValid(ret, suffix, suffixRegexp) {
+ for (var i = 0; i < ret.length; i += 2) {
+ var key = ret[i];
+ if (suffixRegexp.test(key)) {
+ var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
+ for (var j = 0; j < ret.length; j += 2) {
+ if (ret[j] === keyWithoutAsyncSuffix) {
+ throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/iWrZbw\u000a"
+ .replace("%s", suffix));
+ }
+ }
+ }
+ }
+}
+
+function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
+ var keys = util.inheritedDataKeys(obj);
+ var ret = [];
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ var value = obj[key];
+ var passesDefaultFilter = filter === defaultFilter
+ ? true : defaultFilter(key, value, obj);
+ if (typeof value === "function" &&
+ !isPromisified(value) &&
+ !hasPromisified(obj, key, suffix) &&
+ filter(key, value, obj, passesDefaultFilter)) {
+ ret.push(key, value);
+ }
+ }
+ checkValid(ret, suffix, suffixRegexp);
+ return ret;
+}
+
+var escapeIdentRegex = function(str) {
+ return str.replace(/([$])/, "\\$");
+};
+
+var makeNodePromisifiedEval;
+if (!true) {
+var switchCaseArgumentOrder = function(likelyArgumentCount) {
+ var ret = [likelyArgumentCount];
+ var min = Math.max(0, likelyArgumentCount - 1 - 3);
+ for(var i = likelyArgumentCount - 1; i >= min; --i) {
+ ret.push(i);
+ }
+ for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
+ ret.push(i);
+ }
+ return ret;
+};
+
+var argumentSequence = function(argumentCount) {
+ return util.filledRange(argumentCount, "_arg", "");
+};
+
+var parameterDeclaration = function(parameterCount) {
+ return util.filledRange(
+ Math.max(parameterCount, 3), "_arg", "");
+};
+
+var parameterCount = function(fn) {
+ if (typeof fn.length === "number") {
+ return Math.max(Math.min(fn.length, 1023 + 1), 0);
+ }
+ return 0;
+};
+
+makeNodePromisifiedEval =
+function(callback, receiver, originalName, fn) {
+ var newParameterCount = Math.max(0, parameterCount(fn) - 1);
+ var argumentOrder = switchCaseArgumentOrder(newParameterCount);
+ var shouldProxyThis = typeof callback === "string" || receiver === THIS;
+
+ function generateCallForArgumentCount(count) {
+ var args = argumentSequence(count).join(", ");
+ var comma = count > 0 ? ", " : "";
+ var ret;
+ if (shouldProxyThis) {
+ ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
+ } else {
+ ret = receiver === undefined
+ ? "ret = callback({{args}}, nodeback); break;\n"
+ : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
+ }
+ return ret.replace("{{args}}", args).replace(", ", comma);
+ }
+
+ function generateArgumentSwitchCase() {
+ var ret = "";
+ for (var i = 0; i < argumentOrder.length; ++i) {
+ ret += "case " + argumentOrder[i] +":" +
+ generateCallForArgumentCount(argumentOrder[i]);
+ }
+
+ ret += " \n\
+ default: \n\
+ var args = new Array(len + 1); \n\
+ var i = 0; \n\
+ for (var i = 0; i < len; ++i) { \n\
+ args[i] = arguments[i]; \n\
+ } \n\
+ args[i] = nodeback; \n\
+ [CodeForCall] \n\
+ break; \n\
+ ".replace("[CodeForCall]", (shouldProxyThis
+ ? "ret = callback.apply(this, args);\n"
+ : "ret = callback.apply(receiver, args);\n"));
+ return ret;
+ }
+
+ var getFunctionCode = typeof callback === "string"
+ ? ("this != null ? this['"+callback+"'] : fn")
+ : "fn";
+
+ return new Function("Promise",
+ "fn",
+ "receiver",
+ "withAppended",
+ "maybeWrapAsError",
+ "nodebackForPromise",
+ "tryCatch",
+ "errorObj",
+ "notEnumerableProp",
+ "INTERNAL","'use strict'; \n\
+ var ret = function (Parameters) { \n\
+ 'use strict'; \n\
+ var len = arguments.length; \n\
+ var promise = new Promise(INTERNAL); \n\
+ promise._captureStackTrace(); \n\
+ var nodeback = nodebackForPromise(promise); \n\
+ var ret; \n\
+ var callback = tryCatch([GetFunctionCode]); \n\
+ switch(len) { \n\
+ [CodeForSwitchCase] \n\
+ } \n\
+ if (ret === errorObj) { \n\
+ promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
+ } \n\
+ return promise; \n\
+ }; \n\
+ notEnumerableProp(ret, '__isPromisified__', true); \n\
+ return ret; \n\
+ "
+ .replace("Parameters", parameterDeclaration(newParameterCount))
+ .replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
+ .replace("[GetFunctionCode]", getFunctionCode))(
+ Promise,
+ fn,
+ receiver,
+ withAppended,
+ maybeWrapAsError,
+ nodebackForPromise,
+ util.tryCatch,
+ util.errorObj,
+ util.notEnumerableProp,
+ INTERNAL
+ );
+};
+}
+
+function makeNodePromisifiedClosure(callback, receiver, _, fn) {
+ var defaultThis = (function() {return this;})();
+ var method = callback;
+ if (typeof method === "string") {
+ callback = fn;
+ }
+ function promisified() {
+ var _receiver = receiver;
+ if (receiver === THIS) _receiver = this;
+ var promise = new Promise(INTERNAL);
+ promise._captureStackTrace();
+ var cb = typeof method === "string" && this !== defaultThis
+ ? this[method] : callback;
+ var fn = nodebackForPromise(promise);
+ try {
+ cb.apply(_receiver, withAppended(arguments, fn));
+ } catch(e) {
+ promise._rejectCallback(maybeWrapAsError(e), true, true);
+ }
+ return promise;
+ }
+ util.notEnumerableProp(promisified, "__isPromisified__", true);
+ return promisified;
+}
+
+var makeNodePromisified = canEvaluate
+ ? makeNodePromisifiedEval
+ : makeNodePromisifiedClosure;
+
+function promisifyAll(obj, suffix, filter, promisifier) {
+ var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
+ var methods =
+ promisifiableMethods(obj, suffix, suffixRegexp, filter);
+
+ for (var i = 0, len = methods.length; i < len; i+= 2) {
+ var key = methods[i];
+ var fn = methods[i+1];
+ var promisifiedKey = key + suffix;
+ if (promisifier === makeNodePromisified) {
+ obj[promisifiedKey] =
+ makeNodePromisified(key, THIS, key, fn, suffix);
+ } else {
+ var promisified = promisifier(fn, function() {
+ return makeNodePromisified(key, THIS, key, fn, suffix);
+ });
+ util.notEnumerableProp(promisified, "__isPromisified__", true);
+ obj[promisifiedKey] = promisified;
+ }
+ }
+ util.toFastProperties(obj);
+ return obj;
+}
+
+function promisify(callback, receiver) {
+ return makeNodePromisified(callback, receiver, undefined, callback);
+}
+
+Promise.promisify = function (fn, receiver) {
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ if (isPromisified(fn)) {
+ return fn;
+ }
+ var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
+ util.copyDescriptors(fn, ret, propsFilter);
+ return ret;
+};
+
+Promise.promisifyAll = function (target, options) {
+ if (typeof target !== "function" && typeof target !== "object") {
+ throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/9ITlV0\u000a");
+ }
+ options = Object(options);
+ var suffix = options.suffix;
+ if (typeof suffix !== "string") suffix = defaultSuffix;
+ var filter = options.filter;
+ if (typeof filter !== "function") filter = defaultFilter;
+ var promisifier = options.promisifier;
+ if (typeof promisifier !== "function") promisifier = makeNodePromisified;
+
+ if (!util.isIdentifier(suffix)) {
+ throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/8FZo5V\u000a");
+ }
+
+ var keys = util.inheritedDataKeys(target);
+ for (var i = 0; i < keys.length; ++i) {
+ var value = target[keys[i]];
+ if (keys[i] !== "constructor" &&
+ util.isClass(value)) {
+ promisifyAll(value.prototype, suffix, filter, promisifier);
+ promisifyAll(value, suffix, filter, promisifier);
+ }
+ }
+
+ return promisifyAll(target, suffix, filter, promisifier);
+};
+};
+
+
+},{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(
+ Promise, PromiseArray, tryConvertToPromise, apiRejection) {
+var util = _dereq_("./util.js");
+var isObject = util.isObject;
+var es5 = _dereq_("./es5.js");
+
+function PropertiesPromiseArray(obj) {
+ var keys = es5.keys(obj);
+ var len = keys.length;
+ var values = new Array(len * 2);
+ for (var i = 0; i < len; ++i) {
+ var key = keys[i];
+ values[i] = obj[key];
+ values[i + len] = key;
+ }
+ this.constructor$(values);
+}
+util.inherits(PropertiesPromiseArray, PromiseArray);
+
+PropertiesPromiseArray.prototype._init = function () {
+ this._init$(undefined, -3) ;
+};
+
+PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ var val = {};
+ var keyOffset = this.length();
+ for (var i = 0, len = this.length(); i < len; ++i) {
+ val[this._values[i + keyOffset]] = this._values[i];
+ }
+ this._resolve(val);
+ }
+};
+
+PropertiesPromiseArray.prototype._promiseProgressed = function (value, index) {
+ this._promise._progress({
+ key: this._values[index + this.length()],
+ value: value
+ });
+};
+
+PropertiesPromiseArray.prototype.shouldCopyValues = function () {
+ return false;
+};
+
+PropertiesPromiseArray.prototype.getActualLength = function (len) {
+ return len >> 1;
+};
+
+function props(promises) {
+ var ret;
+ var castValue = tryConvertToPromise(promises);
+
+ if (!isObject(castValue)) {
+ return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/OsFKC8\u000a");
+ } else if (castValue instanceof Promise) {
+ ret = castValue._then(
+ Promise.props, undefined, undefined, undefined, undefined);
+ } else {
+ ret = new PropertiesPromiseArray(castValue).promise();
+ }
+
+ if (castValue instanceof Promise) {
+ ret._propagateFrom(castValue, 4);
+ }
+ return ret;
+}
+
+Promise.prototype.props = function () {
+ return props(this);
+};
+
+Promise.props = function (promises) {
+ return props(promises);
+};
+};
+
+},{"./es5.js":14,"./util.js":38}],28:[function(_dereq_,module,exports){
+"use strict";
+function arrayMove(src, srcIndex, dst, dstIndex, len) {
+ for (var j = 0; j < len; ++j) {
+ dst[j + dstIndex] = src[j + srcIndex];
+ src[j + srcIndex] = void 0;
+ }
+}
+
+function Queue(capacity) {
+ this._capacity = capacity;
+ this._length = 0;
+ this._front = 0;
+}
+
+Queue.prototype._willBeOverCapacity = function (size) {
+ return this._capacity < size;
+};
+
+Queue.prototype._pushOne = function (arg) {
+ var length = this.length();
+ this._checkCapacity(length + 1);
+ var i = (this._front + length) & (this._capacity - 1);
+ this[i] = arg;
+ this._length = length + 1;
+};
+
+Queue.prototype._unshiftOne = function(value) {
+ var capacity = this._capacity;
+ this._checkCapacity(this.length() + 1);
+ var front = this._front;
+ var i = (((( front - 1 ) &
+ ( capacity - 1) ) ^ capacity ) - capacity );
+ this[i] = value;
+ this._front = i;
+ this._length = this.length() + 1;
+};
+
+Queue.prototype.unshift = function(fn, receiver, arg) {
+ this._unshiftOne(arg);
+ this._unshiftOne(receiver);
+ this._unshiftOne(fn);
+};
+
+Queue.prototype.push = function (fn, receiver, arg) {
+ var length = this.length() + 3;
+ if (this._willBeOverCapacity(length)) {
+ this._pushOne(fn);
+ this._pushOne(receiver);
+ this._pushOne(arg);
+ return;
+ }
+ var j = this._front + length - 3;
+ this._checkCapacity(length);
+ var wrapMask = this._capacity - 1;
+ this[(j + 0) & wrapMask] = fn;
+ this[(j + 1) & wrapMask] = receiver;
+ this[(j + 2) & wrapMask] = arg;
+ this._length = length;
+};
+
+Queue.prototype.shift = function () {
+ var front = this._front,
+ ret = this[front];
+
+ this[front] = undefined;
+ this._front = (front + 1) & (this._capacity - 1);
+ this._length--;
+ return ret;
+};
+
+Queue.prototype.length = function () {
+ return this._length;
+};
+
+Queue.prototype._checkCapacity = function (size) {
+ if (this._capacity < size) {
+ this._resizeTo(this._capacity << 1);
+ }
+};
+
+Queue.prototype._resizeTo = function (capacity) {
+ var oldCapacity = this._capacity;
+ this._capacity = capacity;
+ var front = this._front;
+ var length = this._length;
+ var moveItemsCount = (front + length) & (oldCapacity - 1);
+ arrayMove(this, 0, this, oldCapacity, moveItemsCount);
+};
+
+module.exports = Queue;
+
+},{}],29:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(
+ Promise, INTERNAL, tryConvertToPromise, apiRejection) {
+var isArray = _dereq_("./util.js").isArray;
+
+var raceLater = function (promise) {
+ return promise.then(function(array) {
+ return race(array, promise);
+ });
+};
+
+function race(promises, parent) {
+ var maybePromise = tryConvertToPromise(promises);
+
+ if (maybePromise instanceof Promise) {
+ return raceLater(maybePromise);
+ } else if (!isArray(promises)) {
+ return apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
+ }
+
+ var ret = new Promise(INTERNAL);
+ if (parent !== undefined) {
+ ret._propagateFrom(parent, 4 | 1);
+ }
+ var fulfill = ret._fulfill;
+ var reject = ret._reject;
+ for (var i = 0, len = promises.length; i < len; ++i) {
+ var val = promises[i];
+
+ if (val === undefined && !(i in promises)) {
+ continue;
+ }
+
+ Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
+ }
+ return ret;
+}
+
+Promise.race = function (promises) {
+ return race(promises, undefined);
+};
+
+Promise.prototype.race = function () {
+ return race(this, undefined);
+};
+
+};
+
+},{"./util.js":38}],30:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise,
+ PromiseArray,
+ apiRejection,
+ tryConvertToPromise,
+ INTERNAL) {
+var getDomain = Promise._getDomain;
+var async = _dereq_("./async.js");
+var util = _dereq_("./util.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+function ReductionPromiseArray(promises, fn, accum, _each) {
+ this.constructor$(promises);
+ this._promise._captureStackTrace();
+ this._preservedValues = _each === INTERNAL ? [] : null;
+ this._zerothIsAccum = (accum === undefined);
+ this._gotAccum = false;
+ this._reducingIndex = (this._zerothIsAccum ? 1 : 0);
+ this._valuesPhase = undefined;
+ var maybePromise = tryConvertToPromise(accum, this._promise);
+ var rejected = false;
+ var isPromise = maybePromise instanceof Promise;
+ if (isPromise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ maybePromise._proxyPromiseArray(this, -1);
+ } else if (maybePromise._isFulfilled()) {
+ accum = maybePromise._value();
+ this._gotAccum = true;
+ } else {
+ this._reject(maybePromise._reason());
+ rejected = true;
+ }
+ }
+ if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true;
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
+ this._accum = accum;
+ if (!rejected) async.invoke(init, this, undefined);
+}
+function init() {
+ this._init$(undefined, -5);
+}
+util.inherits(ReductionPromiseArray, PromiseArray);
+
+ReductionPromiseArray.prototype._init = function () {};
+
+ReductionPromiseArray.prototype._resolveEmptyArray = function () {
+ if (this._gotAccum || this._zerothIsAccum) {
+ this._resolve(this._preservedValues !== null
+ ? [] : this._accum);
+ }
+};
+
+ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var values = this._values;
+ values[index] = value;
+ var length = this.length();
+ var preservedValues = this._preservedValues;
+ var isEach = preservedValues !== null;
+ var gotAccum = this._gotAccum;
+ var valuesPhase = this._valuesPhase;
+ var valuesPhaseIndex;
+ if (!valuesPhase) {
+ valuesPhase = this._valuesPhase = new Array(length);
+ for (valuesPhaseIndex=0; valuesPhaseIndex<length; ++valuesPhaseIndex) {
+ valuesPhase[valuesPhaseIndex] = 0;
+ }
+ }
+ valuesPhaseIndex = valuesPhase[index];
+
+ if (index === 0 && this._zerothIsAccum) {
+ this._accum = value;
+ this._gotAccum = gotAccum = true;
+ valuesPhase[index] = ((valuesPhaseIndex === 0)
+ ? 1 : 2);
+ } else if (index === -1) {
+ this._accum = value;
+ this._gotAccum = gotAccum = true;
+ } else {
+ if (valuesPhaseIndex === 0) {
+ valuesPhase[index] = 1;
+ } else {
+ valuesPhase[index] = 2;
+ this._accum = value;
+ }
+ }
+ if (!gotAccum) return;
+
+ var callback = this._callback;
+ var receiver = this._promise._boundValue();
+ var ret;
+
+ for (var i = this._reducingIndex; i < length; ++i) {
+ valuesPhaseIndex = valuesPhase[i];
+ if (valuesPhaseIndex === 2) {
+ this._reducingIndex = i + 1;
+ continue;
+ }
+ if (valuesPhaseIndex !== 1) return;
+ value = values[i];
+ this._promise._pushContext();
+ if (isEach) {
+ preservedValues.push(value);
+ ret = tryCatch(callback).call(receiver, value, i, length);
+ }
+ else {
+ ret = tryCatch(callback)
+ .call(receiver, this._accum, value, i, length);
+ }
+ this._promise._popContext();
+
+ if (ret === errorObj) return this._reject(ret.e);
+
+ var maybePromise = tryConvertToPromise(ret, this._promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ valuesPhase[i] = 4;
+ return maybePromise._proxyPromiseArray(this, i);
+ } else if (maybePromise._isFulfilled()) {
+ ret = maybePromise._value();
+ } else {
+ return this._reject(maybePromise._reason());
+ }
+ }
+
+ this._reducingIndex = i + 1;
+ this._accum = ret;
+ }
+
+ this._resolve(isEach ? preservedValues : this._accum);
+};
+
+function reduce(promises, fn, initialValue, _each) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
+ return array.promise();
+}
+
+Promise.prototype.reduce = function (fn, initialValue) {
+ return reduce(this, fn, initialValue, null);
+};
+
+Promise.reduce = function (promises, fn, initialValue, _each) {
+ return reduce(promises, fn, initialValue, _each);
+};
+};
+
+},{"./async.js":2,"./util.js":38}],31:[function(_dereq_,module,exports){
+"use strict";
+var schedule;
+var util = _dereq_("./util");
+var noAsyncScheduler = function() {
+ throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
+};
+if (util.isNode && typeof MutationObserver === "undefined") {
+ var GlobalSetImmediate = global.setImmediate;
+ var ProcessNextTick = process.nextTick;
+ schedule = util.isRecentNode
+ ? function(fn) { GlobalSetImmediate.call(global, fn); }
+ : function(fn) { ProcessNextTick.call(process, fn); };
+} else if ((typeof MutationObserver !== "undefined") &&
+ !(typeof window !== "undefined" &&
+ window.navigator &&
+ window.navigator.standalone)) {
+ schedule = function(fn) {
+ var div = document.createElement("div");
+ var observer = new MutationObserver(fn);
+ observer.observe(div, {attributes: true});
+ return function() { div.classList.toggle("foo"); };
+ };
+ schedule.isStatic = true;
+} else if (typeof setImmediate !== "undefined") {
+ schedule = function (fn) {
+ setImmediate(fn);
+ };
+} else if (typeof setTimeout !== "undefined") {
+ schedule = function (fn) {
+ setTimeout(fn, 0);
+ };
+} else {
+ schedule = noAsyncScheduler;
+}
+module.exports = schedule;
+
+},{"./util":38}],32:[function(_dereq_,module,exports){
+"use strict";
+module.exports =
+ function(Promise, PromiseArray) {
+var PromiseInspection = Promise.PromiseInspection;
+var util = _dereq_("./util.js");
+
+function SettledPromiseArray(values) {
+ this.constructor$(values);
+}
+util.inherits(SettledPromiseArray, PromiseArray);
+
+SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
+ this._values[index] = inspection;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var ret = new PromiseInspection();
+ ret._bitField = 268435456;
+ ret._settledValue = value;
+ this._promiseResolved(index, ret);
+};
+SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
+ var ret = new PromiseInspection();
+ ret._bitField = 134217728;
+ ret._settledValue = reason;
+ this._promiseResolved(index, ret);
+};
+
+Promise.settle = function (promises) {
+ return new SettledPromiseArray(promises).promise();
+};
+
+Promise.prototype.settle = function () {
+ return new SettledPromiseArray(this).promise();
+};
+};
+
+},{"./util.js":38}],33:[function(_dereq_,module,exports){
+"use strict";
+module.exports =
+function(Promise, PromiseArray, apiRejection) {
+var util = _dereq_("./util.js");
+var RangeError = _dereq_("./errors.js").RangeError;
+var AggregateError = _dereq_("./errors.js").AggregateError;
+var isArray = util.isArray;
+
+
+function SomePromiseArray(values) {
+ this.constructor$(values);
+ this._howMany = 0;
+ this._unwrap = false;
+ this._initialized = false;
+}
+util.inherits(SomePromiseArray, PromiseArray);
+
+SomePromiseArray.prototype._init = function () {
+ if (!this._initialized) {
+ return;
+ }
+ if (this._howMany === 0) {
+ this._resolve([]);
+ return;
+ }
+ this._init$(undefined, -5);
+ var isArrayResolved = isArray(this._values);
+ if (!this._isResolved() &&
+ isArrayResolved &&
+ this._howMany > this._canPossiblyFulfill()) {
+ this._reject(this._getRangeError(this.length()));
+ }
+};
+
+SomePromiseArray.prototype.init = function () {
+ this._initialized = true;
+ this._init();
+};
+
+SomePromiseArray.prototype.setUnwrap = function () {
+ this._unwrap = true;
+};
+
+SomePromiseArray.prototype.howMany = function () {
+ return this._howMany;
+};
+
+SomePromiseArray.prototype.setHowMany = function (count) {
+ this._howMany = count;
+};
+
+SomePromiseArray.prototype._promiseFulfilled = function (value) {
+ this._addFulfilled(value);
+ if (this._fulfilled() === this.howMany()) {
+ this._values.length = this.howMany();
+ if (this.howMany() === 1 && this._unwrap) {
+ this._resolve(this._values[0]);
+ } else {
+ this._resolve(this._values);
+ }
+ }
+
+};
+SomePromiseArray.prototype._promiseRejected = function (reason) {
+ this._addRejected(reason);
+ if (this.howMany() > this._canPossiblyFulfill()) {
+ var e = new AggregateError();
+ for (var i = this.length(); i < this._values.length; ++i) {
+ e.push(this._values[i]);
+ }
+ this._reject(e);
+ }
+};
+
+SomePromiseArray.prototype._fulfilled = function () {
+ return this._totalResolved;
+};
+
+SomePromiseArray.prototype._rejected = function () {
+ return this._values.length - this.length();
+};
+
+SomePromiseArray.prototype._addRejected = function (reason) {
+ this._values.push(reason);
+};
+
+SomePromiseArray.prototype._addFulfilled = function (value) {
+ this._values[this._totalResolved++] = value;
+};
+
+SomePromiseArray.prototype._canPossiblyFulfill = function () {
+ return this.length() - this._rejected();
+};
+
+SomePromiseArray.prototype._getRangeError = function (count) {
+ var message = "Input array must contain at least " +
+ this._howMany + " items but contains only " + count + " items";
+ return new RangeError(message);
+};
+
+SomePromiseArray.prototype._resolveEmptyArray = function () {
+ this._reject(this._getRangeError(0));
+};
+
+function some(promises, howMany) {
+ if ((howMany | 0) !== howMany || howMany < 0) {
+ return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/1wAmHx\u000a");
+ }
+ var ret = new SomePromiseArray(promises);
+ var promise = ret.promise();
+ ret.setHowMany(howMany);
+ ret.init();
+ return promise;
+}
+
+Promise.some = function (promises, howMany) {
+ return some(promises, howMany);
+};
+
+Promise.prototype.some = function (howMany) {
+ return some(this, howMany);
+};
+
+Promise._SomePromiseArray = SomePromiseArray;
+};
+
+},{"./errors.js":13,"./util.js":38}],34:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise) {
+function PromiseInspection(promise) {
+ if (promise !== undefined) {
+ promise = promise._target();
+ this._bitField = promise._bitField;
+ this._settledValue = promise._settledValue;
+ }
+ else {
+ this._bitField = 0;
+ this._settledValue = undefined;
+ }
+}
+
+PromiseInspection.prototype.value = function () {
+ if (!this.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.error =
+PromiseInspection.prototype.reason = function () {
+ if (!this.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.isFulfilled =
+Promise.prototype._isFulfilled = function () {
+ return (this._bitField & 268435456) > 0;
+};
+
+PromiseInspection.prototype.isRejected =
+Promise.prototype._isRejected = function () {
+ return (this._bitField & 134217728) > 0;
+};
+
+PromiseInspection.prototype.isPending =
+Promise.prototype._isPending = function () {
+ return (this._bitField & 402653184) === 0;
+};
+
+PromiseInspection.prototype.isResolved =
+Promise.prototype._isResolved = function () {
+ return (this._bitField & 402653184) > 0;
+};
+
+Promise.prototype.isPending = function() {
+ return this._target()._isPending();
+};
+
+Promise.prototype.isRejected = function() {
+ return this._target()._isRejected();
+};
+
+Promise.prototype.isFulfilled = function() {
+ return this._target()._isFulfilled();
+};
+
+Promise.prototype.isResolved = function() {
+ return this._target()._isResolved();
+};
+
+Promise.prototype._value = function() {
+ return this._settledValue;
+};
+
+Promise.prototype._reason = function() {
+ this._unsetRejectionIsUnhandled();
+ return this._settledValue;
+};
+
+Promise.prototype.value = function() {
+ var target = this._target();
+ if (!target.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
+ }
+ return target._settledValue;
+};
+
+Promise.prototype.reason = function() {
+ var target = this._target();
+ if (!target.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
+ }
+ target._unsetRejectionIsUnhandled();
+ return target._settledValue;
+};
+
+
+Promise.PromiseInspection = PromiseInspection;
+};
+
+},{}],35:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var util = _dereq_("./util.js");
+var errorObj = util.errorObj;
+var isObject = util.isObject;
+
+function tryConvertToPromise(obj, context) {
+ if (isObject(obj)) {
+ if (obj instanceof Promise) {
+ return obj;
+ }
+ else if (isAnyBluebirdPromise(obj)) {
+ var ret = new Promise(INTERNAL);
+ obj._then(
+ ret._fulfillUnchecked,
+ ret._rejectUncheckedCheckError,
+ ret._progressUnchecked,
+ ret,
+ null
+ );
+ return ret;
+ }
+ var then = util.tryCatch(getThen)(obj);
+ if (then === errorObj) {
+ if (context) context._pushContext();
+ var ret = Promise.reject(then.e);
+ if (context) context._popContext();
+ return ret;
+ } else if (typeof then === "function") {
+ return doThenable(obj, then, context);
+ }
+ }
+ return obj;
+}
+
+function getThen(obj) {
+ return obj.then;
+}
+
+var hasProp = {}.hasOwnProperty;
+function isAnyBluebirdPromise(obj) {
+ return hasProp.call(obj, "_promise0");
+}
+
+function doThenable(x, then, context) {
+ var promise = new Promise(INTERNAL);
+ var ret = promise;
+ if (context) context._pushContext();
+ promise._captureStackTrace();
+ if (context) context._popContext();
+ var synchronous = true;
+ var result = util.tryCatch(then).call(x,
+ resolveFromThenable,
+ rejectFromThenable,
+ progressFromThenable);
+ synchronous = false;
+ if (promise && result === errorObj) {
+ promise._rejectCallback(result.e, true, true);
+ promise = null;
+ }
+
+ function resolveFromThenable(value) {
+ if (!promise) return;
+ promise._resolveCallback(value);
+ promise = null;
+ }
+
+ function rejectFromThenable(reason) {
+ if (!promise) return;
+ promise._rejectCallback(reason, synchronous, true);
+ promise = null;
+ }
+
+ function progressFromThenable(value) {
+ if (!promise) return;
+ if (typeof promise._progress === "function") {
+ promise._progress(value);
+ }
+ }
+ return ret;
+}
+
+return tryConvertToPromise;
+};
+
+},{"./util.js":38}],36:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var util = _dereq_("./util.js");
+var TimeoutError = Promise.TimeoutError;
+
+var afterTimeout = function (promise, message) {
+ if (!promise.isPending()) return;
+
+ var err;
+ if(!util.isPrimitive(message) && (message instanceof Error)) {
+ err = message;
+ } else {
+ if (typeof message !== "string") {
+ message = "operation timed out";
+ }
+ err = new TimeoutError(message);
+ }
+ util.markAsOriginatingFromRejection(err);
+ promise._attachExtraTrace(err);
+ promise._cancel(err);
+};
+
+var afterValue = function(value) { return delay(+this).thenReturn(value); };
+var delay = Promise.delay = function (value, ms) {
+ if (ms === undefined) {
+ ms = value;
+ value = undefined;
+ var ret = new Promise(INTERNAL);
+ setTimeout(function() { ret._fulfill(); }, ms);
+ return ret;
+ }
+ ms = +ms;
+ return Promise.resolve(value)._then(afterValue, null, null, ms, undefined);
+};
+
+Promise.prototype.delay = function (ms) {
+ return delay(this, ms);
+};
+
+function successClear(value) {
+ var handle = this;
+ if (handle instanceof Number) handle = +handle;
+ clearTimeout(handle);
+ return value;
+}
+
+function failureClear(reason) {
+ var handle = this;
+ if (handle instanceof Number) handle = +handle;
+ clearTimeout(handle);
+ throw reason;
+}
+
+Promise.prototype.timeout = function (ms, message) {
+ ms = +ms;
+ var ret = this.then().cancellable();
+ ret._cancellationParent = this;
+ var handle = setTimeout(function timeoutTimeout() {
+ afterTimeout(ret, message);
+ }, ms);
+ return ret._then(successClear, failureClear, undefined, handle, undefined);
+};
+
+};
+
+},{"./util.js":38}],37:[function(_dereq_,module,exports){
+"use strict";
+module.exports = function (Promise, apiRejection, tryConvertToPromise,
+ createContext) {
+ var TypeError = _dereq_("./errors.js").TypeError;
+ var inherits = _dereq_("./util.js").inherits;
+ var PromiseInspection = Promise.PromiseInspection;
+
+ function inspectionMapper(inspections) {
+ var len = inspections.length;
+ for (var i = 0; i < len; ++i) {
+ var inspection = inspections[i];
+ if (inspection.isRejected()) {
+ return Promise.reject(inspection.error());
+ }
+ inspections[i] = inspection._settledValue;
+ }
+ return inspections;
+ }
+
+ function thrower(e) {
+ setTimeout(function(){throw e;}, 0);
+ }
+
+ function castPreservingDisposable(thenable) {
+ var maybePromise = tryConvertToPromise(thenable);
+ if (maybePromise !== thenable &&
+ typeof thenable._isDisposable === "function" &&
+ typeof thenable._getDisposer === "function" &&
+ thenable._isDisposable()) {
+ maybePromise._setDisposable(thenable._getDisposer());
+ }
+ return maybePromise;
+ }
+ function dispose(resources, inspection) {
+ var i = 0;
+ var len = resources.length;
+ var ret = Promise.defer();
+ function iterator() {
+ if (i >= len) return ret.resolve();
+ var maybePromise = castPreservingDisposable(resources[i++]);
+ if (maybePromise instanceof Promise &&
+ maybePromise._isDisposable()) {
+ try {
+ maybePromise = tryConvertToPromise(
+ maybePromise._getDisposer().tryDispose(inspection),
+ resources.promise);
+ } catch (e) {
+ return thrower(e);
+ }
+ if (maybePromise instanceof Promise) {
+ return maybePromise._then(iterator, thrower,
+ null, null, null);
+ }
+ }
+ iterator();
+ }
+ iterator();
+ return ret.promise;
+ }
+
+ function disposerSuccess(value) {
+ var inspection = new PromiseInspection();
+ inspection._settledValue = value;
+ inspection._bitField = 268435456;
+ return dispose(this, inspection).thenReturn(value);
+ }
+
+ function disposerFail(reason) {
+ var inspection = new PromiseInspection();
+ inspection._settledValue = reason;
+ inspection._bitField = 134217728;
+ return dispose(this, inspection).thenThrow(reason);
+ }
+
+ function Disposer(data, promise, context) {
+ this._data = data;
+ this._promise = promise;
+ this._context = context;
+ }
+
+ Disposer.prototype.data = function () {
+ return this._data;
+ };
+
+ Disposer.prototype.promise = function () {
+ return this._promise;
+ };
+
+ Disposer.prototype.resource = function () {
+ if (this.promise().isFulfilled()) {
+ return this.promise().value();
+ }
+ return null;
+ };
+
+ Disposer.prototype.tryDispose = function(inspection) {
+ var resource = this.resource();
+ var context = this._context;
+ if (context !== undefined) context._pushContext();
+ var ret = resource !== null
+ ? this.doDispose(resource, inspection) : null;
+ if (context !== undefined) context._popContext();
+ this._promise._unsetDisposable();
+ this._data = null;
+ return ret;
+ };
+
+ Disposer.isDisposer = function (d) {
+ return (d != null &&
+ typeof d.resource === "function" &&
+ typeof d.tryDispose === "function");
+ };
+
+ function FunctionDisposer(fn, promise, context) {
+ this.constructor$(fn, promise, context);
+ }
+ inherits(FunctionDisposer, Disposer);
+
+ FunctionDisposer.prototype.doDispose = function (resource, inspection) {
+ var fn = this.data();
+ return fn.call(resource, resource, inspection);
+ };
+
+ function maybeUnwrapDisposer(value) {
+ if (Disposer.isDisposer(value)) {
+ this.resources[this.index]._setDisposable(value);
+ return value.promise();
+ }
+ return value;
+ }
+
+ Promise.using = function () {
+ var len = arguments.length;
+ if (len < 2) return apiRejection(
+ "you must pass at least 2 arguments to Promise.using");
+ var fn = arguments[len - 1];
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+
+ var input;
+ var spreadArgs = true;
+ if (len === 2 && Array.isArray(arguments[0])) {
+ input = arguments[0];
+ len = input.length;
+ spreadArgs = false;
+ } else {
+ input = arguments;
+ len--;
+ }
+ var resources = new Array(len);
+ for (var i = 0; i < len; ++i) {
+ var resource = input[i];
+ if (Disposer.isDisposer(resource)) {
+ var disposer = resource;
+ resource = resource.promise();
+ resource._setDisposable(disposer);
+ } else {
+ var maybePromise = tryConvertToPromise(resource);
+ if (maybePromise instanceof Promise) {
+ resource =
+ maybePromise._then(maybeUnwrapDisposer, null, null, {
+ resources: resources,
+ index: i
+ }, undefined);
+ }
+ }
+ resources[i] = resource;
+ }
+
+ var promise = Promise.settle(resources)
+ .then(inspectionMapper)
+ .then(function(vals) {
+ promise._pushContext();
+ var ret;
+ try {
+ ret = spreadArgs
+ ? fn.apply(undefined, vals) : fn.call(undefined, vals);
+ } finally {
+ promise._popContext();
+ }
+ return ret;
+ })
+ ._then(
+ disposerSuccess, disposerFail, undefined, resources, undefined);
+ resources.promise = promise;
+ return promise;
+ };
+
+ Promise.prototype._setDisposable = function (disposer) {
+ this._bitField = this._bitField | 262144;
+ this._disposer = disposer;
+ };
+
+ Promise.prototype._isDisposable = function () {
+ return (this._bitField & 262144) > 0;
+ };
+
+ Promise.prototype._getDisposer = function () {
+ return this._disposer;
+ };
+
+ Promise.prototype._unsetDisposable = function () {
+ this._bitField = this._bitField & (~262144);
+ this._disposer = undefined;
+ };
+
+ Promise.prototype.disposer = function (fn) {
+ if (typeof fn === "function") {
+ return new FunctionDisposer(fn, this, createContext());
+ }
+ throw new TypeError();
+ };
+
+};
+
+},{"./errors.js":13,"./util.js":38}],38:[function(_dereq_,module,exports){
+"use strict";
+var es5 = _dereq_("./es5.js");
+var canEvaluate = typeof navigator == "undefined";
+var haveGetters = (function(){
+ try {
+ var o = {};
+ es5.defineProperty(o, "f", {
+ get: function () {
+ return 3;
+ }
+ });
+ return o.f === 3;
+ }
+ catch (e) {
+ return false;
+ }
+
+})();
+
+var errorObj = {e: {}};
+var tryCatchTarget;
+function tryCatcher() {
+ try {
+ var target = tryCatchTarget;
+ tryCatchTarget = null;
+ return target.apply(this, arguments);
+ } catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+function tryCatch(fn) {
+ tryCatchTarget = fn;
+ return tryCatcher;
+}
+
+var inherits = function(Child, Parent) {
+ var hasProp = {}.hasOwnProperty;
+
+ function T() {
+ this.constructor = Child;
+ this.constructor$ = Parent;
+ for (var propertyName in Parent.prototype) {
+ if (hasProp.call(Parent.prototype, propertyName) &&
+ propertyName.charAt(propertyName.length-1) !== "$"
+ ) {
+ this[propertyName + "$"] = Parent.prototype[propertyName];
+ }
+ }
+ }
+ T.prototype = Parent.prototype;
+ Child.prototype = new T();
+ return Child.prototype;
+};
+
+
+function isPrimitive(val) {
+ return val == null || val === true || val === false ||
+ typeof val === "string" || typeof val === "number";
+
+}
+
+function isObject(value) {
+ return !isPrimitive(value);
+}
+
+function maybeWrapAsError(maybeError) {
+ if (!isPrimitive(maybeError)) return maybeError;
+
+ return new Error(safeToString(maybeError));
+}
+
+function withAppended(target, appendee) {
+ var len = target.length;
+ var ret = new Array(len + 1);
+ var i;
+ for (i = 0; i < len; ++i) {
+ ret[i] = target[i];
+ }
+ ret[i] = appendee;
+ return ret;
+}
+
+function getDataPropertyOrDefault(obj, key, defaultValue) {
+ if (es5.isES5) {
+ var desc = Object.getOwnPropertyDescriptor(obj, key);
+
+ if (desc != null) {
+ return desc.get == null && desc.set == null
+ ? desc.value
+ : defaultValue;
+ }
+ } else {
+ return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
+ }
+}
+
+function notEnumerableProp(obj, name, value) {
+ if (isPrimitive(obj)) return obj;
+ var descriptor = {
+ value: value,
+ configurable: true,
+ enumerable: false,
+ writable: true
+ };
+ es5.defineProperty(obj, name, descriptor);
+ return obj;
+}
+
+function thrower(r) {
+ throw r;
+}
+
+var inheritedDataKeys = (function() {
+ var excludedPrototypes = [
+ Array.prototype,
+ Object.prototype,
+ Function.prototype
+ ];
+
+ var isExcludedProto = function(val) {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (excludedPrototypes[i] === val) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ if (es5.isES5) {
+ var getKeys = Object.getOwnPropertyNames;
+ return function(obj) {
+ var ret = [];
+ var visitedKeys = Object.create(null);
+ while (obj != null && !isExcludedProto(obj)) {
+ var keys;
+ try {
+ keys = getKeys(obj);
+ } catch (e) {
+ return ret;
+ }
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (visitedKeys[key]) continue;
+ visitedKeys[key] = true;
+ var desc = Object.getOwnPropertyDescriptor(obj, key);
+ if (desc != null && desc.get == null && desc.set == null) {
+ ret.push(key);
+ }
+ }
+ obj = es5.getPrototypeOf(obj);
+ }
+ return ret;
+ };
+ } else {
+ var hasProp = {}.hasOwnProperty;
+ return function(obj) {
+ if (isExcludedProto(obj)) return [];
+ var ret = [];
+
+ /*jshint forin:false */
+ enumeration: for (var key in obj) {
+ if (hasProp.call(obj, key)) {
+ ret.push(key);
+ } else {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (hasProp.call(excludedPrototypes[i], key)) {
+ continue enumeration;
+ }
+ }
+ ret.push(key);
+ }
+ }
+ return ret;
+ };
+ }
+
+})();
+
+var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
+function isClass(fn) {
+ try {
+ if (typeof fn === "function") {
+ var keys = es5.names(fn.prototype);
+
+ var hasMethods = es5.isES5 && keys.length > 1;
+ var hasMethodsOtherThanConstructor = keys.length > 0 &&
+ !(keys.length === 1 && keys[0] === "constructor");
+ var hasThisAssignmentAndStaticMethods =
+ thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
+
+ if (hasMethods || hasMethodsOtherThanConstructor ||
+ hasThisAssignmentAndStaticMethods) {
+ return true;
+ }
+ }
+ return false;
+ } catch (e) {
+ return false;
+ }
+}
+
+function toFastProperties(obj) {
+ /*jshint -W027,-W055,-W031*/
+ function f() {}
+ f.prototype = obj;
+ var l = 8;
+ while (l--) new f();
+ return obj;
+ eval(obj);
+}
+
+var rident = /^[a-z$_][a-z$_0-9]*$/i;
+function isIdentifier(str) {
+ return rident.test(str);
+}
+
+function filledRange(count, prefix, suffix) {
+ var ret = new Array(count);
+ for(var i = 0; i < count; ++i) {
+ ret[i] = prefix + i + suffix;
+ }
+ return ret;
+}
+
+function safeToString(obj) {
+ try {
+ return obj + "";
+ } catch (e) {
+ return "[no string representation]";
+ }
+}
+
+function markAsOriginatingFromRejection(e) {
+ try {
+ notEnumerableProp(e, "isOperational", true);
+ }
+ catch(ignore) {}
+}
+
+function originatesFromRejection(e) {
+ if (e == null) return false;
+ return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
+ e["isOperational"] === true);
+}
+
+function canAttachTrace(obj) {
+ return obj instanceof Error && es5.propertyIsWritable(obj, "stack");
+}
+
+var ensureErrorObject = (function() {
+ if (!("stack" in new Error())) {
+ return function(value) {
+ if (canAttachTrace(value)) return value;
+ try {throw new Error(safeToString(value));}
+ catch(err) {return err;}
+ };
+ } else {
+ return function(value) {
+ if (canAttachTrace(value)) return value;
+ return new Error(safeToString(value));
+ };
+ }
+})();
+
+function classString(obj) {
+ return {}.toString.call(obj);
+}
+
+function copyDescriptors(from, to, filter) {
+ var keys = es5.names(from);
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (filter(key)) {
+ try {
+ es5.defineProperty(to, key, es5.getDescriptor(from, key));
+ } catch (ignore) {}
+ }
+ }
+}
+
+var ret = {
+ isClass: isClass,
+ isIdentifier: isIdentifier,
+ inheritedDataKeys: inheritedDataKeys,
+ getDataPropertyOrDefault: getDataPropertyOrDefault,
+ thrower: thrower,
+ isArray: es5.isArray,
+ haveGetters: haveGetters,
+ notEnumerableProp: notEnumerableProp,
+ isPrimitive: isPrimitive,
+ isObject: isObject,
+ canEvaluate: canEvaluate,
+ errorObj: errorObj,
+ tryCatch: tryCatch,
+ inherits: inherits,
+ withAppended: withAppended,
+ maybeWrapAsError: maybeWrapAsError,
+ toFastProperties: toFastProperties,
+ filledRange: filledRange,
+ toString: safeToString,
+ canAttachTrace: canAttachTrace,
+ ensureErrorObject: ensureErrorObject,
+ originatesFromRejection: originatesFromRejection,
+ markAsOriginatingFromRejection: markAsOriginatingFromRejection,
+ classString: classString,
+ copyDescriptors: copyDescriptors,
+ hasDevTools: typeof chrome !== "undefined" && chrome &&
+ typeof chrome.loadTimes === "function",
+ isNode: typeof process !== "undefined" &&
+ classString(process).toLowerCase() === "[object process]"
+};
+ret.isRecentNode = ret.isNode && (function() {
+ var version = process.versions.node.split(".").map(Number);
+ return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
+})();
+
+if (ret.isNode) ret.toFastProperties(process);
+
+try {throw new Error(); } catch (e) {ret.lastLineError = e;}
+module.exports = ret;
+
+},{"./es5.js":14}]},{},[4])(4)
+}); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; } \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.min.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.min.js
new file mode 100644
index 0000000..9d066dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/browser/bluebird.min.js
@@ -0,0 +1,31 @@
+/* @preserve
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013-2015 Petka Antonov
+ *
+ * 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.
+ *
+ */
+/**
+ * bluebird build version 2.10.2
+ * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, cancel, using, filter, any, each, timers
+*/
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Promise=t()}}(function(){var t,e,r;return function n(t,e,r){function i(s,a){if(!e[s]){if(!t[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=e[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return i(r?r:e)},l,l.exports,n,t,e,r)}return e[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e){"use strict";e.exports=function(t){function e(t){var e=new r(t),n=e.promise();return e.setHowMany(1),e.setUnwrap(),e.init(),n}var r=t._SomePromiseArray;t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},{}],2:[function(t,e){"use strict";function r(){this._isTickUsed=!1,this._lateQueue=new c(16),this._normalQueue=new c(16),this._trampolineEnabled=!0;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=u.isStatic?u(this.drainQueues):u}function n(t,e,r){this._lateQueue.push(t,e,r),this._queueTick()}function i(t,e,r){this._normalQueue.push(t,e,r),this._queueTick()}function o(t){this._normalQueue._pushOne(t),this._queueTick()}var s;try{throw new Error}catch(a){s=a}var u=t("./schedule.js"),c=t("./queue.js"),l=t("./util.js");r.prototype.disableTrampolineIfNecessary=function(){l.hasDevTools&&(this._trampolineEnabled=!1)},r.prototype.enableTrampoline=function(){this._trampolineEnabled||(this._trampolineEnabled=!0,this._schedule=function(t){setTimeout(t,0)})},r.prototype.haveItemsQueued=function(){return this._normalQueue.length()>0},r.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(r){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},l.hasDevTools?(u.isStatic&&(u=function(t){setTimeout(t,0)}),r.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?n.call(this,t,e,r):this._schedule(function(){setTimeout(function(){t.call(e,r)},100)})},r.prototype.invoke=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):this._schedule(function(){t.call(e,r)})},r.prototype.settlePromises=function(t){this._trampolineEnabled?o.call(this,t):this._schedule(function(){t._settlePromises()})}):(r.prototype.invokeLater=n,r.prototype.invoke=i,r.prototype.settlePromises=o),r.prototype.invokeFirst=function(t,e,r){this._normalQueue.unshift(t,e,r),this._queueTick()},r.prototype._drainQueue=function(t){for(;t.length()>0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=new r,e.exports.firstLineError=s},{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(t,e){"use strict";e.exports=function(t,e,r){var n=function(t,e){this._reject(e)},i=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},o=function(t,e){this._isPending()&&this._resolveCallback(e.target)},s=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(n){var a=r(n),u=new t(e);u._propagateFrom(this,1);var c=this._target();if(u._setBoundTo(a),a instanceof t){var l={promiseRejectionQueued:!1,promise:u,target:c,bindingPromise:a};c._then(e,i,u._progress,u,l),a._then(o,s,u._progress,u,l)}else u._resolveCallback(c);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=131072|this._bitField,this._boundTo=t):this._bitField=-131073&this._bitField},t.prototype._isBound=function(){return 131072===(131072&this._bitField)},t.bind=function(n,i){var o=r(n),s=new t(e);return s._setBoundTo(o),o instanceof t?o._then(function(){s._resolveCallback(i)},s._reject,s._progress,s,null):s._resolveCallback(i),s}}},{}],4:[function(t,e){"use strict";function r(){try{Promise===i&&(Promise=n)}catch(t){}return i}var n;"undefined"!=typeof Promise&&(n=Promise);var i=t("./promise.js")();i.noConflict=r,e.exports=i},{"./promise.js":23}],5:[function(t,e){"use strict";var r=Object.create;if(r){var n=r(null),i=r(null);n[" size"]=i[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+a.classString(t)+" has no method '"+a.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}{var s,a=t("./util.js"),u=a.canEvaluate;a.isIdentifier}e.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),i=1;e>i;++i)r[i-1]=arguments[i];return r.push(t),this._then(n,void 0,void 0,r,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(u){var n=s(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util.js":38}],6:[function(t,e){"use strict";e.exports=function(e){var r=t("./errors.js"),n=t("./async.js"),i=r.CancellationError;e.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;this._unsetCancellable(),r._target()._rejectCallback(t,!1,!0)},e.prototype.cancel=function(t){return this.isCancellable()?(void 0===t&&(t=new i),n.invokeLater(this._cancel,this,t),this):this},e.prototype.cancellable=function(){return this._cancellable()?this:(n.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},e.prototype.uncancellable=function(){var t=this.then();return t._unsetCancellable(),t},e.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},{"./async.js":2,"./errors.js":13}],7:[function(t,e){"use strict";e.exports=function(){function e(t){this._parent=t;var r=this._length=1+(void 0===t?0:t._length);j(this,e),r>32&&this.uncycle()}function r(t,e){for(var r=0;r<e.length-1;++r)e[r].push("From previous event:"),e[r]=e[r].join("\n");return r<e.length&&(e[r]=e[r].join("\n")),t+"\n"+e.join("\n")}function n(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}function i(t){for(var e=t[0],r=1;r<t.length;++r){for(var n=t[r],i=e.length-1,o=e[i],s=-1,a=n.length-1;a>=0;--a)if(n[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=n[a];if(e[i]!==u)break;e.pop(),i--}e=n}}function o(t){for(var e=[],r=0;r<t.length;++r){var n=t[r],i=_.test(n)||" (No stack trace)"===n,o=i&&y(n);i&&!o&&(v&&" "!==n.charAt(0)&&(n=" "+n),e.push(n))}return e}function s(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),r=0;r<e.length;++r){var n=e[r];if(" (No stack trace)"===n||_.test(n))break}return r>0&&(e=e.slice(r)),e}function a(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t.toString();var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(i){}0===e.length&&(e="(empty array)")}return"(<"+u(e)+">, no stack trace)"}function u(t){var e=41;return t.length<e?t:t.substr(0,e-3)+"..."}function c(t){var e=t.match(g);return e?{fileName:e[1],line:parseInt(e[2],10)}:void 0}var l,h=t("./async.js"),p=t("./util.js"),f=/[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/,_=null,d=null,v=!1;p.inherits(e,Error),e.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var s=e[n].stack,a=r[s];if(void 0!==a&&a!==n){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;t-1>a?(u._parent=e[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,l=n-2;l>=0;--l)e[l]._length=c,c++;return}}}},e.prototype.parent=function(){return this._parent},e.prototype.hasParent=function(){return void 0!==this._parent},e.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var s=e.parseStackAndMessage(t),a=s.message,u=[s.stack],c=this;void 0!==c;)u.push(o(c.stack.split("\n"))),c=c._parent;i(u),n(u),p.notEnumerableProp(t,"stack",r(a,u)),p.notEnumerableProp(t,"__stackCleaned__",!0)}},e.parseStackAndMessage=function(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?s(t):[" (No stack trace)"],{message:r,stack:o(e)}},e.formatAndLogError=function(t,e){if("undefined"!=typeof console){var r;if("object"==typeof t||"function"==typeof t){var n=t.stack;r=e+d(n,t)}else r=e+String(t);"function"==typeof l?l(r):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}},e.unhandledRejection=function(t){e.formatAndLogError(t,"^--- With additional stack trace: ")},e.isSupported=function(){return"function"==typeof j},e.fireRejectionEvent=function(t,r,n,i){var o=!1;try{"function"==typeof r&&(o=!0,"rejectionHandled"===t?r(i):r(n,i))}catch(s){h.throwLater(s)}var a=!1;try{a=b(t,n,i)}catch(s){a=!0,h.throwLater(s)}var u=!1;if(m)try{u=m(t.toLowerCase(),{reason:n,promise:i})}catch(s){u=!0,h.throwLater(s)}a||o||u||"unhandledRejection"!==t||e.formatAndLogError(n,"Unhandled rejection ")};var y=function(){return!1},g=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;e.setBounds=function(t,r){if(e.isSupported()){for(var n,i,o=t.stack.split("\n"),s=r.stack.split("\n"),a=-1,u=-1,l=0;l<o.length;++l){var h=c(o[l]);if(h){n=h.fileName,a=h.line;break}}for(var l=0;l<s.length;++l){var h=c(s[l]);if(h){i=h.fileName,u=h.line;break}}0>a||0>u||!n||!i||n!==i||a>=u||(y=function(t){if(f.test(t))return!0;var e=c(t);return e&&e.fileName===n&&a<=e.line&&e.line<=u?!0:!1})}};var m,j=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():a(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,_=t,d=e;var r=Error.captureStackTrace;return y=function(t){return f.test(t)},function(t,e){Error.stackTraceLimit=Error.stackTraceLimit+6,r(t,e),Error.stackTraceLimit=Error.stackTraceLimit-6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return _=/@/,d=e,v=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(o){i="stack"in o}return"stack"in n||!i||"number"!=typeof Error.stackTraceLimit?(d=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?a(e):e.toString()},null):(_=t,d=e,function(t){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}([]),b=function(){if(p.isNode)return function(t,e,r){return"rejectionHandled"===t?process.emit(t,r):process.emit(t,e,r)};var t=!1,e=!0;try{var r=new self.CustomEvent("test");t=r instanceof CustomEvent}catch(n){}if(!t)try{var i=document.createEvent("CustomEvent");i.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(i)}catch(n){e=!1}e&&(m=function(e,r){var n;return t?n=new self.CustomEvent(e,{detail:r,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!0,r)),n?!self.dispatchEvent(n):!1});var o={};return o.unhandledRejection="onunhandledRejection".toLowerCase(),o.rejectionHandled="onrejectionHandled".toLowerCase(),function(t,e,r){var n=o[t],i=self[n];return i?("rejectionHandled"===t?i.call(self,r):i.call(self,e,r),!0):!1}}();return"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(l=function(t){console.warn(t)},p.isNode&&process.stderr.isTTY?l=function(t){process.stderr.write(""+t+"\n")}:p.isNode||"string"!=typeof(new Error).stack||(l=function(t){console.warn("%c"+t,"color: red")})),e}},{"./async.js":2,"./util.js":38}],8:[function(t,e){"use strict";e.exports=function(e){function r(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=s(t).call(r,e);if(n===a)return n;var i=u(r);return i.length?(a.e=new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),a):n}var i=t("./util.js"),o=t("./errors.js"),s=i.tryCatch,a=i.errorObj,u=t("./es5.js").keys,c=o.TypeError;return r.prototype.doFilter=function(t){for(var r=this._callback,i=this._promise,o=i._boundValue(),u=0,c=this._instances.length;c>u;++u){var l=this._instances[u],h=l===Error||null!=l&&l.prototype instanceof Error;if(h&&t instanceof l){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}if("function"==typeof l&&!h){var f=n(l,t);if(f===a){t=a.e;break}if(f){var p=s(r).call(o,t);return p===a?(e.e=p.e,e):p}}}return e.e=t,e},r}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(t,e){"use strict";e.exports=function(t,e,r){function n(){this._trace=new e(o())}function i(){return r()?new n:void 0}function o(){var t=s.length-1;return t>=0?s[t]:void 0}var s=[];return n.prototype._pushContext=function(){r()&&void 0!==this._trace&&s.push(this._trace)},n.prototype._popContext=function(){r()&&void 0!==this._trace&&s.pop()},t.prototype._peekContext=o,t.prototype._pushContext=n.prototype._pushContext,t.prototype._popContext=n.prototype._popContext,i}},{}],10:[function(t,e){"use strict";e.exports=function(e,r){var n,i,o=e._getDomain,s=t("./async.js"),a=t("./errors.js").Warning,u=t("./util.js"),c=u.canAttachTrace,l=!1||u.isNode&&(!!process.env.BLUEBIRD_DEBUG||"development"===process.env.NODE_ENV);return u.isNode&&0==process.env.BLUEBIRD_DEBUG&&(l=!1),l&&s.disableTrampolineIfNecessary(),e.prototype._ignoreRejections=function(){this._unsetRejectionIsUnhandled(),this._bitField=16777216|this._bitField},e.prototype._ensurePossibleRejectionHandled=function(){0===(16777216&this._bitField)&&(this._setRejectionIsUnhandled(),s.invokeLater(this._notifyUnhandledRejection,this,void 0))},e.prototype._notifyUnhandledRejectionIsHandled=function(){r.fireRejectionEvent("rejectionHandled",n,void 0,this)},e.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),r.fireRejectionEvent("unhandledRejection",i,t,this)}},e.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},e.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},e.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},e.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},e.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},e.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},e.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},e.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},e.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},e.prototype._captureStackTrace=function(){return l&&(this._trace=new r(this._peekContext())),this},e.prototype._attachExtraTrace=function(t,e){if(l&&c(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var i=r.parseStackAndMessage(t);u.notEnumerableProp(t,"stack",i.message+"\n"+i.stack.join("\n")),u.notEnumerableProp(t,"__stackCleaned__",!0)}}},e.prototype._warn=function(t){var e=new a(t),n=this._peekContext();if(n)n.attachExtraTrace(e);else{var i=r.parseStackAndMessage(e);e.stack=i.message+"\n"+i.stack.join("\n")}r.formatAndLogError(e,"")},e.onPossiblyUnhandledRejection=function(t){var e=o();i="function"==typeof t?null===e?t:e.bind(t):void 0},e.onUnhandledRejectionHandled=function(t){var e=o();n="function"==typeof t?null===e?t:e.bind(t):void 0},e.longStackTraces=function(){if(s.haveItemsQueued()&&l===!1)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");l=r.isSupported(),l&&s.disableTrampolineIfNecessary()},e.hasLongStackTraces=function(){return l&&r.isSupported()},r.isSupported()||(e.longStackTraces=function(){},l=!1),function(){return l}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(t,e){"use strict";var r=t("./util.js"),n=r.isPrimitive;e.exports=function(t){var e=function(){return this},r=function(){throw this},i=function(){},o=function(){throw void 0},s=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype["return"]=t.prototype.thenReturn=function(r){return void 0===r?this.then(i):n(r)?this._then(s(r,2),void 0,void 0,void 0,void 0):(r instanceof t&&r._ignoreRejections(),this._then(e,void 0,void 0,r,void 0))},t.prototype["throw"]=t.prototype.thenThrow=function(t){return void 0===t?this.then(o):n(t)?this._then(s(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},{"./util.js":38}],12:[function(t,e){"use strict";e.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},{}],13:[function(t,e){"use strict";function r(t,e){function r(n){return this instanceof r?(l(this,"message","string"==typeof n?n:e),l(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return c(r,Error),r}function n(t){return this instanceof n?(l(this,"name","OperationalError"),l(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(l(this,"message",t.message),l(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new n(t)}var i,o,s=t("./es5.js"),a=s.freeze,u=t("./util.js"),c=u.inherits,l=u.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),f=r("TimeoutError","timeout error"),_=r("AggregateError","aggregate error");try{i=TypeError,o=RangeError}catch(d){i=r("TypeError","type error"),o=r("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),y=0;y<v.length;++y)"function"==typeof Array.prototype[v[y]]&&(_.prototype[v[y]]=Array.prototype[v[y]]);s.defineProperty(_.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),_.prototype.isOperational=!0;var g=0;_.prototype.toString=function(){var t=Array(4*g+1).join(" "),e="\n"+t+"AggregateError of:\n";g++,t=Array(4*g+1).join(" ");for(var r=0;r<this.length;++r){for(var n=this[r]===this?"[Circular AggregateError]":this[r]+"",i=n.split("\n"),o=0;o<i.length;++o)i[o]=t+i[o];n=i.join("\n"),e+=n+"\n"}return g--,e},c(n,Error);var m=Error.__BluebirdErrorTypes__;m||(m=a({CancellationError:p,TimeoutError:f,OperationalError:n,RejectionError:n,AggregateError:_}),l(Error,"__BluebirdErrorTypes__",m)),e.exports={Error:Error,TypeError:i,RangeError:o,CancellationError:m.CancellationError,OperationalError:m.OperationalError,TimeoutError:m.TimeoutError,AggregateError:m.AggregateError,Warning:h}},{"./es5.js":14,"./util.js":38}],14:[function(t,e){var r=function(){"use strict";return void 0===this}();if(r)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return!(r&&!r.writable&&!r.set)}};else{var n={}.hasOwnProperty,i={}.toString,o={}.constructor.prototype,s=function(t){var e=[];for(var r in t)n.call(t,r)&&e.push(r);return e},a=function(t,e){return{value:t[e]}},u=function(t,e,r){return t[e]=r.value,t},c=function(t){return t},l=function(t){try{return Object(t).constructor.prototype}catch(e){return o}},h=function(t){try{return"[object Array]"===i.call(t)}catch(e){return!1}};e.exports={isArray:h,keys:s,names:s,defineProperty:u,getDescriptor:a,freeze:c,getPrototypeOf:l,isES5:r,propertyIsWritable:function(){return!0}}}},{}],15:[function(t,e){"use strict";e.exports=function(t,e){var r=t.map;t.prototype.filter=function(t,n){return r(this,t,n,e)},t.filter=function(t,n,i){return r(t,n,i,e)}}},{}],16:[function(t,e){"use strict";e.exports=function(e,r,n){function i(){return this}function o(){throw this}function s(t){return function(){return t}}function a(t){return function(){throw t}}function u(t,e,r){var n;return n=p(e)?r?s(e):a(e):r?i:o,t._then(n,f,void 0,e,void 0)}function c(t){var i=this.promise,o=this.handler,s=i._isBound()?o.call(i._boundValue()):o();if(void 0!==s){var a=n(s,i);if(a instanceof e)return a=a._target(),u(a,t,i.isFulfilled())}return i.isRejected()?(r.e=t,r):t}function l(t){var r=this.promise,i=this.handler,o=r._isBound()?i.call(r._boundValue(),t):i(t);if(void 0!==o){var s=n(o,r);if(s instanceof e)return s=s._target(),u(s,t,!0)}return t}var h=t("./util.js"),p=h.isPrimitive,f=h.thrower;e.prototype._passThroughHandler=function(t,e){if("function"!=typeof t)return this.then();var r={promise:this,handler:t};return this._then(e?c:l,e?c:void 0,void 0,r,void 0)},e.prototype.lastly=e.prototype["finally"]=function(t){return this._passThroughHandler(t,!0)},e.prototype.tap=function(t){return this._passThroughHandler(t,!1)}}},{"./util.js":38}],17:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t,r,n){for(var o=0;o<r.length;++o){n._pushContext();var s=h(r[o])(t);if(n._popContext(),s===l){n._pushContext();var a=e.reject(l.e);return n._popContext(),a}var u=i(s,n);if(u instanceof e)return u}return null}function s(t,r,i,o){var s=this._promise=new e(n);s._captureStackTrace(),this._stack=o,this._generatorFunction=t,this._receiver=r,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(p):p}var a=t("./errors.js"),u=a.TypeError,c=t("./util.js"),l=c.errorObj,h=c.tryCatch,p=[];s.prototype.promise=function(){return this._promise},s.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},s.prototype._continue=function(t){if(t===l)return this._promise._rejectCallback(t.e,!1,!0);var r=t.value;if(t.done===!0)this._promise._resolveCallback(r);else{var n=i(r,this._promise);if(!(n instanceof e)&&(n=o(n,this._yieldHandlers,this._promise),null===n))return void this._throw(new u("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/4Y4pDk\n\n".replace("%s",r)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));n._then(this._next,this._throw,void 0,this,null)}},s.prototype._throw=function(t){this._promise._attachExtraTrace(t),this._promise._pushContext();var e=h(this._generator["throw"]).call(this._generator,t);this._promise._popContext(),this._continue(e)},s.prototype._next=function(t){this._promise._pushContext();var e=h(this._generator.next).call(this._generator,t);this._promise._popContext(),this._continue(e)},e.coroutine=function(t,e){if("function"!=typeof t)throw new u("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var r=Object(e).yieldHandler,n=s,i=(new Error).stack;return function(){var e=t.apply(this,arguments),o=new n(void 0,void 0,r,i);return o._generator=e,o._next(void 0),o.promise()}},e.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new u("fn must be a function\n\n See http://goo.gl/916lJJ\n");p.push(t)},e.spawn=function(t){if("function"!=typeof t)return r("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var n=new s(t,this),i=n.promise();return n._run(e.spawn),i}}},{"./errors.js":13,"./util.js":38}],18:[function(t,e){"use strict";e.exports=function(e,r,n,i){{var o=t("./util.js");o.canEvaluate,o.tryCatch,o.errorObj}e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var n}for(var i=arguments.length,o=new Array(i),s=0;i>s;++s)o[s]=arguments[s];t&&o.pop();var n=new r(o).promise();return void 0!==t?n.spread(t):n}}},{"./util.js":38}],19:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace();var i=c();this._callback=null===i?e:i.bind(e),this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:d,l.invoke(a,this,void 0)}function a(){this._init$(void 0,-2)}function u(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new s(t,e,i,n)}var c=e._getDomain,l=t("./async.js"),h=t("./util.js"),p=h.tryCatch,f=h.errorObj,_={},d=[];h.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,a=this._limit;if(n[r]===_){if(n[r]=t,a>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(a>=1&&this._inFlight>=a)return n[r]=t,void this._queue.push(r);null!==s&&(s[r]=t);var u=this._callback,c=this._promise._boundValue();this._promise._pushContext();var l=p(u).call(c,t,r,o);if(this._promise._popContext(),l===f)return this._reject(l.e);var h=i(l,this._promise);if(h instanceof e){if(h=h._target(),h._isPending())return a>=1&&this._inFlight++,n[r]=_,h._proxyPromiseArray(this,r);if(!h._isFulfilled())return this._reject(h._reason());l=h._value()}n[r]=l}var d=++this._totalResolved;d>=o&&(null!==s?this._filter(n,s):this._resolve(n))},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlight<e;){if(this._isResolved())return;var n=t.pop();this._promiseFulfilled(r[n],n)}},s.prototype._filter=function(t,e){for(var r=e.length,n=new Array(r),i=0,o=0;r>o;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(this,t,e,null).promise()},e.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(t,e,r,i).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(t,e){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js"),s=o.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments);return n._popContext(),n._resolveFromSyncValue(i),n}},e.attempt=e["try"]=function(t,n,a){if("function"!=typeof t)return i("fn must be a function\n\n See http://goo.gl/916lJJ\n");var u=new e(r);u._captureStackTrace(),u._pushContext();var c=o.isArray(n)?s(t).apply(a,n):s(t).call(a,n);return u._popContext(),u._resolveFromSyncValue(c),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1,!0):this._resolveCallback(t,!0)}}},{"./util.js":38}],21:[function(t,e){"use strict";e.exports=function(e){function r(t,e){var r=this;if(!o.isArray(t))return n.call(r,t,e);var i=a(e).apply(r._boundValue(),[null].concat(t));i===u&&s.throwLater(i.e)}function n(t,e){var r=this,n=r._boundValue(),i=void 0===t?a(e).call(n,null):a(e).call(n,null,t);i===u&&s.throwLater(i.e)}function i(t,e){var r=this;if(!t){var n=r._target(),i=n._getCarriedStackTrace();i.cause=t,t=i}var o=a(e).call(r._boundValue(),t);o===u&&s.throwLater(o.e)}var o=t("./util.js"),s=t("./async.js"),a=o.tryCatch,u=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=n;void 0!==e&&Object(e).spread&&(o=r),this._then(o,i,void 0,this,t)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(t,e){"use strict";e.exports=function(e,r){var n=t("./util.js"),i=t("./async.js"),o=n.tryCatch,s=n.errorObj;e.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},e.prototype._progress=function(t){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(t)},e.prototype._progressHandlerAt=function(t){return 0===t?this._progressHandler0:this[(t<<2)+t-5+2]},e.prototype._doProgressWith=function(t){var r=t.value,i=t.handler,a=t.promise,u=t.receiver,c=o(i).call(u,r);if(c===s){if(null!=c.e&&"StopProgressPropagation"!==c.e.name){var l=n.canAttachTrace(c.e)?c.e:new Error(n.toString(c.e));a._attachExtraTrace(l),a._progress(c.e)}}else c instanceof e?c._then(a._progress,null,null,a,void 0):a._progress(c)},e.prototype._progressUnchecked=function(t){for(var n=this._length(),o=this._progress,s=0;n>s;s++){var a=this._progressHandlerAt(s),u=this._promiseAt(s);if(u instanceof e)"function"==typeof a?i.invoke(this._doProgressWith,this,{handler:a,promise:u,receiver:this._receiverAt(s),value:t}):i.invoke(o,u,t);else{var c=this._receiverAt(s);"function"==typeof a?a.call(c,t,u):c instanceof r&&!c._isResolved()&&c._promiseProgressed(t,u)}}}}},{"./async.js":2,"./util.js":38}],23:[function(t,e){"use strict";e.exports=function(){function e(t){if("function"!=typeof t)throw new h("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==e)throw new h("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,t!==p&&this._resolveFromResolver(t)}function r(t){var r=new e(p);r._fulfillmentHandler0=t,r._rejectionHandler0=t,r._progressHandler0=t,r._promise0=t,r._receiver0=t,r._settledValue=t}var n,i=function(){return new h("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},o=function(){return new e.PromiseInspection(this._target())},s=function(t){return e.reject(new h(t))},a=t("./util.js");n=a.isNode?function(){var t=process.domain;return void 0===t&&(t=null),t}:function(){return null},a.notEnumerableProp(e,"_getDomain",n);var u={},c=t("./async.js"),l=t("./errors.js"),h=e.TypeError=l.TypeError;e.RangeError=l.RangeError,e.CancellationError=l.CancellationError,e.TimeoutError=l.TimeoutError,e.OperationalError=l.OperationalError,e.RejectionError=l.OperationalError,e.AggregateError=l.AggregateError;var p=function(){},f={},_={e:null},d=t("./thenables.js")(e,p),v=t("./promise_array.js")(e,p,d,s),y=t("./captured_trace.js")(),g=t("./debuggability.js")(e,y),m=t("./context.js")(e,y,g),j=t("./catch_filter.js")(_),b=t("./promise_resolver.js"),w=b._nodebackForPromise,k=a.errorObj,E=a.tryCatch;return e.prototype.toString=function(){return"[object Promise]"},e.prototype.caught=e.prototype["catch"]=function(t){var r=arguments.length;if(r>1){var n,i=new Array(r-1),o=0;for(n=0;r-1>n;++n){var s=arguments[n];if("function"!=typeof s)return e.reject(new h("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));i[o++]=s}i.length=o,t=arguments[n];var a=new j(i,t,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},e.prototype.reflect=function(){return this._then(o,o,void 0,this,void 0)},e.prototype.then=function(t,e,r){if(g()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+a.classString(t);arguments.length>1&&(n+=", "+a.classString(e)),this._warn(n)}return this._then(t,e,r,void 0,void 0)},e.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);
+n._setIsFinal()},e.prototype.spread=function(t,e){return this.all()._then(t,e,void 0,f,void 0)},e.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},e.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},e.prototype.all=function(){return new v(this).promise()},e.prototype.error=function(t){return this.caught(a.originatesFromRejection,t)},e.is=function(t){return t instanceof e},e.fromNode=function(t){var r=new e(p),n=E(t)(w(r));return n===k&&r._rejectCallback(n.e,!0,!0),r},e.all=function(t){return new v(t).promise()},e.defer=e.pending=function(){var t=new e(p);return new b(t)},e.cast=function(t){var r=d(t);if(!(r instanceof e)){var n=r;r=new e(p),r._fulfillUnchecked(n)}return r},e.resolve=e.fulfilled=e.cast,e.reject=e.rejected=function(t){var r=new e(p);return r._captureStackTrace(),r._rejectCallback(t,!0),r},e.setScheduler=function(t){if("function"!=typeof t)throw new h("fn must be a function\n\n See http://goo.gl/916lJJ\n");var e=c._schedule;return c._schedule=t,e},e.prototype._then=function(t,r,i,o,s){var a=void 0!==s,u=a?s:new e(p);a||(u._propagateFrom(this,5),u._captureStackTrace());var l=this._target();l!==this&&(void 0===o&&(o=this._boundTo),a||u._setIsMigrated());var h=l._addCallbacks(t,r,i,u,o,n());return l._isResolved()&&!l._isSettlePromisesQueued()&&c.invoke(l._settlePromiseAtPostResolution,l,h),u},e.prototype._settlePromiseAtPostResolution=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(t)},e.prototype._length=function(){return 131071&this._bitField},e.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},e.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},e.prototype._setLength=function(t){this._bitField=-131072&this._bitField|131071&t},e.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},e.prototype._setRejected=function(){this._bitField=134217728|this._bitField},e.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},e.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},e.prototype._isFinal=function(){return(33554432&this._bitField)>0},e.prototype._cancellable=function(){return(67108864&this._bitField)>0},e.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},e.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},e.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},e.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},e.prototype._isMigrated=function(){return(4194304&this._bitField)>0},e.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[5*t-5+4];return e===u?void 0:void 0===e&&this._isBound()?this._boundValue():e},e.prototype._promiseAt=function(t){return 0===t?this._promise0:this[5*t-5+3]},e.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[5*t-5+0]},e.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[5*t-5+1]},e.prototype._boundValue=function(){var t=this._boundTo;return void 0!==t&&t instanceof e?t.isFulfilled()?t.value():void 0:t},e.prototype._migrateCallbacks=function(t,r){var n=t._fulfillmentHandlerAt(r),i=t._rejectionHandlerAt(r),o=t._progressHandlerAt(r),s=t._promiseAt(r),a=t._receiverAt(r);s instanceof e&&s._setIsMigrated(),void 0===a&&(a=u),this._addCallbacks(n,i,o,s,a,null)},e.prototype._addCallbacks=function(t,e,r,n,i,o){var s=this._length();if(s>=131066&&(s=0,this._setLength(0)),0===s)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=null===o?t:o.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===o?e:o.bind(e)),"function"==typeof r&&(this._progressHandler0=null===o?r:o.bind(r));else{var a=5*s-5;this[a+3]=n,this[a+4]=i,"function"==typeof t&&(this[a+0]=null===o?t:o.bind(t)),"function"==typeof e&&(this[a+1]=null===o?e:o.bind(e)),"function"==typeof r&&(this[a+2]=null===o?r:o.bind(r))}return this._setLength(s+1),s},e.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=131066&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=5*r-5;this[n+3]=e,this[n+4]=t}this._setLength(r+1)},e.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},e.prototype._resolveCallback=function(t,r){if(!this._isFollowingOrFulfilledOrRejected()){if(t===this)return this._rejectCallback(i(),!1,!0);var n=d(t,this);if(!(n instanceof e))return this._fulfill(t);var o=1|(r?4:0);this._propagateFrom(n,o);var s=n._target();if(s._isPending()){for(var a=this._length(),u=0;a>u;++u)s._migrateCallbacks(this,u);this._setFollowing(),this._setLength(0),this._setFollowee(s)}else s._isFulfilled()?this._fulfillUnchecked(s._value()):this._rejectUnchecked(s._reason(),s._getCarriedStackTrace())}},e.prototype._rejectCallback=function(t,e,r){r||a.markAsOriginatingFromRejection(t);var n=a.ensureErrorObject(t),i=n===t;this._attachExtraTrace(n,e?i:!1),this._reject(t,i?void 0:n)},e.prototype._resolveFromResolver=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=E(t)(function(t){null!==e&&(e._resolveCallback(t),e=null)},function(t){null!==e&&(e._rejectCallback(t,r),e=null)});r=!1,this._popContext(),void 0!==n&&n===k&&null!==e&&(e._rejectCallback(n.e,!0,!0),e=null)},e.prototype._settlePromiseFromHandler=function(t,e,r,n){if(!n._isRejected()){n._pushContext();var o;if(o=e!==f||this._isRejected()?E(t).call(e,r):E(t).apply(this._boundValue(),r),n._popContext(),o===k||o===n||o===_){var s=o===n?i():o.e;n._rejectCallback(s,!1,!0)}else n._resolveCallback(o)}},e.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},e.prototype._followee=function(){return this._rejectionHandler0},e.prototype._setFollowee=function(t){this._rejectionHandler0=t},e.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},e.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&t._isBound()&&this._setBoundTo(t._boundTo)},e.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},e.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},e.prototype._settlePromiseAt=function(t){var r=this._promiseAt(t),n=r instanceof e;if(n&&r._isMigrated())return r._unsetIsMigrated(),c.invoke(this._settlePromiseAt,this,t);var i=this._isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),o=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,s=this._settledValue,a=this._receiverAt(t);this._clearCallbackDataAtIndex(t),"function"==typeof i?n?this._settlePromiseFromHandler(i,a,s,r):i.call(a,s,r):a instanceof v?a._isResolved()||(this._isFulfilled()?a._promiseFulfilled(s,r):a._promiseRejected(s,r)):n&&(this._isFulfilled()?r._fulfill(s):r._reject(s,o)),t>=4&&4===(31&t)&&c.invokeLater(this._setLength,this,0)},e.prototype._clearCallbackDataAtIndex=function(t){if(0===t)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var e=5*t-5;this[e+3]=this[e+4]=this[e+0]=this[e+1]=this[e+2]=void 0}},e.prototype._isSettlePromisesQueued=function(){return-1073741824===(-1073741824&this._bitField)},e.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},e.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},e.prototype._queueSettlePromises=function(){c.settlePromises(this),this._setSettlePromisesQueued()},e.prototype._fulfillUnchecked=function(t){if(t===this){var e=i();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._setFulfilled(),this._settledValue=t,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},e.prototype._rejectUncheckedCheckError=function(t){var e=a.ensureErrorObject(t);this._rejectUnchecked(t,e===t?void 0:e)},e.prototype._rejectUnchecked=function(t,e){if(t===this){var r=i();return this._attachExtraTrace(r),this._rejectUnchecked(r)}return this._setRejected(),this._settledValue=t,this._cleanValues(),this._isFinal()?void c.throwLater(function(t){throw"stack"in t&&c.invokeFirst(y.unhandledRejection,void 0,t),t},void 0===e?t:e):(void 0!==e&&e!==t&&this._setCarriedStackTrace(e),void(this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()))},e.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},a.notEnumerableProp(e,"_makeSelfResolutionError",i),t("./progress.js")(e,v),t("./method.js")(e,p,d,s),t("./bind.js")(e,p,d),t("./finally.js")(e,_,d),t("./direct_resolve.js")(e),t("./synchronous_inspection.js")(e),t("./join.js")(e,v,d,p),e.Promise=e,t("./map.js")(e,v,s,d,p),t("./cancel.js")(e),t("./using.js")(e,s,d,m),t("./generators.js")(e,s,p,d),t("./nodeify.js")(e),t("./call_get.js")(e),t("./props.js")(e,v,d,s),t("./race.js")(e,p,d,s),t("./reduce.js")(e,v,s,d,p),t("./settle.js")(e,v),t("./some.js")(e,v,s),t("./promisify.js")(e,p),t("./any.js")(e),t("./each.js")(e,p),t("./timers.js")(e,p),t("./filter.js")(e,p),a.toFastProperties(e),a.toFastProperties(e.prototype),r({a:1}),r({b:2}),r({c:3}),r(1),r(function(){}),r(void 0),r(!1),r(new e(p)),y.setBounds(c.firstLineError,a.lastLineError),e}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n,i=this._promise=new e(r);t instanceof e&&(n=t,i._propagateFrom(n,5)),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var a=t("./util.js"),u=a.isArray;return s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function c(t,r){var s=n(this._values,this._promise);if(s instanceof e){if(s=s._target(),this._values=s,!s._isFulfilled())return s._isPending()?void s._then(c,this._reject,void 0,this,r):void this._reject(s._reason());if(s=s._value(),!u(s)){var a=new e.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(a)}}else if(!u(s))return void this._promise._reject(i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===s.length)return void(-5===r?this._resolveEmptyArray():this._resolve(o(r)));var l=this.getActualLength(s.length);this._length=l,this._values=this.shouldCopyValues()?new Array(l):this._values;for(var h=this._promise,p=0;l>p;++p){var f=this._isResolved(),_=n(s[p],h);_ instanceof e?(_=_._target(),f?_._ignoreRejections():_._isPending()?_._proxyPromiseArray(this,p):_._isFulfilled()?this._promiseFulfilled(_._value(),p):this._promiseRejected(_._reason(),p)):f||this._promiseFulfilled(_,p)}},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype.__hardReject__=s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1,!0)},s.prototype._promiseProgressed=function(t,e){this._promise._progress({index:e,value:t})},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},s.prototype._promiseRejected=function(t){this._totalResolved++,this._reject(t)},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util.js":38}],25:[function(t,e){"use strict";function r(t){return t instanceof Error&&p.getPrototypeOf(t)===Error.prototype}function n(t){var e;if(r(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=p.keys(t),i=0;i<n.length;++i){var o=n[i];f.test(o)||(e[o]=t[o])}return e}return s.markAsOriginatingFromRejection(t),t}function i(t){return function(e,r){if(null!==t){if(e){var i=n(a(e));t._attachExtraTrace(i),t._reject(i)}else if(arguments.length>2){for(var o=arguments.length,s=new Array(o-1),u=1;o>u;++u)s[u-1]=arguments[u];t._fulfill(s)}else t._fulfill(r);t=null}}}var o,s=t("./util.js"),a=s.maybeWrapAsError,u=t("./errors.js"),c=u.TimeoutError,l=u.OperationalError,h=s.haveGetters,p=t("./es5.js"),f=/^(?:name|message|stack|cause)$/;if(o=h?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=i(t),this.callback=this.asCallback},h){var _={get:function(){return i(this.promise)}};p.defineProperty(o.prototype,"asCallback",_),p.defineProperty(o.prototype,"callback",_)}o._nodebackForPromise=i,o.prototype.toString=function(){return"[object PromiseResolver]"},o.prototype.resolve=o.prototype.fulfill=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(t)},o.prototype.reject=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(t)},o.prototype.progress=function(t){if(!(this instanceof o))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(t)},o.prototype.cancel=function(t){this.promise.cancel(t)},o.prototype.timeout=function(){this.reject(new c("timeout"))},o.prototype.isResolved=function(){return this.promise.isResolved()},o.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=o},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e){"use strict";e.exports=function(e,r){function n(t){return!w.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(e){return!1}}function o(t,e,r){var n=f.getDataPropertyOrDefault(t,e+r,j);return n?i(n):!1}function s(t,e,r){for(var n=0;n<t.length;n+=2){var i=t[n];if(r.test(i))for(var o=i.replace(r,""),s=0;s<t.length;s+=2)if(t[s]===o)throw new g("Cannot promisify an API that has normal methods with '%s'-suffix\n\n See http://goo.gl/iWrZbw\n".replace("%s",e))}}function a(t,e,r,n){for(var a=f.inheritedDataKeys(t),u=[],c=0;c<a.length;++c){var l=a[c],h=t[l],p=n===k?!0:k(l,h,t);"function"!=typeof h||i(h)||o(t,l,e)||!n(l,h,t,p)||u.push(l,h)}return s(u,e,r),u}function u(t,n,i,o){function s(){var i=n;n===p&&(i=this);var o=new e(r);o._captureStackTrace();var s="string"==typeof u&&this!==a?this[u]:t,c=_(o);try{s.apply(i,d(arguments,c))}catch(l){o._rejectCallback(v(l),!0,!0)}return o}var a=function(){return this}(),u=t;return"string"==typeof u&&(t=o),f.notEnumerableProp(s,"__isPromisified__",!0),s}function c(t,e,r,n){for(var i=new RegExp(E(e)+"$"),o=a(t,e,i,r),s=0,u=o.length;u>s;s+=2){var c=o[s],l=o[s+1],h=c+e;if(n===F)t[h]=F(c,p,c,l,e);else{var _=n(l,function(){return F(c,p,c,l,e)});f.notEnumerableProp(_,"__isPromisified__",!0),t[h]=_}}return f.toFastProperties(t),t}function l(t,e){return F(t,e,void 0,t)}var h,p={},f=t("./util.js"),_=t("./promise_resolver.js")._nodebackForPromise,d=f.withAppended,v=f.maybeWrapAsError,y=f.canEvaluate,g=t("./errors").TypeError,m="Async",j={__isPromisified__:!0},b=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],w=new RegExp("^(?:"+b.join("|")+")$"),k=function(t){return f.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},E=function(t){return t.replace(/([$])/,"\\$")},F=y?h:u;e.promisify=function(t,e){if("function"!=typeof t)throw new g("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(i(t))return t;var r=l(t,arguments.length<2?p:e);return f.copyDescriptors(t,r,n),r},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=m);var n=e.filter;"function"!=typeof n&&(n=k);var i=e.promisifier;if("function"!=typeof i&&(i=F),!f.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var o=f.inheritedDataKeys(t),s=0;s<o.length;++s){var a=t[o[s]];"constructor"!==o[s]&&f.isClass(a)&&(c(a.prototype,r,n,i),c(a,r,n,i))}return c(t,r,n,i)}}},{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){for(var e=c.keys(t),r=e.length,n=new Array(2*r),i=0;r>i;++i){var o=e[i];n[i]=t[o],n[i+r]=o}this.constructor$(n)}function s(t){var r,s=n(t);return u(s)?(r=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&r._propagateFrom(s,4),r):i("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var a=t("./util.js"),u=a.isObject,c=t("./es5.js");a.inherits(o,r),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),o=0,s=this.length();s>o;++o)n[this._values[o+i]]=this._values[o];this._resolve(n)}},o.prototype._promiseProgressed=function(t,e){this._promise._progress({key:this._values[e+this.length()],value:t})},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5.js":14,"./util.js":38}],28:[function(t,e){"use strict";function r(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function n(t){this._capacity=t,this._length=0,this._front=0}n.prototype._willBeOverCapacity=function(t){return this._capacity<t},n.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1);var r=this._front+e&this._capacity-1;this[r]=t,this._length=e+1},n.prototype._unshiftOne=function(t){var e=this._capacity;this._checkCapacity(this.length()+1);var r=this._front,n=(r-1&e-1^e)-e;this[n]=t,this._front=n,this._length=this.length()+1},n.prototype.unshift=function(t,e,r){this._unshiftOne(r),this._unshiftOne(e),this._unshiftOne(t)},n.prototype.push=function(t,e,r){var n=this.length()+3;if(this._willBeOverCapacity(n))return this._pushOne(t),this._pushOne(e),void this._pushOne(r);var i=this._front+n-3;this._checkCapacity(n);var o=this._capacity-1;this[i+0&o]=t,this[i+1&o]=e,this[i+2&o]=r,this._length=n},n.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},n.prototype.length=function(){return this._length},n.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},n.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var n=this._front,i=this._length,o=n+i&e-1;r(this,0,this,e,o)},e.exports=n},{}],29:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t,o){var u=n(t);if(u instanceof e)return a(u);if(!s(t))return i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");var c=new e(r);void 0!==o&&c._propagateFrom(o,5);for(var l=c._fulfill,h=c._reject,p=0,f=t.length;f>p;++p){var _=t[p];(void 0!==_||p in t)&&e.cast(_)._then(l,h,void 0,c,null)}return c}var s=t("./util.js").isArray,a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util.js":38}],30:[function(t,e){"use strict";e.exports=function(e,r,n,i,o){function s(t,r,n,s){this.constructor$(t),this._promise._captureStackTrace(),this._preservedValues=s===o?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var u=i(n,this._promise),h=!1,p=u instanceof e;p&&(u=u._target(),u._isPending()?u._proxyPromiseArray(this,-1):u._isFulfilled()?(n=u._value(),this._gotAccum=!0):(this._reject(u._reason()),h=!0)),p||this._zerothIsAccum||(this._gotAccum=!0);var f=c();this._callback=null===f?r:f.bind(r),this._accum=n,h||l.invoke(a,this,void 0)}function a(){this._init$(void 0,-5)}function u(t,e,r,i){if("function"!=typeof e)return n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var o=new s(t,e,r,i);return o.promise()}var c=e._getDomain,l=t("./async.js"),h=t("./util.js"),p=h.tryCatch,f=h.errorObj;h.inherits(s,r),s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},s.prototype._promiseFulfilled=function(t,r){var n=this._values;n[r]=t;var o,s=this.length(),a=this._preservedValues,u=null!==a,c=this._gotAccum,l=this._valuesPhase;if(!l)for(l=this._valuesPhase=new Array(s),o=0;s>o;++o)l[o]=0;if(o=l[r],0===r&&this._zerothIsAccum?(this._accum=t,this._gotAccum=c=!0,l[r]=0===o?1:2):-1===r?(this._accum=t,this._gotAccum=c=!0):0===o?l[r]=1:(l[r]=2,this._accum=t),c){for(var h,_=this._callback,d=this._promise._boundValue(),v=this._reducingIndex;s>v;++v)if(o=l[v],2!==o){if(1!==o)return;if(t=n[v],this._promise._pushContext(),u?(a.push(t),h=p(_).call(d,t,v,s)):h=p(_).call(d,this._accum,t,v,s),this._promise._popContext(),h===f)return this._reject(h.e);var y=i(h,this._promise);if(y instanceof e){if(y=y._target(),y._isPending())return l[v]=4,y._proxyPromiseArray(this,v);if(!y._isFulfilled())return this._reject(y._reason());h=y._value()}this._reducingIndex=v+1,this._accum=h}else this._reducingIndex=v+1;this._resolve(u?a:this._accum)}},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./async.js":2,"./util.js":38}],31:[function(t,e){"use strict";var r,n=t("./util"),i=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(n.isNode&&"undefined"==typeof MutationObserver){var o=global.setImmediate,s=process.nextTick;r=n.isRecentNode?function(t){o.call(global,t)}:function(t){s.call(process,t)}}else"undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?r="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:i:(r=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},r.isStatic=!0);e.exports=r},{"./util":38}],32:[function(t,e){"use strict";e.exports=function(e,r){function n(t){this.constructor$(t)}var i=e.PromiseInspection,o=t("./util.js");o.inherits(n,r),n.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)},n.prototype._promiseRejected=function(t,e){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)},e.settle=function(t){return new n(t).promise()},e.prototype.settle=function(){return new n(this).promise()}}},{"./util.js":38}],33:[function(t,e){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var s=t("./util.js"),a=t("./errors.js").RangeError,u=t("./errors.js").AggregateError,c=s.isArray;s.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),this._resolve(1===this.howMany()&&this._unwrap?this._values[0]:this._values))},i.prototype._promiseRejected=function(t){if(this._addRejected(t),this.howMany()>this._canPossiblyFulfill()){for(var e=new u,r=this.length();r<this._values.length;++r)e.push(this._values[r]);this._reject(e)}},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors.js":13,"./util.js":38}],34:[function(t,e){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValue=t._settledValue):(this._bitField=0,this._settledValue=void 0)}e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return this._settledValue},e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return this._settledValue},e.prototype.isFulfilled=t.prototype._isFulfilled=function(){return(268435456&this._bitField)>0},e.prototype.isRejected=t.prototype._isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype._isPending=function(){return 0===(402653184&this._bitField)},e.prototype.isResolved=t.prototype._isResolved=function(){return(402653184&this._bitField)>0},t.prototype.isPending=function(){return this._target()._isPending()},t.prototype.isRejected=function(){return this._target()._isRejected()},t.prototype.isFulfilled=function(){return this._target()._isFulfilled()},t.prototype.isResolved=function(){return this._target()._isResolved()},t.prototype._value=function(){return this._settledValue},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},t.prototype.value=function(){var t=this._target();if(!t.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return t._settledValue},t.prototype.reason=function(){var t=this._target();if(!t.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return t._unsetRejectionIsUnhandled(),t._settledValue},t.PromiseInspection=e}},{}],35:[function(t,e){"use strict";e.exports=function(e,r){function n(t,n){if(c(t)){if(t instanceof e)return t;if(o(t)){var l=new e(r);return t._then(l._fulfillUnchecked,l._rejectUncheckedCheckError,l._progressUnchecked,l,null),l}var h=a.tryCatch(i)(t);if(h===u){n&&n._pushContext();var l=e.reject(h.e);return n&&n._popContext(),l}if("function"==typeof h)return s(t,h,n)}return t}function i(t){return t.then}function o(t){return l.call(t,"_promise0")}function s(t,n,i){function o(t){l&&(l._resolveCallback(t),l=null)}function s(t){l&&(l._rejectCallback(t,p,!0),l=null)}function c(t){l&&"function"==typeof l._progress&&l._progress(t)}var l=new e(r),h=l;i&&i._pushContext(),l._captureStackTrace(),i&&i._popContext();var p=!0,f=a.tryCatch(n).call(t,o,s,c);return p=!1,l&&f===u&&(l._rejectCallback(f.e,!0,!0),l=null),h}var a=t("./util.js"),u=a.errorObj,c=a.isObject,l={}.hasOwnProperty;return n}},{"./util.js":38}],36:[function(t,e){"use strict";e.exports=function(e,r){function n(t){var e=this;return e instanceof Number&&(e=+e),clearTimeout(e),t}function i(t){var e=this;throw e instanceof Number&&(e=+e),clearTimeout(e),t}var o=t("./util.js"),s=e.TimeoutError,a=function(t,e){if(t.isPending()){var r;!o.isPrimitive(e)&&e instanceof Error?r=e:("string"!=typeof e&&(e="operation timed out"),r=new s(e)),o.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._cancel(r)}},u=function(t){return c(+this).thenReturn(t)},c=e.delay=function(t,n){if(void 0===n){n=t,t=void 0;var i=new e(r);return setTimeout(function(){i._fulfill()},n),i}return n=+n,e.resolve(t)._then(u,null,null,n,void 0)};e.prototype.delay=function(t){return c(this,t)},e.prototype.timeout=function(t,e){t=+t;var r=this.then().cancellable();r._cancellationParent=this;var o=setTimeout(function(){a(r,e)},t);return r._then(n,i,void 0,o,void 0)}}},{"./util.js":38}],37:[function(t,e){"use strict";e.exports=function(e,r,n,i){function o(t){for(var r=t.length,n=0;r>n;++n){var i=t[n];if(i.isRejected())return e.reject(i.error());t[n]=i._settledValue}return t}function s(t){setTimeout(function(){throw t},0)}function a(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(o>=u)return c.resolve();var l=a(t[o++]);if(l instanceof e&&l._isDisposable()){try{l=n(l._getDisposer().tryDispose(r),t.promise)}catch(h){return s(h)}if(l instanceof e)return l._then(i,s,null,null,null)}i()}var o=0,u=t.length,c=e.defer();return i(),c.promise}function c(t){var e=new v;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function l(t){var e=new v;return e._settledValue=t,e._bitField=134217728,u(this,e).thenThrow(t)}function h(t,e,r){this._data=t,this._promise=e,this._context=r}function p(t,e,r){this.constructor$(t,e,r)}function f(t){return h.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}var _=t("./errors.js").TypeError,d=t("./util.js").inherits,v=e.PromiseInspection;h.prototype.data=function(){return this._data},h.prototype.promise=function(){return this._promise},h.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},h.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=null!==e?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},h.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},d(p,h),p.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("fn must be a function\n\n See http://goo.gl/916lJJ\n");var s,a=!0;2===t&&Array.isArray(arguments[0])?(s=arguments[0],t=s.length,a=!1):(s=arguments,t--);for(var u=new Array(t),p=0;t>p;++p){var _=s[p];if(h.isDisposer(_)){var d=_;_=_.promise(),_._setDisposable(d)
+}else{var v=n(_);v instanceof e&&(_=v._then(f,null,null,{resources:u,index:p},void 0))}u[p]=_}var y=e.settle(u).then(o).then(function(t){y._pushContext();var e;try{e=a?i.apply(void 0,t):i.call(void 0,t)}finally{y._popContext()}return e})._then(c,l,void 0,u,void 0);return u.promise=y,y},e.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(262144&this._bitField)>0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new p(t,this,i());throw new _}}},{"./errors.js":13,"./util.js":38}],38:[function(t,e,r){"use strict";function n(){try{var t=C;return C=null,t.apply(this,arguments)}catch(e){return F.e=e,F}}function i(t){return C=t,n}function o(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function s(t){return!o(t)}function a(t){return o(t)?new Error(v(t)):t}function u(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function c(t,e,r){if(!w.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function l(t,e,r){if(o(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return w.defineProperty(t,e,n),t}function h(t){throw t}function p(t){try{if("function"==typeof t){var e=w.names(t.prototype),r=w.isES5&&e.length>1,n=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=x.test(t+"")&&w.names(t).length>0;if(r||n||i)return!0}return!1}catch(o){return!1}}function f(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return R.test(t)}function d(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function v(t){try{return t+""}catch(e){return"[no string representation]"}}function y(t){try{l(t,"isOperational",!0)}catch(e){}}function g(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function m(t){return t instanceof Error&&w.propertyIsWritable(t,"stack")}function j(t){return{}.toString.call(t)}function b(t,e,r){for(var n=w.names(t),i=0;i<n.length;++i){var o=n[i];if(r(o))try{w.defineProperty(e,o,w.getDescriptor(t,o))}catch(s){}}}var w=t("./es5.js"),k="undefined"==typeof navigator,E=function(){try{var t={};return w.defineProperty(t,"f",{get:function(){return 3}}),3===t.f}catch(e){return!1}}(),F={e:{}},C,P=function(t,e){function r(){this.constructor=t,this.constructor$=e;for(var r in e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}var n={}.hasOwnProperty;return r.prototype=e.prototype,t.prototype=new r,t.prototype},T=function(){var t=[Array.prototype,Object.prototype,Function.prototype],e=function(e){for(var r=0;r<t.length;++r)if(t[r]===e)return!0;return!1};if(w.isES5){var r=Object.getOwnPropertyNames;return function(t){for(var n=[],i=Object.create(null);null!=t&&!e(t);){var o;try{o=r(t)}catch(s){return n}for(var a=0;a<o.length;++a){var u=o[a];if(!i[u]){i[u]=!0;var c=Object.getOwnPropertyDescriptor(t,u);null!=c&&null==c.get&&null==c.set&&n.push(u)}}t=w.getPrototypeOf(t)}return n}}var n={}.hasOwnProperty;return function(r){if(e(r))return[];var i=[];t:for(var o in r)if(n.call(r,o))i.push(o);else{for(var s=0;s<t.length;++s)if(n.call(t[s],o))continue t;i.push(o)}return i}}(),x=/this\s*\.\s*\S+\s*=/,R=/^[a-z$_][a-z$_0-9]*$/i,S=function(){return"stack"in new Error?function(t){return m(t)?t:new Error(v(t))}:function(t){if(m(t))return t;try{throw new Error(v(t))}catch(e){return e}}}(),A={isClass:p,isIdentifier:_,inheritedDataKeys:T,getDataPropertyOrDefault:c,thrower:h,isArray:w.isArray,haveGetters:E,notEnumerableProp:l,isPrimitive:o,isObject:s,canEvaluate:k,errorObj:F,tryCatch:i,inherits:P,withAppended:u,maybeWrapAsError:a,toFastProperties:f,filledRange:d,toString:v,canAttachTrace:m,ensureErrorObject:S,originatesFromRejection:g,markAsOriginatingFromRejection:y,classString:j,copyDescriptors:b,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:"undefined"!=typeof process&&"[object process]"===j(process).toLowerCase()};A.isRecentNode=A.isNode&&function(){var t=process.versions.node.split(".").map(Number);return 0===t[0]&&t[1]>10||t[0]>0}(),A.isNode&&A.toFastProperties(process);try{throw new Error}catch(O){A.lastLineError=O}e.exports=A},{"./es5.js":14}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise); \ No newline at end of file
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/any.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/any.js
new file mode 100644
index 0000000..05a6228
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/any.js
@@ -0,0 +1,21 @@
+"use strict";
+module.exports = function(Promise) {
+var SomePromiseArray = Promise._SomePromiseArray;
+function any(promises) {
+ var ret = new SomePromiseArray(promises);
+ var promise = ret.promise();
+ ret.setHowMany(1);
+ ret.setUnwrap();
+ ret.init();
+ return promise;
+}
+
+Promise.any = function (promises) {
+ return any(promises);
+};
+
+Promise.prototype.any = function () {
+ return any(this);
+};
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/assert.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/assert.js
new file mode 100644
index 0000000..a98955c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/assert.js
@@ -0,0 +1,55 @@
+"use strict";
+module.exports = (function(){
+var AssertionError = (function() {
+ function AssertionError(a) {
+ this.constructor$(a);
+ this.message = a;
+ this.name = "AssertionError";
+ }
+ AssertionError.prototype = new Error();
+ AssertionError.prototype.constructor = AssertionError;
+ AssertionError.prototype.constructor$ = Error;
+ return AssertionError;
+})();
+
+function getParams(args) {
+ var params = [];
+ for (var i = 0; i < args.length; ++i) params.push("arg" + i);
+ return params;
+}
+
+function nativeAssert(callName, args, expect) {
+ try {
+ var params = getParams(args);
+ var constructorArgs = params;
+ constructorArgs.push("return " +
+ callName + "("+ params.join(",") + ");");
+ var fn = Function.apply(null, constructorArgs);
+ return fn.apply(null, args);
+ } catch (e) {
+ if (!(e instanceof SyntaxError)) {
+ throw e;
+ } else {
+ return expect;
+ }
+ }
+}
+
+return function assert(boolExpr, message) {
+ if (boolExpr === true) return;
+
+ if (typeof boolExpr === "string" &&
+ boolExpr.charAt(0) === "%") {
+ var nativeCallName = boolExpr;
+ var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];}
+ if (nativeAssert(nativeCallName, args, message) === message) return;
+ message = (nativeCallName + " !== " + message);
+ }
+
+ var ret = new AssertionError(message);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(ret, assert);
+ }
+ throw ret;
+};
+})();
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/async.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/async.js
new file mode 100644
index 0000000..0104459
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/async.js
@@ -0,0 +1,150 @@
+"use strict";
+var firstLineError;
+try {throw new Error(); } catch (e) {firstLineError = e;}
+var schedule = require("./schedule.js");
+var Queue = require("./queue.js");
+var util = require("./util.js");
+
+function Async() {
+ this._isTickUsed = false;
+ this._lateQueue = new Queue(16);
+ this._normalQueue = new Queue(16);
+ this._trampolineEnabled = true;
+ var self = this;
+ this.drainQueues = function () {
+ self._drainQueues();
+ };
+ this._schedule =
+ schedule.isStatic ? schedule(this.drainQueues) : schedule;
+}
+
+Async.prototype.disableTrampolineIfNecessary = function() {
+ if (util.hasDevTools) {
+ this._trampolineEnabled = false;
+ }
+};
+
+Async.prototype.enableTrampoline = function() {
+ if (!this._trampolineEnabled) {
+ this._trampolineEnabled = true;
+ this._schedule = function(fn) {
+ setTimeout(fn, 0);
+ };
+ }
+};
+
+Async.prototype.haveItemsQueued = function () {
+ return this._normalQueue.length() > 0;
+};
+
+Async.prototype.throwLater = function(fn, arg) {
+ if (arguments.length === 1) {
+ arg = fn;
+ fn = function () { throw arg; };
+ }
+ if (typeof setTimeout !== "undefined") {
+ setTimeout(function() {
+ fn(arg);
+ }, 0);
+ } else try {
+ this._schedule(function() {
+ fn(arg);
+ });
+ } catch (e) {
+ throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
+ }
+};
+
+function AsyncInvokeLater(fn, receiver, arg) {
+ this._lateQueue.push(fn, receiver, arg);
+ this._queueTick();
+}
+
+function AsyncInvoke(fn, receiver, arg) {
+ this._normalQueue.push(fn, receiver, arg);
+ this._queueTick();
+}
+
+function AsyncSettlePromises(promise) {
+ this._normalQueue._pushOne(promise);
+ this._queueTick();
+}
+
+if (!util.hasDevTools) {
+ Async.prototype.invokeLater = AsyncInvokeLater;
+ Async.prototype.invoke = AsyncInvoke;
+ Async.prototype.settlePromises = AsyncSettlePromises;
+} else {
+ if (schedule.isStatic) {
+ schedule = function(fn) { setTimeout(fn, 0); };
+ }
+ Async.prototype.invokeLater = function (fn, receiver, arg) {
+ if (this._trampolineEnabled) {
+ AsyncInvokeLater.call(this, fn, receiver, arg);
+ } else {
+ this._schedule(function() {
+ setTimeout(function() {
+ fn.call(receiver, arg);
+ }, 100);
+ });
+ }
+ };
+
+ Async.prototype.invoke = function (fn, receiver, arg) {
+ if (this._trampolineEnabled) {
+ AsyncInvoke.call(this, fn, receiver, arg);
+ } else {
+ this._schedule(function() {
+ fn.call(receiver, arg);
+ });
+ }
+ };
+
+ Async.prototype.settlePromises = function(promise) {
+ if (this._trampolineEnabled) {
+ AsyncSettlePromises.call(this, promise);
+ } else {
+ this._schedule(function() {
+ promise._settlePromises();
+ });
+ }
+ };
+}
+
+Async.prototype.invokeFirst = function (fn, receiver, arg) {
+ this._normalQueue.unshift(fn, receiver, arg);
+ this._queueTick();
+};
+
+Async.prototype._drainQueue = function(queue) {
+ while (queue.length() > 0) {
+ var fn = queue.shift();
+ if (typeof fn !== "function") {
+ fn._settlePromises();
+ continue;
+ }
+ var receiver = queue.shift();
+ var arg = queue.shift();
+ fn.call(receiver, arg);
+ }
+};
+
+Async.prototype._drainQueues = function () {
+ this._drainQueue(this._normalQueue);
+ this._reset();
+ this._drainQueue(this._lateQueue);
+};
+
+Async.prototype._queueTick = function () {
+ if (!this._isTickUsed) {
+ this._isTickUsed = true;
+ this._schedule(this.drainQueues);
+ }
+};
+
+Async.prototype._reset = function () {
+ this._isTickUsed = false;
+};
+
+module.exports = new Async();
+module.exports.firstLineError = firstLineError;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bind.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bind.js
new file mode 100644
index 0000000..9d8257a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bind.js
@@ -0,0 +1,72 @@
+"use strict";
+module.exports = function(Promise, INTERNAL, tryConvertToPromise) {
+var rejectThis = function(_, e) {
+ this._reject(e);
+};
+
+var targetRejected = function(e, context) {
+ context.promiseRejectionQueued = true;
+ context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
+};
+
+var bindingResolved = function(thisArg, context) {
+ if (this._isPending()) {
+ this._resolveCallback(context.target);
+ }
+};
+
+var bindingRejected = function(e, context) {
+ if (!context.promiseRejectionQueued) this._reject(e);
+};
+
+Promise.prototype.bind = function (thisArg) {
+ var maybePromise = tryConvertToPromise(thisArg);
+ var ret = new Promise(INTERNAL);
+ ret._propagateFrom(this, 1);
+ var target = this._target();
+
+ ret._setBoundTo(maybePromise);
+ if (maybePromise instanceof Promise) {
+ var context = {
+ promiseRejectionQueued: false,
+ promise: ret,
+ target: target,
+ bindingPromise: maybePromise
+ };
+ target._then(INTERNAL, targetRejected, ret._progress, ret, context);
+ maybePromise._then(
+ bindingResolved, bindingRejected, ret._progress, ret, context);
+ } else {
+ ret._resolveCallback(target);
+ }
+ return ret;
+};
+
+Promise.prototype._setBoundTo = function (obj) {
+ if (obj !== undefined) {
+ this._bitField = this._bitField | 131072;
+ this._boundTo = obj;
+ } else {
+ this._bitField = this._bitField & (~131072);
+ }
+};
+
+Promise.prototype._isBound = function () {
+ return (this._bitField & 131072) === 131072;
+};
+
+Promise.bind = function (thisArg, value) {
+ var maybePromise = tryConvertToPromise(thisArg);
+ var ret = new Promise(INTERNAL);
+
+ ret._setBoundTo(maybePromise);
+ if (maybePromise instanceof Promise) {
+ maybePromise._then(function() {
+ ret._resolveCallback(value);
+ }, ret._reject, ret._progress, ret, null);
+ } else {
+ ret._resolveCallback(value);
+ }
+ return ret;
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bluebird.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bluebird.js
new file mode 100644
index 0000000..ed6226e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/bluebird.js
@@ -0,0 +1,11 @@
+"use strict";
+var old;
+if (typeof Promise !== "undefined") old = Promise;
+function noConflict() {
+ try { if (Promise === bluebird) Promise = old; }
+ catch (e) {}
+ return bluebird;
+}
+var bluebird = require("./promise.js")();
+bluebird.noConflict = noConflict;
+module.exports = bluebird;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/call_get.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/call_get.js
new file mode 100644
index 0000000..62c166d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/call_get.js
@@ -0,0 +1,123 @@
+"use strict";
+var cr = Object.create;
+if (cr) {
+ var callerCache = cr(null);
+ var getterCache = cr(null);
+ callerCache[" size"] = getterCache[" size"] = 0;
+}
+
+module.exports = function(Promise) {
+var util = require("./util.js");
+var canEvaluate = util.canEvaluate;
+var isIdentifier = util.isIdentifier;
+
+var getMethodCaller;
+var getGetter;
+if (!false) {
+var makeMethodCaller = function (methodName) {
+ return new Function("ensureMethod", " \n\
+ return function(obj) { \n\
+ 'use strict' \n\
+ var len = this.length; \n\
+ ensureMethod(obj, 'methodName'); \n\
+ switch(len) { \n\
+ case 1: return obj.methodName(this[0]); \n\
+ case 2: return obj.methodName(this[0], this[1]); \n\
+ case 3: return obj.methodName(this[0], this[1], this[2]); \n\
+ case 0: return obj.methodName(); \n\
+ default: \n\
+ return obj.methodName.apply(obj, this); \n\
+ } \n\
+ }; \n\
+ ".replace(/methodName/g, methodName))(ensureMethod);
+};
+
+var makeGetter = function (propertyName) {
+ return new Function("obj", " \n\
+ 'use strict'; \n\
+ return obj.propertyName; \n\
+ ".replace("propertyName", propertyName));
+};
+
+var getCompiled = function(name, compiler, cache) {
+ var ret = cache[name];
+ if (typeof ret !== "function") {
+ if (!isIdentifier(name)) {
+ return null;
+ }
+ ret = compiler(name);
+ cache[name] = ret;
+ cache[" size"]++;
+ if (cache[" size"] > 512) {
+ var keys = Object.keys(cache);
+ for (var i = 0; i < 256; ++i) delete cache[keys[i]];
+ cache[" size"] = keys.length - 256;
+ }
+ }
+ return ret;
+};
+
+getMethodCaller = function(name) {
+ return getCompiled(name, makeMethodCaller, callerCache);
+};
+
+getGetter = function(name) {
+ return getCompiled(name, makeGetter, getterCache);
+};
+}
+
+function ensureMethod(obj, methodName) {
+ var fn;
+ if (obj != null) fn = obj[methodName];
+ if (typeof fn !== "function") {
+ var message = "Object " + util.classString(obj) + " has no method '" +
+ util.toString(methodName) + "'";
+ throw new Promise.TypeError(message);
+ }
+ return fn;
+}
+
+function caller(obj) {
+ var methodName = this.pop();
+ var fn = ensureMethod(obj, methodName);
+ return fn.apply(obj, this);
+}
+Promise.prototype.call = function (methodName) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ if (!false) {
+ if (canEvaluate) {
+ var maybeCaller = getMethodCaller(methodName);
+ if (maybeCaller !== null) {
+ return this._then(
+ maybeCaller, undefined, undefined, args, undefined);
+ }
+ }
+ }
+ args.push(methodName);
+ return this._then(caller, undefined, undefined, args, undefined);
+};
+
+function namedGetter(obj) {
+ return obj[this];
+}
+function indexedGetter(obj) {
+ var index = +this;
+ if (index < 0) index = Math.max(0, index + obj.length);
+ return obj[index];
+}
+Promise.prototype.get = function (propertyName) {
+ var isIndex = (typeof propertyName === "number");
+ var getter;
+ if (!isIndex) {
+ if (canEvaluate) {
+ var maybeGetter = getGetter(propertyName);
+ getter = maybeGetter !== null ? maybeGetter : namedGetter;
+ } else {
+ getter = namedGetter;
+ }
+ } else {
+ getter = indexedGetter;
+ }
+ return this._then(getter, undefined, undefined, propertyName, undefined);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/cancel.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/cancel.js
new file mode 100644
index 0000000..9eb40b6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/cancel.js
@@ -0,0 +1,48 @@
+"use strict";
+module.exports = function(Promise) {
+var errors = require("./errors.js");
+var async = require("./async.js");
+var CancellationError = errors.CancellationError;
+
+Promise.prototype._cancel = function (reason) {
+ if (!this.isCancellable()) return this;
+ var parent;
+ var promiseToReject = this;
+ while ((parent = promiseToReject._cancellationParent) !== undefined &&
+ parent.isCancellable()) {
+ promiseToReject = parent;
+ }
+ this._unsetCancellable();
+ promiseToReject._target()._rejectCallback(reason, false, true);
+};
+
+Promise.prototype.cancel = function (reason) {
+ if (!this.isCancellable()) return this;
+ if (reason === undefined) reason = new CancellationError();
+ async.invokeLater(this._cancel, this, reason);
+ return this;
+};
+
+Promise.prototype.cancellable = function () {
+ if (this._cancellable()) return this;
+ async.enableTrampoline();
+ this._setCancellable();
+ this._cancellationParent = undefined;
+ return this;
+};
+
+Promise.prototype.uncancellable = function () {
+ var ret = this.then();
+ ret._unsetCancellable();
+ return ret;
+};
+
+Promise.prototype.fork = function (didFulfill, didReject, didProgress) {
+ var ret = this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+
+ ret._setCancellable();
+ ret._cancellationParent = undefined;
+ return ret;
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/captured_trace.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/captured_trace.js
new file mode 100644
index 0000000..802acd3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/captured_trace.js
@@ -0,0 +1,493 @@
+"use strict";
+module.exports = function() {
+var async = require("./async.js");
+var util = require("./util.js");
+var bluebirdFramePattern =
+ /[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/;
+var stackFramePattern = null;
+var formatStack = null;
+var indentStackFrames = false;
+var warn;
+
+function CapturedTrace(parent) {
+ this._parent = parent;
+ var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
+ captureStackTrace(this, CapturedTrace);
+ if (length > 32) this.uncycle();
+}
+util.inherits(CapturedTrace, Error);
+
+CapturedTrace.prototype.uncycle = function() {
+ var length = this._length;
+ if (length < 2) return;
+ var nodes = [];
+ var stackToIndex = {};
+
+ for (var i = 0, node = this; node !== undefined; ++i) {
+ nodes.push(node);
+ node = node._parent;
+ }
+ length = this._length = i;
+ for (var i = length - 1; i >= 0; --i) {
+ var stack = nodes[i].stack;
+ if (stackToIndex[stack] === undefined) {
+ stackToIndex[stack] = i;
+ }
+ }
+ for (var i = 0; i < length; ++i) {
+ var currentStack = nodes[i].stack;
+ var index = stackToIndex[currentStack];
+ if (index !== undefined && index !== i) {
+ if (index > 0) {
+ nodes[index - 1]._parent = undefined;
+ nodes[index - 1]._length = 1;
+ }
+ nodes[i]._parent = undefined;
+ nodes[i]._length = 1;
+ var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
+
+ if (index < length - 1) {
+ cycleEdgeNode._parent = nodes[index + 1];
+ cycleEdgeNode._parent.uncycle();
+ cycleEdgeNode._length =
+ cycleEdgeNode._parent._length + 1;
+ } else {
+ cycleEdgeNode._parent = undefined;
+ cycleEdgeNode._length = 1;
+ }
+ var currentChildLength = cycleEdgeNode._length + 1;
+ for (var j = i - 2; j >= 0; --j) {
+ nodes[j]._length = currentChildLength;
+ currentChildLength++;
+ }
+ return;
+ }
+ }
+};
+
+CapturedTrace.prototype.parent = function() {
+ return this._parent;
+};
+
+CapturedTrace.prototype.hasParent = function() {
+ return this._parent !== undefined;
+};
+
+CapturedTrace.prototype.attachExtraTrace = function(error) {
+ if (error.__stackCleaned__) return;
+ this.uncycle();
+ var parsed = CapturedTrace.parseStackAndMessage(error);
+ var message = parsed.message;
+ var stacks = [parsed.stack];
+
+ var trace = this;
+ while (trace !== undefined) {
+ stacks.push(cleanStack(trace.stack.split("\n")));
+ trace = trace._parent;
+ }
+ removeCommonRoots(stacks);
+ removeDuplicateOrEmptyJumps(stacks);
+ util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
+ util.notEnumerableProp(error, "__stackCleaned__", true);
+};
+
+function reconstructStack(message, stacks) {
+ for (var i = 0; i < stacks.length - 1; ++i) {
+ stacks[i].push("From previous event:");
+ stacks[i] = stacks[i].join("\n");
+ }
+ if (i < stacks.length) {
+ stacks[i] = stacks[i].join("\n");
+ }
+ return message + "\n" + stacks.join("\n");
+}
+
+function removeDuplicateOrEmptyJumps(stacks) {
+ for (var i = 0; i < stacks.length; ++i) {
+ if (stacks[i].length === 0 ||
+ ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
+ stacks.splice(i, 1);
+ i--;
+ }
+ }
+}
+
+function removeCommonRoots(stacks) {
+ var current = stacks[0];
+ for (var i = 1; i < stacks.length; ++i) {
+ var prev = stacks[i];
+ var currentLastIndex = current.length - 1;
+ var currentLastLine = current[currentLastIndex];
+ var commonRootMeetPoint = -1;
+
+ for (var j = prev.length - 1; j >= 0; --j) {
+ if (prev[j] === currentLastLine) {
+ commonRootMeetPoint = j;
+ break;
+ }
+ }
+
+ for (var j = commonRootMeetPoint; j >= 0; --j) {
+ var line = prev[j];
+ if (current[currentLastIndex] === line) {
+ current.pop();
+ currentLastIndex--;
+ } else {
+ break;
+ }
+ }
+ current = prev;
+ }
+}
+
+function cleanStack(stack) {
+ var ret = [];
+ for (var i = 0; i < stack.length; ++i) {
+ var line = stack[i];
+ var isTraceLine = stackFramePattern.test(line) ||
+ " (No stack trace)" === line;
+ var isInternalFrame = isTraceLine && shouldIgnore(line);
+ if (isTraceLine && !isInternalFrame) {
+ if (indentStackFrames && line.charAt(0) !== " ") {
+ line = " " + line;
+ }
+ ret.push(line);
+ }
+ }
+ return ret;
+}
+
+function stackFramesAsArray(error) {
+ var stack = error.stack.replace(/\s+$/g, "").split("\n");
+ for (var i = 0; i < stack.length; ++i) {
+ var line = stack[i];
+ if (" (No stack trace)" === line || stackFramePattern.test(line)) {
+ break;
+ }
+ }
+ if (i > 0) {
+ stack = stack.slice(i);
+ }
+ return stack;
+}
+
+CapturedTrace.parseStackAndMessage = function(error) {
+ var stack = error.stack;
+ var message = error.toString();
+ stack = typeof stack === "string" && stack.length > 0
+ ? stackFramesAsArray(error) : [" (No stack trace)"];
+ return {
+ message: message,
+ stack: cleanStack(stack)
+ };
+};
+
+CapturedTrace.formatAndLogError = function(error, title) {
+ if (typeof console !== "undefined") {
+ var message;
+ if (typeof error === "object" || typeof error === "function") {
+ var stack = error.stack;
+ message = title + formatStack(stack, error);
+ } else {
+ message = title + String(error);
+ }
+ if (typeof warn === "function") {
+ warn(message);
+ } else if (typeof console.log === "function" ||
+ typeof console.log === "object") {
+ console.log(message);
+ }
+ }
+};
+
+CapturedTrace.unhandledRejection = function (reason) {
+ CapturedTrace.formatAndLogError(reason, "^--- With additional stack trace: ");
+};
+
+CapturedTrace.isSupported = function () {
+ return typeof captureStackTrace === "function";
+};
+
+CapturedTrace.fireRejectionEvent =
+function(name, localHandler, reason, promise) {
+ var localEventFired = false;
+ try {
+ if (typeof localHandler === "function") {
+ localEventFired = true;
+ if (name === "rejectionHandled") {
+ localHandler(promise);
+ } else {
+ localHandler(reason, promise);
+ }
+ }
+ } catch (e) {
+ async.throwLater(e);
+ }
+
+ var globalEventFired = false;
+ try {
+ globalEventFired = fireGlobalEvent(name, reason, promise);
+ } catch (e) {
+ globalEventFired = true;
+ async.throwLater(e);
+ }
+
+ var domEventFired = false;
+ if (fireDomEvent) {
+ try {
+ domEventFired = fireDomEvent(name.toLowerCase(), {
+ reason: reason,
+ promise: promise
+ });
+ } catch (e) {
+ domEventFired = true;
+ async.throwLater(e);
+ }
+ }
+
+ if (!globalEventFired && !localEventFired && !domEventFired &&
+ name === "unhandledRejection") {
+ CapturedTrace.formatAndLogError(reason, "Unhandled rejection ");
+ }
+};
+
+function formatNonError(obj) {
+ var str;
+ if (typeof obj === "function") {
+ str = "[function " +
+ (obj.name || "anonymous") +
+ "]";
+ } else {
+ str = obj.toString();
+ var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
+ if (ruselessToString.test(str)) {
+ try {
+ var newStr = JSON.stringify(obj);
+ str = newStr;
+ }
+ catch(e) {
+
+ }
+ }
+ if (str.length === 0) {
+ str = "(empty array)";
+ }
+ }
+ return ("(<" + snip(str) + ">, no stack trace)");
+}
+
+function snip(str) {
+ var maxChars = 41;
+ if (str.length < maxChars) {
+ return str;
+ }
+ return str.substr(0, maxChars - 3) + "...";
+}
+
+var shouldIgnore = function() { return false; };
+var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
+function parseLineInfo(line) {
+ var matches = line.match(parseLineInfoRegex);
+ if (matches) {
+ return {
+ fileName: matches[1],
+ line: parseInt(matches[2], 10)
+ };
+ }
+}
+CapturedTrace.setBounds = function(firstLineError, lastLineError) {
+ if (!CapturedTrace.isSupported()) return;
+ var firstStackLines = firstLineError.stack.split("\n");
+ var lastStackLines = lastLineError.stack.split("\n");
+ var firstIndex = -1;
+ var lastIndex = -1;
+ var firstFileName;
+ var lastFileName;
+ for (var i = 0; i < firstStackLines.length; ++i) {
+ var result = parseLineInfo(firstStackLines[i]);
+ if (result) {
+ firstFileName = result.fileName;
+ firstIndex = result.line;
+ break;
+ }
+ }
+ for (var i = 0; i < lastStackLines.length; ++i) {
+ var result = parseLineInfo(lastStackLines[i]);
+ if (result) {
+ lastFileName = result.fileName;
+ lastIndex = result.line;
+ break;
+ }
+ }
+ if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
+ firstFileName !== lastFileName || firstIndex >= lastIndex) {
+ return;
+ }
+
+ shouldIgnore = function(line) {
+ if (bluebirdFramePattern.test(line)) return true;
+ var info = parseLineInfo(line);
+ if (info) {
+ if (info.fileName === firstFileName &&
+ (firstIndex <= info.line && info.line <= lastIndex)) {
+ return true;
+ }
+ }
+ return false;
+ };
+};
+
+var captureStackTrace = (function stackDetection() {
+ var v8stackFramePattern = /^\s*at\s*/;
+ var v8stackFormatter = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if (error.name !== undefined &&
+ error.message !== undefined) {
+ return error.toString();
+ }
+ return formatNonError(error);
+ };
+
+ if (typeof Error.stackTraceLimit === "number" &&
+ typeof Error.captureStackTrace === "function") {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ stackFramePattern = v8stackFramePattern;
+ formatStack = v8stackFormatter;
+ var captureStackTrace = Error.captureStackTrace;
+
+ shouldIgnore = function(line) {
+ return bluebirdFramePattern.test(line);
+ };
+ return function(receiver, ignoreUntil) {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ captureStackTrace(receiver, ignoreUntil);
+ Error.stackTraceLimit = Error.stackTraceLimit - 6;
+ };
+ }
+ var err = new Error();
+
+ if (typeof err.stack === "string" &&
+ err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
+ stackFramePattern = /@/;
+ formatStack = v8stackFormatter;
+ indentStackFrames = true;
+ return function captureStackTrace(o) {
+ o.stack = new Error().stack;
+ };
+ }
+
+ var hasStackAfterThrow;
+ try { throw new Error(); }
+ catch(e) {
+ hasStackAfterThrow = ("stack" in e);
+ }
+ if (!("stack" in err) && hasStackAfterThrow &&
+ typeof Error.stackTraceLimit === "number") {
+ stackFramePattern = v8stackFramePattern;
+ formatStack = v8stackFormatter;
+ return function captureStackTrace(o) {
+ Error.stackTraceLimit = Error.stackTraceLimit + 6;
+ try { throw new Error(); }
+ catch(e) { o.stack = e.stack; }
+ Error.stackTraceLimit = Error.stackTraceLimit - 6;
+ };
+ }
+
+ formatStack = function(stack, error) {
+ if (typeof stack === "string") return stack;
+
+ if ((typeof error === "object" ||
+ typeof error === "function") &&
+ error.name !== undefined &&
+ error.message !== undefined) {
+ return error.toString();
+ }
+ return formatNonError(error);
+ };
+
+ return null;
+
+})([]);
+
+var fireDomEvent;
+var fireGlobalEvent = (function() {
+ if (util.isNode) {
+ return function(name, reason, promise) {
+ if (name === "rejectionHandled") {
+ return process.emit(name, promise);
+ } else {
+ return process.emit(name, reason, promise);
+ }
+ };
+ } else {
+ var customEventWorks = false;
+ var anyEventWorks = true;
+ try {
+ var ev = new self.CustomEvent("test");
+ customEventWorks = ev instanceof CustomEvent;
+ } catch (e) {}
+ if (!customEventWorks) {
+ try {
+ var event = document.createEvent("CustomEvent");
+ event.initCustomEvent("testingtheevent", false, true, {});
+ self.dispatchEvent(event);
+ } catch (e) {
+ anyEventWorks = false;
+ }
+ }
+ if (anyEventWorks) {
+ fireDomEvent = function(type, detail) {
+ var event;
+ if (customEventWorks) {
+ event = new self.CustomEvent(type, {
+ detail: detail,
+ bubbles: false,
+ cancelable: true
+ });
+ } else if (self.dispatchEvent) {
+ event = document.createEvent("CustomEvent");
+ event.initCustomEvent(type, false, true, detail);
+ }
+
+ return event ? !self.dispatchEvent(event) : false;
+ };
+ }
+
+ var toWindowMethodNameMap = {};
+ toWindowMethodNameMap["unhandledRejection"] = ("on" +
+ "unhandledRejection").toLowerCase();
+ toWindowMethodNameMap["rejectionHandled"] = ("on" +
+ "rejectionHandled").toLowerCase();
+
+ return function(name, reason, promise) {
+ var methodName = toWindowMethodNameMap[name];
+ var method = self[methodName];
+ if (!method) return false;
+ if (name === "rejectionHandled") {
+ method.call(self, promise);
+ } else {
+ method.call(self, reason, promise);
+ }
+ return true;
+ };
+ }
+})();
+
+if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
+ warn = function (message) {
+ console.warn(message);
+ };
+ if (util.isNode && process.stderr.isTTY) {
+ warn = function(message) {
+ process.stderr.write("\u001b[31m" + message + "\u001b[39m\n");
+ };
+ } else if (!util.isNode && typeof (new Error().stack) === "string") {
+ warn = function(message) {
+ console.warn("%c" + message, "color: red");
+ };
+ }
+}
+
+return CapturedTrace;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/catch_filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/catch_filter.js
new file mode 100644
index 0000000..df12733
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/catch_filter.js
@@ -0,0 +1,66 @@
+"use strict";
+module.exports = function(NEXT_FILTER) {
+var util = require("./util.js");
+var errors = require("./errors.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var keys = require("./es5.js").keys;
+var TypeError = errors.TypeError;
+
+function CatchFilter(instances, callback, promise) {
+ this._instances = instances;
+ this._callback = callback;
+ this._promise = promise;
+}
+
+function safePredicate(predicate, e) {
+ var safeObject = {};
+ var retfilter = tryCatch(predicate).call(safeObject, e);
+
+ if (retfilter === errorObj) return retfilter;
+
+ var safeKeys = keys(safeObject);
+ if (safeKeys.length) {
+ errorObj.e = new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a");
+ return errorObj;
+ }
+ return retfilter;
+}
+
+CatchFilter.prototype.doFilter = function (e) {
+ var cb = this._callback;
+ var promise = this._promise;
+ var boundTo = promise._boundValue();
+ for (var i = 0, len = this._instances.length; i < len; ++i) {
+ var item = this._instances[i];
+ var itemIsErrorType = item === Error ||
+ (item != null && item.prototype instanceof Error);
+
+ if (itemIsErrorType && e instanceof item) {
+ var ret = tryCatch(cb).call(boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ } else if (typeof item === "function" && !itemIsErrorType) {
+ var shouldHandle = safePredicate(item, e);
+ if (shouldHandle === errorObj) {
+ e = errorObj.e;
+ break;
+ } else if (shouldHandle) {
+ var ret = tryCatch(cb).call(boundTo, e);
+ if (ret === errorObj) {
+ NEXT_FILTER.e = ret.e;
+ return NEXT_FILTER;
+ }
+ return ret;
+ }
+ }
+ }
+ NEXT_FILTER.e = e;
+ return NEXT_FILTER;
+};
+
+return CatchFilter;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/context.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/context.js
new file mode 100644
index 0000000..ccd7702
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/context.js
@@ -0,0 +1,38 @@
+"use strict";
+module.exports = function(Promise, CapturedTrace, isDebugging) {
+var contextStack = [];
+function Context() {
+ this._trace = new CapturedTrace(peekContext());
+}
+Context.prototype._pushContext = function () {
+ if (!isDebugging()) return;
+ if (this._trace !== undefined) {
+ contextStack.push(this._trace);
+ }
+};
+
+Context.prototype._popContext = function () {
+ if (!isDebugging()) return;
+ if (this._trace !== undefined) {
+ contextStack.pop();
+ }
+};
+
+function createContext() {
+ if (isDebugging()) return new Context();
+}
+
+function peekContext() {
+ var lastIndex = contextStack.length - 1;
+ if (lastIndex >= 0) {
+ return contextStack[lastIndex];
+ }
+ return undefined;
+}
+
+Promise.prototype._peekContext = peekContext;
+Promise.prototype._pushContext = Context.prototype._pushContext;
+Promise.prototype._popContext = Context.prototype._popContext;
+
+return createContext;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/debuggability.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/debuggability.js
new file mode 100644
index 0000000..106baf6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/debuggability.js
@@ -0,0 +1,162 @@
+"use strict";
+module.exports = function(Promise, CapturedTrace) {
+var getDomain = Promise._getDomain;
+var async = require("./async.js");
+var Warning = require("./errors.js").Warning;
+var util = require("./util.js");
+var canAttachTrace = util.canAttachTrace;
+var unhandledRejectionHandled;
+var possiblyUnhandledRejection;
+var debugging = false || (util.isNode &&
+ (!!process.env["BLUEBIRD_DEBUG"] ||
+ process.env["NODE_ENV"] === "development"));
+
+if (util.isNode && process.env["BLUEBIRD_DEBUG"] == 0) debugging = false;
+
+if (debugging) {
+ async.disableTrampolineIfNecessary();
+}
+
+Promise.prototype._ignoreRejections = function() {
+ this._unsetRejectionIsUnhandled();
+ this._bitField = this._bitField | 16777216;
+};
+
+Promise.prototype._ensurePossibleRejectionHandled = function () {
+ if ((this._bitField & 16777216) !== 0) return;
+ this._setRejectionIsUnhandled();
+ async.invokeLater(this._notifyUnhandledRejection, this, undefined);
+};
+
+Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
+ CapturedTrace.fireRejectionEvent("rejectionHandled",
+ unhandledRejectionHandled, undefined, this);
+};
+
+Promise.prototype._notifyUnhandledRejection = function () {
+ if (this._isRejectionUnhandled()) {
+ var reason = this._getCarriedStackTrace() || this._settledValue;
+ this._setUnhandledRejectionIsNotified();
+ CapturedTrace.fireRejectionEvent("unhandledRejection",
+ possiblyUnhandledRejection, reason, this);
+ }
+};
+
+Promise.prototype._setUnhandledRejectionIsNotified = function () {
+ this._bitField = this._bitField | 524288;
+};
+
+Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
+ this._bitField = this._bitField & (~524288);
+};
+
+Promise.prototype._isUnhandledRejectionNotified = function () {
+ return (this._bitField & 524288) > 0;
+};
+
+Promise.prototype._setRejectionIsUnhandled = function () {
+ this._bitField = this._bitField | 2097152;
+};
+
+Promise.prototype._unsetRejectionIsUnhandled = function () {
+ this._bitField = this._bitField & (~2097152);
+ if (this._isUnhandledRejectionNotified()) {
+ this._unsetUnhandledRejectionIsNotified();
+ this._notifyUnhandledRejectionIsHandled();
+ }
+};
+
+Promise.prototype._isRejectionUnhandled = function () {
+ return (this._bitField & 2097152) > 0;
+};
+
+Promise.prototype._setCarriedStackTrace = function (capturedTrace) {
+ this._bitField = this._bitField | 1048576;
+ this._fulfillmentHandler0 = capturedTrace;
+};
+
+Promise.prototype._isCarryingStackTrace = function () {
+ return (this._bitField & 1048576) > 0;
+};
+
+Promise.prototype._getCarriedStackTrace = function () {
+ return this._isCarryingStackTrace()
+ ? this._fulfillmentHandler0
+ : undefined;
+};
+
+Promise.prototype._captureStackTrace = function () {
+ if (debugging) {
+ this._trace = new CapturedTrace(this._peekContext());
+ }
+ return this;
+};
+
+Promise.prototype._attachExtraTrace = function (error, ignoreSelf) {
+ if (debugging && canAttachTrace(error)) {
+ var trace = this._trace;
+ if (trace !== undefined) {
+ if (ignoreSelf) trace = trace._parent;
+ }
+ if (trace !== undefined) {
+ trace.attachExtraTrace(error);
+ } else if (!error.__stackCleaned__) {
+ var parsed = CapturedTrace.parseStackAndMessage(error);
+ util.notEnumerableProp(error, "stack",
+ parsed.message + "\n" + parsed.stack.join("\n"));
+ util.notEnumerableProp(error, "__stackCleaned__", true);
+ }
+ }
+};
+
+Promise.prototype._warn = function(message) {
+ var warning = new Warning(message);
+ var ctx = this._peekContext();
+ if (ctx) {
+ ctx.attachExtraTrace(warning);
+ } else {
+ var parsed = CapturedTrace.parseStackAndMessage(warning);
+ warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
+ }
+ CapturedTrace.formatAndLogError(warning, "");
+};
+
+Promise.onPossiblyUnhandledRejection = function (fn) {
+ var domain = getDomain();
+ possiblyUnhandledRejection =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
+};
+
+Promise.onUnhandledRejectionHandled = function (fn) {
+ var domain = getDomain();
+ unhandledRejectionHandled =
+ typeof fn === "function" ? (domain === null ? fn : domain.bind(fn))
+ : undefined;
+};
+
+Promise.longStackTraces = function () {
+ if (async.haveItemsQueued() &&
+ debugging === false
+ ) {
+ throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/DT1qyG\u000a");
+ }
+ debugging = CapturedTrace.isSupported();
+ if (debugging) {
+ async.disableTrampolineIfNecessary();
+ }
+};
+
+Promise.hasLongStackTraces = function () {
+ return debugging && CapturedTrace.isSupported();
+};
+
+if (!CapturedTrace.isSupported()) {
+ Promise.longStackTraces = function(){};
+ debugging = false;
+}
+
+return function() {
+ return debugging;
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/direct_resolve.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/direct_resolve.js
new file mode 100644
index 0000000..054685a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/direct_resolve.js
@@ -0,0 +1,63 @@
+"use strict";
+var util = require("./util.js");
+var isPrimitive = util.isPrimitive;
+
+module.exports = function(Promise) {
+var returner = function () {
+ return this;
+};
+var thrower = function () {
+ throw this;
+};
+var returnUndefined = function() {};
+var throwUndefined = function() {
+ throw undefined;
+};
+
+var wrapper = function (value, action) {
+ if (action === 1) {
+ return function () {
+ throw value;
+ };
+ } else if (action === 2) {
+ return function () {
+ return value;
+ };
+ }
+};
+
+
+Promise.prototype["return"] =
+Promise.prototype.thenReturn = function (value) {
+ if (value === undefined) return this.then(returnUndefined);
+
+ if (isPrimitive(value)) {
+ return this._then(
+ wrapper(value, 2),
+ undefined,
+ undefined,
+ undefined,
+ undefined
+ );
+ } else if (value instanceof Promise) {
+ value._ignoreRejections();
+ }
+ return this._then(returner, undefined, undefined, value, undefined);
+};
+
+Promise.prototype["throw"] =
+Promise.prototype.thenThrow = function (reason) {
+ if (reason === undefined) return this.then(throwUndefined);
+
+ if (isPrimitive(reason)) {
+ return this._then(
+ wrapper(reason, 1),
+ undefined,
+ undefined,
+ undefined,
+ undefined
+ );
+ }
+ return this._then(thrower, undefined, undefined, reason, undefined);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/each.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/each.js
new file mode 100644
index 0000000..a37e22c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/each.js
@@ -0,0 +1,12 @@
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var PromiseReduce = Promise.reduce;
+
+Promise.prototype.each = function (fn) {
+ return PromiseReduce(this, fn, null, INTERNAL);
+};
+
+Promise.each = function (promises, fn) {
+ return PromiseReduce(promises, fn, null, INTERNAL);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/errors.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/errors.js
new file mode 100644
index 0000000..c334bb1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/errors.js
@@ -0,0 +1,111 @@
+"use strict";
+var es5 = require("./es5.js");
+var Objectfreeze = es5.freeze;
+var util = require("./util.js");
+var inherits = util.inherits;
+var notEnumerableProp = util.notEnumerableProp;
+
+function subError(nameProperty, defaultMessage) {
+ function SubError(message) {
+ if (!(this instanceof SubError)) return new SubError(message);
+ notEnumerableProp(this, "message",
+ typeof message === "string" ? message : defaultMessage);
+ notEnumerableProp(this, "name", nameProperty);
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ Error.call(this);
+ }
+ }
+ inherits(SubError, Error);
+ return SubError;
+}
+
+var _TypeError, _RangeError;
+var Warning = subError("Warning", "warning");
+var CancellationError = subError("CancellationError", "cancellation error");
+var TimeoutError = subError("TimeoutError", "timeout error");
+var AggregateError = subError("AggregateError", "aggregate error");
+try {
+ _TypeError = TypeError;
+ _RangeError = RangeError;
+} catch(e) {
+ _TypeError = subError("TypeError", "type error");
+ _RangeError = subError("RangeError", "range error");
+}
+
+var methods = ("join pop push shift unshift slice filter forEach some " +
+ "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
+
+for (var i = 0; i < methods.length; ++i) {
+ if (typeof Array.prototype[methods[i]] === "function") {
+ AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
+ }
+}
+
+es5.defineProperty(AggregateError.prototype, "length", {
+ value: 0,
+ configurable: false,
+ writable: true,
+ enumerable: true
+});
+AggregateError.prototype["isOperational"] = true;
+var level = 0;
+AggregateError.prototype.toString = function() {
+ var indent = Array(level * 4 + 1).join(" ");
+ var ret = "\n" + indent + "AggregateError of:" + "\n";
+ level++;
+ indent = Array(level * 4 + 1).join(" ");
+ for (var i = 0; i < this.length; ++i) {
+ var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
+ var lines = str.split("\n");
+ for (var j = 0; j < lines.length; ++j) {
+ lines[j] = indent + lines[j];
+ }
+ str = lines.join("\n");
+ ret += str + "\n";
+ }
+ level--;
+ return ret;
+};
+
+function OperationalError(message) {
+ if (!(this instanceof OperationalError))
+ return new OperationalError(message);
+ notEnumerableProp(this, "name", "OperationalError");
+ notEnumerableProp(this, "message", message);
+ this.cause = message;
+ this["isOperational"] = true;
+
+ if (message instanceof Error) {
+ notEnumerableProp(this, "message", message.message);
+ notEnumerableProp(this, "stack", message.stack);
+ } else if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, this.constructor);
+ }
+
+}
+inherits(OperationalError, Error);
+
+var errorTypes = Error["__BluebirdErrorTypes__"];
+if (!errorTypes) {
+ errorTypes = Objectfreeze({
+ CancellationError: CancellationError,
+ TimeoutError: TimeoutError,
+ OperationalError: OperationalError,
+ RejectionError: OperationalError,
+ AggregateError: AggregateError
+ });
+ notEnumerableProp(Error, "__BluebirdErrorTypes__", errorTypes);
+}
+
+module.exports = {
+ Error: Error,
+ TypeError: _TypeError,
+ RangeError: _RangeError,
+ CancellationError: errorTypes.CancellationError,
+ OperationalError: errorTypes.OperationalError,
+ TimeoutError: errorTypes.TimeoutError,
+ AggregateError: errorTypes.AggregateError,
+ Warning: Warning
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/es5.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/es5.js
new file mode 100644
index 0000000..ea41d5a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/es5.js
@@ -0,0 +1,80 @@
+var isES5 = (function(){
+ "use strict";
+ return this === undefined;
+})();
+
+if (isES5) {
+ module.exports = {
+ freeze: Object.freeze,
+ defineProperty: Object.defineProperty,
+ getDescriptor: Object.getOwnPropertyDescriptor,
+ keys: Object.keys,
+ names: Object.getOwnPropertyNames,
+ getPrototypeOf: Object.getPrototypeOf,
+ isArray: Array.isArray,
+ isES5: isES5,
+ propertyIsWritable: function(obj, prop) {
+ var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
+ return !!(!descriptor || descriptor.writable || descriptor.set);
+ }
+ };
+} else {
+ var has = {}.hasOwnProperty;
+ var str = {}.toString;
+ var proto = {}.constructor.prototype;
+
+ var ObjectKeys = function (o) {
+ var ret = [];
+ for (var key in o) {
+ if (has.call(o, key)) {
+ ret.push(key);
+ }
+ }
+ return ret;
+ };
+
+ var ObjectGetDescriptor = function(o, key) {
+ return {value: o[key]};
+ };
+
+ var ObjectDefineProperty = function (o, key, desc) {
+ o[key] = desc.value;
+ return o;
+ };
+
+ var ObjectFreeze = function (obj) {
+ return obj;
+ };
+
+ var ObjectGetPrototypeOf = function (obj) {
+ try {
+ return Object(obj).constructor.prototype;
+ }
+ catch (e) {
+ return proto;
+ }
+ };
+
+ var ArrayIsArray = function (obj) {
+ try {
+ return str.call(obj) === "[object Array]";
+ }
+ catch(e) {
+ return false;
+ }
+ };
+
+ module.exports = {
+ isArray: ArrayIsArray,
+ keys: ObjectKeys,
+ names: ObjectKeys,
+ defineProperty: ObjectDefineProperty,
+ getDescriptor: ObjectGetDescriptor,
+ freeze: ObjectFreeze,
+ getPrototypeOf: ObjectGetPrototypeOf,
+ isES5: isES5,
+ propertyIsWritable: function() {
+ return true;
+ }
+ };
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/filter.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/filter.js
new file mode 100644
index 0000000..ed57bf0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/filter.js
@@ -0,0 +1,12 @@
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var PromiseMap = Promise.map;
+
+Promise.prototype.filter = function (fn, options) {
+ return PromiseMap(this, fn, options, INTERNAL);
+};
+
+Promise.filter = function (promises, fn, options) {
+ return PromiseMap(promises, fn, options, INTERNAL);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/finally.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/finally.js
new file mode 100644
index 0000000..c9342bc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/finally.js
@@ -0,0 +1,98 @@
+"use strict";
+module.exports = function(Promise, NEXT_FILTER, tryConvertToPromise) {
+var util = require("./util.js");
+var isPrimitive = util.isPrimitive;
+var thrower = util.thrower;
+
+function returnThis() {
+ return this;
+}
+function throwThis() {
+ throw this;
+}
+function return$(r) {
+ return function() {
+ return r;
+ };
+}
+function throw$(r) {
+ return function() {
+ throw r;
+ };
+}
+function promisedFinally(ret, reasonOrValue, isFulfilled) {
+ var then;
+ if (isPrimitive(reasonOrValue)) {
+ then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue);
+ } else {
+ then = isFulfilled ? returnThis : throwThis;
+ }
+ return ret._then(then, thrower, undefined, reasonOrValue, undefined);
+}
+
+function finallyHandler(reasonOrValue) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundValue())
+ : handler();
+
+ if (ret !== undefined) {
+ var maybePromise = tryConvertToPromise(ret, promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ return promisedFinally(maybePromise, reasonOrValue,
+ promise.isFulfilled());
+ }
+ }
+
+ if (promise.isRejected()) {
+ NEXT_FILTER.e = reasonOrValue;
+ return NEXT_FILTER;
+ } else {
+ return reasonOrValue;
+ }
+}
+
+function tapHandler(value) {
+ var promise = this.promise;
+ var handler = this.handler;
+
+ var ret = promise._isBound()
+ ? handler.call(promise._boundValue(), value)
+ : handler(value);
+
+ if (ret !== undefined) {
+ var maybePromise = tryConvertToPromise(ret, promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ return promisedFinally(maybePromise, value, true);
+ }
+ }
+ return value;
+}
+
+Promise.prototype._passThroughHandler = function (handler, isFinally) {
+ if (typeof handler !== "function") return this.then();
+
+ var promiseAndHandler = {
+ promise: this,
+ handler: handler
+ };
+
+ return this._then(
+ isFinally ? finallyHandler : tapHandler,
+ isFinally ? finallyHandler : undefined, undefined,
+ promiseAndHandler, undefined);
+};
+
+Promise.prototype.lastly =
+Promise.prototype["finally"] = function (handler) {
+ return this._passThroughHandler(handler, true);
+};
+
+Promise.prototype.tap = function (handler) {
+ return this._passThroughHandler(handler, false);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/generators.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/generators.js
new file mode 100644
index 0000000..4c0568d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/generators.js
@@ -0,0 +1,136 @@
+"use strict";
+module.exports = function(Promise,
+ apiRejection,
+ INTERNAL,
+ tryConvertToPromise) {
+var errors = require("./errors.js");
+var TypeError = errors.TypeError;
+var util = require("./util.js");
+var errorObj = util.errorObj;
+var tryCatch = util.tryCatch;
+var yieldHandlers = [];
+
+function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
+ for (var i = 0; i < yieldHandlers.length; ++i) {
+ traceParent._pushContext();
+ var result = tryCatch(yieldHandlers[i])(value);
+ traceParent._popContext();
+ if (result === errorObj) {
+ traceParent._pushContext();
+ var ret = Promise.reject(errorObj.e);
+ traceParent._popContext();
+ return ret;
+ }
+ var maybePromise = tryConvertToPromise(result, traceParent);
+ if (maybePromise instanceof Promise) return maybePromise;
+ }
+ return null;
+}
+
+function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
+ var promise = this._promise = new Promise(INTERNAL);
+ promise._captureStackTrace();
+ this._stack = stack;
+ this._generatorFunction = generatorFunction;
+ this._receiver = receiver;
+ this._generator = undefined;
+ this._yieldHandlers = typeof yieldHandler === "function"
+ ? [yieldHandler].concat(yieldHandlers)
+ : yieldHandlers;
+}
+
+PromiseSpawn.prototype.promise = function () {
+ return this._promise;
+};
+
+PromiseSpawn.prototype._run = function () {
+ this._generator = this._generatorFunction.call(this._receiver);
+ this._receiver =
+ this._generatorFunction = undefined;
+ this._next(undefined);
+};
+
+PromiseSpawn.prototype._continue = function (result) {
+ if (result === errorObj) {
+ return this._promise._rejectCallback(result.e, false, true);
+ }
+
+ var value = result.value;
+ if (result.done === true) {
+ this._promise._resolveCallback(value);
+ } else {
+ var maybePromise = tryConvertToPromise(value, this._promise);
+ if (!(maybePromise instanceof Promise)) {
+ maybePromise =
+ promiseFromYieldHandler(maybePromise,
+ this._yieldHandlers,
+ this._promise);
+ if (maybePromise === null) {
+ this._throw(
+ new TypeError(
+ "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/4Y4pDk\u000a\u000a".replace("%s", value) +
+ "From coroutine:\u000a" +
+ this._stack.split("\n").slice(1, -7).join("\n")
+ )
+ );
+ return;
+ }
+ }
+ maybePromise._then(
+ this._next,
+ this._throw,
+ undefined,
+ this,
+ null
+ );
+ }
+};
+
+PromiseSpawn.prototype._throw = function (reason) {
+ this._promise._attachExtraTrace(reason);
+ this._promise._pushContext();
+ var result = tryCatch(this._generator["throw"])
+ .call(this._generator, reason);
+ this._promise._popContext();
+ this._continue(result);
+};
+
+PromiseSpawn.prototype._next = function (value) {
+ this._promise._pushContext();
+ var result = tryCatch(this._generator.next).call(this._generator, value);
+ this._promise._popContext();
+ this._continue(result);
+};
+
+Promise.coroutine = function (generatorFunction, options) {
+ if (typeof generatorFunction !== "function") {
+ throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
+ }
+ var yieldHandler = Object(options).yieldHandler;
+ var PromiseSpawn$ = PromiseSpawn;
+ var stack = new Error().stack;
+ return function () {
+ var generator = generatorFunction.apply(this, arguments);
+ var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
+ stack);
+ spawn._generator = generator;
+ spawn._next(undefined);
+ return spawn.promise();
+ };
+};
+
+Promise.coroutine.addYieldHandler = function(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ yieldHandlers.push(fn);
+};
+
+Promise.spawn = function (generatorFunction) {
+ if (typeof generatorFunction !== "function") {
+ return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/6Vqhm0\u000a");
+ }
+ var spawn = new PromiseSpawn(generatorFunction, this);
+ var ret = spawn.promise();
+ spawn._run(Promise.spawn);
+ return ret;
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/join.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/join.js
new file mode 100644
index 0000000..cf33eb1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/join.js
@@ -0,0 +1,107 @@
+"use strict";
+module.exports =
+function(Promise, PromiseArray, tryConvertToPromise, INTERNAL) {
+var util = require("./util.js");
+var canEvaluate = util.canEvaluate;
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var reject;
+
+if (!false) {
+if (canEvaluate) {
+ var thenCallback = function(i) {
+ return new Function("value", "holder", " \n\
+ 'use strict'; \n\
+ holder.pIndex = value; \n\
+ holder.checkFulfillment(this); \n\
+ ".replace(/Index/g, i));
+ };
+
+ var caller = function(count) {
+ var values = [];
+ for (var i = 1; i <= count; ++i) values.push("holder.p" + i);
+ return new Function("holder", " \n\
+ 'use strict'; \n\
+ var callback = holder.fn; \n\
+ return callback(values); \n\
+ ".replace(/values/g, values.join(", ")));
+ };
+ var thenCallbacks = [];
+ var callers = [undefined];
+ for (var i = 1; i <= 5; ++i) {
+ thenCallbacks.push(thenCallback(i));
+ callers.push(caller(i));
+ }
+
+ var Holder = function(total, fn) {
+ this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null;
+ this.fn = fn;
+ this.total = total;
+ this.now = 0;
+ };
+
+ Holder.prototype.callers = callers;
+ Holder.prototype.checkFulfillment = function(promise) {
+ var now = this.now;
+ now++;
+ var total = this.total;
+ if (now >= total) {
+ var handler = this.callers[total];
+ promise._pushContext();
+ var ret = tryCatch(handler)(this);
+ promise._popContext();
+ if (ret === errorObj) {
+ promise._rejectCallback(ret.e, false, true);
+ } else {
+ promise._resolveCallback(ret);
+ }
+ } else {
+ this.now = now;
+ }
+ };
+
+ var reject = function (reason) {
+ this._reject(reason);
+ };
+}
+}
+
+Promise.join = function () {
+ var last = arguments.length - 1;
+ var fn;
+ if (last > 0 && typeof arguments[last] === "function") {
+ fn = arguments[last];
+ if (!false) {
+ if (last < 6 && canEvaluate) {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ var holder = new Holder(last, fn);
+ var callbacks = thenCallbacks;
+ for (var i = 0; i < last; ++i) {
+ var maybePromise = tryConvertToPromise(arguments[i], ret);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ maybePromise._then(callbacks[i], reject,
+ undefined, ret, holder);
+ } else if (maybePromise._isFulfilled()) {
+ callbacks[i].call(ret,
+ maybePromise._value(), holder);
+ } else {
+ ret._reject(maybePromise._reason());
+ }
+ } else {
+ callbacks[i].call(ret, maybePromise, holder);
+ }
+ }
+ return ret;
+ }
+ }
+ }
+ var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}
+ if (fn) args.pop();
+ var ret = new PromiseArray(args).promise();
+ return fn !== undefined ? ret.spread(fn) : ret;
+};
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/map.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/map.js
new file mode 100644
index 0000000..2f40efd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/map.js
@@ -0,0 +1,133 @@
+"use strict";
+module.exports = function(Promise,
+ PromiseArray,
+ apiRejection,
+ tryConvertToPromise,
+ INTERNAL) {
+var getDomain = Promise._getDomain;
+var async = require("./async.js");
+var util = require("./util.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+var PENDING = {};
+var EMPTY_ARRAY = [];
+
+function MappingPromiseArray(promises, fn, limit, _filter) {
+ this.constructor$(promises);
+ this._promise._captureStackTrace();
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
+ this._preservedValues = _filter === INTERNAL
+ ? new Array(this.length())
+ : null;
+ this._limit = limit;
+ this._inFlight = 0;
+ this._queue = limit >= 1 ? [] : EMPTY_ARRAY;
+ async.invoke(init, this, undefined);
+}
+util.inherits(MappingPromiseArray, PromiseArray);
+function init() {this._init$(undefined, -2);}
+
+MappingPromiseArray.prototype._init = function () {};
+
+MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var values = this._values;
+ var length = this.length();
+ var preservedValues = this._preservedValues;
+ var limit = this._limit;
+ if (values[index] === PENDING) {
+ values[index] = value;
+ if (limit >= 1) {
+ this._inFlight--;
+ this._drainQueue();
+ if (this._isResolved()) return;
+ }
+ } else {
+ if (limit >= 1 && this._inFlight >= limit) {
+ values[index] = value;
+ this._queue.push(index);
+ return;
+ }
+ if (preservedValues !== null) preservedValues[index] = value;
+
+ var callback = this._callback;
+ var receiver = this._promise._boundValue();
+ this._promise._pushContext();
+ var ret = tryCatch(callback).call(receiver, value, index, length);
+ this._promise._popContext();
+ if (ret === errorObj) return this._reject(ret.e);
+
+ var maybePromise = tryConvertToPromise(ret, this._promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ if (limit >= 1) this._inFlight++;
+ values[index] = PENDING;
+ return maybePromise._proxyPromiseArray(this, index);
+ } else if (maybePromise._isFulfilled()) {
+ ret = maybePromise._value();
+ } else {
+ return this._reject(maybePromise._reason());
+ }
+ }
+ values[index] = ret;
+ }
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= length) {
+ if (preservedValues !== null) {
+ this._filter(values, preservedValues);
+ } else {
+ this._resolve(values);
+ }
+
+ }
+};
+
+MappingPromiseArray.prototype._drainQueue = function () {
+ var queue = this._queue;
+ var limit = this._limit;
+ var values = this._values;
+ while (queue.length > 0 && this._inFlight < limit) {
+ if (this._isResolved()) return;
+ var index = queue.pop();
+ this._promiseFulfilled(values[index], index);
+ }
+};
+
+MappingPromiseArray.prototype._filter = function (booleans, values) {
+ var len = values.length;
+ var ret = new Array(len);
+ var j = 0;
+ for (var i = 0; i < len; ++i) {
+ if (booleans[i]) ret[j++] = values[i];
+ }
+ ret.length = j;
+ this._resolve(ret);
+};
+
+MappingPromiseArray.prototype.preservedValues = function () {
+ return this._preservedValues;
+};
+
+function map(promises, fn, options, _filter) {
+ var limit = typeof options === "object" && options !== null
+ ? options.concurrency
+ : 0;
+ limit = typeof limit === "number" &&
+ isFinite(limit) && limit >= 1 ? limit : 0;
+ return new MappingPromiseArray(promises, fn, limit, _filter);
+}
+
+Promise.prototype.map = function (fn, options) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+
+ return map(this, fn, options, null).promise();
+};
+
+Promise.map = function (promises, fn, options, _filter) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ return map(promises, fn, options, _filter).promise();
+};
+
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/method.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/method.js
new file mode 100644
index 0000000..3d3eeb1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/method.js
@@ -0,0 +1,44 @@
+"use strict";
+module.exports =
+function(Promise, INTERNAL, tryConvertToPromise, apiRejection) {
+var util = require("./util.js");
+var tryCatch = util.tryCatch;
+
+Promise.method = function (fn) {
+ if (typeof fn !== "function") {
+ throw new Promise.TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ return function () {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._pushContext();
+ var value = tryCatch(fn).apply(this, arguments);
+ ret._popContext();
+ ret._resolveFromSyncValue(value);
+ return ret;
+ };
+};
+
+Promise.attempt = Promise["try"] = function (fn, args, ctx) {
+ if (typeof fn !== "function") {
+ return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._pushContext();
+ var value = util.isArray(args)
+ ? tryCatch(fn).apply(ctx, args)
+ : tryCatch(fn).call(ctx, args);
+ ret._popContext();
+ ret._resolveFromSyncValue(value);
+ return ret;
+};
+
+Promise.prototype._resolveFromSyncValue = function (value) {
+ if (value === util.errorObj) {
+ this._rejectCallback(value.e, false, true);
+ } else {
+ this._resolveCallback(value, true);
+ }
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/nodeify.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/nodeify.js
new file mode 100644
index 0000000..257565d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/nodeify.js
@@ -0,0 +1,59 @@
+"use strict";
+module.exports = function(Promise) {
+var util = require("./util.js");
+var async = require("./async.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+
+function spreadAdapter(val, nodeback) {
+ var promise = this;
+ if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
+ var ret =
+ tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+
+function successAdapter(val, nodeback) {
+ var promise = this;
+ var receiver = promise._boundValue();
+ var ret = val === undefined
+ ? tryCatch(nodeback).call(receiver, null)
+ : tryCatch(nodeback).call(receiver, null, val);
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+function errorAdapter(reason, nodeback) {
+ var promise = this;
+ if (!reason) {
+ var target = promise._target();
+ var newReason = target._getCarriedStackTrace();
+ newReason.cause = reason;
+ reason = newReason;
+ }
+ var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
+ if (ret === errorObj) {
+ async.throwLater(ret.e);
+ }
+}
+
+Promise.prototype.asCallback =
+Promise.prototype.nodeify = function (nodeback, options) {
+ if (typeof nodeback == "function") {
+ var adapter = successAdapter;
+ if (options !== undefined && Object(options).spread) {
+ adapter = spreadAdapter;
+ }
+ this._then(
+ adapter,
+ errorAdapter,
+ undefined,
+ this,
+ nodeback
+ );
+ }
+ return this;
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/progress.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/progress.js
new file mode 100644
index 0000000..2e3e95e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/progress.js
@@ -0,0 +1,76 @@
+"use strict";
+module.exports = function(Promise, PromiseArray) {
+var util = require("./util.js");
+var async = require("./async.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+
+Promise.prototype.progressed = function (handler) {
+ return this._then(undefined, undefined, handler, undefined, undefined);
+};
+
+Promise.prototype._progress = function (progressValue) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._target()._progressUnchecked(progressValue);
+
+};
+
+Promise.prototype._progressHandlerAt = function (index) {
+ return index === 0
+ ? this._progressHandler0
+ : this[(index << 2) + index - 5 + 2];
+};
+
+Promise.prototype._doProgressWith = function (progression) {
+ var progressValue = progression.value;
+ var handler = progression.handler;
+ var promise = progression.promise;
+ var receiver = progression.receiver;
+
+ var ret = tryCatch(handler).call(receiver, progressValue);
+ if (ret === errorObj) {
+ if (ret.e != null &&
+ ret.e.name !== "StopProgressPropagation") {
+ var trace = util.canAttachTrace(ret.e)
+ ? ret.e : new Error(util.toString(ret.e));
+ promise._attachExtraTrace(trace);
+ promise._progress(ret.e);
+ }
+ } else if (ret instanceof Promise) {
+ ret._then(promise._progress, null, null, promise, undefined);
+ } else {
+ promise._progress(ret);
+ }
+};
+
+
+Promise.prototype._progressUnchecked = function (progressValue) {
+ var len = this._length();
+ var progress = this._progress;
+ for (var i = 0; i < len; i++) {
+ var handler = this._progressHandlerAt(i);
+ var promise = this._promiseAt(i);
+ if (!(promise instanceof Promise)) {
+ var receiver = this._receiverAt(i);
+ if (typeof handler === "function") {
+ handler.call(receiver, progressValue, promise);
+ } else if (receiver instanceof PromiseArray &&
+ !receiver._isResolved()) {
+ receiver._promiseProgressed(progressValue, promise);
+ }
+ continue;
+ }
+
+ if (typeof handler === "function") {
+ async.invoke(this._doProgressWith, this, {
+ handler: handler,
+ promise: promise,
+ receiver: this._receiverAt(i),
+ value: progressValue
+ });
+ } else {
+ async.invoke(progress, promise, progressValue);
+ }
+ }
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise.js
new file mode 100644
index 0000000..96bd545
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise.js
@@ -0,0 +1,754 @@
+"use strict";
+module.exports = function() {
+var makeSelfResolutionError = function () {
+ return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/LhFpo0\u000a");
+};
+var reflect = function() {
+ return new Promise.PromiseInspection(this._target());
+};
+var apiRejection = function(msg) {
+ return Promise.reject(new TypeError(msg));
+};
+
+var util = require("./util.js");
+
+var getDomain;
+if (util.isNode) {
+ getDomain = function() {
+ var ret = process.domain;
+ if (ret === undefined) ret = null;
+ return ret;
+ };
+} else {
+ getDomain = function() {
+ return null;
+ };
+}
+util.notEnumerableProp(Promise, "_getDomain", getDomain);
+
+var UNDEFINED_BINDING = {};
+var async = require("./async.js");
+var errors = require("./errors.js");
+var TypeError = Promise.TypeError = errors.TypeError;
+Promise.RangeError = errors.RangeError;
+Promise.CancellationError = errors.CancellationError;
+Promise.TimeoutError = errors.TimeoutError;
+Promise.OperationalError = errors.OperationalError;
+Promise.RejectionError = errors.OperationalError;
+Promise.AggregateError = errors.AggregateError;
+var INTERNAL = function(){};
+var APPLY = {};
+var NEXT_FILTER = {e: null};
+var tryConvertToPromise = require("./thenables.js")(Promise, INTERNAL);
+var PromiseArray =
+ require("./promise_array.js")(Promise, INTERNAL,
+ tryConvertToPromise, apiRejection);
+var CapturedTrace = require("./captured_trace.js")();
+var isDebugging = require("./debuggability.js")(Promise, CapturedTrace);
+ /*jshint unused:false*/
+var createContext =
+ require("./context.js")(Promise, CapturedTrace, isDebugging);
+var CatchFilter = require("./catch_filter.js")(NEXT_FILTER);
+var PromiseResolver = require("./promise_resolver.js");
+var nodebackForPromise = PromiseResolver._nodebackForPromise;
+var errorObj = util.errorObj;
+var tryCatch = util.tryCatch;
+function Promise(resolver) {
+ if (typeof resolver !== "function") {
+ throw new TypeError("the promise constructor requires a resolver function\u000a\u000a See http://goo.gl/EC22Yn\u000a");
+ }
+ if (this.constructor !== Promise) {
+ throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/KsIlge\u000a");
+ }
+ this._bitField = 0;
+ this._fulfillmentHandler0 = undefined;
+ this._rejectionHandler0 = undefined;
+ this._progressHandler0 = undefined;
+ this._promise0 = undefined;
+ this._receiver0 = undefined;
+ this._settledValue = undefined;
+ if (resolver !== INTERNAL) this._resolveFromResolver(resolver);
+}
+
+Promise.prototype.toString = function () {
+ return "[object Promise]";
+};
+
+Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
+ var len = arguments.length;
+ if (len > 1) {
+ var catchInstances = new Array(len - 1),
+ j = 0, i;
+ for (i = 0; i < len - 1; ++i) {
+ var item = arguments[i];
+ if (typeof item === "function") {
+ catchInstances[j++] = item;
+ } else {
+ return Promise.reject(
+ new TypeError("Catch filter must inherit from Error or be a simple predicate function\u000a\u000a See http://goo.gl/o84o68\u000a"));
+ }
+ }
+ catchInstances.length = j;
+ fn = arguments[i];
+ var catchFilter = new CatchFilter(catchInstances, fn, this);
+ return this._then(undefined, catchFilter.doFilter, undefined,
+ catchFilter, undefined);
+ }
+ return this._then(undefined, fn, undefined, undefined, undefined);
+};
+
+Promise.prototype.reflect = function () {
+ return this._then(reflect, reflect, undefined, this, undefined);
+};
+
+Promise.prototype.then = function (didFulfill, didReject, didProgress) {
+ if (isDebugging() && arguments.length > 0 &&
+ typeof didFulfill !== "function" &&
+ typeof didReject !== "function") {
+ var msg = ".then() only accepts functions but was passed: " +
+ util.classString(didFulfill);
+ if (arguments.length > 1) {
+ msg += ", " + util.classString(didReject);
+ }
+ this._warn(msg);
+ }
+ return this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+};
+
+Promise.prototype.done = function (didFulfill, didReject, didProgress) {
+ var promise = this._then(didFulfill, didReject, didProgress,
+ undefined, undefined);
+ promise._setIsFinal();
+};
+
+Promise.prototype.spread = function (didFulfill, didReject) {
+ return this.all()._then(didFulfill, didReject, undefined, APPLY, undefined);
+};
+
+Promise.prototype.isCancellable = function () {
+ return !this.isResolved() &&
+ this._cancellable();
+};
+
+Promise.prototype.toJSON = function () {
+ var ret = {
+ isFulfilled: false,
+ isRejected: false,
+ fulfillmentValue: undefined,
+ rejectionReason: undefined
+ };
+ if (this.isFulfilled()) {
+ ret.fulfillmentValue = this.value();
+ ret.isFulfilled = true;
+ } else if (this.isRejected()) {
+ ret.rejectionReason = this.reason();
+ ret.isRejected = true;
+ }
+ return ret;
+};
+
+Promise.prototype.all = function () {
+ return new PromiseArray(this).promise();
+};
+
+Promise.prototype.error = function (fn) {
+ return this.caught(util.originatesFromRejection, fn);
+};
+
+Promise.is = function (val) {
+ return val instanceof Promise;
+};
+
+Promise.fromNode = function(fn) {
+ var ret = new Promise(INTERNAL);
+ var result = tryCatch(fn)(nodebackForPromise(ret));
+ if (result === errorObj) {
+ ret._rejectCallback(result.e, true, true);
+ }
+ return ret;
+};
+
+Promise.all = function (promises) {
+ return new PromiseArray(promises).promise();
+};
+
+Promise.defer = Promise.pending = function () {
+ var promise = new Promise(INTERNAL);
+ return new PromiseResolver(promise);
+};
+
+Promise.cast = function (obj) {
+ var ret = tryConvertToPromise(obj);
+ if (!(ret instanceof Promise)) {
+ var val = ret;
+ ret = new Promise(INTERNAL);
+ ret._fulfillUnchecked(val);
+ }
+ return ret;
+};
+
+Promise.resolve = Promise.fulfilled = Promise.cast;
+
+Promise.reject = Promise.rejected = function (reason) {
+ var ret = new Promise(INTERNAL);
+ ret._captureStackTrace();
+ ret._rejectCallback(reason, true);
+ return ret;
+};
+
+Promise.setScheduler = function(fn) {
+ if (typeof fn !== "function") throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ var prev = async._schedule;
+ async._schedule = fn;
+ return prev;
+};
+
+Promise.prototype._then = function (
+ didFulfill,
+ didReject,
+ didProgress,
+ receiver,
+ internalData
+) {
+ var haveInternalData = internalData !== undefined;
+ var ret = haveInternalData ? internalData : new Promise(INTERNAL);
+
+ if (!haveInternalData) {
+ ret._propagateFrom(this, 4 | 1);
+ ret._captureStackTrace();
+ }
+
+ var target = this._target();
+ if (target !== this) {
+ if (receiver === undefined) receiver = this._boundTo;
+ if (!haveInternalData) ret._setIsMigrated();
+ }
+
+ var callbackIndex = target._addCallbacks(didFulfill,
+ didReject,
+ didProgress,
+ ret,
+ receiver,
+ getDomain());
+
+ if (target._isResolved() && !target._isSettlePromisesQueued()) {
+ async.invoke(
+ target._settlePromiseAtPostResolution, target, callbackIndex);
+ }
+
+ return ret;
+};
+
+Promise.prototype._settlePromiseAtPostResolution = function (index) {
+ if (this._isRejectionUnhandled()) this._unsetRejectionIsUnhandled();
+ this._settlePromiseAt(index);
+};
+
+Promise.prototype._length = function () {
+ return this._bitField & 131071;
+};
+
+Promise.prototype._isFollowingOrFulfilledOrRejected = function () {
+ return (this._bitField & 939524096) > 0;
+};
+
+Promise.prototype._isFollowing = function () {
+ return (this._bitField & 536870912) === 536870912;
+};
+
+Promise.prototype._setLength = function (len) {
+ this._bitField = (this._bitField & -131072) |
+ (len & 131071);
+};
+
+Promise.prototype._setFulfilled = function () {
+ this._bitField = this._bitField | 268435456;
+};
+
+Promise.prototype._setRejected = function () {
+ this._bitField = this._bitField | 134217728;
+};
+
+Promise.prototype._setFollowing = function () {
+ this._bitField = this._bitField | 536870912;
+};
+
+Promise.prototype._setIsFinal = function () {
+ this._bitField = this._bitField | 33554432;
+};
+
+Promise.prototype._isFinal = function () {
+ return (this._bitField & 33554432) > 0;
+};
+
+Promise.prototype._cancellable = function () {
+ return (this._bitField & 67108864) > 0;
+};
+
+Promise.prototype._setCancellable = function () {
+ this._bitField = this._bitField | 67108864;
+};
+
+Promise.prototype._unsetCancellable = function () {
+ this._bitField = this._bitField & (~67108864);
+};
+
+Promise.prototype._setIsMigrated = function () {
+ this._bitField = this._bitField | 4194304;
+};
+
+Promise.prototype._unsetIsMigrated = function () {
+ this._bitField = this._bitField & (~4194304);
+};
+
+Promise.prototype._isMigrated = function () {
+ return (this._bitField & 4194304) > 0;
+};
+
+Promise.prototype._receiverAt = function (index) {
+ var ret = index === 0
+ ? this._receiver0
+ : this[
+ index * 5 - 5 + 4];
+ if (ret === UNDEFINED_BINDING) {
+ return undefined;
+ } else if (ret === undefined && this._isBound()) {
+ return this._boundValue();
+ }
+ return ret;
+};
+
+Promise.prototype._promiseAt = function (index) {
+ return index === 0
+ ? this._promise0
+ : this[index * 5 - 5 + 3];
+};
+
+Promise.prototype._fulfillmentHandlerAt = function (index) {
+ return index === 0
+ ? this._fulfillmentHandler0
+ : this[index * 5 - 5 + 0];
+};
+
+Promise.prototype._rejectionHandlerAt = function (index) {
+ return index === 0
+ ? this._rejectionHandler0
+ : this[index * 5 - 5 + 1];
+};
+
+Promise.prototype._boundValue = function() {
+ var ret = this._boundTo;
+ if (ret !== undefined) {
+ if (ret instanceof Promise) {
+ if (ret.isFulfilled()) {
+ return ret.value();
+ } else {
+ return undefined;
+ }
+ }
+ }
+ return ret;
+};
+
+Promise.prototype._migrateCallbacks = function (follower, index) {
+ var fulfill = follower._fulfillmentHandlerAt(index);
+ var reject = follower._rejectionHandlerAt(index);
+ var progress = follower._progressHandlerAt(index);
+ var promise = follower._promiseAt(index);
+ var receiver = follower._receiverAt(index);
+ if (promise instanceof Promise) promise._setIsMigrated();
+ if (receiver === undefined) receiver = UNDEFINED_BINDING;
+ this._addCallbacks(fulfill, reject, progress, promise, receiver, null);
+};
+
+Promise.prototype._addCallbacks = function (
+ fulfill,
+ reject,
+ progress,
+ promise,
+ receiver,
+ domain
+) {
+ var index = this._length();
+
+ if (index >= 131071 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+
+ if (index === 0) {
+ this._promise0 = promise;
+ if (receiver !== undefined) this._receiver0 = receiver;
+ if (typeof fulfill === "function" && !this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this._rejectionHandler0 =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this._progressHandler0 =
+ domain === null ? progress : domain.bind(progress);
+ }
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] = promise;
+ this[base + 4] = receiver;
+ if (typeof fulfill === "function") {
+ this[base + 0] =
+ domain === null ? fulfill : domain.bind(fulfill);
+ }
+ if (typeof reject === "function") {
+ this[base + 1] =
+ domain === null ? reject : domain.bind(reject);
+ }
+ if (typeof progress === "function") {
+ this[base + 2] =
+ domain === null ? progress : domain.bind(progress);
+ }
+ }
+ this._setLength(index + 1);
+ return index;
+};
+
+Promise.prototype._setProxyHandlers = function (receiver, promiseSlotValue) {
+ var index = this._length();
+
+ if (index >= 131071 - 5) {
+ index = 0;
+ this._setLength(0);
+ }
+ if (index === 0) {
+ this._promise0 = promiseSlotValue;
+ this._receiver0 = receiver;
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] = promiseSlotValue;
+ this[base + 4] = receiver;
+ }
+ this._setLength(index + 1);
+};
+
+Promise.prototype._proxyPromiseArray = function (promiseArray, index) {
+ this._setProxyHandlers(promiseArray, index);
+};
+
+Promise.prototype._resolveCallback = function(value, shouldBind) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ if (value === this)
+ return this._rejectCallback(makeSelfResolutionError(), false, true);
+ var maybePromise = tryConvertToPromise(value, this);
+ if (!(maybePromise instanceof Promise)) return this._fulfill(value);
+
+ var propagationFlags = 1 | (shouldBind ? 4 : 0);
+ this._propagateFrom(maybePromise, propagationFlags);
+ var promise = maybePromise._target();
+ if (promise._isPending()) {
+ var len = this._length();
+ for (var i = 0; i < len; ++i) {
+ promise._migrateCallbacks(this, i);
+ }
+ this._setFollowing();
+ this._setLength(0);
+ this._setFollowee(promise);
+ } else if (promise._isFulfilled()) {
+ this._fulfillUnchecked(promise._value());
+ } else {
+ this._rejectUnchecked(promise._reason(),
+ promise._getCarriedStackTrace());
+ }
+};
+
+Promise.prototype._rejectCallback =
+function(reason, synchronous, shouldNotMarkOriginatingFromRejection) {
+ if (!shouldNotMarkOriginatingFromRejection) {
+ util.markAsOriginatingFromRejection(reason);
+ }
+ var trace = util.ensureErrorObject(reason);
+ var hasStack = trace === reason;
+ this._attachExtraTrace(trace, synchronous ? hasStack : false);
+ this._reject(reason, hasStack ? undefined : trace);
+};
+
+Promise.prototype._resolveFromResolver = function (resolver) {
+ var promise = this;
+ this._captureStackTrace();
+ this._pushContext();
+ var synchronous = true;
+ var r = tryCatch(resolver)(function(value) {
+ if (promise === null) return;
+ promise._resolveCallback(value);
+ promise = null;
+ }, function (reason) {
+ if (promise === null) return;
+ promise._rejectCallback(reason, synchronous);
+ promise = null;
+ });
+ synchronous = false;
+ this._popContext();
+
+ if (r !== undefined && r === errorObj && promise !== null) {
+ promise._rejectCallback(r.e, true, true);
+ promise = null;
+ }
+};
+
+Promise.prototype._settlePromiseFromHandler = function (
+ handler, receiver, value, promise
+) {
+ if (promise._isRejected()) return;
+ promise._pushContext();
+ var x;
+ if (receiver === APPLY && !this._isRejected()) {
+ x = tryCatch(handler).apply(this._boundValue(), value);
+ } else {
+ x = tryCatch(handler).call(receiver, value);
+ }
+ promise._popContext();
+
+ if (x === errorObj || x === promise || x === NEXT_FILTER) {
+ var err = x === promise ? makeSelfResolutionError() : x.e;
+ promise._rejectCallback(err, false, true);
+ } else {
+ promise._resolveCallback(x);
+ }
+};
+
+Promise.prototype._target = function() {
+ var ret = this;
+ while (ret._isFollowing()) ret = ret._followee();
+ return ret;
+};
+
+Promise.prototype._followee = function() {
+ return this._rejectionHandler0;
+};
+
+Promise.prototype._setFollowee = function(promise) {
+ this._rejectionHandler0 = promise;
+};
+
+Promise.prototype._cleanValues = function () {
+ if (this._cancellable()) {
+ this._cancellationParent = undefined;
+ }
+};
+
+Promise.prototype._propagateFrom = function (parent, flags) {
+ if ((flags & 1) > 0 && parent._cancellable()) {
+ this._setCancellable();
+ this._cancellationParent = parent;
+ }
+ if ((flags & 4) > 0 && parent._isBound()) {
+ this._setBoundTo(parent._boundTo);
+ }
+};
+
+Promise.prototype._fulfill = function (value) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._fulfillUnchecked(value);
+};
+
+Promise.prototype._reject = function (reason, carriedStackTrace) {
+ if (this._isFollowingOrFulfilledOrRejected()) return;
+ this._rejectUnchecked(reason, carriedStackTrace);
+};
+
+Promise.prototype._settlePromiseAt = function (index) {
+ var promise = this._promiseAt(index);
+ var isPromise = promise instanceof Promise;
+
+ if (isPromise && promise._isMigrated()) {
+ promise._unsetIsMigrated();
+ return async.invoke(this._settlePromiseAt, this, index);
+ }
+ var handler = this._isFulfilled()
+ ? this._fulfillmentHandlerAt(index)
+ : this._rejectionHandlerAt(index);
+
+ var carriedStackTrace =
+ this._isCarryingStackTrace() ? this._getCarriedStackTrace() : undefined;
+ var value = this._settledValue;
+ var receiver = this._receiverAt(index);
+ this._clearCallbackDataAtIndex(index);
+
+ if (typeof handler === "function") {
+ if (!isPromise) {
+ handler.call(receiver, value, promise);
+ } else {
+ this._settlePromiseFromHandler(handler, receiver, value, promise);
+ }
+ } else if (receiver instanceof PromiseArray) {
+ if (!receiver._isResolved()) {
+ if (this._isFulfilled()) {
+ receiver._promiseFulfilled(value, promise);
+ }
+ else {
+ receiver._promiseRejected(value, promise);
+ }
+ }
+ } else if (isPromise) {
+ if (this._isFulfilled()) {
+ promise._fulfill(value);
+ } else {
+ promise._reject(value, carriedStackTrace);
+ }
+ }
+
+ if (index >= 4 && (index & 31) === 4)
+ async.invokeLater(this._setLength, this, 0);
+};
+
+Promise.prototype._clearCallbackDataAtIndex = function(index) {
+ if (index === 0) {
+ if (!this._isCarryingStackTrace()) {
+ this._fulfillmentHandler0 = undefined;
+ }
+ this._rejectionHandler0 =
+ this._progressHandler0 =
+ this._receiver0 =
+ this._promise0 = undefined;
+ } else {
+ var base = index * 5 - 5;
+ this[base + 3] =
+ this[base + 4] =
+ this[base + 0] =
+ this[base + 1] =
+ this[base + 2] = undefined;
+ }
+};
+
+Promise.prototype._isSettlePromisesQueued = function () {
+ return (this._bitField &
+ -1073741824) === -1073741824;
+};
+
+Promise.prototype._setSettlePromisesQueued = function () {
+ this._bitField = this._bitField | -1073741824;
+};
+
+Promise.prototype._unsetSettlePromisesQueued = function () {
+ this._bitField = this._bitField & (~-1073741824);
+};
+
+Promise.prototype._queueSettlePromises = function() {
+ async.settlePromises(this);
+ this._setSettlePromisesQueued();
+};
+
+Promise.prototype._fulfillUnchecked = function (value) {
+ if (value === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err, undefined);
+ }
+ this._setFulfilled();
+ this._settledValue = value;
+ this._cleanValues();
+
+ if (this._length() > 0) {
+ this._queueSettlePromises();
+ }
+};
+
+Promise.prototype._rejectUncheckedCheckError = function (reason) {
+ var trace = util.ensureErrorObject(reason);
+ this._rejectUnchecked(reason, trace === reason ? undefined : trace);
+};
+
+Promise.prototype._rejectUnchecked = function (reason, trace) {
+ if (reason === this) {
+ var err = makeSelfResolutionError();
+ this._attachExtraTrace(err);
+ return this._rejectUnchecked(err);
+ }
+ this._setRejected();
+ this._settledValue = reason;
+ this._cleanValues();
+
+ if (this._isFinal()) {
+ async.throwLater(function(e) {
+ if ("stack" in e) {
+ async.invokeFirst(
+ CapturedTrace.unhandledRejection, undefined, e);
+ }
+ throw e;
+ }, trace === undefined ? reason : trace);
+ return;
+ }
+
+ if (trace !== undefined && trace !== reason) {
+ this._setCarriedStackTrace(trace);
+ }
+
+ if (this._length() > 0) {
+ this._queueSettlePromises();
+ } else {
+ this._ensurePossibleRejectionHandled();
+ }
+};
+
+Promise.prototype._settlePromises = function () {
+ this._unsetSettlePromisesQueued();
+ var len = this._length();
+ for (var i = 0; i < len; i++) {
+ this._settlePromiseAt(i);
+ }
+};
+
+util.notEnumerableProp(Promise,
+ "_makeSelfResolutionError",
+ makeSelfResolutionError);
+
+require("./progress.js")(Promise, PromiseArray);
+require("./method.js")(Promise, INTERNAL, tryConvertToPromise, apiRejection);
+require("./bind.js")(Promise, INTERNAL, tryConvertToPromise);
+require("./finally.js")(Promise, NEXT_FILTER, tryConvertToPromise);
+require("./direct_resolve.js")(Promise);
+require("./synchronous_inspection.js")(Promise);
+require("./join.js")(Promise, PromiseArray, tryConvertToPromise, INTERNAL);
+Promise.Promise = Promise;
+require('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
+require('./cancel.js')(Promise);
+require('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext);
+require('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise);
+require('./nodeify.js')(Promise);
+require('./call_get.js')(Promise);
+require('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
+require('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
+require('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL);
+require('./settle.js')(Promise, PromiseArray);
+require('./some.js')(Promise, PromiseArray, apiRejection);
+require('./promisify.js')(Promise, INTERNAL);
+require('./any.js')(Promise);
+require('./each.js')(Promise, INTERNAL);
+require('./timers.js')(Promise, INTERNAL);
+require('./filter.js')(Promise, INTERNAL);
+
+ util.toFastProperties(Promise);
+ util.toFastProperties(Promise.prototype);
+ function fillTypes(value) {
+ var p = new Promise(INTERNAL);
+ p._fulfillmentHandler0 = value;
+ p._rejectionHandler0 = value;
+ p._progressHandler0 = value;
+ p._promise0 = value;
+ p._receiver0 = value;
+ p._settledValue = value;
+ }
+ // Complete slack tracking, opt out of field-type tracking and
+ // stabilize map
+ fillTypes({a: 1});
+ fillTypes({b: 2});
+ fillTypes({c: 3});
+ fillTypes(1);
+ fillTypes(function(){});
+ fillTypes(undefined);
+ fillTypes(false);
+ fillTypes(new Promise(INTERNAL));
+ CapturedTrace.setBounds(async.firstLineError, util.lastLineError);
+ return Promise;
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_array.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_array.js
new file mode 100644
index 0000000..b2e8f1c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_array.js
@@ -0,0 +1,142 @@
+"use strict";
+module.exports = function(Promise, INTERNAL, tryConvertToPromise,
+ apiRejection) {
+var util = require("./util.js");
+var isArray = util.isArray;
+
+function toResolutionValue(val) {
+ switch(val) {
+ case -2: return [];
+ case -3: return {};
+ }
+}
+
+function PromiseArray(values) {
+ var promise = this._promise = new Promise(INTERNAL);
+ var parent;
+ if (values instanceof Promise) {
+ parent = values;
+ promise._propagateFrom(parent, 1 | 4);
+ }
+ this._values = values;
+ this._length = 0;
+ this._totalResolved = 0;
+ this._init(undefined, -2);
+}
+PromiseArray.prototype.length = function () {
+ return this._length;
+};
+
+PromiseArray.prototype.promise = function () {
+ return this._promise;
+};
+
+PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
+ var values = tryConvertToPromise(this._values, this._promise);
+ if (values instanceof Promise) {
+ values = values._target();
+ this._values = values;
+ if (values._isFulfilled()) {
+ values = values._value();
+ if (!isArray(values)) {
+ var err = new Promise.TypeError("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
+ this.__hardReject__(err);
+ return;
+ }
+ } else if (values._isPending()) {
+ values._then(
+ init,
+ this._reject,
+ undefined,
+ this,
+ resolveValueIfEmpty
+ );
+ return;
+ } else {
+ this._reject(values._reason());
+ return;
+ }
+ } else if (!isArray(values)) {
+ this._promise._reject(apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a")._reason());
+ return;
+ }
+
+ if (values.length === 0) {
+ if (resolveValueIfEmpty === -5) {
+ this._resolveEmptyArray();
+ }
+ else {
+ this._resolve(toResolutionValue(resolveValueIfEmpty));
+ }
+ return;
+ }
+ var len = this.getActualLength(values.length);
+ this._length = len;
+ this._values = this.shouldCopyValues() ? new Array(len) : this._values;
+ var promise = this._promise;
+ for (var i = 0; i < len; ++i) {
+ var isResolved = this._isResolved();
+ var maybePromise = tryConvertToPromise(values[i], promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (isResolved) {
+ maybePromise._ignoreRejections();
+ } else if (maybePromise._isPending()) {
+ maybePromise._proxyPromiseArray(this, i);
+ } else if (maybePromise._isFulfilled()) {
+ this._promiseFulfilled(maybePromise._value(), i);
+ } else {
+ this._promiseRejected(maybePromise._reason(), i);
+ }
+ } else if (!isResolved) {
+ this._promiseFulfilled(maybePromise, i);
+ }
+ }
+};
+
+PromiseArray.prototype._isResolved = function () {
+ return this._values === null;
+};
+
+PromiseArray.prototype._resolve = function (value) {
+ this._values = null;
+ this._promise._fulfill(value);
+};
+
+PromiseArray.prototype.__hardReject__ =
+PromiseArray.prototype._reject = function (reason) {
+ this._values = null;
+ this._promise._rejectCallback(reason, false, true);
+};
+
+PromiseArray.prototype._promiseProgressed = function (progressValue, index) {
+ this._promise._progress({
+ index: index,
+ value: progressValue
+ });
+};
+
+
+PromiseArray.prototype._promiseFulfilled = function (value, index) {
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+PromiseArray.prototype._promiseRejected = function (reason, index) {
+ this._totalResolved++;
+ this._reject(reason);
+};
+
+PromiseArray.prototype.shouldCopyValues = function () {
+ return true;
+};
+
+PromiseArray.prototype.getActualLength = function (len) {
+ return len;
+};
+
+return PromiseArray;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_resolver.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_resolver.js
new file mode 100644
index 0000000..b180a32
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promise_resolver.js
@@ -0,0 +1,123 @@
+"use strict";
+var util = require("./util.js");
+var maybeWrapAsError = util.maybeWrapAsError;
+var errors = require("./errors.js");
+var TimeoutError = errors.TimeoutError;
+var OperationalError = errors.OperationalError;
+var haveGetters = util.haveGetters;
+var es5 = require("./es5.js");
+
+function isUntypedError(obj) {
+ return obj instanceof Error &&
+ es5.getPrototypeOf(obj) === Error.prototype;
+}
+
+var rErrorKey = /^(?:name|message|stack|cause)$/;
+function wrapAsOperationalError(obj) {
+ var ret;
+ if (isUntypedError(obj)) {
+ ret = new OperationalError(obj);
+ ret.name = obj.name;
+ ret.message = obj.message;
+ ret.stack = obj.stack;
+ var keys = es5.keys(obj);
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (!rErrorKey.test(key)) {
+ ret[key] = obj[key];
+ }
+ }
+ return ret;
+ }
+ util.markAsOriginatingFromRejection(obj);
+ return obj;
+}
+
+function nodebackForPromise(promise) {
+ return function(err, value) {
+ if (promise === null) return;
+
+ if (err) {
+ var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
+ promise._attachExtraTrace(wrapped);
+ promise._reject(wrapped);
+ } else if (arguments.length > 2) {
+ var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}
+ promise._fulfill(args);
+ } else {
+ promise._fulfill(value);
+ }
+
+ promise = null;
+ };
+}
+
+
+var PromiseResolver;
+if (!haveGetters) {
+ PromiseResolver = function (promise) {
+ this.promise = promise;
+ this.asCallback = nodebackForPromise(promise);
+ this.callback = this.asCallback;
+ };
+}
+else {
+ PromiseResolver = function (promise) {
+ this.promise = promise;
+ };
+}
+if (haveGetters) {
+ var prop = {
+ get: function() {
+ return nodebackForPromise(this.promise);
+ }
+ };
+ es5.defineProperty(PromiseResolver.prototype, "asCallback", prop);
+ es5.defineProperty(PromiseResolver.prototype, "callback", prop);
+}
+
+PromiseResolver._nodebackForPromise = nodebackForPromise;
+
+PromiseResolver.prototype.toString = function () {
+ return "[object PromiseResolver]";
+};
+
+PromiseResolver.prototype.resolve =
+PromiseResolver.prototype.fulfill = function (value) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._resolveCallback(value);
+};
+
+PromiseResolver.prototype.reject = function (reason) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._rejectCallback(reason);
+};
+
+PromiseResolver.prototype.progress = function (value) {
+ if (!(this instanceof PromiseResolver)) {
+ throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\u000a\u000a See http://goo.gl/sdkXL9\u000a");
+ }
+ this.promise._progress(value);
+};
+
+PromiseResolver.prototype.cancel = function (err) {
+ this.promise.cancel(err);
+};
+
+PromiseResolver.prototype.timeout = function () {
+ this.reject(new TimeoutError("timeout"));
+};
+
+PromiseResolver.prototype.isResolved = function () {
+ return this.promise.isResolved();
+};
+
+PromiseResolver.prototype.toJSON = function () {
+ return this.promise.toJSON();
+};
+
+module.exports = PromiseResolver;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promisify.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promisify.js
new file mode 100644
index 0000000..86763d6
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/promisify.js
@@ -0,0 +1,307 @@
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var THIS = {};
+var util = require("./util.js");
+var nodebackForPromise = require("./promise_resolver.js")
+ ._nodebackForPromise;
+var withAppended = util.withAppended;
+var maybeWrapAsError = util.maybeWrapAsError;
+var canEvaluate = util.canEvaluate;
+var TypeError = require("./errors").TypeError;
+var defaultSuffix = "Async";
+var defaultPromisified = {__isPromisified__: true};
+var noCopyProps = [
+ "arity", "length",
+ "name",
+ "arguments",
+ "caller",
+ "callee",
+ "prototype",
+ "__isPromisified__"
+];
+var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
+
+var defaultFilter = function(name) {
+ return util.isIdentifier(name) &&
+ name.charAt(0) !== "_" &&
+ name !== "constructor";
+};
+
+function propsFilter(key) {
+ return !noCopyPropsPattern.test(key);
+}
+
+function isPromisified(fn) {
+ try {
+ return fn.__isPromisified__ === true;
+ }
+ catch (e) {
+ return false;
+ }
+}
+
+function hasPromisified(obj, key, suffix) {
+ var val = util.getDataPropertyOrDefault(obj, key + suffix,
+ defaultPromisified);
+ return val ? isPromisified(val) : false;
+}
+function checkValid(ret, suffix, suffixRegexp) {
+ for (var i = 0; i < ret.length; i += 2) {
+ var key = ret[i];
+ if (suffixRegexp.test(key)) {
+ var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
+ for (var j = 0; j < ret.length; j += 2) {
+ if (ret[j] === keyWithoutAsyncSuffix) {
+ throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/iWrZbw\u000a"
+ .replace("%s", suffix));
+ }
+ }
+ }
+ }
+}
+
+function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
+ var keys = util.inheritedDataKeys(obj);
+ var ret = [];
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ var value = obj[key];
+ var passesDefaultFilter = filter === defaultFilter
+ ? true : defaultFilter(key, value, obj);
+ if (typeof value === "function" &&
+ !isPromisified(value) &&
+ !hasPromisified(obj, key, suffix) &&
+ filter(key, value, obj, passesDefaultFilter)) {
+ ret.push(key, value);
+ }
+ }
+ checkValid(ret, suffix, suffixRegexp);
+ return ret;
+}
+
+var escapeIdentRegex = function(str) {
+ return str.replace(/([$])/, "\\$");
+};
+
+var makeNodePromisifiedEval;
+if (!false) {
+var switchCaseArgumentOrder = function(likelyArgumentCount) {
+ var ret = [likelyArgumentCount];
+ var min = Math.max(0, likelyArgumentCount - 1 - 3);
+ for(var i = likelyArgumentCount - 1; i >= min; --i) {
+ ret.push(i);
+ }
+ for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
+ ret.push(i);
+ }
+ return ret;
+};
+
+var argumentSequence = function(argumentCount) {
+ return util.filledRange(argumentCount, "_arg", "");
+};
+
+var parameterDeclaration = function(parameterCount) {
+ return util.filledRange(
+ Math.max(parameterCount, 3), "_arg", "");
+};
+
+var parameterCount = function(fn) {
+ if (typeof fn.length === "number") {
+ return Math.max(Math.min(fn.length, 1023 + 1), 0);
+ }
+ return 0;
+};
+
+makeNodePromisifiedEval =
+function(callback, receiver, originalName, fn) {
+ var newParameterCount = Math.max(0, parameterCount(fn) - 1);
+ var argumentOrder = switchCaseArgumentOrder(newParameterCount);
+ var shouldProxyThis = typeof callback === "string" || receiver === THIS;
+
+ function generateCallForArgumentCount(count) {
+ var args = argumentSequence(count).join(", ");
+ var comma = count > 0 ? ", " : "";
+ var ret;
+ if (shouldProxyThis) {
+ ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
+ } else {
+ ret = receiver === undefined
+ ? "ret = callback({{args}}, nodeback); break;\n"
+ : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
+ }
+ return ret.replace("{{args}}", args).replace(", ", comma);
+ }
+
+ function generateArgumentSwitchCase() {
+ var ret = "";
+ for (var i = 0; i < argumentOrder.length; ++i) {
+ ret += "case " + argumentOrder[i] +":" +
+ generateCallForArgumentCount(argumentOrder[i]);
+ }
+
+ ret += " \n\
+ default: \n\
+ var args = new Array(len + 1); \n\
+ var i = 0; \n\
+ for (var i = 0; i < len; ++i) { \n\
+ args[i] = arguments[i]; \n\
+ } \n\
+ args[i] = nodeback; \n\
+ [CodeForCall] \n\
+ break; \n\
+ ".replace("[CodeForCall]", (shouldProxyThis
+ ? "ret = callback.apply(this, args);\n"
+ : "ret = callback.apply(receiver, args);\n"));
+ return ret;
+ }
+
+ var getFunctionCode = typeof callback === "string"
+ ? ("this != null ? this['"+callback+"'] : fn")
+ : "fn";
+
+ return new Function("Promise",
+ "fn",
+ "receiver",
+ "withAppended",
+ "maybeWrapAsError",
+ "nodebackForPromise",
+ "tryCatch",
+ "errorObj",
+ "notEnumerableProp",
+ "INTERNAL","'use strict'; \n\
+ var ret = function (Parameters) { \n\
+ 'use strict'; \n\
+ var len = arguments.length; \n\
+ var promise = new Promise(INTERNAL); \n\
+ promise._captureStackTrace(); \n\
+ var nodeback = nodebackForPromise(promise); \n\
+ var ret; \n\
+ var callback = tryCatch([GetFunctionCode]); \n\
+ switch(len) { \n\
+ [CodeForSwitchCase] \n\
+ } \n\
+ if (ret === errorObj) { \n\
+ promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
+ } \n\
+ return promise; \n\
+ }; \n\
+ notEnumerableProp(ret, '__isPromisified__', true); \n\
+ return ret; \n\
+ "
+ .replace("Parameters", parameterDeclaration(newParameterCount))
+ .replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
+ .replace("[GetFunctionCode]", getFunctionCode))(
+ Promise,
+ fn,
+ receiver,
+ withAppended,
+ maybeWrapAsError,
+ nodebackForPromise,
+ util.tryCatch,
+ util.errorObj,
+ util.notEnumerableProp,
+ INTERNAL
+ );
+};
+}
+
+function makeNodePromisifiedClosure(callback, receiver, _, fn) {
+ var defaultThis = (function() {return this;})();
+ var method = callback;
+ if (typeof method === "string") {
+ callback = fn;
+ }
+ function promisified() {
+ var _receiver = receiver;
+ if (receiver === THIS) _receiver = this;
+ var promise = new Promise(INTERNAL);
+ promise._captureStackTrace();
+ var cb = typeof method === "string" && this !== defaultThis
+ ? this[method] : callback;
+ var fn = nodebackForPromise(promise);
+ try {
+ cb.apply(_receiver, withAppended(arguments, fn));
+ } catch(e) {
+ promise._rejectCallback(maybeWrapAsError(e), true, true);
+ }
+ return promise;
+ }
+ util.notEnumerableProp(promisified, "__isPromisified__", true);
+ return promisified;
+}
+
+var makeNodePromisified = canEvaluate
+ ? makeNodePromisifiedEval
+ : makeNodePromisifiedClosure;
+
+function promisifyAll(obj, suffix, filter, promisifier) {
+ var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
+ var methods =
+ promisifiableMethods(obj, suffix, suffixRegexp, filter);
+
+ for (var i = 0, len = methods.length; i < len; i+= 2) {
+ var key = methods[i];
+ var fn = methods[i+1];
+ var promisifiedKey = key + suffix;
+ if (promisifier === makeNodePromisified) {
+ obj[promisifiedKey] =
+ makeNodePromisified(key, THIS, key, fn, suffix);
+ } else {
+ var promisified = promisifier(fn, function() {
+ return makeNodePromisified(key, THIS, key, fn, suffix);
+ });
+ util.notEnumerableProp(promisified, "__isPromisified__", true);
+ obj[promisifiedKey] = promisified;
+ }
+ }
+ util.toFastProperties(obj);
+ return obj;
+}
+
+function promisify(callback, receiver) {
+ return makeNodePromisified(callback, receiver, undefined, callback);
+}
+
+Promise.promisify = function (fn, receiver) {
+ if (typeof fn !== "function") {
+ throw new TypeError("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ }
+ if (isPromisified(fn)) {
+ return fn;
+ }
+ var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
+ util.copyDescriptors(fn, ret, propsFilter);
+ return ret;
+};
+
+Promise.promisifyAll = function (target, options) {
+ if (typeof target !== "function" && typeof target !== "object") {
+ throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/9ITlV0\u000a");
+ }
+ options = Object(options);
+ var suffix = options.suffix;
+ if (typeof suffix !== "string") suffix = defaultSuffix;
+ var filter = options.filter;
+ if (typeof filter !== "function") filter = defaultFilter;
+ var promisifier = options.promisifier;
+ if (typeof promisifier !== "function") promisifier = makeNodePromisified;
+
+ if (!util.isIdentifier(suffix)) {
+ throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/8FZo5V\u000a");
+ }
+
+ var keys = util.inheritedDataKeys(target);
+ for (var i = 0; i < keys.length; ++i) {
+ var value = target[keys[i]];
+ if (keys[i] !== "constructor" &&
+ util.isClass(value)) {
+ promisifyAll(value.prototype, suffix, filter, promisifier);
+ promisifyAll(value, suffix, filter, promisifier);
+ }
+ }
+
+ return promisifyAll(target, suffix, filter, promisifier);
+};
+};
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/props.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/props.js
new file mode 100644
index 0000000..d6f9e64
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/props.js
@@ -0,0 +1,79 @@
+"use strict";
+module.exports = function(
+ Promise, PromiseArray, tryConvertToPromise, apiRejection) {
+var util = require("./util.js");
+var isObject = util.isObject;
+var es5 = require("./es5.js");
+
+function PropertiesPromiseArray(obj) {
+ var keys = es5.keys(obj);
+ var len = keys.length;
+ var values = new Array(len * 2);
+ for (var i = 0; i < len; ++i) {
+ var key = keys[i];
+ values[i] = obj[key];
+ values[i + len] = key;
+ }
+ this.constructor$(values);
+}
+util.inherits(PropertiesPromiseArray, PromiseArray);
+
+PropertiesPromiseArray.prototype._init = function () {
+ this._init$(undefined, -3) ;
+};
+
+PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ this._values[index] = value;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ var val = {};
+ var keyOffset = this.length();
+ for (var i = 0, len = this.length(); i < len; ++i) {
+ val[this._values[i + keyOffset]] = this._values[i];
+ }
+ this._resolve(val);
+ }
+};
+
+PropertiesPromiseArray.prototype._promiseProgressed = function (value, index) {
+ this._promise._progress({
+ key: this._values[index + this.length()],
+ value: value
+ });
+};
+
+PropertiesPromiseArray.prototype.shouldCopyValues = function () {
+ return false;
+};
+
+PropertiesPromiseArray.prototype.getActualLength = function (len) {
+ return len >> 1;
+};
+
+function props(promises) {
+ var ret;
+ var castValue = tryConvertToPromise(promises);
+
+ if (!isObject(castValue)) {
+ return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/OsFKC8\u000a");
+ } else if (castValue instanceof Promise) {
+ ret = castValue._then(
+ Promise.props, undefined, undefined, undefined, undefined);
+ } else {
+ ret = new PropertiesPromiseArray(castValue).promise();
+ }
+
+ if (castValue instanceof Promise) {
+ ret._propagateFrom(castValue, 4);
+ }
+ return ret;
+}
+
+Promise.prototype.props = function () {
+ return props(this);
+};
+
+Promise.props = function (promises) {
+ return props(promises);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/queue.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/queue.js
new file mode 100644
index 0000000..84d57d5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/queue.js
@@ -0,0 +1,90 @@
+"use strict";
+function arrayMove(src, srcIndex, dst, dstIndex, len) {
+ for (var j = 0; j < len; ++j) {
+ dst[j + dstIndex] = src[j + srcIndex];
+ src[j + srcIndex] = void 0;
+ }
+}
+
+function Queue(capacity) {
+ this._capacity = capacity;
+ this._length = 0;
+ this._front = 0;
+}
+
+Queue.prototype._willBeOverCapacity = function (size) {
+ return this._capacity < size;
+};
+
+Queue.prototype._pushOne = function (arg) {
+ var length = this.length();
+ this._checkCapacity(length + 1);
+ var i = (this._front + length) & (this._capacity - 1);
+ this[i] = arg;
+ this._length = length + 1;
+};
+
+Queue.prototype._unshiftOne = function(value) {
+ var capacity = this._capacity;
+ this._checkCapacity(this.length() + 1);
+ var front = this._front;
+ var i = (((( front - 1 ) &
+ ( capacity - 1) ) ^ capacity ) - capacity );
+ this[i] = value;
+ this._front = i;
+ this._length = this.length() + 1;
+};
+
+Queue.prototype.unshift = function(fn, receiver, arg) {
+ this._unshiftOne(arg);
+ this._unshiftOne(receiver);
+ this._unshiftOne(fn);
+};
+
+Queue.prototype.push = function (fn, receiver, arg) {
+ var length = this.length() + 3;
+ if (this._willBeOverCapacity(length)) {
+ this._pushOne(fn);
+ this._pushOne(receiver);
+ this._pushOne(arg);
+ return;
+ }
+ var j = this._front + length - 3;
+ this._checkCapacity(length);
+ var wrapMask = this._capacity - 1;
+ this[(j + 0) & wrapMask] = fn;
+ this[(j + 1) & wrapMask] = receiver;
+ this[(j + 2) & wrapMask] = arg;
+ this._length = length;
+};
+
+Queue.prototype.shift = function () {
+ var front = this._front,
+ ret = this[front];
+
+ this[front] = undefined;
+ this._front = (front + 1) & (this._capacity - 1);
+ this._length--;
+ return ret;
+};
+
+Queue.prototype.length = function () {
+ return this._length;
+};
+
+Queue.prototype._checkCapacity = function (size) {
+ if (this._capacity < size) {
+ this._resizeTo(this._capacity << 1);
+ }
+};
+
+Queue.prototype._resizeTo = function (capacity) {
+ var oldCapacity = this._capacity;
+ this._capacity = capacity;
+ var front = this._front;
+ var length = this._length;
+ var moveItemsCount = (front + length) & (oldCapacity - 1);
+ arrayMove(this, 0, this, oldCapacity, moveItemsCount);
+};
+
+module.exports = Queue;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/race.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/race.js
new file mode 100644
index 0000000..30e7bb0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/race.js
@@ -0,0 +1,47 @@
+"use strict";
+module.exports = function(
+ Promise, INTERNAL, tryConvertToPromise, apiRejection) {
+var isArray = require("./util.js").isArray;
+
+var raceLater = function (promise) {
+ return promise.then(function(array) {
+ return race(array, promise);
+ });
+};
+
+function race(promises, parent) {
+ var maybePromise = tryConvertToPromise(promises);
+
+ if (maybePromise instanceof Promise) {
+ return raceLater(maybePromise);
+ } else if (!isArray(promises)) {
+ return apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
+ }
+
+ var ret = new Promise(INTERNAL);
+ if (parent !== undefined) {
+ ret._propagateFrom(parent, 4 | 1);
+ }
+ var fulfill = ret._fulfill;
+ var reject = ret._reject;
+ for (var i = 0, len = promises.length; i < len; ++i) {
+ var val = promises[i];
+
+ if (val === undefined && !(i in promises)) {
+ continue;
+ }
+
+ Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
+ }
+ return ret;
+}
+
+Promise.race = function (promises) {
+ return race(promises, undefined);
+};
+
+Promise.prototype.race = function () {
+ return race(this, undefined);
+};
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/reduce.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/reduce.js
new file mode 100644
index 0000000..1f92daf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/reduce.js
@@ -0,0 +1,148 @@
+"use strict";
+module.exports = function(Promise,
+ PromiseArray,
+ apiRejection,
+ tryConvertToPromise,
+ INTERNAL) {
+var getDomain = Promise._getDomain;
+var async = require("./async.js");
+var util = require("./util.js");
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+function ReductionPromiseArray(promises, fn, accum, _each) {
+ this.constructor$(promises);
+ this._promise._captureStackTrace();
+ this._preservedValues = _each === INTERNAL ? [] : null;
+ this._zerothIsAccum = (accum === undefined);
+ this._gotAccum = false;
+ this._reducingIndex = (this._zerothIsAccum ? 1 : 0);
+ this._valuesPhase = undefined;
+ var maybePromise = tryConvertToPromise(accum, this._promise);
+ var rejected = false;
+ var isPromise = maybePromise instanceof Promise;
+ if (isPromise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ maybePromise._proxyPromiseArray(this, -1);
+ } else if (maybePromise._isFulfilled()) {
+ accum = maybePromise._value();
+ this._gotAccum = true;
+ } else {
+ this._reject(maybePromise._reason());
+ rejected = true;
+ }
+ }
+ if (!(isPromise || this._zerothIsAccum)) this._gotAccum = true;
+ var domain = getDomain();
+ this._callback = domain === null ? fn : domain.bind(fn);
+ this._accum = accum;
+ if (!rejected) async.invoke(init, this, undefined);
+}
+function init() {
+ this._init$(undefined, -5);
+}
+util.inherits(ReductionPromiseArray, PromiseArray);
+
+ReductionPromiseArray.prototype._init = function () {};
+
+ReductionPromiseArray.prototype._resolveEmptyArray = function () {
+ if (this._gotAccum || this._zerothIsAccum) {
+ this._resolve(this._preservedValues !== null
+ ? [] : this._accum);
+ }
+};
+
+ReductionPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var values = this._values;
+ values[index] = value;
+ var length = this.length();
+ var preservedValues = this._preservedValues;
+ var isEach = preservedValues !== null;
+ var gotAccum = this._gotAccum;
+ var valuesPhase = this._valuesPhase;
+ var valuesPhaseIndex;
+ if (!valuesPhase) {
+ valuesPhase = this._valuesPhase = new Array(length);
+ for (valuesPhaseIndex=0; valuesPhaseIndex<length; ++valuesPhaseIndex) {
+ valuesPhase[valuesPhaseIndex] = 0;
+ }
+ }
+ valuesPhaseIndex = valuesPhase[index];
+
+ if (index === 0 && this._zerothIsAccum) {
+ this._accum = value;
+ this._gotAccum = gotAccum = true;
+ valuesPhase[index] = ((valuesPhaseIndex === 0)
+ ? 1 : 2);
+ } else if (index === -1) {
+ this._accum = value;
+ this._gotAccum = gotAccum = true;
+ } else {
+ if (valuesPhaseIndex === 0) {
+ valuesPhase[index] = 1;
+ } else {
+ valuesPhase[index] = 2;
+ this._accum = value;
+ }
+ }
+ if (!gotAccum) return;
+
+ var callback = this._callback;
+ var receiver = this._promise._boundValue();
+ var ret;
+
+ for (var i = this._reducingIndex; i < length; ++i) {
+ valuesPhaseIndex = valuesPhase[i];
+ if (valuesPhaseIndex === 2) {
+ this._reducingIndex = i + 1;
+ continue;
+ }
+ if (valuesPhaseIndex !== 1) return;
+ value = values[i];
+ this._promise._pushContext();
+ if (isEach) {
+ preservedValues.push(value);
+ ret = tryCatch(callback).call(receiver, value, i, length);
+ }
+ else {
+ ret = tryCatch(callback)
+ .call(receiver, this._accum, value, i, length);
+ }
+ this._promise._popContext();
+
+ if (ret === errorObj) return this._reject(ret.e);
+
+ var maybePromise = tryConvertToPromise(ret, this._promise);
+ if (maybePromise instanceof Promise) {
+ maybePromise = maybePromise._target();
+ if (maybePromise._isPending()) {
+ valuesPhase[i] = 4;
+ return maybePromise._proxyPromiseArray(this, i);
+ } else if (maybePromise._isFulfilled()) {
+ ret = maybePromise._value();
+ } else {
+ return this._reject(maybePromise._reason());
+ }
+ }
+
+ this._reducingIndex = i + 1;
+ this._accum = ret;
+ }
+
+ this._resolve(isEach ? preservedValues : this._accum);
+};
+
+function reduce(promises, fn, initialValue, _each) {
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+ var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
+ return array.promise();
+}
+
+Promise.prototype.reduce = function (fn, initialValue) {
+ return reduce(this, fn, initialValue, null);
+};
+
+Promise.reduce = function (promises, fn, initialValue, _each) {
+ return reduce(promises, fn, initialValue, _each);
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/schedule.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/schedule.js
new file mode 100644
index 0000000..bb04a8a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/schedule.js
@@ -0,0 +1,35 @@
+"use strict";
+var schedule;
+var util = require("./util");
+var noAsyncScheduler = function() {
+ throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/m3OTXk\u000a");
+};
+if (util.isNode && typeof MutationObserver === "undefined") {
+ var GlobalSetImmediate = global.setImmediate;
+ var ProcessNextTick = process.nextTick;
+ schedule = util.isRecentNode
+ ? function(fn) { GlobalSetImmediate.call(global, fn); }
+ : function(fn) { ProcessNextTick.call(process, fn); };
+} else if ((typeof MutationObserver !== "undefined") &&
+ !(typeof window !== "undefined" &&
+ window.navigator &&
+ window.navigator.standalone)) {
+ schedule = function(fn) {
+ var div = document.createElement("div");
+ var observer = new MutationObserver(fn);
+ observer.observe(div, {attributes: true});
+ return function() { div.classList.toggle("foo"); };
+ };
+ schedule.isStatic = true;
+} else if (typeof setImmediate !== "undefined") {
+ schedule = function (fn) {
+ setImmediate(fn);
+ };
+} else if (typeof setTimeout !== "undefined") {
+ schedule = function (fn) {
+ setTimeout(fn, 0);
+ };
+} else {
+ schedule = noAsyncScheduler;
+}
+module.exports = schedule;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/settle.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/settle.js
new file mode 100644
index 0000000..f9299c2
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/settle.js
@@ -0,0 +1,40 @@
+"use strict";
+module.exports =
+ function(Promise, PromiseArray) {
+var PromiseInspection = Promise.PromiseInspection;
+var util = require("./util.js");
+
+function SettledPromiseArray(values) {
+ this.constructor$(values);
+}
+util.inherits(SettledPromiseArray, PromiseArray);
+
+SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
+ this._values[index] = inspection;
+ var totalResolved = ++this._totalResolved;
+ if (totalResolved >= this._length) {
+ this._resolve(this._values);
+ }
+};
+
+SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
+ var ret = new PromiseInspection();
+ ret._bitField = 268435456;
+ ret._settledValue = value;
+ this._promiseResolved(index, ret);
+};
+SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
+ var ret = new PromiseInspection();
+ ret._bitField = 134217728;
+ ret._settledValue = reason;
+ this._promiseResolved(index, ret);
+};
+
+Promise.settle = function (promises) {
+ return new SettledPromiseArray(promises).promise();
+};
+
+Promise.prototype.settle = function () {
+ return new SettledPromiseArray(this).promise();
+};
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/some.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/some.js
new file mode 100644
index 0000000..f3968cf
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/some.js
@@ -0,0 +1,125 @@
+"use strict";
+module.exports =
+function(Promise, PromiseArray, apiRejection) {
+var util = require("./util.js");
+var RangeError = require("./errors.js").RangeError;
+var AggregateError = require("./errors.js").AggregateError;
+var isArray = util.isArray;
+
+
+function SomePromiseArray(values) {
+ this.constructor$(values);
+ this._howMany = 0;
+ this._unwrap = false;
+ this._initialized = false;
+}
+util.inherits(SomePromiseArray, PromiseArray);
+
+SomePromiseArray.prototype._init = function () {
+ if (!this._initialized) {
+ return;
+ }
+ if (this._howMany === 0) {
+ this._resolve([]);
+ return;
+ }
+ this._init$(undefined, -5);
+ var isArrayResolved = isArray(this._values);
+ if (!this._isResolved() &&
+ isArrayResolved &&
+ this._howMany > this._canPossiblyFulfill()) {
+ this._reject(this._getRangeError(this.length()));
+ }
+};
+
+SomePromiseArray.prototype.init = function () {
+ this._initialized = true;
+ this._init();
+};
+
+SomePromiseArray.prototype.setUnwrap = function () {
+ this._unwrap = true;
+};
+
+SomePromiseArray.prototype.howMany = function () {
+ return this._howMany;
+};
+
+SomePromiseArray.prototype.setHowMany = function (count) {
+ this._howMany = count;
+};
+
+SomePromiseArray.prototype._promiseFulfilled = function (value) {
+ this._addFulfilled(value);
+ if (this._fulfilled() === this.howMany()) {
+ this._values.length = this.howMany();
+ if (this.howMany() === 1 && this._unwrap) {
+ this._resolve(this._values[0]);
+ } else {
+ this._resolve(this._values);
+ }
+ }
+
+};
+SomePromiseArray.prototype._promiseRejected = function (reason) {
+ this._addRejected(reason);
+ if (this.howMany() > this._canPossiblyFulfill()) {
+ var e = new AggregateError();
+ for (var i = this.length(); i < this._values.length; ++i) {
+ e.push(this._values[i]);
+ }
+ this._reject(e);
+ }
+};
+
+SomePromiseArray.prototype._fulfilled = function () {
+ return this._totalResolved;
+};
+
+SomePromiseArray.prototype._rejected = function () {
+ return this._values.length - this.length();
+};
+
+SomePromiseArray.prototype._addRejected = function (reason) {
+ this._values.push(reason);
+};
+
+SomePromiseArray.prototype._addFulfilled = function (value) {
+ this._values[this._totalResolved++] = value;
+};
+
+SomePromiseArray.prototype._canPossiblyFulfill = function () {
+ return this.length() - this._rejected();
+};
+
+SomePromiseArray.prototype._getRangeError = function (count) {
+ var message = "Input array must contain at least " +
+ this._howMany + " items but contains only " + count + " items";
+ return new RangeError(message);
+};
+
+SomePromiseArray.prototype._resolveEmptyArray = function () {
+ this._reject(this._getRangeError(0));
+};
+
+function some(promises, howMany) {
+ if ((howMany | 0) !== howMany || howMany < 0) {
+ return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/1wAmHx\u000a");
+ }
+ var ret = new SomePromiseArray(promises);
+ var promise = ret.promise();
+ ret.setHowMany(howMany);
+ ret.init();
+ return promise;
+}
+
+Promise.some = function (promises, howMany) {
+ return some(promises, howMany);
+};
+
+Promise.prototype.some = function (howMany) {
+ return some(this, howMany);
+};
+
+Promise._SomePromiseArray = SomePromiseArray;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/synchronous_inspection.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/synchronous_inspection.js
new file mode 100644
index 0000000..7aac149
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/synchronous_inspection.js
@@ -0,0 +1,94 @@
+"use strict";
+module.exports = function(Promise) {
+function PromiseInspection(promise) {
+ if (promise !== undefined) {
+ promise = promise._target();
+ this._bitField = promise._bitField;
+ this._settledValue = promise._settledValue;
+ }
+ else {
+ this._bitField = 0;
+ this._settledValue = undefined;
+ }
+}
+
+PromiseInspection.prototype.value = function () {
+ if (!this.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.error =
+PromiseInspection.prototype.reason = function () {
+ if (!this.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
+ }
+ return this._settledValue;
+};
+
+PromiseInspection.prototype.isFulfilled =
+Promise.prototype._isFulfilled = function () {
+ return (this._bitField & 268435456) > 0;
+};
+
+PromiseInspection.prototype.isRejected =
+Promise.prototype._isRejected = function () {
+ return (this._bitField & 134217728) > 0;
+};
+
+PromiseInspection.prototype.isPending =
+Promise.prototype._isPending = function () {
+ return (this._bitField & 402653184) === 0;
+};
+
+PromiseInspection.prototype.isResolved =
+Promise.prototype._isResolved = function () {
+ return (this._bitField & 402653184) > 0;
+};
+
+Promise.prototype.isPending = function() {
+ return this._target()._isPending();
+};
+
+Promise.prototype.isRejected = function() {
+ return this._target()._isRejected();
+};
+
+Promise.prototype.isFulfilled = function() {
+ return this._target()._isFulfilled();
+};
+
+Promise.prototype.isResolved = function() {
+ return this._target()._isResolved();
+};
+
+Promise.prototype._value = function() {
+ return this._settledValue;
+};
+
+Promise.prototype._reason = function() {
+ this._unsetRejectionIsUnhandled();
+ return this._settledValue;
+};
+
+Promise.prototype.value = function() {
+ var target = this._target();
+ if (!target.isFulfilled()) {
+ throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/hc1DLj\u000a");
+ }
+ return target._settledValue;
+};
+
+Promise.prototype.reason = function() {
+ var target = this._target();
+ if (!target.isRejected()) {
+ throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/hPuiwB\u000a");
+ }
+ target._unsetRejectionIsUnhandled();
+ return target._settledValue;
+};
+
+
+Promise.PromiseInspection = PromiseInspection;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/thenables.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/thenables.js
new file mode 100644
index 0000000..eadfffb
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/thenables.js
@@ -0,0 +1,84 @@
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var util = require("./util.js");
+var errorObj = util.errorObj;
+var isObject = util.isObject;
+
+function tryConvertToPromise(obj, context) {
+ if (isObject(obj)) {
+ if (obj instanceof Promise) {
+ return obj;
+ }
+ else if (isAnyBluebirdPromise(obj)) {
+ var ret = new Promise(INTERNAL);
+ obj._then(
+ ret._fulfillUnchecked,
+ ret._rejectUncheckedCheckError,
+ ret._progressUnchecked,
+ ret,
+ null
+ );
+ return ret;
+ }
+ var then = util.tryCatch(getThen)(obj);
+ if (then === errorObj) {
+ if (context) context._pushContext();
+ var ret = Promise.reject(then.e);
+ if (context) context._popContext();
+ return ret;
+ } else if (typeof then === "function") {
+ return doThenable(obj, then, context);
+ }
+ }
+ return obj;
+}
+
+function getThen(obj) {
+ return obj.then;
+}
+
+var hasProp = {}.hasOwnProperty;
+function isAnyBluebirdPromise(obj) {
+ return hasProp.call(obj, "_promise0");
+}
+
+function doThenable(x, then, context) {
+ var promise = new Promise(INTERNAL);
+ var ret = promise;
+ if (context) context._pushContext();
+ promise._captureStackTrace();
+ if (context) context._popContext();
+ var synchronous = true;
+ var result = util.tryCatch(then).call(x,
+ resolveFromThenable,
+ rejectFromThenable,
+ progressFromThenable);
+ synchronous = false;
+ if (promise && result === errorObj) {
+ promise._rejectCallback(result.e, true, true);
+ promise = null;
+ }
+
+ function resolveFromThenable(value) {
+ if (!promise) return;
+ promise._resolveCallback(value);
+ promise = null;
+ }
+
+ function rejectFromThenable(reason) {
+ if (!promise) return;
+ promise._rejectCallback(reason, synchronous, true);
+ promise = null;
+ }
+
+ function progressFromThenable(value) {
+ if (!promise) return;
+ if (typeof promise._progress === "function") {
+ promise._progress(value);
+ }
+ }
+ return ret;
+}
+
+return tryConvertToPromise;
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/timers.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/timers.js
new file mode 100644
index 0000000..f26431a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/timers.js
@@ -0,0 +1,64 @@
+"use strict";
+module.exports = function(Promise, INTERNAL) {
+var util = require("./util.js");
+var TimeoutError = Promise.TimeoutError;
+
+var afterTimeout = function (promise, message) {
+ if (!promise.isPending()) return;
+
+ var err;
+ if(!util.isPrimitive(message) && (message instanceof Error)) {
+ err = message;
+ } else {
+ if (typeof message !== "string") {
+ message = "operation timed out";
+ }
+ err = new TimeoutError(message);
+ }
+ util.markAsOriginatingFromRejection(err);
+ promise._attachExtraTrace(err);
+ promise._cancel(err);
+};
+
+var afterValue = function(value) { return delay(+this).thenReturn(value); };
+var delay = Promise.delay = function (value, ms) {
+ if (ms === undefined) {
+ ms = value;
+ value = undefined;
+ var ret = new Promise(INTERNAL);
+ setTimeout(function() { ret._fulfill(); }, ms);
+ return ret;
+ }
+ ms = +ms;
+ return Promise.resolve(value)._then(afterValue, null, null, ms, undefined);
+};
+
+Promise.prototype.delay = function (ms) {
+ return delay(this, ms);
+};
+
+function successClear(value) {
+ var handle = this;
+ if (handle instanceof Number) handle = +handle;
+ clearTimeout(handle);
+ return value;
+}
+
+function failureClear(reason) {
+ var handle = this;
+ if (handle instanceof Number) handle = +handle;
+ clearTimeout(handle);
+ throw reason;
+}
+
+Promise.prototype.timeout = function (ms, message) {
+ ms = +ms;
+ var ret = this.then().cancellable();
+ ret._cancellationParent = this;
+ var handle = setTimeout(function timeoutTimeout() {
+ afterTimeout(ret, message);
+ }, ms);
+ return ret._then(successClear, failureClear, undefined, handle, undefined);
+};
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/using.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/using.js
new file mode 100644
index 0000000..957182d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/using.js
@@ -0,0 +1,213 @@
+"use strict";
+module.exports = function (Promise, apiRejection, tryConvertToPromise,
+ createContext) {
+ var TypeError = require("./errors.js").TypeError;
+ var inherits = require("./util.js").inherits;
+ var PromiseInspection = Promise.PromiseInspection;
+
+ function inspectionMapper(inspections) {
+ var len = inspections.length;
+ for (var i = 0; i < len; ++i) {
+ var inspection = inspections[i];
+ if (inspection.isRejected()) {
+ return Promise.reject(inspection.error());
+ }
+ inspections[i] = inspection._settledValue;
+ }
+ return inspections;
+ }
+
+ function thrower(e) {
+ setTimeout(function(){throw e;}, 0);
+ }
+
+ function castPreservingDisposable(thenable) {
+ var maybePromise = tryConvertToPromise(thenable);
+ if (maybePromise !== thenable &&
+ typeof thenable._isDisposable === "function" &&
+ typeof thenable._getDisposer === "function" &&
+ thenable._isDisposable()) {
+ maybePromise._setDisposable(thenable._getDisposer());
+ }
+ return maybePromise;
+ }
+ function dispose(resources, inspection) {
+ var i = 0;
+ var len = resources.length;
+ var ret = Promise.defer();
+ function iterator() {
+ if (i >= len) return ret.resolve();
+ var maybePromise = castPreservingDisposable(resources[i++]);
+ if (maybePromise instanceof Promise &&
+ maybePromise._isDisposable()) {
+ try {
+ maybePromise = tryConvertToPromise(
+ maybePromise._getDisposer().tryDispose(inspection),
+ resources.promise);
+ } catch (e) {
+ return thrower(e);
+ }
+ if (maybePromise instanceof Promise) {
+ return maybePromise._then(iterator, thrower,
+ null, null, null);
+ }
+ }
+ iterator();
+ }
+ iterator();
+ return ret.promise;
+ }
+
+ function disposerSuccess(value) {
+ var inspection = new PromiseInspection();
+ inspection._settledValue = value;
+ inspection._bitField = 268435456;
+ return dispose(this, inspection).thenReturn(value);
+ }
+
+ function disposerFail(reason) {
+ var inspection = new PromiseInspection();
+ inspection._settledValue = reason;
+ inspection._bitField = 134217728;
+ return dispose(this, inspection).thenThrow(reason);
+ }
+
+ function Disposer(data, promise, context) {
+ this._data = data;
+ this._promise = promise;
+ this._context = context;
+ }
+
+ Disposer.prototype.data = function () {
+ return this._data;
+ };
+
+ Disposer.prototype.promise = function () {
+ return this._promise;
+ };
+
+ Disposer.prototype.resource = function () {
+ if (this.promise().isFulfilled()) {
+ return this.promise().value();
+ }
+ return null;
+ };
+
+ Disposer.prototype.tryDispose = function(inspection) {
+ var resource = this.resource();
+ var context = this._context;
+ if (context !== undefined) context._pushContext();
+ var ret = resource !== null
+ ? this.doDispose(resource, inspection) : null;
+ if (context !== undefined) context._popContext();
+ this._promise._unsetDisposable();
+ this._data = null;
+ return ret;
+ };
+
+ Disposer.isDisposer = function (d) {
+ return (d != null &&
+ typeof d.resource === "function" &&
+ typeof d.tryDispose === "function");
+ };
+
+ function FunctionDisposer(fn, promise, context) {
+ this.constructor$(fn, promise, context);
+ }
+ inherits(FunctionDisposer, Disposer);
+
+ FunctionDisposer.prototype.doDispose = function (resource, inspection) {
+ var fn = this.data();
+ return fn.call(resource, resource, inspection);
+ };
+
+ function maybeUnwrapDisposer(value) {
+ if (Disposer.isDisposer(value)) {
+ this.resources[this.index]._setDisposable(value);
+ return value.promise();
+ }
+ return value;
+ }
+
+ Promise.using = function () {
+ var len = arguments.length;
+ if (len < 2) return apiRejection(
+ "you must pass at least 2 arguments to Promise.using");
+ var fn = arguments[len - 1];
+ if (typeof fn !== "function") return apiRejection("fn must be a function\u000a\u000a See http://goo.gl/916lJJ\u000a");
+
+ var input;
+ var spreadArgs = true;
+ if (len === 2 && Array.isArray(arguments[0])) {
+ input = arguments[0];
+ len = input.length;
+ spreadArgs = false;
+ } else {
+ input = arguments;
+ len--;
+ }
+ var resources = new Array(len);
+ for (var i = 0; i < len; ++i) {
+ var resource = input[i];
+ if (Disposer.isDisposer(resource)) {
+ var disposer = resource;
+ resource = resource.promise();
+ resource._setDisposable(disposer);
+ } else {
+ var maybePromise = tryConvertToPromise(resource);
+ if (maybePromise instanceof Promise) {
+ resource =
+ maybePromise._then(maybeUnwrapDisposer, null, null, {
+ resources: resources,
+ index: i
+ }, undefined);
+ }
+ }
+ resources[i] = resource;
+ }
+
+ var promise = Promise.settle(resources)
+ .then(inspectionMapper)
+ .then(function(vals) {
+ promise._pushContext();
+ var ret;
+ try {
+ ret = spreadArgs
+ ? fn.apply(undefined, vals) : fn.call(undefined, vals);
+ } finally {
+ promise._popContext();
+ }
+ return ret;
+ })
+ ._then(
+ disposerSuccess, disposerFail, undefined, resources, undefined);
+ resources.promise = promise;
+ return promise;
+ };
+
+ Promise.prototype._setDisposable = function (disposer) {
+ this._bitField = this._bitField | 262144;
+ this._disposer = disposer;
+ };
+
+ Promise.prototype._isDisposable = function () {
+ return (this._bitField & 262144) > 0;
+ };
+
+ Promise.prototype._getDisposer = function () {
+ return this._disposer;
+ };
+
+ Promise.prototype._unsetDisposable = function () {
+ this._bitField = this._bitField & (~262144);
+ this._disposer = undefined;
+ };
+
+ Promise.prototype.disposer = function (fn) {
+ if (typeof fn === "function") {
+ return new FunctionDisposer(fn, this, createContext());
+ }
+ throw new TypeError();
+ };
+
+};
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/util.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/util.js
new file mode 100644
index 0000000..ea39344
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/js/main/util.js
@@ -0,0 +1,321 @@
+"use strict";
+var es5 = require("./es5.js");
+var canEvaluate = typeof navigator == "undefined";
+var haveGetters = (function(){
+ try {
+ var o = {};
+ es5.defineProperty(o, "f", {
+ get: function () {
+ return 3;
+ }
+ });
+ return o.f === 3;
+ }
+ catch (e) {
+ return false;
+ }
+
+})();
+
+var errorObj = {e: {}};
+var tryCatchTarget;
+function tryCatcher() {
+ try {
+ var target = tryCatchTarget;
+ tryCatchTarget = null;
+ return target.apply(this, arguments);
+ } catch (e) {
+ errorObj.e = e;
+ return errorObj;
+ }
+}
+function tryCatch(fn) {
+ tryCatchTarget = fn;
+ return tryCatcher;
+}
+
+var inherits = function(Child, Parent) {
+ var hasProp = {}.hasOwnProperty;
+
+ function T() {
+ this.constructor = Child;
+ this.constructor$ = Parent;
+ for (var propertyName in Parent.prototype) {
+ if (hasProp.call(Parent.prototype, propertyName) &&
+ propertyName.charAt(propertyName.length-1) !== "$"
+ ) {
+ this[propertyName + "$"] = Parent.prototype[propertyName];
+ }
+ }
+ }
+ T.prototype = Parent.prototype;
+ Child.prototype = new T();
+ return Child.prototype;
+};
+
+
+function isPrimitive(val) {
+ return val == null || val === true || val === false ||
+ typeof val === "string" || typeof val === "number";
+
+}
+
+function isObject(value) {
+ return !isPrimitive(value);
+}
+
+function maybeWrapAsError(maybeError) {
+ if (!isPrimitive(maybeError)) return maybeError;
+
+ return new Error(safeToString(maybeError));
+}
+
+function withAppended(target, appendee) {
+ var len = target.length;
+ var ret = new Array(len + 1);
+ var i;
+ for (i = 0; i < len; ++i) {
+ ret[i] = target[i];
+ }
+ ret[i] = appendee;
+ return ret;
+}
+
+function getDataPropertyOrDefault(obj, key, defaultValue) {
+ if (es5.isES5) {
+ var desc = Object.getOwnPropertyDescriptor(obj, key);
+
+ if (desc != null) {
+ return desc.get == null && desc.set == null
+ ? desc.value
+ : defaultValue;
+ }
+ } else {
+ return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
+ }
+}
+
+function notEnumerableProp(obj, name, value) {
+ if (isPrimitive(obj)) return obj;
+ var descriptor = {
+ value: value,
+ configurable: true,
+ enumerable: false,
+ writable: true
+ };
+ es5.defineProperty(obj, name, descriptor);
+ return obj;
+}
+
+function thrower(r) {
+ throw r;
+}
+
+var inheritedDataKeys = (function() {
+ var excludedPrototypes = [
+ Array.prototype,
+ Object.prototype,
+ Function.prototype
+ ];
+
+ var isExcludedProto = function(val) {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (excludedPrototypes[i] === val) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+ if (es5.isES5) {
+ var getKeys = Object.getOwnPropertyNames;
+ return function(obj) {
+ var ret = [];
+ var visitedKeys = Object.create(null);
+ while (obj != null && !isExcludedProto(obj)) {
+ var keys;
+ try {
+ keys = getKeys(obj);
+ } catch (e) {
+ return ret;
+ }
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (visitedKeys[key]) continue;
+ visitedKeys[key] = true;
+ var desc = Object.getOwnPropertyDescriptor(obj, key);
+ if (desc != null && desc.get == null && desc.set == null) {
+ ret.push(key);
+ }
+ }
+ obj = es5.getPrototypeOf(obj);
+ }
+ return ret;
+ };
+ } else {
+ var hasProp = {}.hasOwnProperty;
+ return function(obj) {
+ if (isExcludedProto(obj)) return [];
+ var ret = [];
+
+ /*jshint forin:false */
+ enumeration: for (var key in obj) {
+ if (hasProp.call(obj, key)) {
+ ret.push(key);
+ } else {
+ for (var i = 0; i < excludedPrototypes.length; ++i) {
+ if (hasProp.call(excludedPrototypes[i], key)) {
+ continue enumeration;
+ }
+ }
+ ret.push(key);
+ }
+ }
+ return ret;
+ };
+ }
+
+})();
+
+var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
+function isClass(fn) {
+ try {
+ if (typeof fn === "function") {
+ var keys = es5.names(fn.prototype);
+
+ var hasMethods = es5.isES5 && keys.length > 1;
+ var hasMethodsOtherThanConstructor = keys.length > 0 &&
+ !(keys.length === 1 && keys[0] === "constructor");
+ var hasThisAssignmentAndStaticMethods =
+ thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
+
+ if (hasMethods || hasMethodsOtherThanConstructor ||
+ hasThisAssignmentAndStaticMethods) {
+ return true;
+ }
+ }
+ return false;
+ } catch (e) {
+ return false;
+ }
+}
+
+function toFastProperties(obj) {
+ /*jshint -W027,-W055,-W031*/
+ function f() {}
+ f.prototype = obj;
+ var l = 8;
+ while (l--) new f();
+ return obj;
+ eval(obj);
+}
+
+var rident = /^[a-z$_][a-z$_0-9]*$/i;
+function isIdentifier(str) {
+ return rident.test(str);
+}
+
+function filledRange(count, prefix, suffix) {
+ var ret = new Array(count);
+ for(var i = 0; i < count; ++i) {
+ ret[i] = prefix + i + suffix;
+ }
+ return ret;
+}
+
+function safeToString(obj) {
+ try {
+ return obj + "";
+ } catch (e) {
+ return "[no string representation]";
+ }
+}
+
+function markAsOriginatingFromRejection(e) {
+ try {
+ notEnumerableProp(e, "isOperational", true);
+ }
+ catch(ignore) {}
+}
+
+function originatesFromRejection(e) {
+ if (e == null) return false;
+ return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
+ e["isOperational"] === true);
+}
+
+function canAttachTrace(obj) {
+ return obj instanceof Error && es5.propertyIsWritable(obj, "stack");
+}
+
+var ensureErrorObject = (function() {
+ if (!("stack" in new Error())) {
+ return function(value) {
+ if (canAttachTrace(value)) return value;
+ try {throw new Error(safeToString(value));}
+ catch(err) {return err;}
+ };
+ } else {
+ return function(value) {
+ if (canAttachTrace(value)) return value;
+ return new Error(safeToString(value));
+ };
+ }
+})();
+
+function classString(obj) {
+ return {}.toString.call(obj);
+}
+
+function copyDescriptors(from, to, filter) {
+ var keys = es5.names(from);
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ if (filter(key)) {
+ try {
+ es5.defineProperty(to, key, es5.getDescriptor(from, key));
+ } catch (ignore) {}
+ }
+ }
+}
+
+var ret = {
+ isClass: isClass,
+ isIdentifier: isIdentifier,
+ inheritedDataKeys: inheritedDataKeys,
+ getDataPropertyOrDefault: getDataPropertyOrDefault,
+ thrower: thrower,
+ isArray: es5.isArray,
+ haveGetters: haveGetters,
+ notEnumerableProp: notEnumerableProp,
+ isPrimitive: isPrimitive,
+ isObject: isObject,
+ canEvaluate: canEvaluate,
+ errorObj: errorObj,
+ tryCatch: tryCatch,
+ inherits: inherits,
+ withAppended: withAppended,
+ maybeWrapAsError: maybeWrapAsError,
+ toFastProperties: toFastProperties,
+ filledRange: filledRange,
+ toString: safeToString,
+ canAttachTrace: canAttachTrace,
+ ensureErrorObject: ensureErrorObject,
+ originatesFromRejection: originatesFromRejection,
+ markAsOriginatingFromRejection: markAsOriginatingFromRejection,
+ classString: classString,
+ copyDescriptors: copyDescriptors,
+ hasDevTools: typeof chrome !== "undefined" && chrome &&
+ typeof chrome.loadTimes === "function",
+ isNode: typeof process !== "undefined" &&
+ classString(process).toLowerCase() === "[object process]"
+};
+ret.isRecentNode = ret.isNode && (function() {
+ var version = process.versions.node.split(".").map(Number);
+ return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
+})();
+
+if (ret.isNode) ret.toFastProperties(process);
+
+try {throw new Error(); } catch (e) {ret.lastLineError = e;}
+module.exports = ret;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/package.json
new file mode 100644
index 0000000..776bc8e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/bluebird/package.json
@@ -0,0 +1,100 @@
+{
+ "name": "bluebird",
+ "description": "Full featured Promises/A+ implementation with exceptionally good performance",
+ "version": "2.10.2",
+ "keywords": [
+ "promise",
+ "performance",
+ "promises",
+ "promises-a",
+ "promises-aplus",
+ "async",
+ "await",
+ "deferred",
+ "deferreds",
+ "future",
+ "flow control",
+ "dsl",
+ "fluent interface",
+ "parallel",
+ "thread",
+ "concurrency"
+ ],
+ "scripts": {
+ "lint": "node scripts/jshint.js",
+ "test": "node tools/test.js",
+ "istanbul": "istanbul",
+ "prepublish": "node tools/build.js --no-debug --main --zalgo --browser --minify",
+ "generate-browser-core": "node tools/build.js --features=core --no-debug --main --zalgo --browser --minify && mv js/browser/bluebird.js js/browser/bluebird.core.js && mv js/browser/bluebird.min.js js/browser/bluebird.core.min.js"
+ },
+ "homepage": "https://github.com/petkaantonov/bluebird",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/petkaantonov/bluebird.git"
+ },
+ "bugs": {
+ "url": "http://github.com/petkaantonov/bluebird/issues"
+ },
+ "license": "MIT",
+ "author": {
+ "name": "Petka Antonov",
+ "email": "petka_antonov@hotmail.com",
+ "url": "http://github.com/petkaantonov/"
+ },
+ "devDependencies": {
+ "acorn": "~0.6.0",
+ "baconjs": "^0.7.43",
+ "bluebird": "^2.9.2",
+ "body-parser": "^1.10.2",
+ "browserify": "^8.1.1",
+ "cli-table": "~0.3.1",
+ "co": "^4.2.0",
+ "cross-spawn": "^0.2.3",
+ "glob": "^4.3.2",
+ "grunt-saucelabs": "~8.4.1",
+ "highland": "^2.3.0",
+ "istanbul": "^0.3.5",
+ "jshint": "^2.6.0",
+ "jshint-stylish": "~0.2.0",
+ "mkdirp": "~0.5.0",
+ "mocha": "~2.1",
+ "open": "~0.0.5",
+ "optimist": "~0.6.1",
+ "rimraf": "~2.2.6",
+ "rx": "^2.3.25",
+ "serve-static": "^1.7.1",
+ "sinon": "~1.7.3",
+ "uglify-js": "~2.4.16",
+ "kefir": "^2.4.1"
+ },
+ "main": "./js/main/bluebird.js",
+ "browser": "./js/browser/bluebird.js",
+ "files": [
+ "js/browser",
+ "js/main",
+ "js/zalgo",
+ "zalgo.js"
+ ],
+ "gitHead": "02c0fd252cf7c0c86e6b27bb06422c404829b539",
+ "_id": "bluebird@2.10.2",
+ "_shasum": "024a5517295308857f14f91f1106fc3b555f446b",
+ "_from": "bluebird@2.10.2",
+ "_npmVersion": "2.11.1",
+ "_nodeVersion": "2.3.0",
+ "_npmUser": {
+ "name": "esailija",
+ "email": "petka_antonov@hotmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "esailija",
+ "email": "petka_antonov@hotmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "024a5517295308857f14f91f1106fc3b555f446b",
+ "tarball": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.jshintrc b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.jshintrc
new file mode 100644
index 0000000..299877f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.jshintrc
@@ -0,0 +1,3 @@
+{
+ "laxbreak": true
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.npmignore
new file mode 100644
index 0000000..7e6163d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/.npmignore
@@ -0,0 +1,6 @@
+support
+test
+examples
+example
+*.sock
+dist
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/History.md
new file mode 100644
index 0000000..854c971
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/History.md
@@ -0,0 +1,195 @@
+
+2.2.0 / 2015-05-09
+==================
+
+ * package: update "ms" to v0.7.1 (#202, @dougwilson)
+ * README: add logging to file example (#193, @DanielOchoa)
+ * README: fixed a typo (#191, @amir-s)
+ * browser: expose `storage` (#190, @stephenmathieson)
+ * Makefile: add a `distclean` target (#189, @stephenmathieson)
+
+2.1.3 / 2015-03-13
+==================
+
+ * Updated stdout/stderr example (#186)
+ * Updated example/stdout.js to match debug current behaviour
+ * Renamed example/stderr.js to stdout.js
+ * Update Readme.md (#184)
+ * replace high intensity foreground color for bold (#182, #183)
+
+2.1.2 / 2015-03-01
+==================
+
+ * dist: recompile
+ * update "ms" to v0.7.0
+ * package: update "browserify" to v9.0.3
+ * component: fix "ms.js" repo location
+ * changed bower package name
+ * updated documentation about using debug in a browser
+ * fix: security error on safari (#167, #168, @yields)
+
+2.1.1 / 2014-12-29
+==================
+
+ * browser: use `typeof` to check for `console` existence
+ * browser: check for `console.log` truthiness (fix IE 8/9)
+ * browser: add support for Chrome apps
+ * Readme: added Windows usage remarks
+ * Add `bower.json` to properly support bower install
+
+2.1.0 / 2014-10-15
+==================
+
+ * node: implement `DEBUG_FD` env variable support
+ * package: update "browserify" to v6.1.0
+ * package: add "license" field to package.json (#135, @panuhorsmalahti)
+
+2.0.0 / 2014-09-01
+==================
+
+ * package: update "browserify" to v5.11.0
+ * node: use stderr rather than stdout for logging (#29, @stephenmathieson)
+
+1.0.4 / 2014-07-15
+==================
+
+ * dist: recompile
+ * example: remove `console.info()` log usage
+ * example: add "Content-Type" UTF-8 header to browser example
+ * browser: place %c marker after the space character
+ * browser: reset the "content" color via `color: inherit`
+ * browser: add colors support for Firefox >= v31
+ * debug: prefer an instance `log()` function over the global one (#119)
+ * Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
+
+1.0.3 / 2014-07-09
+==================
+
+ * Add support for multiple wildcards in namespaces (#122, @seegno)
+ * browser: fix lint
+
+1.0.2 / 2014-06-10
+==================
+
+ * browser: update color palette (#113, @gscottolson)
+ * common: make console logging function configurable (#108, @timoxley)
+ * node: fix %o colors on old node <= 0.8.x
+ * Makefile: find node path using shell/which (#109, @timoxley)
+
+1.0.1 / 2014-06-06
+==================
+
+ * browser: use `removeItem()` to clear localStorage
+ * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
+ * package: add "contributors" section
+ * node: fix comment typo
+ * README: list authors
+
+1.0.0 / 2014-06-04
+==================
+
+ * make ms diff be global, not be scope
+ * debug: ignore empty strings in enable()
+ * node: make DEBUG_COLORS able to disable coloring
+ * *: export the `colors` array
+ * npmignore: don't publish the `dist` dir
+ * Makefile: refactor to use browserify
+ * package: add "browserify" as a dev dependency
+ * Readme: add Web Inspector Colors section
+ * node: reset terminal color for the debug content
+ * node: map "%o" to `util.inspect()`
+ * browser: map "%j" to `JSON.stringify()`
+ * debug: add custom "formatters"
+ * debug: use "ms" module for humanizing the diff
+ * Readme: add "bash" syntax highlighting
+ * browser: add Firebug color support
+ * browser: add colors for WebKit browsers
+ * node: apply log to `console`
+ * rewrite: abstract common logic for Node & browsers
+ * add .jshintrc file
+
+0.8.1 / 2014-04-14
+==================
+
+ * package: re-add the "component" section
+
+0.8.0 / 2014-03-30
+==================
+
+ * add `enable()` method for nodejs. Closes #27
+ * change from stderr to stdout
+ * remove unnecessary index.js file
+
+0.7.4 / 2013-11-13
+==================
+
+ * remove "browserify" key from package.json (fixes something in browserify)
+
+0.7.3 / 2013-10-30
+==================
+
+ * fix: catch localStorage security error when cookies are blocked (Chrome)
+ * add debug(err) support. Closes #46
+ * add .browser prop to package.json. Closes #42
+
+0.7.2 / 2013-02-06
+==================
+
+ * fix package.json
+ * fix: Mobile Safari (private mode) is broken with debug
+ * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
+
+0.7.1 / 2013-02-05
+==================
+
+ * add repository URL to package.json
+ * add DEBUG_COLORED to force colored output
+ * add browserify support
+ * fix component. Closes #24
+
+0.7.0 / 2012-05-04
+==================
+
+ * Added .component to package.json
+ * Added debug.component.js build
+
+0.6.0 / 2012-03-16
+==================
+
+ * Added support for "-" prefix in DEBUG [Vinay Pulim]
+ * Added `.enabled` flag to the node version [TooTallNate]
+
+0.5.0 / 2012-02-02
+==================
+
+ * Added: humanize diffs. Closes #8
+ * Added `debug.disable()` to the CS variant
+ * Removed padding. Closes #10
+ * Fixed: persist client-side variant again. Closes #9
+
+0.4.0 / 2012-02-01
+==================
+
+ * Added browser variant support for older browsers [TooTallNate]
+ * Added `debug.enable('project:*')` to browser variant [TooTallNate]
+ * Added padding to diff (moved it to the right)
+
+0.3.0 / 2012-01-26
+==================
+
+ * Added millisecond diff when isatty, otherwise UTC string
+
+0.2.0 / 2012-01-22
+==================
+
+ * Added wildcard support
+
+0.1.0 / 2011-12-02
+==================
+
+ * Added: remove colors unless stderr isatty [TooTallNate]
+
+0.0.1 / 2010-01-03
+==================
+
+ * Initial release
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Makefile
new file mode 100644
index 0000000..5cf4a59
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Makefile
@@ -0,0 +1,36 @@
+
+# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
+THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
+THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
+
+# BIN directory
+BIN := $(THIS_DIR)/node_modules/.bin
+
+# applications
+NODE ?= $(shell which node)
+NPM ?= $(NODE) $(shell which npm)
+BROWSERIFY ?= $(NODE) $(BIN)/browserify
+
+all: dist/debug.js
+
+install: node_modules
+
+clean:
+ @rm -rf dist
+
+dist:
+ @mkdir -p $@
+
+dist/debug.js: node_modules browser.js debug.js dist
+ @$(BROWSERIFY) \
+ --standalone debug \
+ . > $@
+
+distclean: clean
+ @rm -rf node_modules
+
+node_modules: package.json
+ @NODE_ENV= $(NPM) install
+ @touch node_modules
+
+.PHONY: all install clean distclean
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Readme.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Readme.md
new file mode 100644
index 0000000..b4f45e3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/Readme.md
@@ -0,0 +1,188 @@
+# debug
+
+ tiny node.js debugging utility modelled after node core's debugging technique.
+
+## Installation
+
+```bash
+$ npm install debug
+```
+
+## Usage
+
+ With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
+
+Example _app.js_:
+
+```js
+var debug = require('debug')('http')
+ , http = require('http')
+ , name = 'My App';
+
+// fake app
+
+debug('booting %s', name);
+
+http.createServer(function(req, res){
+ debug(req.method + ' ' + req.url);
+ res.end('hello\n');
+}).listen(3000, function(){
+ debug('listening');
+});
+
+// fake worker of some kind
+
+require('./worker');
+```
+
+Example _worker.js_:
+
+```js
+var debug = require('debug')('worker');
+
+setInterval(function(){
+ debug('doing some work');
+}, 1000);
+```
+
+ The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
+
+ ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)
+
+ ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)
+
+#### Windows note
+
+ On Windows the environment variable is set using the `set` command.
+
+ ```cmd
+ set DEBUG=*,-not_this
+ ```
+
+Then, run the program to be debugged as usual.
+
+## Millisecond diff
+
+ When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
+
+ ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
+
+ When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
+
+ ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)
+
+## Conventions
+
+ If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
+
+## Wildcards
+
+ The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
+
+ You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:".
+
+## Browser support
+
+ Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include:
+
+```js
+window.myDebug = require("debug");
+```
+
+ ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console:
+
+```js
+myDebug.enable("worker:*")
+```
+
+ Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console.
+
+```js
+a = debug('worker:a');
+b = debug('worker:b');
+
+setInterval(function(){
+ a('doing some work');
+}, 1000);
+
+setInterval(function(){
+ b('doing some work');
+}, 1200);
+```
+
+#### Web Inspector Colors
+
+ Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
+ option. These are WebKit web inspectors, Firefox ([since version
+ 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
+ and the Firebug plugin for Firefox (any version).
+
+ Colored output looks something like:
+
+ ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png)
+
+### stderr vs stdout
+
+You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:
+
+Example _stdout.js_:
+
+```js
+var debug = require('debug');
+var error = debug('app:error');
+
+// by default stderr is used
+error('goes to stderr!');
+
+var log = debug('app:log');
+// set this namespace to log via console.log
+log.log = console.log.bind(console); // don't forget to bind to console!
+log('goes to stdout');
+error('still goes to stderr!');
+
+// set all output to go via console.info
+// overrides all per-namespace log settings
+debug.log = console.info.bind(console);
+error('now goes to stdout via console.info');
+log('still goes to stdout, but via console.info now');
+```
+
+### Save debug output to a file
+
+You can save all debug statements to a file by piping them.
+
+Example:
+
+```bash
+$ DEBUG_FD=3 node your-app.js 3> whatever.log
+```
+
+## Authors
+
+ - TJ Holowaychuk
+ - Nathan Rajlich
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2014 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
+
+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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/bower.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/bower.json
new file mode 100644
index 0000000..6af573f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/bower.json
@@ -0,0 +1,28 @@
+{
+ "name": "visionmedia-debug",
+ "main": "dist/debug.js",
+ "version": "2.2.0",
+ "homepage": "https://github.com/visionmedia/debug",
+ "authors": [
+ "TJ Holowaychuk <tj@vision-media.ca>"
+ ],
+ "description": "visionmedia-debug",
+ "moduleType": [
+ "amd",
+ "es6",
+ "globals",
+ "node"
+ ],
+ "keywords": [
+ "visionmedia",
+ "debug"
+ ],
+ "license": "MIT",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/browser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/browser.js
new file mode 100644
index 0000000..7c76452
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/browser.js
@@ -0,0 +1,168 @@
+
+/**
+ * This is the web browser implementation of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
+
+exports = module.exports = require('./debug');
+exports.log = log;
+exports.formatArgs = formatArgs;
+exports.save = save;
+exports.load = load;
+exports.useColors = useColors;
+exports.storage = 'undefined' != typeof chrome
+ && 'undefined' != typeof chrome.storage
+ ? chrome.storage.local
+ : localstorage();
+
+/**
+ * Colors.
+ */
+
+exports.colors = [
+ 'lightseagreen',
+ 'forestgreen',
+ 'goldenrod',
+ 'dodgerblue',
+ 'darkorchid',
+ 'crimson'
+];
+
+/**
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
+ * and the Firebug extension (any Firefox version) are known
+ * to support "%c" CSS customizations.
+ *
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
+ */
+
+function useColors() {
+ // is webkit? http://stackoverflow.com/a/16459606/376773
+ return ('WebkitAppearance' in document.documentElement.style) ||
+ // is firebug? http://stackoverflow.com/a/398120/376773
+ (window.console && (console.firebug || (console.exception && console.table))) ||
+ // is firefox >= v31?
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
+ (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
+}
+
+/**
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
+ */
+
+exports.formatters.j = function(v) {
+ return JSON.stringify(v);
+};
+
+
+/**
+ * Colorize log arguments if enabled.
+ *
+ * @api public
+ */
+
+function formatArgs() {
+ var args = arguments;
+ var useColors = this.useColors;
+
+ args[0] = (useColors ? '%c' : '')
+ + this.namespace
+ + (useColors ? ' %c' : ' ')
+ + args[0]
+ + (useColors ? '%c ' : ' ')
+ + '+' + exports.humanize(this.diff);
+
+ if (!useColors) return args;
+
+ var c = 'color: ' + this.color;
+ args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
+
+ // the final "%c" is somewhat tricky, because there could be other
+ // arguments passed either before or after the %c, so we need to
+ // figure out the correct index to insert the CSS into
+ var index = 0;
+ var lastC = 0;
+ args[0].replace(/%[a-z%]/g, function(match) {
+ if ('%%' === match) return;
+ index++;
+ if ('%c' === match) {
+ // we only are interested in the *last* %c
+ // (the user may have provided their own)
+ lastC = index;
+ }
+ });
+
+ args.splice(lastC, 0, c);
+ return args;
+}
+
+/**
+ * Invokes `console.log()` when available.
+ * No-op when `console.log` is not a "function".
+ *
+ * @api public
+ */
+
+function log() {
+ // this hackery is required for IE8/9, where
+ // the `console.log` function doesn't have 'apply'
+ return 'object' === typeof console
+ && console.log
+ && Function.prototype.apply.call(console.log, console, arguments);
+}
+
+/**
+ * Save `namespaces`.
+ *
+ * @param {String} namespaces
+ * @api private
+ */
+
+function save(namespaces) {
+ try {
+ if (null == namespaces) {
+ exports.storage.removeItem('debug');
+ } else {
+ exports.storage.debug = namespaces;
+ }
+ } catch(e) {}
+}
+
+/**
+ * Load `namespaces`.
+ *
+ * @return {String} returns the previously persisted debug modes
+ * @api private
+ */
+
+function load() {
+ var r;
+ try {
+ r = exports.storage.debug;
+ } catch(e) {}
+ return r;
+}
+
+/**
+ * Enable namespaces listed in `localStorage.debug` initially.
+ */
+
+exports.enable(load());
+
+/**
+ * Localstorage attempts to return the localstorage.
+ *
+ * This is necessary because safari throws
+ * when a user disables cookies/localstorage
+ * and you attempt to access it.
+ *
+ * @return {LocalStorage}
+ * @api private
+ */
+
+function localstorage(){
+ try {
+ return window.localStorage;
+ } catch (e) {}
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/component.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/component.json
new file mode 100644
index 0000000..ca10637
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/component.json
@@ -0,0 +1,19 @@
+{
+ "name": "debug",
+ "repo": "visionmedia/debug",
+ "description": "small debugging utility",
+ "version": "2.2.0",
+ "keywords": [
+ "debug",
+ "log",
+ "debugger"
+ ],
+ "main": "browser.js",
+ "scripts": [
+ "browser.js",
+ "debug.js"
+ ],
+ "dependencies": {
+ "rauchg/ms.js": "0.7.1"
+ }
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/debug.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/debug.js
new file mode 100644
index 0000000..7571a86
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/debug.js
@@ -0,0 +1,197 @@
+
+/**
+ * This is the common logic for both the Node.js and web browser
+ * implementations of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
+
+exports = module.exports = debug;
+exports.coerce = coerce;
+exports.disable = disable;
+exports.enable = enable;
+exports.enabled = enabled;
+exports.humanize = require('ms');
+
+/**
+ * The currently active debug mode names, and names to skip.
+ */
+
+exports.names = [];
+exports.skips = [];
+
+/**
+ * Map of special "%n" handling functions, for the debug "format" argument.
+ *
+ * Valid key names are a single, lowercased letter, i.e. "n".
+ */
+
+exports.formatters = {};
+
+/**
+ * Previously assigned color.
+ */
+
+var prevColor = 0;
+
+/**
+ * Previous log timestamp.
+ */
+
+var prevTime;
+
+/**
+ * Select a color.
+ *
+ * @return {Number}
+ * @api private
+ */
+
+function selectColor() {
+ return exports.colors[prevColor++ % exports.colors.length];
+}
+
+/**
+ * Create a debugger with the given `namespace`.
+ *
+ * @param {String} namespace
+ * @return {Function}
+ * @api public
+ */
+
+function debug(namespace) {
+
+ // define the `disabled` version
+ function disabled() {
+ }
+ disabled.enabled = false;
+
+ // define the `enabled` version
+ function enabled() {
+
+ var self = enabled;
+
+ // set `diff` timestamp
+ var curr = +new Date();
+ var ms = curr - (prevTime || curr);
+ self.diff = ms;
+ self.prev = prevTime;
+ self.curr = curr;
+ prevTime = curr;
+
+ // add the `color` if not set
+ if (null == self.useColors) self.useColors = exports.useColors();
+ if (null == self.color && self.useColors) self.color = selectColor();
+
+ var args = Array.prototype.slice.call(arguments);
+
+ args[0] = exports.coerce(args[0]);
+
+ if ('string' !== typeof args[0]) {
+ // anything else let's inspect with %o
+ args = ['%o'].concat(args);
+ }
+
+ // apply any `formatters` transformations
+ var index = 0;
+ args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
+ // if we encounter an escaped % then don't increase the array index
+ if (match === '%%') return match;
+ index++;
+ var formatter = exports.formatters[format];
+ if ('function' === typeof formatter) {
+ var val = args[index];
+ match = formatter.call(self, val);
+
+ // now we need to remove `args[index]` since it's inlined in the `format`
+ args.splice(index, 1);
+ index--;
+ }
+ return match;
+ });
+
+ if ('function' === typeof exports.formatArgs) {
+ args = exports.formatArgs.apply(self, args);
+ }
+ var logFn = enabled.log || exports.log || console.log.bind(console);
+ logFn.apply(self, args);
+ }
+ enabled.enabled = true;
+
+ var fn = exports.enabled(namespace) ? enabled : disabled;
+
+ fn.namespace = namespace;
+
+ return fn;
+}
+
+/**
+ * Enables a debug mode by namespaces. This can include modes
+ * separated by a colon and wildcards.
+ *
+ * @param {String} namespaces
+ * @api public
+ */
+
+function enable(namespaces) {
+ exports.save(namespaces);
+
+ var split = (namespaces || '').split(/[\s,]+/);
+ var len = split.length;
+
+ for (var i = 0; i < len; i++) {
+ if (!split[i]) continue; // ignore empty strings
+ namespaces = split[i].replace(/\*/g, '.*?');
+ if (namespaces[0] === '-') {
+ exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
+ } else {
+ exports.names.push(new RegExp('^' + namespaces + '$'));
+ }
+ }
+}
+
+/**
+ * Disable debug output.
+ *
+ * @api public
+ */
+
+function disable() {
+ exports.enable('');
+}
+
+/**
+ * Returns true if the given mode name is enabled, false otherwise.
+ *
+ * @param {String} name
+ * @return {Boolean}
+ * @api public
+ */
+
+function enabled(name) {
+ var i, len;
+ for (i = 0, len = exports.skips.length; i < len; i++) {
+ if (exports.skips[i].test(name)) {
+ return false;
+ }
+ }
+ for (i = 0, len = exports.names.length; i < len; i++) {
+ if (exports.names[i].test(name)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Coerce `val`.
+ *
+ * @param {Mixed} val
+ * @return {Mixed}
+ * @api private
+ */
+
+function coerce(val) {
+ if (val instanceof Error) return val.stack || val.message;
+ return val;
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/node.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/node.js
new file mode 100644
index 0000000..1d392a8
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/node.js
@@ -0,0 +1,209 @@
+
+/**
+ * Module dependencies.
+ */
+
+var tty = require('tty');
+var util = require('util');
+
+/**
+ * This is the Node.js implementation of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
+
+exports = module.exports = require('./debug');
+exports.log = log;
+exports.formatArgs = formatArgs;
+exports.save = save;
+exports.load = load;
+exports.useColors = useColors;
+
+/**
+ * Colors.
+ */
+
+exports.colors = [6, 2, 3, 4, 5, 1];
+
+/**
+ * The file descriptor to write the `debug()` calls to.
+ * Set the `DEBUG_FD` env variable to override with another value. i.e.:
+ *
+ * $ DEBUG_FD=3 node script.js 3>debug.log
+ */
+
+var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
+var stream = 1 === fd ? process.stdout :
+ 2 === fd ? process.stderr :
+ createWritableStdioStream(fd);
+
+/**
+ * Is stdout a TTY? Colored output is enabled when `true`.
+ */
+
+function useColors() {
+ var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
+ if (0 === debugColors.length) {
+ return tty.isatty(fd);
+ } else {
+ return '0' !== debugColors
+ && 'no' !== debugColors
+ && 'false' !== debugColors
+ && 'disabled' !== debugColors;
+ }
+}
+
+/**
+ * Map %o to `util.inspect()`, since Node doesn't do that out of the box.
+ */
+
+var inspect = (4 === util.inspect.length ?
+ // node <= 0.8.x
+ function (v, colors) {
+ return util.inspect(v, void 0, void 0, colors);
+ } :
+ // node > 0.8.x
+ function (v, colors) {
+ return util.inspect(v, { colors: colors });
+ }
+);
+
+exports.formatters.o = function(v) {
+ return inspect(v, this.useColors)
+ .replace(/\s*\n\s*/g, ' ');
+};
+
+/**
+ * Adds ANSI color escape codes if enabled.
+ *
+ * @api public
+ */
+
+function formatArgs() {
+ var args = arguments;
+ var useColors = this.useColors;
+ var name = this.namespace;
+
+ if (useColors) {
+ var c = this.color;
+
+ args[0] = ' \u001b[3' + c + ';1m' + name + ' '
+ + '\u001b[0m'
+ + args[0] + '\u001b[3' + c + 'm'
+ + ' +' + exports.humanize(this.diff) + '\u001b[0m';
+ } else {
+ args[0] = new Date().toUTCString()
+ + ' ' + name + ' ' + args[0];
+ }
+ return args;
+}
+
+/**
+ * Invokes `console.error()` with the specified arguments.
+ */
+
+function log() {
+ return stream.write(util.format.apply(this, arguments) + '\n');
+}
+
+/**
+ * Save `namespaces`.
+ *
+ * @param {String} namespaces
+ * @api private
+ */
+
+function save(namespaces) {
+ if (null == namespaces) {
+ // If you set a process.env field to null or undefined, it gets cast to the
+ // string 'null' or 'undefined'. Just delete instead.
+ delete process.env.DEBUG;
+ } else {
+ process.env.DEBUG = namespaces;
+ }
+}
+
+/**
+ * Load `namespaces`.
+ *
+ * @return {String} returns the previously persisted debug modes
+ * @api private
+ */
+
+function load() {
+ return process.env.DEBUG;
+}
+
+/**
+ * Copied from `node/src/node.js`.
+ *
+ * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
+ * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
+ */
+
+function createWritableStdioStream (fd) {
+ var stream;
+ var tty_wrap = process.binding('tty_wrap');
+
+ // Note stream._type is used for test-module-load-list.js
+
+ switch (tty_wrap.guessHandleType(fd)) {
+ case 'TTY':
+ stream = new tty.WriteStream(fd);
+ stream._type = 'tty';
+
+ // Hack to have stream not keep the event loop alive.
+ // See https://github.com/joyent/node/issues/1726
+ if (stream._handle && stream._handle.unref) {
+ stream._handle.unref();
+ }
+ break;
+
+ case 'FILE':
+ var fs = require('fs');
+ stream = new fs.SyncWriteStream(fd, { autoClose: false });
+ stream._type = 'fs';
+ break;
+
+ case 'PIPE':
+ case 'TCP':
+ var net = require('net');
+ stream = new net.Socket({
+ fd: fd,
+ readable: false,
+ writable: true
+ });
+
+ // FIXME Should probably have an option in net.Socket to create a
+ // stream from an existing fd which is writable only. But for now
+ // we'll just add this hack and set the `readable` member to false.
+ // Test: ./node test/fixtures/echo.js < /etc/passwd
+ stream.readable = false;
+ stream.read = null;
+ stream._type = 'pipe';
+
+ // FIXME Hack to have stream not keep the event loop alive.
+ // See https://github.com/joyent/node/issues/1726
+ if (stream._handle && stream._handle.unref) {
+ stream._handle.unref();
+ }
+ break;
+
+ default:
+ // Probably an error on in uv_guess_handle()
+ throw new Error('Implement me. Unknown stream file type!');
+ }
+
+ // For supporting legacy API we put the FD here.
+ stream.fd = fd;
+
+ stream._isStdio = true;
+
+ return stream;
+}
+
+/**
+ * Enable namespaces listed in `process.env.DEBUG` initially.
+ */
+
+exports.enable(load());
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/package.json
new file mode 100644
index 0000000..46ce4c5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/debug/package.json
@@ -0,0 +1,73 @@
+{
+ "name": "debug",
+ "version": "2.2.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/visionmedia/debug.git"
+ },
+ "description": "small debugging utility",
+ "keywords": [
+ "debug",
+ "log",
+ "debugger"
+ ],
+ "author": {
+ "name": "TJ Holowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ "contributors": [
+ {
+ "name": "Nathan Rajlich",
+ "email": "nathan@tootallnate.net",
+ "url": "http://n8.io"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "ms": "0.7.1"
+ },
+ "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",
+ "_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"
+ }
+ ],
+ "dist": {
+ "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da",
+ "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
+ "readme": "ERROR: No README data found!"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.npmignore
new file mode 100644
index 0000000..be106ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.npmignore
@@ -0,0 +1,2 @@
+*.sw*
+node_modules/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.travis.yml
new file mode 100644
index 0000000..895dbd3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/History.md
new file mode 100644
index 0000000..33abe6d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/History.md
@@ -0,0 +1,30 @@
+
+0.0.5 / 2013-02-05
+==================
+
+ * optimization: remove use of arguments [jkroso](https://github.com/jkroso)
+ * add scripts to component.json [jkroso](https://github.com/jkroso)
+ * tests; remove time for travis
+
+0.0.4 / 2013-01-07
+==================
+
+ * added component.json #1 [jkroso](https://github.com/jkroso)
+ * reversed array loop #1 [jkroso](https://github.com/jkroso)
+ * remove fn params
+
+0.0.3 / 2012-09-29
+==================
+
+ * faster with negative start args
+
+0.0.2 / 2012-09-29
+==================
+
+ * support full [].slice semantics
+
+0.0.1 / 2012-09-29
+===================
+
+ * initial release
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/Makefile
new file mode 100644
index 0000000..2ad4e47
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/Makefile
@@ -0,0 +1,5 @@
+
+test:
+ @./node_modules/.bin/mocha $(T) $(TESTS)
+
+.PHONY: test
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/README.md
new file mode 100644
index 0000000..6605c39
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/README.md
@@ -0,0 +1,62 @@
+#sliced
+==========
+
+A faster alternative to `[].slice.call(arguments)`.
+
+[![Build Status](https://secure.travis-ci.org/aheckmann/sliced.png)](http://travis-ci.org/aheckmann/sliced)
+
+Example output from [benchmark.js](https://github.com/bestiejs/benchmark.js)
+
+ Array.prototype.slice.call x 1,320,205 ops/sec ±2.35% (92 runs sampled)
+ [].slice.call x 1,314,605 ops/sec ±1.60% (95 runs sampled)
+ cached slice.call x 10,468,380 ops/sec ±1.45% (95 runs sampled)
+ sliced x 16,608,237 ops/sec ±1.40% (92 runs sampled)
+ fastest is sliced
+
+ Array.prototype.slice.call(arguments, 1) x 1,383,584 ops/sec ±1.73% (97 runs sampled)
+ [].slice.call(arguments, 1) x 1,494,735 ops/sec ±1.33% (95 runs sampled)
+ cached slice.call(arguments, 1) x 10,085,270 ops/sec ±1.51% (97 runs sampled)
+ sliced(arguments, 1) x 16,620,480 ops/sec ±1.29% (95 runs sampled)
+ fastest is sliced(arguments, 1)
+
+ Array.prototype.slice.call(arguments, -1) x 1,303,262 ops/sec ±1.62% (94 runs sampled)
+ [].slice.call(arguments, -1) x 1,325,615 ops/sec ±1.36% (97 runs sampled)
+ cached slice.call(arguments, -1) x 9,673,603 ops/sec ±1.70% (96 runs sampled)
+ sliced(arguments, -1) x 16,384,575 ops/sec ±1.06% (91 runs sampled)
+ fastest is sliced(arguments, -1)
+
+ Array.prototype.slice.call(arguments, -2, -10) x 1,404,390 ops/sec ±1.61% (95 runs sampled)
+ [].slice.call(arguments, -2, -10) x 1,514,367 ops/sec ±1.21% (96 runs sampled)
+ cached slice.call(arguments, -2, -10) x 9,836,017 ops/sec ±1.21% (95 runs sampled)
+ sliced(arguments, -2, -10) x 18,544,882 ops/sec ±1.30% (91 runs sampled)
+ fastest is sliced(arguments, -2, -10)
+
+ Array.prototype.slice.call(arguments, -2, -1) x 1,458,604 ops/sec ±1.41% (97 runs sampled)
+ [].slice.call(arguments, -2, -1) x 1,536,547 ops/sec ±1.63% (99 runs sampled)
+ cached slice.call(arguments, -2, -1) x 10,060,633 ops/sec ±1.37% (96 runs sampled)
+ sliced(arguments, -2, -1) x 18,608,712 ops/sec ±1.08% (93 runs sampled)
+ fastest is sliced(arguments, -2, -1)
+
+_Benchmark [source](https://github.com/aheckmann/sliced/blob/master/bench.js)._
+
+##Usage
+
+`sliced` accepts the same arguments as `Array#slice` so you can easily swap it out.
+
+```js
+function zing () {
+ var slow = [].slice.call(arguments, 1, 8);
+ var args = slice(arguments, 1, 8);
+
+ var slow = Array.prototype.slice.call(arguments);
+ var args = slice(arguments);
+ // etc
+}
+```
+
+## install
+
+ npm install sliced
+
+
+[LICENSE](https://github.com/aheckmann/sliced/blob/master/LICENSE)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/bench.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/bench.js
new file mode 100644
index 0000000..f201d16
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/bench.js
@@ -0,0 +1,95 @@
+
+var sliced = require('./')
+var Bench = require('benchmark');
+var s = new Bench.Suite;
+var slice = [].slice;
+
+s.add('Array.prototype.slice.call', function () {
+ Array.prototype.slice.call(arguments);
+}).add('[].slice.call', function () {
+ [].slice.call(arguments);
+}).add('cached slice.call', function () {
+ slice.call(arguments)
+}).add('sliced', function () {
+ sliced(arguments)
+}).on('cycle', function (evt) {
+ console.log(String(evt.target));
+}).on('complete', function () {
+ console.log('fastest is %s', this.filter('fastest').pluck('name'));
+})
+.run();
+
+var s = new Bench.Suite;
+s.add('Array.prototype.slice.call(arguments, 1)', function () {
+ Array.prototype.slice.call(arguments, 1);
+}).add('[].slice.call(arguments, 1)', function () {
+ [].slice.call(arguments, 1);
+}).add('cached slice.call(arguments, 1)', function () {
+ slice.call(arguments, 1)
+}).add('sliced(arguments, 1)', function () {
+ sliced(arguments, 1)
+}).on('cycle', function (evt) {
+ console.log(String(evt.target));
+}).on('complete', function () {
+ console.log('fastest is %s', this.filter('fastest').pluck('name'));
+})
+.run();
+
+var s = new Bench.Suite;
+s.add('Array.prototype.slice.call(arguments, -1)', function () {
+ Array.prototype.slice.call(arguments, -1);
+}).add('[].slice.call(arguments, -1)', function () {
+ [].slice.call(arguments, -1);
+}).add('cached slice.call(arguments, -1)', function () {
+ slice.call(arguments, -1)
+}).add('sliced(arguments, -1)', function () {
+ sliced(arguments, -1)
+}).on('cycle', function (evt) {
+ console.log(String(evt.target));
+}).on('complete', function () {
+ console.log('fastest is %s', this.filter('fastest').pluck('name'));
+})
+.run();
+
+var s = new Bench.Suite;
+s.add('Array.prototype.slice.call(arguments, -2, -10)', function () {
+ Array.prototype.slice.call(arguments, -2, -10);
+}).add('[].slice.call(arguments, -2, -10)', function () {
+ [].slice.call(arguments, -2, -10);
+}).add('cached slice.call(arguments, -2, -10)', function () {
+ slice.call(arguments, -2, -10)
+}).add('sliced(arguments, -2, -10)', function () {
+ sliced(arguments, -2, -10)
+}).on('cycle', function (evt) {
+ console.log(String(evt.target));
+}).on('complete', function () {
+ console.log('fastest is %s', this.filter('fastest').pluck('name'));
+})
+.run();
+
+var s = new Bench.Suite;
+s.add('Array.prototype.slice.call(arguments, -2, -1)', function () {
+ Array.prototype.slice.call(arguments, -2, -1);
+}).add('[].slice.call(arguments, -2, -1)', function () {
+ [].slice.call(arguments, -2, -1);
+}).add('cached slice.call(arguments, -2, -1)', function () {
+ slice.call(arguments, -2, -1)
+}).add('sliced(arguments, -2, -1)', function () {
+ sliced(arguments, -2, -1)
+}).on('cycle', function (evt) {
+ console.log(String(evt.target));
+}).on('complete', function () {
+ console.log('fastest is %s', this.filter('fastest').pluck('name'));
+})
+.run();
+
+/**
+ * Output:
+ *
+ * Array.prototype.slice.call x 1,289,592 ops/sec ±2.88% (87 runs sampled)
+ * [].slice.call x 1,345,451 ops/sec ±1.68% (97 runs sampled)
+ * cached slice.call x 10,719,886 ops/sec ±1.04% (99 runs sampled)
+ * sliced x 15,809,545 ops/sec ±1.46% (93 runs sampled)
+ * fastest is sliced
+ *
+ */
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/component.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/component.json
new file mode 100644
index 0000000..57e9e0c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/component.json
@@ -0,0 +1,14 @@
+{
+ "name": "sliced",
+ "version": "0.0.5",
+ "description": "A faster Node.js alternative to Array.prototype.slice.call(arguments)",
+ "repo" : "aheckmann/sliced",
+ "keywords": [
+ "arguments",
+ "slice",
+ "array"
+ ],
+ "scripts": ["lib/sliced.js", "index.js"],
+ "author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>",
+ "license": "MIT"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/index.js
new file mode 100644
index 0000000..3b90ae7
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/index.js
@@ -0,0 +1 @@
+module.exports = exports = require('./lib/sliced');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/lib/sliced.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/lib/sliced.js
new file mode 100644
index 0000000..d88c85b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/lib/sliced.js
@@ -0,0 +1,33 @@
+
+/**
+ * An Array.prototype.slice.call(arguments) alternative
+ *
+ * @param {Object} args something with a length
+ * @param {Number} slice
+ * @param {Number} sliceEnd
+ * @api public
+ */
+
+module.exports = function (args, slice, sliceEnd) {
+ var ret = [];
+ var len = args.length;
+
+ if (0 === len) return ret;
+
+ var start = slice < 0
+ ? Math.max(0, slice + len)
+ : slice || 0;
+
+ if (sliceEnd !== undefined) {
+ len = sliceEnd < 0
+ ? sliceEnd + len
+ : sliceEnd
+ }
+
+ while (len-- > start) {
+ ret[len - start] = args[len];
+ }
+
+ return ret;
+}
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/package.json
new file mode 100644
index 0000000..cc39bb0
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "sliced",
+ "version": "0.0.5",
+ "description": "A faster Node.js alternative to Array.prototype.slice.call(arguments)",
+ "main": "index.js",
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/sliced"
+ },
+ "keywords": [
+ "arguments",
+ "slice",
+ "array"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "1.5.0",
+ "benchmark": "~1.0.0"
+ },
+ "_id": "sliced@0.0.5",
+ "dist": {
+ "shasum": "5edc044ca4eb6f7816d50ba2fc63e25d8fe4707f",
+ "tarball": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz"
+ },
+ "_npmVersion": "1.1.59",
+ "_npmUser": {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "5edc044ca4eb6f7816d50ba2fc63e25d8fe4707f",
+ "_resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
+ "_from": "sliced@0.0.5"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/test/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/test/index.js
new file mode 100644
index 0000000..33d36a1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/node_modules/sliced/test/index.js
@@ -0,0 +1,80 @@
+
+var sliced = require('../')
+var assert = require('assert')
+
+describe('sliced', function(){
+ it('exports a function', function(){
+ assert.equal('function', typeof sliced);
+ })
+ describe('with 1 arg', function(){
+ it('returns an array of the arg', function(){
+ var o = [3, "4", {}];
+ var r = sliced(o);
+ assert.equal(3, r.length);
+ assert.equal(o[0], r[0]);
+ assert.equal(o[1], r[1]);
+ assert.equal(o[1], r[1]);
+ })
+ })
+ describe('with 2 args', function(){
+ it('returns an array of the arg starting at the 2nd arg', function(){
+ var o = [3, "4", 5, null];
+ var r = sliced(o, 2);
+ assert.equal(2, r.length);
+ assert.equal(o[2], r[0]);
+ assert.equal(o[3], r[1]);
+ })
+ })
+ describe('with 3 args', function(){
+ it('returns an array of the arg from the 2nd to the 3rd arg', function(){
+ var o = [3, "4", 5, null];
+ var r = sliced(o, 1, 2);
+ assert.equal(1, r.length);
+ assert.equal(o[1], r[0]);
+ })
+ })
+ describe('with negative start and no end', function(){
+ it('begins at an offset from the end and includes all following elements', function(){
+ var o = [3, "4", 5, null];
+ var r = sliced(o, -2);
+ assert.equal(2, r.length);
+ assert.equal(o[2], r[0]);
+ assert.equal(o[3], r[1]);
+
+ var r = sliced(o, -12);
+ assert.equal(4, r.length);
+ assert.equal(o[0], r[0]);
+ assert.equal(o[1], r[1]);
+ })
+ })
+ describe('with negative start and positive end', function(){
+ it('begins at an offset from the end and includes `end` elements', function(){
+ var o = [3, "4", {x:1}, null];
+
+ var r = sliced(o, -2, 1);
+ assert.equal(0, r.length);
+
+ var r = sliced(o, -2, 2);
+ assert.equal(0, r.length);
+
+ var r = sliced(o, -2, 3);
+ assert.equal(1, r.length);
+ assert.equal(o[2], r[0]);
+ })
+ })
+ describe('with negative start and negative end', function(){
+ it('begins at `start` offset from the end and includes all elements up to `end` offset from the end', function(){
+ var o = [3, "4", {x:1}, null];
+ var r = sliced(o, -3, -1);
+ assert.equal(2, r.length);
+ assert.equal(o[1], r[0]);
+ assert.equal(o[2], r[1]);
+
+ var r = sliced(o, -3, -3);
+ assert.equal(0, r.length);
+
+ var r = sliced(o, -3, -4);
+ assert.equal(0, r.length);
+ })
+ })
+})
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/package.json
new file mode 100644
index 0000000..87b3422
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "mquery",
+ "version": "2.0.0",
+ "description": "Expressive query building for MongoDB",
+ "main": "lib/mquery.js",
+ "scripts": {
+ "test": "mocha test/index.js test/*.test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/mquery.git"
+ },
+ "dependencies": {
+ "bluebird": "2.10.2",
+ "debug": "2.2.0",
+ "regexp-clone": "0.0.1",
+ "sliced": "0.0.5"
+ },
+ "devDependencies": {
+ "mongodb": "~2.2",
+ "mocha": "1.9.x",
+ "istanbul": "0.3.2"
+ },
+ "bugs": {
+ "url": "https://github.com/aheckmann/mquery/issues/new"
+ },
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "keywords": [
+ "mongodb",
+ "query",
+ "builder"
+ ],
+ "homepage": "https://github.com/aheckmann/mquery/",
+ "gitHead": "2da32ab0c16efa531dad69a34113424858b6bd97",
+ "_id": "mquery@2.0.0",
+ "_shasum": "b5abc850b90dffc3e10ae49b4b6e7a479752df22",
+ "_from": "mquery@2.0.0",
+ "_npmVersion": "3.9.5",
+ "_nodeVersion": "6.2.2",
+ "_npmUser": {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ "dist": {
+ "shasum": "b5abc850b90dffc3e10ae49b4b6e7a479752df22",
+ "tarball": "https://registry.npmjs.org/mquery/-/mquery-2.0.0.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ {
+ "name": "ebensing",
+ "email": "ebensing38@gmail.com"
+ },
+ {
+ "name": "vkarpov15",
+ "email": "valkar207@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/mquery-2.0.0.tgz_1474848720074_0.5682471790350974"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/mquery/-/mquery-2.0.0.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/browser.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/browser.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/browser.js
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/mongo.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/mongo.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/mongo.js
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/node.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/node.js
new file mode 100644
index 0000000..c6ad119
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/collection/node.js
@@ -0,0 +1,28 @@
+
+var assert = require('assert')
+var slice = require('sliced')
+var mongo = require('mongodb')
+var utils = require('../../').utils;
+
+var uri = process.env.MQUERY_URI || 'mongodb://localhost/mquery';
+var db;
+
+exports.getCollection = function (cb) {
+ mongo.MongoClient.connect(uri, function (err, db_) {
+ assert.ifError(err);
+ db = db_;
+
+ var collection = db.collection('stuff');
+
+ // clean test db before starting
+ db.dropDatabase(function () {
+ cb(null, collection);
+ });
+ })
+}
+
+exports.dropCollection = function (cb) {
+ db.dropDatabase(function () {
+ db.close(cb);
+ })
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/env.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/env.js
new file mode 100644
index 0000000..9b9b80b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/env.js
@@ -0,0 +1,20 @@
+
+var assert = require('assert')
+var env = require('../').env;
+
+console.log('environment: %s', env.type);
+
+var col;
+switch (env.type) {
+ case 'node':
+ col = require('./collection/node');
+ break;
+ case 'mongo':
+ col = require('./collection/mongo');
+ case 'browser':
+ col = require('./collection/browser');
+ default:
+ throw new Error('missing collection implementation for environment: ' + env.type);
+}
+
+module.exports = exports = col;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/index.js
new file mode 100644
index 0000000..7c18bf1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/index.js
@@ -0,0 +1,2857 @@
+var mquery = require('../');
+var assert = require('assert');
+
+describe('mquery', function(){
+ var col;
+
+ before(function(done){
+ // get the env specific collection interface
+ require('./env').getCollection(function (err, collection) {
+ assert.ifError(err);
+ col = collection;
+ done();
+ });
+ })
+
+ after(function(done){
+ require('./env').dropCollection(done);
+ })
+
+ describe('mquery', function(){
+ it('is a function', function(){
+ assert.equal('function', typeof mquery);
+ })
+ it('creates instances with the `new` keyword', function(){
+ assert.ok(mquery() instanceof mquery);
+ })
+ describe('defaults', function(){
+ it('are set', function(){
+ var m = mquery();
+ assert.strictEqual(undefined, m.op);
+ assert.deepEqual({}, m.options);
+ })
+ })
+ describe('criteria', function(){
+ it('if collection-like is used as collection', function(){
+ var m = mquery(col);
+ assert.equal(col, m._collection.collection);
+ })
+ it('non-collection-like is used as criteria', function(){
+ var m = mquery({ works: true });
+ assert.ok(!m._collection);
+ assert.deepEqual({ works: true }, m._conditions);
+ })
+ })
+ describe('options', function(){
+ it('are merged when passed', function(){
+ var m = mquery(col, { safe: true });
+ assert.deepEqual({ safe: true }, m.options);
+ var m = mquery({ name: 'mquery' }, { safe: true });
+ assert.deepEqual({ safe: true }, m.options);
+ })
+ })
+ })
+
+ describe('toConstructor', function(){
+ it('creates subclasses of mquery', function(){
+ var opts = { safe: { w: 'majority' }, readPreference: 'p' };
+ var match = { name: 'test', count: { $gt: 101 }};
+ var select = { name: 1, count: 0 }
+ var update = { $set: { x: true }};
+ var path = 'street';
+
+ var q = mquery().setOptions(opts);
+ q.where(match);
+ q.select(select);
+ q.update(update);
+ q.where(path);
+ q.find();
+
+ var M = q.toConstructor();
+ var m = M();
+
+ assert.ok(m instanceof mquery);
+ assert.deepEqual(opts, m.options);
+ assert.deepEqual(match, m._conditions);
+ assert.deepEqual(select, m._fields);
+ assert.deepEqual(update, m._update);
+ assert.equal(path, m._path);
+ assert.equal('find', m.op);
+ })
+ })
+
+ describe('setOptions', function(){
+ it('calls associated methods', function(){
+ var m = mquery();
+ assert.equal(m._collection, null);
+ m.setOptions({ collection: col });
+ assert.equal(m._collection.collection, col);
+ })
+ it('directly sets option when no method exists', function(){
+ var m = mquery();
+ assert.equal(m.options.woot, null);
+ m.setOptions({ woot: 'yay' });
+ assert.equal(m.options.woot, 'yay');
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.setOptions();
+ assert.equal(m, n);
+ var n = m.setOptions({ x: 1 });
+ assert.equal(m, n);
+ })
+ })
+
+ describe('collection', function(){
+ it('sets the _collection', function(){
+ var m = mquery();
+ m.collection(col);
+ assert.equal(m._collection.collection, col);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.collection(col);
+ assert.equal(m, n);
+ })
+ })
+
+ describe('$where', function(){
+ it('sets the $where condition', function(){
+ var m = mquery();
+ function go () {}
+ m.$where(go);
+ assert.ok(go === m._conditions.$where);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.$where('x');
+ assert.equal(m, n);
+ })
+ })
+
+ describe('where', function(){
+ it('without arguments', function(){
+ var m = mquery();
+ m.where();
+ assert.deepEqual({}, m._conditions);
+ })
+ it('with non-string/object argument', function(){
+ var m = mquery();
+
+ assert.throws(function(){
+ m.where([]);
+ }, /path must be a string or object/);
+ })
+ describe('with one argument', function(){
+ it('that is an object', function(){
+ var m = mquery();
+ m.where({ name: 'flawed' });
+ assert.strictEqual(m._conditions.name, 'flawed');
+ })
+ it('that is a query', function(){
+ var m = mquery({ name: 'first' });
+ var n = mquery({ name: 'changed' });
+ m.where(n);
+ assert.strictEqual(m._conditions.name, 'changed');
+ })
+ it('that is a string', function(){
+ var m = mquery();
+ m.where('name');
+ assert.equal('name', m._path);
+ assert.strictEqual(m._conditions.name, undefined);
+ })
+ })
+ it('with two arguments', function(){
+ var m = mquery();
+ m.where('name', 'The Great Pumpkin');
+ assert.equal('name', m._path);
+ assert.strictEqual(m._conditions.name, 'The Great Pumpkin');
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.where('x', 'y');
+ assert.equal(m, n);
+ var n = m.where()
+ assert.equal(m, n);
+ })
+ })
+ describe('equals', function(){
+ it('must be called after where()', function(){
+ var m = mquery();
+ assert.throws(function () {
+ m.equals();
+ }, /must be used after where/)
+ })
+ it('sets value of path set with where()', function(){
+ var m = mquery();
+ m.where('age').equals(1000);
+ assert.deepEqual({ age: 1000 }, m._conditions);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.where('x').equals(3);
+ assert.equal(m, n);
+ })
+ })
+ describe('eq', function(){
+ it('is alias of equals', function(){
+ var m = mquery();
+ m.where('age').eq(1000);
+ assert.deepEqual({ age: 1000 }, m._conditions);
+ })
+ })
+ describe('or', function(){
+ it('pushes onto the internal $or condition', function(){
+ var m = mquery();
+ m.or({ 'Nightmare Before Christmas': true });
+ assert.deepEqual([{'Nightmare Before Christmas': true }], m._conditions.$or)
+ })
+ it('allows passing arrays', function(){
+ var m = mquery();
+ var arg = [{ 'Nightmare Before Christmas': true }, { x: 1 }];
+ m.or(arg);
+ assert.deepEqual(arg, m._conditions.$or)
+ })
+ it('allows calling multiple times', function(){
+ var m = mquery();
+ var arg = [{ looper: true }, { x: 1 }];
+ m.or(arg);
+ m.or({ y: 1 })
+ m.or([{ w: 'oo' }, { z: 'oo'} ])
+ assert.deepEqual([{looper:true},{x:1},{y:1},{w:'oo'},{z:'oo'}], m._conditions.$or)
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ m.or({ o: "k"}).where('name', 'table');
+ assert.deepEqual({ name: 'table', $or: [{ o: 'k' }] }, m._conditions)
+ })
+ })
+
+ describe('nor', function(){
+ it('pushes onto the internal $nor condition', function(){
+ var m = mquery();
+ m.nor({ 'Nightmare Before Christmas': true });
+ assert.deepEqual([{'Nightmare Before Christmas': true }], m._conditions.$nor)
+ })
+ it('allows passing arrays', function(){
+ var m = mquery();
+ var arg = [{ 'Nightmare Before Christmas': true }, { x: 1 }];
+ m.nor(arg);
+ assert.deepEqual(arg, m._conditions.$nor)
+ })
+ it('allows calling multiple times', function(){
+ var m = mquery();
+ var arg = [{ looper: true }, { x: 1 }];
+ m.nor(arg);
+ m.nor({ y: 1 })
+ m.nor([{ w: 'oo' }, { z: 'oo'} ])
+ assert.deepEqual([{looper:true},{x:1},{y:1},{w:'oo'},{z:'oo'}], m._conditions.$nor)
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ m.nor({ o: "k"}).where('name', 'table');
+ assert.deepEqual({ name: 'table', $nor: [{ o: 'k' }] }, m._conditions)
+ })
+ })
+
+ describe('and', function(){
+ it('pushes onto the internal $and condition', function(){
+ var m = mquery();
+ m.and({ 'Nightmare Before Christmas': true });
+ assert.deepEqual([{'Nightmare Before Christmas': true }], m._conditions.$and)
+ })
+ it('allows passing arrays', function(){
+ var m = mquery();
+ var arg = [{ 'Nightmare Before Christmas': true }, { x: 1 }];
+ m.and(arg);
+ assert.deepEqual(arg, m._conditions.$and)
+ })
+ it('allows calling multiple times', function(){
+ var m = mquery();
+ var arg = [{ looper: true }, { x: 1 }];
+ m.and(arg);
+ m.and({ y: 1 })
+ m.and([{ w: 'oo' }, { z: 'oo'} ])
+ assert.deepEqual([{looper:true},{x:1},{y:1},{w:'oo'},{z:'oo'}], m._conditions.$and)
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ m.and({ o: "k"}).where('name', 'table');
+ assert.deepEqual({ name: 'table', $and: [{ o: 'k' }] }, m._conditions)
+ })
+ })
+
+ function generalCondition (type) {
+ return function () {
+ it('accepts 2 args', function(){
+ var m = mquery()[type]('count', 3);
+ var check = {};
+ check['$' + type] = 3;
+ assert.deepEqual(m._conditions.count, check);
+ })
+ it('uses previously set `where` path if 1 arg passed', function(){
+ var m = mquery().where('count')[type](3);
+ var check = {};
+ check['$' + type] = 3;
+ assert.deepEqual(m._conditions.count, check);
+ })
+ it('throws if 1 arg was passed but no previous `where` was used', function(){
+ assert.throws(function(){
+ mquery()[type](3);
+ }, /must be used after where/);
+ })
+ it('is chainable', function(){
+ var m = mquery().where('count')[type](3).where('x', 8);
+ var check = {x: 8, count: {}};
+ check.count['$' + type] = 3;
+ assert.deepEqual(m._conditions, check);
+ })
+ it('overwrites previous value', function(){
+ var m = mquery().where('count')[type](3)[type](8);
+ var check = {};
+ check['$' + type] = 8;
+ assert.deepEqual(m._conditions.count, check);
+ })
+ }
+ }
+
+ 'gt gte lt lte ne in nin regex size maxDistance minDistance'.split(' ').forEach(function (type) {
+ describe(type, generalCondition(type))
+ })
+
+ describe('mod', function () {
+ describe('with 1 argument', function(){
+ it('requires a previous where()', function(){
+ assert.throws(function () {
+ mquery().mod([30, 10])
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('madmen').mod([10,20]);
+ assert.deepEqual(m._conditions, { madmen: { $mod: [10,20] }})
+ })
+ })
+
+ describe('with 2 arguments and second is non-Array', function(){
+ it('requires a previous where()', function(){
+ assert.throws(function () {
+ mquery().mod('x', 10)
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('madmen').mod(10, 20);
+ assert.deepEqual(m._conditions, { madmen: { $mod: [10,20] }})
+ })
+ })
+
+ it('with 2 arguments and second is an array', function(){
+ var m = mquery().mod('madmen', [10,20]);
+ assert.deepEqual(m._conditions, { madmen: { $mod: [10,20] }})
+ })
+
+ it('with 3 arguments', function(){
+ var m = mquery().mod('madmen', 10, 20);
+ assert.deepEqual(m._conditions, { madmen: { $mod: [10,20] }})
+ })
+
+ it('is chainable', function(){
+ var m = mquery().mod('madmen', 10, 20).where('x', 8);
+ var check = { madmen: { $mod: [10,20] }, x: 8};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+
+ describe('exists', function(){
+ it('with 0 args', function(){
+ it('throws if not used after where()', function(){
+ assert.throws(function () {
+ mquery().exists()
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('name').exists();
+ var check = { name: { $exists: true }};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+
+ describe('with 1 arg', function(){
+ describe('that is boolean', function(){
+ it('throws if not used after where()', function(){
+ assert.throws(function () {
+ mquery().exists()
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().exists('name', false);
+ var check = { name: { $exists: false }};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+ describe('that is not boolean', function(){
+ it('sets the value to `true`', function(){
+ var m = mquery().where('name').exists('yummy');
+ var check = { yummy: { $exists: true }};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+ })
+
+ describe('with 2 args', function(){
+ it('works', function(){
+ var m = mquery().exists('yummy', false);
+ var check = { yummy: { $exists: false }};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery().where('name').exists().find({ x: 1 });
+ var check = { name: { $exists: true }, x: 1};
+ assert.deepEqual(m._conditions, check);
+ })
+ })
+
+ describe('elemMatch', function(){
+ describe('with null/undefined first argument', function(){
+ assert.throws(function () {
+ mquery().elemMatch();
+ }, /Invalid argument/);
+ assert.throws(function () {
+ mquery().elemMatch(null);
+ }, /Invalid argument/);
+ assert.doesNotThrow(function () {
+ mquery().elemMatch('', {});
+ });
+ })
+
+ describe('with 1 argument', function(){
+ it('throws if not a function or object', function(){
+ assert.throws(function () {
+ mquery().elemMatch([]);
+ }, /Invalid argument/);
+ })
+
+ describe('that is an object', function(){
+ it('throws if no previous `where` was used', function(){
+ assert.throws(function () {
+ mquery().elemMatch({});
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('comment').elemMatch({ author: 'joe', votes: {$gte: 3 }});
+ assert.deepEqual({ comment: { $elemMatch: { author: 'joe', votes: {$gte: 3}}}}, m._conditions);
+ })
+ })
+ describe('that is a function', function(){
+ it('throws if no previous `where` was used', function(){
+ assert.throws(function () {
+ mquery().elemMatch(function(){});
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('comment').elemMatch(function (query) {
+ query.where({ author: 'joe', votes: {$gte: 3 }})
+ });
+ assert.deepEqual({ comment: { $elemMatch: { author: 'joe', votes: {$gte: 3}}}}, m._conditions);
+ })
+ })
+ })
+
+ describe('with 2 arguments', function(){
+ describe('and the 2nd is an object', function(){
+ it('works', function(){
+ var m = mquery().elemMatch('comment', { author: 'joe', votes: {$gte: 3 }});
+ assert.deepEqual({ comment: { $elemMatch: { author: 'joe', votes: {$gte: 3}}}}, m._conditions);
+ })
+ })
+ describe('and the 2nd is a function', function(){
+ it('works', function(){
+ var m = mquery().elemMatch('comment', function (query) {
+ query.where({ author: 'joe', votes: {$gte: 3 }})
+ });
+ assert.deepEqual({ comment: { $elemMatch: { author: 'joe', votes: {$gte: 3}}}}, m._conditions);
+ })
+ })
+ it('and the 2nd is not a function or object', function(){
+ assert.throws(function () {
+ mquery().elemMatch('comment', []);
+ }, /Invalid argument/);
+ })
+ })
+ })
+
+ describe('within', function(){
+ it('is chainable', function(){
+ var m = mquery();
+ assert.equal(m.where('a').within(), m);
+ })
+ describe('when called with arguments', function(){
+ it('must follow where()', function(){
+ assert.throws(function () {
+ mquery().within([]);
+ }, /must be used after where/);
+ })
+
+ describe('of length 1', function(){
+ it('throws if not a recognized shape', function(){
+ assert.throws(function () {
+ mquery().where('loc').within({});
+ }, /Invalid argument/)
+ assert.throws(function () {
+ mquery().where('loc').within(null);
+ }, /Invalid argument/)
+ })
+ it('delegates to circle when center exists', function(){
+ var m = mquery().where('loc').within({ center: [10,10], radius: 3 });
+ assert.deepEqual({ $geoWithin: {$center:[[10,10], 3]}}, m._conditions.loc);
+ })
+ it('delegates to box when exists', function(){
+ var m = mquery().where('loc').within({ box: [[10,10], [11,14]] });
+ assert.deepEqual({ $geoWithin: {$box:[[10,10], [11,14]]}}, m._conditions.loc);
+ })
+ it('delegates to polygon when exists', function(){
+ var m = mquery().where('loc').within({ polygon: [[10,10], [11,14],[10,9]] });
+ assert.deepEqual({ $geoWithin: {$polygon:[[10,10], [11,14],[10,9]]}}, m._conditions.loc);
+ })
+ it('delegates to geometry when exists', function(){
+ var m = mquery().where('loc').within({ type: 'Polygon', coordinates: [[10,10], [11,14],[10,9]] });
+ assert.deepEqual({ $geoWithin: {$geometry: {type:'Polygon', coordinates: [[10,10], [11,14],[10,9]]}}}, m._conditions.loc);
+ })
+ })
+
+ describe('of length 2', function(){
+ it('delegates to box()', function(){
+ var m = mquery().where('loc').within([1,2],[2,5]);
+ assert.deepEqual(m._conditions.loc, { $geoWithin: { $box: [[1,2],[2,5]]}});
+ })
+ })
+
+ describe('of length > 2', function(){
+ it('delegates to polygon()', function(){
+ var m = mquery().where('loc').within([1,2],[2,5],[2,4],[1,3]);
+ assert.deepEqual(m._conditions.loc, { $geoWithin: { $polygon: [[1,2],[2,5],[2,4],[1,3]]}});
+ })
+ })
+ })
+ })
+
+ describe('geoWithin', function(){
+ before(function(){
+ mquery.use$geoWithin = false;
+ })
+ after(function(){
+ mquery.use$geoWithin = true;
+ })
+ describe('when called with arguments', function(){
+ describe('of length 1', function(){
+ it('delegates to circle when center exists', function(){
+ var m = mquery().where('loc').within({ center: [10,10], radius: 3 });
+ assert.deepEqual({ $within: {$center:[[10,10], 3]}}, m._conditions.loc);
+ })
+ it('delegates to box when exists', function(){
+ var m = mquery().where('loc').within({ box: [[10,10], [11,14]] });
+ assert.deepEqual({ $within: {$box:[[10,10], [11,14]]}}, m._conditions.loc);
+ })
+ it('delegates to polygon when exists', function(){
+ var m = mquery().where('loc').within({ polygon: [[10,10], [11,14],[10,9]] });
+ assert.deepEqual({ $within: {$polygon:[[10,10], [11,14],[10,9]]}}, m._conditions.loc);
+ })
+ it('delegates to geometry when exists', function(){
+ var m = mquery().where('loc').within({ type: 'Polygon', coordinates: [[10,10], [11,14],[10,9]] });
+ assert.deepEqual({ $within: {$geometry: {type:'Polygon', coordinates: [[10,10], [11,14],[10,9]]}}}, m._conditions.loc);
+ })
+ })
+
+ describe('of length 2', function(){
+ it('delegates to box()', function(){
+ var m = mquery().where('loc').within([1,2],[2,5]);
+ assert.deepEqual(m._conditions.loc, { $within: { $box: [[1,2],[2,5]]}});
+ })
+ })
+
+ describe('of length > 2', function(){
+ it('delegates to polygon()', function(){
+ var m = mquery().where('loc').within([1,2],[2,5],[2,4],[1,3]);
+ assert.deepEqual(m._conditions.loc, { $within: { $polygon: [[1,2],[2,5],[2,4],[1,3]]}});
+ })
+ })
+ })
+ })
+
+ describe('box', function(){
+ describe('with 1 argument', function(){
+ it('throws', function(){
+ assert.throws(function () {
+ mquery().box('sometihng');
+ }, /Invalid argument/);
+ })
+ })
+ describe('with > 3 arguments', function(){
+ it('throws', function(){
+ assert.throws(function () {
+ mquery().box(1,2,3,4);
+ }, /Invalid argument/);
+ })
+ })
+
+ describe('with 2 arguments', function(){
+ it('throws if not used after where()', function(){
+ assert.throws(function () {
+ mquery().box([],[]);
+ }, /must be used after where/);
+ })
+ it('works', function(){
+ var m = mquery().where('loc').box([1,2],[3,4]);
+ assert.deepEqual(m._conditions.loc, { $geoWithin: { $box: [[1,2],[3,4]] }});
+ })
+ })
+
+ describe('with 3 arguments', function(){
+ it('works', function(){
+ var m = mquery().box('loc', [1,2],[3,4]);
+ assert.deepEqual(m._conditions.loc, { $geoWithin: { $box: [[1,2],[3,4]] }});
+ })
+ })
+ })
+
+ describe('polygon', function(){
+ describe('when first argument is not a string', function(){
+ it('throws if not used after where()', function(){
+ assert.throws(function () {
+ mquery().polygon({});
+ }, /must be used after where/);
+
+ assert.doesNotThrow(function () {
+ mquery().where('loc').polygon([1,2], [2,3], [3,6]);
+ });
+ })
+
+ it('assigns arguments to within polygon condition', function(){
+ var m = mquery().where('loc').polygon([1,2], [2,3], [3,6]);
+ assert.deepEqual(m._conditions, { loc: {$geoWithin: {$polygon: [[1,2],[2,3],[3,6]]}} });
+ })
+ })
+
+ describe('when first arg is a string', function(){
+ it('assigns remaining arguments to within polygon condition', function(){
+ var m = mquery().polygon('loc', [1,2], [2,3], [3,6]);
+ assert.deepEqual(m._conditions, { loc: {$geoWithin: {$polygon: [[1,2],[2,3],[3,6]]}} });
+ })
+ })
+ })
+
+ describe('circle', function(){
+ describe('with one arg', function(){
+ it('must follow where()', function(){
+ assert.throws(function () {
+ mquery().circle('x');
+ }, /must be used after where/);
+ assert.doesNotThrow(function () {
+ mquery().where('loc').circle({center:[0,0], radius: 3 });
+ });
+ })
+ it('works', function(){
+ var m = mquery().where('loc').circle({center:[0,0], radius: 3 });
+ assert.deepEqual(m._conditions, { loc: { $geoWithin: {$center: [[0,0],3] }}});
+ })
+ })
+ describe('with 3 args', function(){
+ it('throws', function(){
+ assert.throws(function () {
+ mquery().where('loc').circle(1,2,3);
+ }, /Invalid argument/);
+ })
+ })
+ describe('requires radius and center', function(){
+ assert.throws(function () {
+ mquery().circle('loc', { center: 1 });
+ }, /center and radius are required/);
+ assert.throws(function () {
+ mquery().circle('loc', { radius: 1 });
+ }, /center and radius are required/);
+ assert.doesNotThrow(function () {
+ mquery().circle('loc', { center: [1,2], radius: 1 });
+ });
+ })
+ })
+
+ describe('geometry', function(){
+ // within + intersects
+ var point = { type: 'Point', coordinates: [[0,0],[1,1]] };
+
+ it('must be called after within or intersects', function(done){
+ assert.throws(function () {
+ mquery().where('a').geometry(point);
+ }, /must come after/);
+
+ assert.doesNotThrow(function () {
+ mquery().where('a').within().geometry(point);
+ });
+
+ assert.doesNotThrow(function () {
+ mquery().where('a').intersects().geometry(point);
+ });
+
+ done();
+ })
+
+ describe('when called with one argument', function(){
+ describe('after within()', function(){
+ it('and arg quacks like geoJSON', function(done){
+ var m = mquery().where('a').within().geometry(point);
+ assert.deepEqual({ a: { $geoWithin: { $geometry: point }}}, m._conditions);
+ done();
+ })
+ })
+
+ describe('after intersects()', function(){
+ it('and arg quacks like geoJSON', function(done){
+ var m = mquery().where('a').intersects().geometry(point);
+ assert.deepEqual({ a: { $geoIntersects: { $geometry: point }}}, m._conditions);
+ done();
+ })
+ })
+
+ it('and arg does not quack like geoJSON', function(done){
+ assert.throws(function () {
+ mquery().where('b').within().geometry({type:1, coordinates:2});
+ }, /Invalid argument/);
+ done();
+ })
+ })
+
+ describe('when called with zero arguments', function(){
+ it('throws', function(done){
+ assert.throws(function () {
+ mquery().where('a').within().geometry();
+ }, /Invalid argument/);
+
+ done();
+ })
+ })
+
+ describe('when called with more than one arguments', function(){
+ it('throws', function(done){
+ assert.throws(function () {
+ mquery().where('a').within().geometry({type:'a',coordinates:[]}, 2);
+ }, /Invalid argument/);
+ done();
+ })
+ })
+ })
+
+ describe('intersects', function(){
+ it('must be used after where()', function(done){
+ var m = mquery();
+ assert.throws(function () {
+ m.intersects();
+ }, /must be used after where/)
+ done();
+ })
+
+ it('sets geo comparison to "$intersects"', function(done){
+ var n = mquery().where('a').intersects();
+ assert.equal('$geoIntersects', n._geoComparison);
+ done();
+ })
+
+ it('is chainable', function(){
+ var m = mquery();
+ assert.equal(m.where('a').intersects(), m);
+ })
+
+ it('calls geometry if argument quacks like geojson', function(done){
+ var m = mquery();
+ var o = { type: 'LineString', coordinates: [[0,1],[3,40]] };
+ var ran = false;
+
+ m.geometry = function (arg) {
+ ran = true;
+ assert.deepEqual(o, arg);
+ }
+
+ m.where('a').intersects(o);
+ assert.ok(ran);
+
+ done();
+ })
+
+ it('throws if argument is not geometry-like', function(done){
+ var m = mquery().where('a');
+
+ assert.throws(function () {
+ m.intersects(null);
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects(undefined);
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects(false);
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects({});
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects([]);
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects(function(){});
+ }, /Invalid argument/);
+
+ assert.throws(function () {
+ m.intersects(NaN);
+ }, /Invalid argument/);
+
+ done();
+ })
+ })
+
+ describe('near', function(){
+ // near nearSphere
+ describe('with 0 args', function(){
+ it('is compatible with geometry()', function(done){
+ var q = mquery().where('x').near().geometry({ type: 'Point', coordinates: [180, 11] });
+ assert.deepEqual({ $near: {$geometry: {type:'Point', coordinates: [180,11]}}}, q._conditions.x);
+ done();
+ })
+ })
+
+ describe('with 1 arg', function(){
+ it('throws if not used after where()', function(){
+ assert.throws(function () {
+ mquery().near(1);
+ }, /must be used after where/)
+ })
+ it('does not throw if used after where()', function(){
+ assert.doesNotThrow(function () {
+ mquery().where('loc').near({center:[1,1]});
+ })
+ })
+ })
+ describe('with > 2 args', function(){
+ it('throws', function(){
+ assert.throws(function () {
+ mquery().near(1,2,3);
+ }, /Invalid argument/)
+ })
+ })
+
+ it('creates $geometry args for GeoJSON', function(){
+ var m = mquery().where('loc').near({ center: { type: 'Point', coordinates: [10,10] }});
+ assert.deepEqual({ $near: {$geometry: {type:'Point', coordinates: [10,10]}}}, m._conditions.loc);
+ })
+
+ it('expects `center`', function(){
+ assert.throws(function () {
+ mquery().near('loc', { maxDistance: 3 });
+ }, /center is required/)
+ assert.doesNotThrow(function () {
+ mquery().near('loc', { center: [3,4] });
+ })
+ })
+
+ it('accepts spherical conditions', function(){
+ var m = mquery().where('loc').near({ center: [1,2], spherical: true });
+ assert.deepEqual(m._conditions, { loc: { $nearSphere: [1,2]}});
+ })
+
+ it('is non-spherical by default', function(){
+ var m = mquery().where('loc').near({ center: [1,2] });
+ assert.deepEqual(m._conditions, { loc: { $near: [1,2]}});
+ })
+
+ it('supports maxDistance', function(){
+ var m = mquery().where('loc').near({ center: [1,2], maxDistance:4 });
+ assert.deepEqual(m._conditions, { loc: { $near: [1,2], $maxDistance: 4}});
+ })
+
+ it('supports minDistance', function(){
+ var m = mquery().where('loc').near({ center: [1,2], minDistance:4 });
+ assert.deepEqual(m._conditions, { loc: { $near: [1,2], $minDistance: 4}});
+ })
+
+ it('is chainable', function(){
+ var m = mquery().where('loc').near({ center: [1,2], maxDistance:4 }).find({ x: 1 });
+ assert.deepEqual(m._conditions, { loc: { $near: [1,2], $maxDistance: 4}, x: 1});
+ })
+
+ describe('supports passing GeoJSON, gh-13', function(){
+ it('with center', function(){
+ var m = mquery().where('loc').near({
+ center: { type: 'Point', coordinates: [1,1] }
+ , maxDistance: 2
+ });
+
+ var expect = {
+ loc: {
+ $near: {
+ $geometry: {
+ type: 'Point'
+ , coordinates : [1,1]
+ }
+ , $maxDistance : 2
+ }
+ }
+ }
+
+ assert.deepEqual(m._conditions, expect);
+ })
+ })
+ })
+
+ // fields
+
+ describe('select', function(){
+ describe('with 0 args', function(){
+ it('is chainable', function(){
+ var m = mquery()
+ assert.equal(m, m.select());
+ })
+ })
+
+ it('accepts an object', function(){
+ var o = { x: 1, y: 1 }
+ var m = mquery().select(o);
+ assert.deepEqual(m._fields, o);
+ })
+
+ it('accepts a string', function(){
+ var o = 'x -y';
+ var m = mquery().select(o);
+ assert.deepEqual(m._fields, { x: 1, y: 0 });
+ })
+
+ it('does not accept an array', function(done){
+ assert.throws(function () {
+ var o = ['x', '-y'];
+ var m = mquery().select(o);
+ }, /Invalid select/);
+ done();
+ })
+
+ it('merges previous arguments', function(){
+ var o = { x: 1, y: 0, a: 1 }
+ var m = mquery().select(o);
+ m.select('z -u w').select({ x: 0 })
+ assert.deepEqual(m._fields, {
+ x: 0
+ , y: 0
+ , z: 1
+ , u: 0
+ , w: 1
+ , a: 1
+ });
+ })
+
+ it('rejects non-string, object, arrays', function(){
+ assert.throws(function () {
+ mquery().select(function(){});
+ }, /Invalid select\(\) argument/);
+ })
+
+ it('accepts arguments objects', function(){
+ var m = mquery();
+ function t () {
+ m.select(arguments);
+ assert.deepEqual(m._fields, { x: 1, y: 0 });
+ }
+ t('x', '-y');
+ })
+
+ noDistinct('select');
+ })
+
+ describe('selected', function() {
+ it('returns true when fields have been selected', function(done) {
+ var m = mquery().select({ name: 1 });
+ assert.ok(m.selected());
+
+ var m = mquery().select('name');
+ assert.ok(m.selected());
+
+ done();
+ });
+
+ it('returns false when no fields have been selected', function(done) {
+ var m = mquery();
+ assert.strictEqual(false, m.selected());
+ done();
+ });
+ });
+
+ describe('selectedInclusively', function() {
+ describe('returns false', function(){
+ it('when no fields have been selected', function(done) {
+ assert.strictEqual(false, mquery().selectedInclusively());
+ assert.equal(false, mquery().select({}).selectedInclusively());
+ done();
+ });
+ it('when any fields have been excluded', function(done) {
+ assert.strictEqual(false, mquery().select('-name').selectedInclusively());
+ assert.strictEqual(false, mquery().select({ name: 0 }).selectedInclusively());
+ assert.strictEqual(false, mquery().select('name bio -_id').selectedInclusively());
+ assert.strictEqual(false, mquery().select({ name: 1, _id: 0 }).selectedInclusively());
+ done();
+ });
+ it('when using $meta', function(done) {
+ assert.strictEqual(false, mquery().select({ name: { $meta: 'textScore' } }).selectedInclusively());
+ done();
+ });
+ });
+
+ describe('returns true', function() {
+ it('when fields have been included', function(done) {
+ assert.equal(true, mquery().select('name').selectedInclusively());
+ assert.equal(true, mquery().select({ name:1 }).selectedInclusively());
+ done();
+ });
+ });
+ });
+
+ describe('selectedExclusively', function() {
+ describe('returns false', function(){
+ it('when no fields have been selected', function(done) {
+ assert.equal(false, mquery().selectedExclusively());
+ assert.equal(false, mquery().select({}).selectedExclusively());
+ done();
+ });
+ it('when fields have only been included', function(done) {
+ assert.equal(false, mquery().select('name').selectedExclusively());
+ assert.equal(false, mquery().select({ name: 1 }).selectedExclusively());
+ done();
+ });
+ });
+
+ describe('returns true', function() {
+ it('when any field has been excluded', function(done) {
+ assert.equal(true, mquery().select('-name').selectedExclusively());
+ assert.equal(true, mquery().select({ name:0 }).selectedExclusively());
+ assert.equal(true, mquery().select('-_id').selectedExclusively());
+ assert.strictEqual(true, mquery().select('name bio -_id').selectedExclusively());
+ assert.strictEqual(true, mquery().select({ name: 1, _id: 0 }).selectedExclusively());
+ done();
+ });
+ });
+ });
+
+ describe('slice', function(){
+ describe('with 0 args', function(){
+ it('is chainable', function(){
+ var m = mquery()
+ assert.equal(m, m.slice());
+ })
+ it('is a noop', function(){
+ var m = mquery().slice();
+ assert.deepEqual(m._fields, undefined);
+ })
+ })
+
+ describe('with 1 arg', function(){
+ it('throws if not called after where()', function(){
+ assert.throws(function () {
+ mquery().slice(1);
+ }, /must be used after where/);
+ assert.doesNotThrow(function () {
+ mquery().where('a').slice(1);
+ });
+ })
+ it('that is a number', function(){
+ var query = mquery();
+ query.where('collection').slice(5);
+ assert.deepEqual(query._fields, {collection: {$slice: 5}});
+ })
+ it('that is an array', function(){
+ var query = mquery();
+ query.where('collection').slice([5,10]);
+ assert.deepEqual(query._fields, {collection: {$slice: [5,10]}});
+ })
+ it('that is an object', function() {
+ var query = mquery();
+ query.slice({ collection: [5, 10] });
+ assert.deepEqual(query._fields, {collection: {$slice: [5,10]}});
+ })
+ })
+
+ describe('with 2 args', function(){
+ describe('and first is a number', function(){
+ it('throws if not called after where', function(){
+ assert.throws(function () {
+ mquery().slice(2,3);
+ }, /must be used after where/);
+ })
+ it('does not throw if used after where', function(){
+ var query = mquery();
+ query.where('collection').slice(2,3);
+ assert.deepEqual(query._fields, {collection: {$slice: [2,3]}});
+ })
+ })
+ it('and first is not a number', function(){
+ var query = mquery().slice('collection', [-5, 2]);
+ assert.deepEqual(query._fields, {collection: {$slice: [-5,2]}});
+ })
+ })
+
+ describe('with 3 args', function(){
+ it('works', function(){
+ var query = mquery();
+ query.slice('collection', 14, 10);
+ assert.deepEqual(query._fields, {collection: {$slice: [14, 10]}});
+ })
+ })
+
+ noDistinct('slice');
+ no('count', 'slice');
+ })
+
+ // options
+
+ describe('sort', function(){
+ describe('with 0 args', function(){
+ it('chains', function(){
+ var m = mquery();
+ assert.equal(m, m.sort());
+ })
+ it('has no affect', function(){
+ var m = mquery();
+ assert.equal(m.options.sort, undefined);
+ })
+ });
+
+ it('works', function(){
+ var query = mquery();
+ query.sort('a -c b');
+ assert.deepEqual(query.options.sort, { a : 1, b: 1, c : -1});
+
+ query = mquery();
+ query.sort({'a': 1, 'c': -1, 'b': 'asc', e: 'descending', f: 'ascending'});
+ assert.deepEqual(query.options.sort, {'a': 1, 'c': -1, 'b': 1, 'e': -1, 'f': 1});
+
+ query = mquery();
+ var e= undefined;
+
+ e= undefined;
+ try {
+ query.sort('a', 1, 'c', -1, 'b', 1);
+ } catch (err) {
+ e= err;
+ }
+ assert.ok(e, 'uh oh. no error was thrown');
+ assert.equal(e.message, 'Invalid sort() argument. Must be a string, object, or array.');
+ });
+
+ it('handles $meta sort options', function(){
+ var query = mquery();
+ query.sort({ score: { $meta : "textScore" } });
+ assert.deepEqual(query.options.sort, { score : { $meta : "textScore" } });
+ });
+
+ it('array syntax', function(){
+ var query = mquery();
+ query.sort([['field', 1], ['test', -1]]);
+ assert.deepEqual(query.options.sort, [['field', 1], ['test', -1]]);
+ });
+
+ it('throws with mixed array/object syntax', function(){
+ var query = mquery();
+ assert.throws(function() {
+ query.sort({ field: 1 }).sort([['test', -1]]);
+ }, /Can't mix sort syntaxes/);
+ assert.throws(function() {
+ query.sort([['field', 1]]).sort({ test: 1 });
+ }, /Can't mix sort syntaxes/);
+ });
+ })
+
+ function simpleOption (type, options) {
+ describe(type, function(){
+ it('sets the ' + type + ' option', function(){
+ var m = mquery()[type](2);
+ var optionName = options.name || type;
+ assert.equal(2, m.options[optionName]);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ assert.equal(m[type](3), m);
+ })
+
+ if (!options.distinct) noDistinct(type);
+ if (!options.count) no('count', type);
+ })
+ }
+
+ var negated = {
+ limit: {distinct: false, count: true}
+ , skip: {distinct: false, count: true}
+ , maxScan: {distinct: false, count: false}
+ , batchSize: {distinct: false, count: false}
+ , maxTime: {distinct: true, count: true, name: 'maxTimeMS' }
+ , comment: {distinct: false, count: false}
+ };
+ Object.keys(negated).forEach(function (key) {
+ simpleOption(key, negated[key]);
+ })
+
+ describe('snapshot', function(){
+ it('works', function(){
+ var query = mquery();
+ query.snapshot();
+ assert.equal(true, query.options.snapshot);
+
+ var query = mquery()
+ query.snapshot(true);
+ assert.equal(true, query.options.snapshot);
+
+ var query = mquery()
+ query.snapshot(false);
+ assert.equal(false, query.options.snapshot);
+ })
+ noDistinct('snapshot');
+ no('count', 'snapshot');
+ })
+
+ describe('hint', function(){
+ it('accepts an object', function(){
+ var query2 = mquery();
+ query2.hint({'a': 1, 'b': -1});
+ assert.deepEqual(query2.options.hint, {'a': 1, 'b': -1});
+ })
+
+ it('rejects everything else', function(){
+ assert.throws(function(){
+ mquery().hint('c');
+ }, /Invalid hint./);
+ assert.throws(function(){
+ mquery().hint(['c']);
+ }, /Invalid hint./);
+ assert.throws(function(){
+ mquery().hint(1);
+ }, /Invalid hint./);
+ })
+
+ describe('does not have side affects', function(){
+ it('on invalid arg', function(){
+ var m = mquery();
+ try {
+ m.hint(1);
+ } catch (err) {
+ // ignore
+ }
+ assert.equal(undefined, m.options.hint);
+ })
+ it('on missing arg', function(){
+ var m = mquery().hint();
+ assert.equal(undefined, m.options.hint);
+ })
+ })
+
+ noDistinct('hint');
+ })
+
+ describe('slaveOk', function(){
+ it('works', function(){
+ var query = mquery();
+ query.slaveOk();
+ assert.equal(true, query.options.slaveOk);
+
+ var query = mquery()
+ query.slaveOk(true);
+ assert.equal(true, query.options.slaveOk);
+
+ var query = mquery()
+ query.slaveOk(false);
+ assert.equal(false, query.options.slaveOk);
+ })
+ })
+
+ describe('read', function(){
+ it('sets associated readPreference option', function(){
+ var m = mquery();
+ m.read('p');
+ assert.equal('primary', m.options.readPreference);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ assert.equal(m, m.read('sp'));
+ })
+ })
+
+ describe('tailable', function(){
+ it('works', function(){
+ var query = mquery();
+ query.tailable();
+ assert.equal(true, query.options.tailable);
+
+ var query = mquery()
+ query.tailable(true);
+ assert.equal(true, query.options.tailable);
+
+ var query = mquery()
+ query.tailable(false);
+ assert.equal(false, query.options.tailable);
+ })
+ it('is chainable', function(){
+ var m = mquery();
+ assert.equal(m, m.tailable());
+ })
+ noDistinct('tailable');
+ no('count', 'tailable');
+ })
+
+ // query utilities
+
+ describe('merge', function(){
+ describe('with falsy arg', function(){
+ it('returns itself', function(){
+ var m = mquery();
+ assert.equal(m, m.merge());
+ assert.equal(m, m.merge(null));
+ assert.equal(m, m.merge(0));
+ })
+ })
+ describe('with an argument', function(){
+ describe('that is not a query or plain object', function(){
+ it('throws', function(){
+ assert.throws(function () {
+ mquery().merge([]);
+ }, /Invalid argument/);
+ assert.throws(function () {
+ mquery().merge('merge');
+ }, /Invalid argument/);
+ assert.doesNotThrow(function () {
+ mquery().merge({});
+ }, /Invalid argument/);
+ })
+ })
+
+ describe('that is a query', function(){
+ it('merges conditions, field selection, and options', function(){
+ var m = mquery({ x: 'hi' }, { select: 'x y', another: true })
+ var n = mquery().merge(m);
+ assert.deepEqual(n._conditions, m._conditions);
+ assert.deepEqual(n._fields, m._fields);
+ assert.deepEqual(n.options, m.options);
+ })
+ it('clones update arguments', function(done){
+ var original = { $set: { iTerm: true }}
+ var m = mquery().update(original);
+ var n = mquery().merge(m);
+ m.update({ $set: { x: 2 }})
+ assert.notDeepEqual(m._update, n._update);
+ done();
+ })
+ it('is chainable', function(){
+ var m = mquery({ x: 'hi' });
+ var n = mquery();
+ assert.equal(n, n.merge(m));
+ })
+ })
+
+ describe('that is an object', function(){
+ it('merges', function(){
+ var m = { x: 'hi' };
+ var n = mquery().merge(m);
+ assert.deepEqual(n._conditions, { x: 'hi' });
+ })
+ it('clones update arguments', function(done){
+ var original = { $set: { iTerm: true }}
+ var m = mquery().update(original);
+ var n = mquery().merge(original);
+ m.update({ $set: { x: 2 }})
+ assert.notDeepEqual(m._update, n._update);
+ done();
+ })
+ it('is chainable', function(){
+ var m = { x: 'hi' };
+ var n = mquery();
+ assert.equal(n, n.merge(m));
+ })
+ })
+ })
+ })
+
+ // queries
+
+ describe('find', function(){
+ describe('with no callback', function(){
+ it('does not execute', function(){
+ var m = mquery();
+ assert.doesNotThrow(function () {
+ m.find()
+ })
+ assert.doesNotThrow(function () {
+ m.find({ x: 1 })
+ })
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery().find({ x: 1 }).find().find({ y: 2 });
+ assert.deepEqual(m._conditions, {x:1,y:2});
+ })
+
+ it('merges other queries', function(){
+ var m = mquery({ name: 'mquery' });
+ m.tailable();
+ m.select('_id');
+ var a = mquery().find(m);
+ assert.deepEqual(a._conditions, m._conditions);
+ assert.deepEqual(a.options, m.options);
+ assert.deepEqual(a._fields, m._fields);
+ })
+
+ describe('executes', function(){
+ before(function (done) {
+ col.insert({ name: 'mquery' }, { safe: true }, done);
+ });
+
+ after(function(done){
+ col.remove({ name: 'mquery' }, done);
+ })
+
+ it('when criteria is passed with a callback', function(done){
+ mquery(col).find({ name: 'mquery' }, function (err, docs) {
+ assert.ifError(err);
+ assert.equal(1, docs.length);
+ done();
+ })
+ })
+ it('when Query is passed with a callback', function(done){
+ var m = mquery({ name: 'mquery' });
+ mquery(col).find(m, function (err, docs) {
+ assert.ifError(err);
+ assert.equal(1, docs.length);
+ done();
+ })
+ })
+ it('when just a callback is passed', function(done){
+ mquery({ name: 'mquery' }).collection(col).find(function (err, docs) {
+ assert.ifError(err);
+ assert.equal(1, docs.length);
+ done();
+ });
+ })
+ })
+ })
+
+ describe('findOne', function(){
+ describe('with no callback', function(){
+ it('does not execute', function(){
+ var m = mquery();
+ assert.doesNotThrow(function () {
+ m.findOne()
+ })
+ assert.doesNotThrow(function () {
+ m.findOne({ x: 1 })
+ })
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.findOne({ x: 1 }).findOne().findOne({ y: 2 });
+ assert.equal(m, n);
+ assert.deepEqual(m._conditions, {x:1,y:2});
+ assert.equal('findOne', m.op);
+ })
+
+ it('merges other queries', function(){
+ var m = mquery({ name: 'mquery' });
+ m.read('nearest');
+ m.select('_id');
+ var a = mquery().findOne(m);
+ assert.deepEqual(a._conditions, m._conditions);
+ assert.deepEqual(a.options, m.options);
+ assert.deepEqual(a._fields, m._fields);
+ })
+
+ describe('executes', function(){
+ before(function (done) {
+ col.insert({ name: 'mquery findone' }, { safe: true }, done);
+ });
+
+ after(function(done){
+ col.remove({ name: 'mquery findone' }, done);
+ })
+
+ it('when criteria is passed with a callback', function(done){
+ mquery(col).findOne({ name: 'mquery findone' }, function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ assert.equal('mquery findone', doc.name);
+ done();
+ })
+ })
+ it('when Query is passed with a callback', function(done){
+ var m = mquery(col).where({ name: 'mquery findone' });
+ mquery(col).findOne(m, function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ assert.equal('mquery findone', doc.name);
+ done();
+ })
+ })
+ it('when just a callback is passed', function(done){
+ mquery({ name: 'mquery findone' }).collection(col).findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ assert.equal('mquery findone', doc.name);
+ done();
+ });
+ })
+ })
+ })
+
+ describe('count', function(){
+ describe('with no callback', function(){
+ it('does not execute', function(){
+ var m = mquery();
+ assert.doesNotThrow(function () {
+ m.count()
+ })
+ assert.doesNotThrow(function () {
+ m.count({ x: 1 })
+ })
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery();
+ var n = m.count({ x: 1 }).count().count({ y: 2 });
+ assert.equal(m, n);
+ assert.deepEqual(m._conditions, {x:1,y:2});
+ assert.equal('count', m.op);
+ })
+
+ it('merges other queries', function(){
+ var m = mquery({ name: 'mquery' });
+ m.read('nearest');
+ m.select('_id');
+ var a = mquery().count(m);
+ assert.deepEqual(a._conditions, m._conditions);
+ assert.deepEqual(a.options, m.options);
+ assert.deepEqual(a._fields, m._fields);
+ })
+
+ describe('executes', function(){
+ before(function (done) {
+ col.insert({ name: 'mquery count' }, { safe: true }, done);
+ });
+
+ after(function(done){
+ col.remove({ name: 'mquery count' }, done);
+ })
+
+ it('when criteria is passed with a callback', function(done){
+ mquery(col).count({ name: 'mquery count' }, function (err, count) {
+ assert.ifError(err);
+ assert.ok(count);
+ assert.ok(1 === count);
+ done();
+ })
+ })
+ it('when Query is passed with a callback', function(done){
+ var m = mquery({ name: 'mquery count' });
+ mquery(col).count(m, function (err, count) {
+ assert.ifError(err);
+ assert.ok(count);
+ assert.ok(1 === count);
+ done();
+ })
+ })
+ it('when just a callback is passed', function(done){
+ mquery({ name: 'mquery count' }).collection(col).count(function (err, count) {
+ assert.ifError(err);
+ assert.ok(1 === count);
+ done();
+ });
+ })
+ })
+
+ describe('validates its option', function(){
+ it('sort', function(done){
+ assert.doesNotThrow(function(){
+ var m = mquery().sort('x').count();
+ });
+ done();
+ })
+
+ it('select', function(done){
+ assert.throws(function(){
+ var m = mquery().select('x').count();
+ }, /field selection and slice cannot be used with count/);
+ done();
+ })
+
+ it('slice', function(done){
+ assert.throws(function(){
+ var m = mquery().where('x').slice(-3).count();
+ }, /field selection and slice cannot be used with count/);
+ done();
+ })
+
+ it('limit', function(done){
+ assert.doesNotThrow(function(){
+ var m = mquery().limit(3).count();
+ })
+ done();
+ })
+
+ it('skip', function(done){
+ assert.doesNotThrow(function(){
+ var m = mquery().skip(3).count();
+ })
+ done();
+ })
+
+ it('batchSize', function(done){
+ assert.throws(function(){
+ var m = mquery({}, { batchSize: 3 }).count();
+ }, /batchSize cannot be used with count/);
+ done();
+ })
+
+ it('comment', function(done){
+ assert.throws(function(){
+ var m = mquery().comment('mquery').count();
+ }, /comment cannot be used with count/);
+ done();
+ })
+
+ it('maxScan', function(done){
+ assert.throws(function(){
+ var m = mquery().maxScan(300).count();
+ }, /maxScan cannot be used with count/);
+ done();
+ })
+
+ it('snapshot', function(done){
+ assert.throws(function(){
+ var m = mquery().snapshot().count();
+ }, /snapshot cannot be used with count/);
+ done();
+ })
+
+ it('tailable', function(done){
+ assert.throws(function(){
+ var m = mquery().tailable().count();
+ }, /tailable cannot be used with count/);
+ done();
+ })
+ })
+ })
+
+ describe('distinct', function(){
+ describe('with no callback', function(){
+ it('does not execute', function(){
+ var m = mquery();
+ assert.doesNotThrow(function () {
+ m.distinct()
+ })
+ assert.doesNotThrow(function () {
+ m.distinct('name')
+ })
+ assert.doesNotThrow(function () {
+ m.distinct({ name: 'mquery distinct' })
+ })
+ assert.doesNotThrow(function () {
+ m.distinct({ name: 'mquery distinct' }, 'name')
+ })
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery({x:1}).distinct('name');
+ var n = m.distinct({y:2});
+ assert.equal(m, n);
+ assert.deepEqual(n._conditions, {x:1, y:2});
+ assert.equal('name', n._distinct);
+ assert.equal('distinct', n.op);
+ });
+
+ it('overwrites field', function(){
+ var m = mquery({ name: 'mquery' }).distinct('name');
+ m.distinct('rename');
+ assert.equal(m._distinct, 'rename');
+ m.distinct({x:1}, 'renamed');
+ assert.equal(m._distinct, 'renamed');
+ })
+
+ it('merges other queries', function(){
+ var m = mquery().distinct({ name: 'mquery' }, 'age')
+ m.read('nearest');
+ var a = mquery().distinct(m);
+ assert.deepEqual(a._conditions, m._conditions);
+ assert.deepEqual(a.options, m.options);
+ assert.deepEqual(a._fields, m._fields);
+ assert.deepEqual(a._distinct, m._distinct);
+ })
+
+ describe('executes', function(){
+ before(function (done) {
+ col.insert({ name: 'mquery distinct', age: 1 }, { safe: true }, done);
+ });
+
+ after(function(done){
+ col.remove({ name: 'mquery distinct' }, done);
+ })
+
+ it('when distinct arg is passed with a callback', function(done){
+ mquery(col).distinct('distinct', function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ done();
+ })
+ })
+ describe('when criteria is passed with a callback', function(){
+ it('if distinct arg was declared', function(done){
+ mquery(col).distinct('age').distinct({ name: 'mquery distinct' }, function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ done();
+ })
+ })
+ it('but not if distinct arg was not declared', function(){
+ assert.throws(function(){
+ mquery(col).distinct({ name: 'mquery distinct' }, function(){})
+ }, /No value for `distinct`/)
+ })
+ })
+ describe('when Query is passed with a callback', function(){
+ var m = mquery({ name: 'mquery distinct' });
+ it('if distinct arg was declared', function(done){
+ mquery(col).distinct('age').distinct(m, function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ done();
+ })
+ })
+ it('but not if distinct arg was not declared', function(){
+ assert.throws(function(){
+ mquery(col).distinct(m, function(){})
+ }, /No value for `distinct`/)
+ })
+ })
+ describe('when just a callback is passed', function(done){
+ it('if distinct arg was declared', function(done){
+ var m = mquery({ name: 'mquery distinct' });
+ m.collection(col);
+ m.distinct('age');
+ m.distinct(function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ done();
+ });
+ })
+ it('but not if no distinct arg was declared', function(){
+ var m = mquery();
+ m.collection(col);
+ assert.throws(function () {
+ m.distinct(function(){});
+ }, /No value for `distinct`/);
+ })
+ })
+ })
+
+ describe('validates its option', function(){
+ it('sort', function(done){
+ assert.throws(function(){
+ var m = mquery().sort('x').distinct();
+ }, /sort cannot be used with distinct/);
+ done();
+ })
+
+ it('select', function(done){
+ assert.throws(function(){
+ var m = mquery().select('x').distinct();
+ }, /field selection and slice cannot be used with distinct/);
+ done();
+ })
+
+ it('slice', function(done){
+ assert.throws(function(){
+ var m = mquery().where('x').slice(-3).distinct();
+ }, /field selection and slice cannot be used with distinct/);
+ done();
+ })
+
+ it('limit', function(done){
+ assert.throws(function(){
+ var m = mquery().limit(3).distinct();
+ }, /limit cannot be used with distinct/);
+ done();
+ })
+
+ it('skip', function(done){
+ assert.throws(function(){
+ var m = mquery().skip(3).distinct();
+ }, /skip cannot be used with distinct/);
+ done();
+ })
+
+ it('batchSize', function(done){
+ assert.throws(function(){
+ var m = mquery({}, { batchSize: 3 }).distinct();
+ }, /batchSize cannot be used with distinct/);
+ done();
+ })
+
+ it('comment', function(done){
+ assert.throws(function(){
+ var m = mquery().comment('mquery').distinct();
+ }, /comment cannot be used with distinct/);
+ done();
+ })
+
+ it('maxScan', function(done){
+ assert.throws(function(){
+ var m = mquery().maxScan(300).distinct();
+ }, /maxScan cannot be used with distinct/);
+ done();
+ })
+
+ it('snapshot', function(done){
+ assert.throws(function(){
+ var m = mquery().snapshot().distinct();
+ }, /snapshot cannot be used with distinct/);
+ done();
+ })
+
+ it('hint', function(done){
+ assert.throws(function(){
+ var m = mquery().hint({ x: 1 }).distinct();
+ }, /hint cannot be used with distinct/);
+ done();
+ })
+
+ it('tailable', function(done){
+ assert.throws(function(){
+ var m = mquery().tailable().distinct();
+ }, /tailable cannot be used with distinct/);
+ done();
+ })
+ })
+ })
+
+ describe('update', function(){
+ describe('with no callback', function(){
+ it('does not execute', function(){
+ var m = mquery();
+ assert.doesNotThrow(function () {
+ m.update({ name: 'old' }, { name: 'updated' }, { multi: true })
+ })
+ assert.doesNotThrow(function () {
+ m.update({ name: 'old' }, { name: 'updated' })
+ })
+ assert.doesNotThrow(function () {
+ m.update({ name: 'updated' })
+ })
+ assert.doesNotThrow(function () {
+ m.update()
+ })
+ })
+ })
+
+ it('is chainable', function(){
+ var m = mquery({x:1}).update({ y: 2 });
+ var n = m.where({y:2});
+ assert.equal(m, n);
+ assert.deepEqual(n._conditions, {x:1, y:2});
+ assert.deepEqual({ y: 2 }, n._update);
+ assert.equal('update', n.op);
+ });
+
+ it('merges update doc arg', function(){
+ var a = [1,2];
+ var m = mquery().where({ name: 'mquery' }).update({ x: 'stuff', a: a });
+ m.update({ z: 'stuff' });
+ assert.deepEqual(m._update, { z: 'stuff', x: 'stuff', a: a });
+ assert.deepEqual(m._conditions, { name: 'mquery' });
+ assert.ok(!m.options.overwrite);
+ m.update({}, { z: 'renamed' }, { overwrite: true });
+ assert.ok(m.options.overwrite === true);
+ assert.deepEqual(m._conditions, { name: 'mquery' });
+ assert.deepEqual(m._update, { z: 'renamed', x: 'stuff', a: a });
+ a.push(3);
+ assert.notDeepEqual(m._update, { z: 'renamed', x: 'stuff', a: a });
+ })
+
+ it('merges other options', function(){
+ var m = mquery();
+ m.setOptions({ overwrite: true });
+ m.update({ age: 77 }, { name: 'pagemill' }, { multi: true })
+ assert.deepEqual({ age: 77 }, m._conditions);
+ assert.deepEqual({ name: 'pagemill' }, m._update);
+ assert.deepEqual({ overwrite: true, multi: true }, m.options);
+ })
+
+ describe('executes', function(){
+ var id;
+ before(function (done) {
+ col.insert({ name: 'mquery update', age: 1 }, { safe: true }, function (err, res) {
+ id = res.insertedIds[0];
+ done();
+ });
+ });
+
+ after(function(done){
+ col.remove({ _id: id }, done);
+ })
+
+ describe('when conds + doc + opts + callback passed', function(){
+ it('works', function(done){
+ var m = mquery(col).where({ _id: id })
+ m.update({}, { name: 'Sparky' }, { safe: true }, function (err, res) {
+ assert.ifError(err);
+ assert.equal(res.result.n, 1);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(doc.name, 'Sparky');
+ done();
+ })
+ })
+ })
+ })
+
+ describe('when conds + doc + callback passed', function(){
+ it('works', function (done) {
+ var m = mquery(col).update({ _id: id }, { name: 'fairgrounds' }, function (err, num, doc) {
+ assert.ifError(err);
+ assert.ok(1, num);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(doc.name, 'fairgrounds');
+ done();
+ })
+ })
+ })
+ })
+
+ describe('when doc + callback passed', function(){
+ it('works', function (done) {
+ var m = mquery(col).where({ _id: id }).update({ name: 'changed' }, function (err, num, doc) {
+ assert.ifError(err);
+ assert.ok(1, num);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(doc.name, 'changed');
+ done();
+ })
+ })
+ })
+ })
+
+ describe('when just callback passed', function(){
+ it('works', function (done) {
+ var m = mquery(col).where({ _id: id });
+ m.setOptions({ safe: true });
+ m.update({ name: 'Frankenweenie' });
+ m.update(function (err, res) {
+ assert.ifError(err);
+ assert.equal(res.result.n, 1);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(doc.name, 'Frankenweenie');
+ done();
+ })
+ })
+ })
+ })
+
+ describe('without a callback', function(){
+ it('when forced by exec()', function(done){
+ var m = mquery(col).where({ _id: id });
+ m.setOptions({ safe: true, multi: true });
+ m.update({ name: 'forced' });
+
+ var update = m._collection.update;
+ m._collection.update = function (conds, doc, opts, cb) {
+ m._collection.update = update;
+
+ assert.ok(opts.safe);
+ assert.ok(true === opts.multi);
+ assert.equal('forced', doc.$set.name);
+ done();
+ }
+
+ m.exec()
+ })
+ })
+
+ describe('except when update doc is empty and missing overwrite flag', function(){
+ it('works', function (done) {
+ var m = mquery(col).where({ _id: id });
+ m.setOptions({ safe: true });
+ m.update({ }, function (err, num) {
+ assert.ifError(err);
+ assert.ok(0 === num);
+ setTimeout(function(){
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(3, mquery.utils.keys(doc).length);
+ assert.equal(id, doc._id.toString());
+ assert.equal('Frankenweenie', doc.name);
+ done();
+ })
+ }, 300);
+ })
+ })
+ });
+
+ describe('when update doc is set with overwrite flag', function(){
+ it('works', function (done) {
+ var m = mquery(col).where({ _id: id });
+ m.setOptions({ safe: true, overwrite: true });
+ m.update({ all: 'yep', two: 2 }, function (err, res) {
+ assert.ifError(err);
+ assert.equal(res.result.n, 1);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(3, mquery.utils.keys(doc).length);
+ assert.equal('yep', doc.all);
+ assert.equal(2, doc.two);
+ assert.equal(id, doc._id.toString());
+ done();
+ })
+ })
+ })
+ })
+
+ describe('when update doc is empty with overwrite flag', function(){
+ it('works', function (done) {
+ var m = mquery(col).where({ _id: id });
+ m.setOptions({ safe: true, overwrite: true });
+ m.update({ }, function (err, res) {
+ assert.ifError(err);
+ assert.equal(res.result.n, 1);
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(1, mquery.utils.keys(doc).length);
+ assert.equal(id, doc._id.toString());
+ done();
+ })
+ })
+ })
+ })
+
+ describe('when boolean (true) - exec()', function(){
+ it('works', function(done){
+ var m = mquery(col).where({ _id: id });
+ m.update({ name: 'bool' }).update(true);
+ setTimeout(function () {
+ m.findOne(function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ assert.equal('bool', doc.name);
+ done();
+ })
+ }, 300)
+ })
+ })
+ })
+ })
+
+ describe('remove', function(){
+ describe('with 0 args', function(){
+ var name = 'remove: no args test'
+ before(function(done){
+ col.insert({ name: name }, { safe: true }, done)
+ })
+ after(function(done){
+ col.remove({ name: name }, { safe: true }, done)
+ })
+
+ it('does not execute', function(done){
+ var remove = col.remove;
+ col.remove = function () {
+ col.remove = remove;
+ done(new Error('remove executed!'));
+ }
+
+ var m = mquery(col).where({ name: name }).remove()
+ setTimeout(function () {
+ col.remove = remove;
+ done();
+ }, 10);
+ })
+
+ it('chains', function(){
+ var m = mquery();
+ assert.equal(m, m.remove());
+ })
+ })
+
+ describe('with 1 argument', function(){
+ var name = 'remove: 1 arg test'
+ before(function(done){
+ col.insert({ name: name }, { safe: true }, done)
+ })
+ after(function(done){
+ col.remove({ name: name }, { safe: true }, done)
+ })
+
+ describe('that is a', function(){
+ it('plain object', function(){
+ var m = mquery(col).remove({ name: 'Whiskers' });
+ m.remove({ color: '#fff' })
+ assert.deepEqual({ name: 'Whiskers', color: '#fff' }, m._conditions);
+ })
+
+ it('query', function(){
+ var q = mquery({ color: '#fff' });
+ var m = mquery(col).remove({ name: 'Whiskers' });
+ m.remove(q)
+ assert.deepEqual({ name: 'Whiskers', color: '#fff' }, m._conditions);
+ })
+
+ it('function', function(done){
+ mquery(col, { safe: true }).where({name: name}).remove(function (err) {
+ assert.ifError(err);
+ mquery(col).findOne({ name: name }, function (err, doc) {
+ assert.ifError(err);
+ assert.equal(null, doc);
+ done();
+ })
+ });
+ })
+
+ it('boolean (true) - execute', function(done){
+ col.insert({ name: name }, { safe: true }, function (err) {
+ assert.ifError(err);
+ mquery(col).findOne({ name: name }, function (err, doc) {
+ assert.ifError(err);
+ assert.ok(doc);
+ mquery(col).remove(true);
+ setTimeout(function () {
+ mquery(col).find(function (err, docs) {
+ assert.ifError(err);
+ assert.ok(docs);
+ assert.equal(0, docs.length);
+ done();
+ })
+ }, 300)
+ })
+ })
+ })
+ })
+ })
+
+ describe('with 2 arguments', function(){
+ var name = 'remove: 2 arg test'
+ beforeEach(function(done){
+ col.remove({}, { safe: true }, function (err) {
+ assert.ifError(err);
+ col.insert([{ name: 'shelly' }, { name: name }], { safe: true }, function (err) {
+ assert.ifError(err);
+ mquery(col).find(function (err, docs) {
+ assert.ifError(err);
+ assert.equal(2, docs.length);
+ done();
+ })
+ })
+ })
+ })
+
+ describe('plain object + callback', function(){
+ it('works', function(done){
+ mquery(col).remove({ name: name }, function (err) {
+ assert.ifError(err);
+ mquery(col).find(function (err, docs) {
+ assert.ifError(err);
+ assert.ok(docs);
+ assert.equal(1, docs.length);
+ assert.equal('shelly', docs[0].name);
+ done();
+ })
+ });
+ })
+ })
+
+ describe('mquery + callback', function(){
+ it('works', function(done){
+ var m = mquery({ name: name });
+ mquery(col).remove(m, function (err) {
+ assert.ifError(err);
+ mquery(col).find(function (err, docs) {
+ assert.ifError(err);
+ assert.ok(docs);
+ assert.equal(1, docs.length);
+ assert.equal('shelly', docs[0].name);
+ done();
+ })
+ });
+ })
+ })
+ })
+ })
+
+ function validateFindAndModifyOptions (method) {
+ describe('validates its option', function(){
+ it('sort', function(done){
+ assert.doesNotThrow(function(){
+ var m = mquery().sort('x')[method]();
+ })
+ done();
+ })
+
+ it('select', function(done){
+ assert.doesNotThrow(function(){
+ var m = mquery().select('x')[method]();
+ })
+ done();
+ })
+
+ it('limit', function(done){
+ assert.throws(function(){
+ var m = mquery().limit(3)[method]();
+ }, new RegExp('limit cannot be used with ' + method));
+ done();
+ })
+
+ it('skip', function(done){
+ assert.throws(function(){
+ var m = mquery().skip(3)[method]();
+ }, new RegExp('skip cannot be used with ' + method));
+ done();
+ })
+
+ it('batchSize', function(done){
+ assert.throws(function(){
+ var m = mquery({}, { batchSize: 3 })[method]();
+ }, new RegExp('batchSize cannot be used with ' + method));
+ done();
+ })
+
+ it('maxScan', function(done){
+ assert.throws(function(){
+ var m = mquery().maxScan(300)[method]();
+ }, new RegExp('maxScan cannot be used with ' + method));
+ done();
+ })
+
+ it('snapshot', function(done){
+ assert.throws(function(){
+ var m = mquery().snapshot()[method]();
+ }, new RegExp('snapshot cannot be used with ' + method));
+ done();
+ })
+
+ it('hint', function(done){
+ assert.throws(function(){
+ var m = mquery().hint({ x: 1 })[method]();
+ }, new RegExp('hint cannot be used with ' + method));
+ done();
+ })
+
+ it('tailable', function(done){
+ assert.throws(function(){
+ var m = mquery().tailable()[method]();
+ }, new RegExp('tailable cannot be used with ' + method));
+ done();
+ })
+
+ it('comment', function(done){
+ assert.throws(function(){
+ var m = mquery().comment('mquery')[method]();
+ }, new RegExp('comment cannot be used with ' + method));
+ done();
+ })
+ })
+ }
+
+ describe('findOneAndUpdate', function(){
+ var name = 'findOneAndUpdate + fn'
+
+ validateFindAndModifyOptions('findOneAndUpdate');
+
+ describe('with 0 args', function(){
+ it('makes no changes', function(){
+ var m = mquery();
+ var n = m.findOneAndUpdate();
+ assert.deepEqual(m, n);
+ })
+ })
+ describe('with 1 arg', function(){
+ describe('that is an object', function(){
+ it('updates the doc', function(){
+ var m = mquery();
+ var n = m.findOneAndUpdate({ $set: { name: '1 arg' }});
+ assert.deepEqual(n._update, { $set: { name: '1 arg' }});
+ })
+ })
+ describe('that is a query', function(){
+ it('updates the doc', function(){
+ var m = mquery({ name: name }).update({ x: 1 });
+ var n = mquery().findOneAndUpdate(m);
+ assert.deepEqual(n._update, { x: 1 });
+ })
+ })
+ it('that is a function', function(done){
+ col.insert({ name: name }, { safe: true }, function (err) {
+ assert.ifError(err);
+ var m = mquery({ name: name }).collection(col);
+ name = '1 arg';
+ var n = m.update({ $set: { name: name }});
+ n.findOneAndUpdate(function (err, res) {
+ assert.ifError(err);
+ assert.ok(res.value);
+ assert.equal(name, res.value.name);
+ done();
+ });
+ })
+ })
+ })
+ describe('with 2 args', function(){
+ it('conditions + update', function(){
+ var m = mquery(col);
+ m.findOneAndUpdate({ name: name }, { age: 100 });
+ assert.deepEqual({ name: name }, m._conditions);
+ assert.deepEqual({ age: 100 }, m._update);
+ })
+ it('query + update', function(){
+ var n = mquery({ name: name });
+ var m = mquery(col);
+ m.findOneAndUpdate(n, { age: 100 });
+ assert.deepEqual({ name: name }, m._conditions);
+ assert.deepEqual({ age: 100 }, m._update);
+ })
+ it('update + callback', function(done){
+ var m = mquery(col).where({ name: name });
+ m.findOneAndUpdate({}, { $inc: { age: 10 }}, { new: true }, function (err, res) {
+ assert.ifError(err);
+ assert.equal(10, res.value.age);
+ done();
+ });
+ })
+ })
+ describe('with 3 args', function(){
+ it('conditions + update + options', function(){
+ var m = mquery();
+ var n = m.findOneAndUpdate({ name: name }, { works: true }, { new: false });
+ assert.deepEqual({ name: name}, n._conditions);
+ assert.deepEqual({ works: true }, n._update);
+ assert.deepEqual({ new: false }, n.options);
+ })
+ it('conditions + update + callback', function(done){
+ var m = mquery(col);
+ m.findOneAndUpdate({ name: name }, { works: true }, { new: true }, function (err, res) {
+ assert.ifError(err);
+ assert.ok(res.value);
+ assert.equal(name, res.value.name);
+ assert.ok(true === res.value.works);
+ done();
+ });
+ })
+ })
+ describe('with 4 args', function(){
+ it('conditions + update + options + callback', function(done){
+ var m = mquery(col);
+ m.findOneAndUpdate({ name: name }, { works: false }, { new: false }, function (err, res) {
+ assert.ifError(err);
+ assert.ok(res.value);
+ assert.equal(name, res.value.name);
+ assert.ok(true === res.value.works);
+ done();
+ });
+ })
+ })
+ })
+
+ describe('findOneAndRemove', function(){
+ var name = 'findOneAndRemove'
+
+ validateFindAndModifyOptions('findOneAndRemove');
+
+ describe('with 0 args', function(){
+ it('makes no changes', function(){
+ var m = mquery();
+ var n = m.findOneAndRemove();
+ assert.deepEqual(m, n);
+ })
+ })
+ describe('with 1 arg', function(){
+ describe('that is an object', function(){
+ it('updates the doc', function(){
+ var m = mquery();
+ var n = m.findOneAndRemove({ name: '1 arg' });
+ assert.deepEqual(n._conditions, { name: '1 arg' });
+ })
+ })
+ describe('that is a query', function(){
+ it('updates the doc', function(){
+ var m = mquery({ name: name });
+ var n = m.findOneAndRemove(m);
+ assert.deepEqual(n._conditions, { name: name });
+ })
+ })
+ it('that is a function', function(done){
+ col.insert({ name: name }, { safe: true }, function (err) {
+ assert.ifError(err);
+ var m = mquery({ name: name }).collection(col);
+ m.findOneAndRemove(function (err, res) {
+ assert.ifError(err);
+ assert.ok(res.value);
+ assert.equal(name, res.value.name);
+ done();
+ });
+ })
+ })
+ })
+ describe('with 2 args', function(){
+ it('conditions + options', function(){
+ var m = mquery(col);
+ m.findOneAndRemove({ name: name }, { new: false });
+ assert.deepEqual({ name: name }, m._conditions);
+ assert.deepEqual({ new: false }, m.options);
+ })
+ it('query + options', function(){
+ var n = mquery({ name: name });
+ var m = mquery(col);
+ m.findOneAndRemove(n, { sort: { x: 1 }});
+ assert.deepEqual({ name: name }, m._conditions);
+ assert.deepEqual({ sort: { 'x': 1 }}, m.options);
+ })
+ it('conditions + callback', function(done){
+ col.insert({ name: name }, { safe: true }, function (err) {
+ assert.ifError(err);
+ var m = mquery(col);
+ m.findOneAndRemove({ name: name }, function (err, res) {
+ assert.ifError(err);
+ assert.equal(name, res.value.name);
+ done();
+ });
+ });
+ })
+ it('query + callback', function(done){
+ col.insert({ name: name }, { safe: true }, function (err) {
+ assert.ifError(err);
+ var n = mquery({ name: name })
+ var m = mquery(col);
+ m.findOneAndRemove(n, function (err, res) {
+ assert.ifError(err);
+ assert.equal(name, res.value.name);
+ done();
+ });
+ });
+ })
+ })
+ describe('with 3 args', function(){
+ it('conditions + options + callback', function(done){
+ name = 'findOneAndRemove + conds + options + cb';
+ col.insert([{ name: name }, { name: 'a' }], { safe: true }, function (err) {
+ assert.ifError(err);
+ var m = mquery(col);
+ m.findOneAndRemove({ name: name }, { sort: { name: 1 }}, function (err, res) {
+ assert.ifError(err);
+ assert.ok(res.value);
+ assert.equal(name, res.value.name);
+ done();
+ });
+ })
+ })
+ })
+ })
+
+ describe('exec', function(){
+ beforeEach(function(done){
+ col.insert([{ name: 'exec', age: 1 }, { name: 'exec', age: 2 }], done);
+ })
+
+ afterEach(function(done){
+ mquery(col).remove(done);
+ })
+
+ it('requires an op', function(){
+ assert.throws(function () {
+ mquery().exec()
+ }, /Missing query type/);
+ })
+
+ describe('find', function() {
+ it('works', function(done){
+ var m = mquery(col).find({ name: 'exec' });
+ m.exec(function (err, docs) {
+ assert.ifError(err);
+ assert.equal(2, docs.length);
+ done();
+ })
+ })
+
+ it('works with readPreferences', function (done) {
+ var m = mquery(col).find({ name: 'exec' });
+ try {
+ var rp = new require('mongodb').ReadPreference('primary');
+ m.read(rp);
+ } catch (e) {
+ if (e.code === 'MODULE_NOT_FOUND')
+ e = null;
+ done(e);
+ return;
+ }
+ m.exec(function (err, docs) {
+ assert.ifError(err);
+ assert.equal(2, docs.length);
+ done();
+ })
+ })
+ });
+
+ it('findOne', function(done){
+ var m = mquery(col).findOne({ age: 2 });
+ m.exec(function (err, doc) {
+ assert.ifError(err);
+ assert.equal(2, doc.age);
+ done();
+ })
+ })
+
+ it('count', function(done){
+ var m = mquery(col).count({ name: 'exec' });
+ m.exec(function (err, count) {
+ assert.ifError(err);
+ assert.equal(2, count);
+ done();
+ })
+ })
+
+ it('distinct', function(done){
+ var m = mquery({ name: 'exec' });
+ m.collection(col);
+ m.distinct('age');
+ m.exec(function (err, array) {
+ assert.ifError(err);
+ assert.ok(Array.isArray(array));
+ assert.equal(2, array.length);
+ assert(~array.indexOf(1));
+ assert(~array.indexOf(2));
+ done();
+ });
+ })
+
+ describe('update', function(){
+ var num;
+
+ it('with a callback', function(done){
+ var m = mquery(col);
+ m.where({ name: 'exec' })
+
+ m.count(function (err, _num) {
+ assert.ifError(err);
+ num = _num;
+ m.setOptions({ multi: true })
+ m.update({ name: 'exec + update' });
+ m.exec(function (err, res) {
+ assert.ifError(err);
+ assert.equal(num, res.result.n);
+ mquery(col).find({ name: 'exec + update' }, function (err, docs) {
+ assert.ifError(err);
+ assert.equal(num, docs.length);
+ done();
+ })
+ })
+ })
+ })
+
+ it('without a callback', function(done){
+ var m = mquery(col)
+ m.where({ name: 'exec + update' }).setOptions({ multi: true })
+ m.update({ name: 'exec' });
+
+ // unsafe write
+ m.exec();
+
+ setTimeout(function () {
+ mquery(col).find({ name: 'exec' }, function (err, docs) {
+ assert.ifError(err);
+ assert.equal(2, docs.length);
+ done();
+ })
+ }, 200)
+ })
+ it('preserves key ordering', function(done) {
+ var m = mquery(col);
+
+ var m2 = m.update({ _id : 'something' }, { '1' : 1, '2' : 2, '3' : 3});
+ var doc = m2._updateForExec().$set;
+ var count = 0;
+ for (var i in doc) {
+ if (count == 0) {
+ assert.equal('1', i);
+ } else if (count == 1) {
+ assert.equal('2', i);
+ } else if (count ==2) {
+ assert.equal('3', i);
+ }
+ count++;
+ }
+ done();
+ });
+ })
+
+ describe('remove', function(){
+ it('with a callback', function(done){
+ var m = mquery(col).where({ age: 2 }).remove();
+ m.exec(function (err, res) {
+ assert.ifError(err);
+ assert.equal(1, res.result.n);
+ done();
+ })
+ })
+
+ it('without a callback', function(done){
+ var m = mquery(col).where({ age: 1 }).remove();
+ m.exec();
+
+ setTimeout(function () {
+ mquery(col).where('name', 'exec').count(function(err, num) {
+ assert.equal(1, num);
+ done();
+ })
+ }, 200)
+ })
+ })
+
+ describe('findOneAndUpdate', function(){
+ it('with a callback', function(done){
+ var m = mquery(col);
+ m.findOneAndUpdate({ name: 'exec', age: 1 }, { $set: { name: 'findOneAndUpdate' }});
+ m.exec(function (err, res) {
+ assert.ifError(err);
+ assert.equal('findOneAndUpdate', res.value.name);
+ done();
+ });
+ })
+ })
+
+ describe('findOneAndRemove', function(){
+ it('with a callback', function(done){
+ var m = mquery(col);
+ m.findOneAndRemove({ name: 'exec', age: 2 });
+ m.exec(function (err, res) {
+ assert.ifError(err);
+ assert.equal('exec', res.value.name);
+ assert.equal(2, res.value.age);
+ mquery(col).count({ name: 'exec' }, function (err, num) {
+ assert.ifError(err);
+ assert.equal(1, num);
+ done();
+ });
+ });
+ })
+ })
+ })
+
+ describe('setTraceFunction', function() {
+ beforeEach(function(done){
+ col.insert([{ name: 'trace', age: 93 }], done);
+ })
+
+ it('calls trace function when executing query', function(done) {
+ var m = mquery(col);
+
+ var resultTraceCalled;
+
+ m.setTraceFunction(function (method, queryInfo) {
+ try {
+ assert.equal('findOne', method);
+ assert.equal('trace', queryInfo.conditions.name);
+ } catch (e) {
+ done(e);
+ }
+
+ return function(err, result, millis) {
+ try {
+ assert.equal(93, result.age);
+ } catch (e) {
+ done(e);
+ }
+ resultTraceCalled = true;
+ };
+ });
+
+ m.findOne({name: 'trace'}, function (err, doc) {
+ assert.ifError(err);
+ assert.equal(resultTraceCalled, true);
+ assert.equal(93, doc.age);
+ done();
+ });
+ });
+
+ it('inherits trace function when calling toConstructor', function(done) {
+ function traceFunction () { return function() {} };
+
+ var tracedQuery = mquery().setTraceFunction(traceFunction).toConstructor();
+
+ var query = tracedQuery();
+ assert.equal(traceFunction, query._traceFunction);
+
+ done();
+ });
+ });
+
+ describe('thunk', function() {
+ it('returns a function', function(done) {
+ assert.equal('function', typeof mquery().thunk());
+ done();
+ });
+
+ it('passes the fn arg to `exec`', function(done) {
+ function cb() {}
+ var m = mquery();
+
+ m.exec = function testing(fn) {
+ assert.equal(this, m);
+ assert.equal(cb, fn);
+ done();
+ }
+
+ m.thunk()(cb);
+ });
+ });
+
+ describe('then', function() {
+ before(function(done){
+ col.insert([{ name: 'then', age: 1 }, { name: 'then', age: 2 }], done);
+ })
+
+ after(function(done){
+ mquery(col).remove({ name: 'then' }).exec(done);
+ })
+
+ it('returns a promise A+ compat object', function(done) {
+ var m = mquery(col).find();
+ assert.equal('function', typeof m.then);
+ done();
+ });
+
+ it('creates a promise that is resolved on success', function(done) {
+ var promise = mquery(col).count({ name: 'then' }).then();
+ promise.then(function(count){
+ assert.equal(2, count);
+ done();
+ }, done);
+ });
+
+ it('supports exec() cb being called synchronously #66', function(done) {
+ var query = mquery(col).count({ name: 'then' });
+ query.exec = function(cb) {
+ cb(null, 66);
+ }
+
+ query.then(success, done);
+ function success(count){
+ assert.equal(66, count);
+ done();
+ }
+ });
+
+ it('supports other Promise libs', function(done) {
+ var bluebird = mquery.Promise;
+
+ // hack for testing
+ mquery.Promise = function P() {
+ mquery.Promise = bluebird;
+ this.then = function(x, y) {
+ return x + y;
+ }
+ }
+
+ var val = mquery(col).count({ name: 'exec' }).then(1, 2);
+ assert.equal(val, 3);
+ done();
+ });
+ });
+
+ describe('stream', function() {
+ before(function(done){
+ col.insert([{ name: 'stream', age: 1 }, { name: 'stream', age: 2 }], done);
+ })
+
+ after(function(done){
+ mquery(col).remove({ name: 'stream' }).exec(done);
+ })
+
+ describe('throws', function() {
+ describe('if used with non-find operations', function() {
+ var ops = ['update', 'findOneAndUpdate', 'remove', 'count', 'distinct'];
+
+ ops.forEach(function(op) {
+ assert.throws(function(){
+ mquery(col)[op]().stream();
+ });
+ });
+ });
+ });
+
+ it('returns a stream', function(done) {
+ var stream = mquery(col).find({ name: 'stream' }).stream();
+ var count = 0;
+ var err;
+
+ stream.on('data', function(doc){
+ assert.equal('stream', doc.name);
+ ++count;
+ });
+
+ stream.on('error', function(er) {
+ err = er;
+ });
+
+ stream.on('end', function(){
+ if (err) return done(err);
+ assert.equal(2, count);
+ done();
+ });
+ });
+ });
+
+ function noDistinct (type) {
+ it('cannot be used with distinct()', function(done){
+ assert.throws(function () {
+ mquery().distinct('name')[type](4);
+ }, new RegExp(type + ' cannot be used with distinct'));
+ done();
+ })
+ }
+
+ function no (method, type) {
+ it('cannot be used with ' + method + '()', function(done){
+ assert.throws(function () {
+ mquery()[method]()[type](4);
+ }, new RegExp(type + ' cannot be used with ' + method));
+ done();
+ })
+ }
+
+ // query internal
+
+ describe('_updateForExec', function(){
+ it('returns a clone of the update object with same key order #19', function(done){
+ var update = {};
+ update.$push = { n: { $each: [{x:10}], $slice: -1, $sort: {x:1}}};
+
+ var q = mquery().update({ x: 1 }, update);
+
+ // capture original key order
+ var order = [];
+ for (var key in q._update.$push.n) {
+ order.push(key);
+ }
+
+ // compare output
+ var doc = q._updateForExec();
+ var i = 0;
+ for (var key in doc.$push.n) {
+ assert.equal(key, order[i]);
+ i++;
+ }
+
+ done();
+ })
+ })
+})
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/utils.test.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/utils.test.js
new file mode 100644
index 0000000..fa5972a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/mquery/test/utils.test.js
@@ -0,0 +1,143 @@
+
+var utils = require('../lib/utils');
+var assert = require('assert');
+
+var mongo;
+try {
+ mongo = new require('mongodb');
+} catch (e) {}
+
+describe('lib/utils', function() {
+ describe('clone', function() {
+ it('clones constructors named ObjectId', function(done) {
+ function ObjectId (id) {
+ this.id = id;
+ }
+
+ var o1 = new ObjectId('1234');
+ var o2 = utils.clone(o1);
+ assert.ok(o2 instanceof ObjectId);
+
+ done();
+ });
+
+ it('clones constructors named ObjectID', function(done) {
+ function ObjectID (id) {
+ this.id = id;
+ }
+
+ var o1 = new ObjectID('1234');
+ var o2 = utils.clone(o1);
+
+ assert.ok(o2 instanceof ObjectID);
+ done();
+ });
+
+ it('does not clone constructors named ObjectIdd', function(done) {
+ function ObjectIdd (id) {
+ this.id = id;
+ }
+
+ var o1 = new ObjectIdd('1234');
+ var o2 = utils.clone(o1);
+ assert.ok(!(o2 instanceof ObjectIdd));
+
+ done();
+ });
+
+ it('optionally clones ObjectId constructors using its clone method', function(done) {
+ function ObjectID (id) {
+ this.id = id;
+ this.cloned = false;
+ }
+
+ ObjectID.prototype.clone = function () {
+ var ret = new ObjectID(this.id);
+ ret.cloned = true;
+ return ret;
+ }
+
+ var id = 1234;
+ var o1 = new ObjectID(id);
+ assert.equal(id, o1.id);
+ assert.equal(false, o1.cloned);
+
+ var o2 = utils.clone(o1);
+ assert.ok(o2 instanceof ObjectID);
+ assert.equal(id, o2.id);
+ assert.ok(o2.cloned);
+ done();
+ });
+
+ it('clones mongodb.ReadPreferences', function (done) {
+ if (!mongo) return done();
+
+ var tags = [
+ {dc: 'tag1'}
+ ];
+ var prefs = [
+ new mongo.ReadPreference("primary"),
+ new mongo.ReadPreference(mongo.ReadPreference.PRIMARY_PREFERRED),
+ new mongo.ReadPreference("primary", tags),
+ mongo.ReadPreference("primary", tags)
+ ];
+
+ var prefsCloned = utils.clone(prefs);
+
+ for (var i = 0; i < prefsCloned.length; i++) {
+ assert.notEqual(prefs[i], prefsCloned[i]);
+ assert.ok(prefsCloned[i] instanceof mongo.ReadPreference);
+ assert.ok(prefsCloned[i].isValid());
+ if (prefs[i].tags) {
+ assert.ok(prefsCloned[i].tags);
+ assert.notEqual(prefs[i].tags, prefsCloned[i].tags);
+ assert.notEqual(prefs[i].tags[0], prefsCloned[i].tags[0]);
+ } else {
+ assert.equal(prefsCloned[i].tags, null);
+ }
+ }
+
+ done();
+ });
+
+ it('clones mongodb.Binary', function(done){
+ if (!mongo) return done();
+
+ var buf = new Buffer('hi');
+ var binary= new mongo.Binary(buf, 2);
+ var clone = utils.clone(binary);
+ assert.equal(binary.sub_type, clone.sub_type);
+ assert.equal(String(binary.buffer), String(buf));
+ assert.ok(binary !== clone);
+ done();
+ })
+
+ it('handles objects with no constructor', function(done) {
+ var name ='335';
+
+ var o = Object.create(null);
+ o.name = name;
+
+ var clone;
+ assert.doesNotThrow(function() {
+ clone = utils.clone(o);
+ });
+
+ assert.equal(name, clone.name);
+ assert.ok(o != clone);
+ done();
+ });
+
+ it('handles buffers', function(done){
+ var buff = new Buffer(10);
+ buff.fill(1);
+ var clone = utils.clone(buff);
+
+ for (var i = 0; i < buff.length; i++) {
+ assert.equal(buff[i], clone[i]);
+ }
+
+ done();
+ });
+ });
+});
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/.npmignore
new file mode 100644
index 0000000..d1aa0ce
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/.npmignore
@@ -0,0 +1,5 @@
+node_modules
+test
+History.md
+Makefile
+component.json
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/History.md
new file mode 100644
index 0000000..32fdfc1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/History.md
@@ -0,0 +1,66 @@
+
+0.7.1 / 2015-04-20
+==================
+
+ * prevent extraordinary long inputs (@evilpacket)
+ * Fixed broken readme link
+
+0.7.0 / 2014-11-24
+==================
+
+ * add time abbreviations, updated tests and readme for the new units
+ * fix example in the readme.
+ * add LICENSE file
+
+0.6.2 / 2013-12-05
+==================
+
+ * Adding repository section to package.json to suppress warning from NPM.
+
+0.6.1 / 2013-05-10
+==================
+
+ * fix singularization [visionmedia]
+
+0.6.0 / 2013-03-15
+==================
+
+ * fix minutes
+
+0.5.1 / 2013-02-24
+==================
+
+ * add component namespace
+
+0.5.0 / 2012-11-09
+==================
+
+ * add short formatting as default and .long option
+ * add .license property to component.json
+ * add version to component.json
+
+0.4.0 / 2012-10-22
+==================
+
+ * add rounding to fix crazy decimals
+
+0.3.0 / 2012-09-07
+==================
+
+ * fix `ms(<String>)` [visionmedia]
+
+0.2.0 / 2012-09-03
+==================
+
+ * add component.json [visionmedia]
+ * add days support [visionmedia]
+ * add hours support [visionmedia]
+ * add minutes support [visionmedia]
+ * add seconds support [visionmedia]
+ * add ms string support [visionmedia]
+ * refactor tests to facilitate ms(number) [visionmedia]
+
+0.1.0 / 2012-03-07
+==================
+
+ * Initial release
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/LICENSE
new file mode 100644
index 0000000..6c07561
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/LICENSE
@@ -0,0 +1,20 @@
+(The MIT License)
+
+Copyright (c) 2014 Guillermo Rauch <rauchg@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/README.md
new file mode 100644
index 0000000..9b4fd03
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/README.md
@@ -0,0 +1,35 @@
+# ms.js: miliseconds conversion utility
+
+```js
+ms('2 days') // 172800000
+ms('1d') // 86400000
+ms('10h') // 36000000
+ms('2.5 hrs') // 9000000
+ms('2h') // 7200000
+ms('1m') // 60000
+ms('5s') // 5000
+ms('100') // 100
+```
+
+```js
+ms(60000) // "1m"
+ms(2 * 60000) // "2m"
+ms(ms('10 hours')) // "10h"
+```
+
+```js
+ms(60000, { long: true }) // "1 minute"
+ms(2 * 60000, { long: true }) // "2 minutes"
+ms(ms('10 hours'), { long: true }) // "10 hours"
+```
+
+- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download).
+- If a number is supplied to `ms`, a string with a unit is returned.
+- If a string that contains the number is supplied, it returns it as
+a number (e.g: it returns `100` for `'100'`).
+- If you pass a string with a number and a valid unit, the number of
+equivalent ms is returned.
+
+## License
+
+MIT
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/index.js
new file mode 100644
index 0000000..4f92771
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/index.js
@@ -0,0 +1,125 @@
+/**
+ * Helpers.
+ */
+
+var s = 1000;
+var m = s * 60;
+var h = m * 60;
+var d = h * 24;
+var y = d * 365.25;
+
+/**
+ * Parse or format the given `val`.
+ *
+ * Options:
+ *
+ * - `long` verbose formatting [false]
+ *
+ * @param {String|Number} val
+ * @param {Object} options
+ * @return {String|Number}
+ * @api public
+ */
+
+module.exports = function(val, options){
+ options = options || {};
+ if ('string' == typeof val) return parse(val);
+ return options.long
+ ? long(val)
+ : short(val);
+};
+
+/**
+ * Parse the given `str` and return milliseconds.
+ *
+ * @param {String} str
+ * @return {Number}
+ * @api private
+ */
+
+function parse(str) {
+ str = '' + str;
+ if (str.length > 10000) return;
+ var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
+ if (!match) return;
+ var n = parseFloat(match[1]);
+ var type = (match[2] || 'ms').toLowerCase();
+ switch (type) {
+ case 'years':
+ case 'year':
+ case 'yrs':
+ case 'yr':
+ case 'y':
+ return n * y;
+ case 'days':
+ case 'day':
+ case 'd':
+ return n * d;
+ case 'hours':
+ case 'hour':
+ case 'hrs':
+ case 'hr':
+ case 'h':
+ return n * h;
+ case 'minutes':
+ case 'minute':
+ case 'mins':
+ case 'min':
+ case 'm':
+ return n * m;
+ case 'seconds':
+ case 'second':
+ case 'secs':
+ case 'sec':
+ case 's':
+ return n * s;
+ case 'milliseconds':
+ case 'millisecond':
+ case 'msecs':
+ case 'msec':
+ case 'ms':
+ return n;
+ }
+}
+
+/**
+ * Short format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
+
+function short(ms) {
+ if (ms >= d) return Math.round(ms / d) + 'd';
+ if (ms >= h) return Math.round(ms / h) + 'h';
+ if (ms >= m) return Math.round(ms / m) + 'm';
+ if (ms >= s) return Math.round(ms / s) + 's';
+ return ms + 'ms';
+}
+
+/**
+ * Long format for `ms`.
+ *
+ * @param {Number} ms
+ * @return {String}
+ * @api private
+ */
+
+function long(ms) {
+ return plural(ms, d, 'day')
+ || plural(ms, h, 'hour')
+ || plural(ms, m, 'minute')
+ || plural(ms, s, 'second')
+ || ms + ' ms';
+}
+
+/**
+ * Pluralization helper.
+ */
+
+function plural(ms, n, name) {
+ if (ms < n) return;
+ if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
+ return Math.ceil(ms / n) + ' ' + name + 's';
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/package.json
new file mode 100644
index 0000000..e36489e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/ms/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "ms",
+ "version": "0.7.1",
+ "description": "Tiny ms conversion utility",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/guille/ms.js.git"
+ },
+ "main": "./index",
+ "devDependencies": {
+ "mocha": "*",
+ "expect.js": "*",
+ "serve": "*"
+ },
+ "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"
+ },
+ "maintainers": [
+ {
+ "name": "rauchg",
+ "email": "rauchg@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "9cd13c03adbff25b65effde7ce864ee952017098",
+ "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
+ "readme": "ERROR: No README data found!"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.npmignore
new file mode 100644
index 0000000..be106ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.npmignore
@@ -0,0 +1,2 @@
+*.sw*
+node_modules/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.travis.yml
new file mode 100644
index 0000000..895dbd3
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/History.md
new file mode 100644
index 0000000..f04c05d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/History.md
@@ -0,0 +1,59 @@
+1.1.1 / 2016-09-26
+==================
+ * fixed; handle parsing of replicaSet with leading number #8
+
+1.1.0 / 2015-04-13
+==================
+ * added; parse ipv6 addresses
+
+1.0.0 / 2014-10-18
+==================
+
+ * fixed; compatibility w/ strict mode #4 [vkarpov15](https://github.com/vkarpov15)
+
+0.3.1 / 2013-02-17
+==================
+
+ * fixed; allow '#' in username and password #3
+
+0.3.0 / 2013-01-14
+==================
+
+ * fixed; default db logic #2
+
+0.2.0 / 2013-01-09
+==================
+
+ * changed; default db is now 'test'
+
+0.1.0 / 2012-12-18
+==================
+
+ * changed; include .sock in UDS
+
+0.0.5 / 2012-12-18
+==================
+
+ * fixed; unix domain sockets used with db names
+
+0.0.4 / 2012-12-01
+==================
+
+ * handle multple specified protocols
+
+0.0.3 / 2012-11-29
+==================
+
+ * validate mongodb:///db
+ * more detailed error message
+
+0.0.2 / 2012-11-02
+==================
+
+ * add readPreferenceTags support
+ * add unix domain support
+
+0.0.1 / 2012-11-01
+==================
+
+ * initial release
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/Makefile
new file mode 100644
index 0000000..e6337bd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/Makefile
@@ -0,0 +1,5 @@
+
+test:
+ @node_modules/mocha/bin/mocha $(T)
+
+.PHONY: test
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/README.md
new file mode 100644
index 0000000..3757419
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/README.md
@@ -0,0 +1,46 @@
+#Meet Muri!
+
+Muri is your friendly neighborhood [MongoDB URI](http://www.mongodb.org/display/DOCS/Connections) parser for Node.js.
+
+
+###Install
+
+ $ npm install muri
+
+###Use
+
+```js
+ var muri = require('muri');
+ var o = muri('mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50');
+
+ console.log(o);
+
+ { hosts: [ { host: 'local', port: 27017 },
+ { host: 'remote', port: 27018 },
+ { host: 'japan', port: 27019 } ],
+ db: 'neatdb',
+ options: {
+ replicaSet: 'myreplset',
+ journal: true,
+ w: 2,
+ wtimeoutMS: 50
+ },
+ auth: {
+ user: 'user',
+ pass: 'pass'
+ }
+ }
+```
+
+### Details
+
+The returned object contains the following properties:
+
+- db: the name of the database. defaults to "admin" if not specified
+- auth: if auth is specified, this object will exist `{ user: 'username', pass: 'password' }`
+- hosts: array of host/port objects, one for each specified `[{ host: 'local', port: 27107 }, { host: '..', port: port }]`
+ - if a port is not specified for a given host, the default port (27017) is used
+ - if a unix domain socket is passed, host/port will be undefined and `ipc` will be set to the value specified `[{ ipc: '/tmp/mongodb-27017' }]`
+- options: this is a hash of all options specified in the querystring
+
+[LICENSE](https://github.com/aheckmann/muri/blob/master/LICENSE)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/index.js
new file mode 100644
index 0000000..f7b65dd
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/index.js
@@ -0,0 +1 @@
+module.exports = exports = require('./lib');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/lib/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/lib/index.js
new file mode 100644
index 0000000..410399e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/lib/index.js
@@ -0,0 +1,241 @@
+// muri
+
+/**
+ * MongoDB URI parser as described here:
+ * http://www.mongodb.org/display/DOCS/Connections
+ */
+
+/**
+ * Module dependencies
+ */
+
+var qs = require('querystring');
+
+/**
+ * Defaults
+ */
+
+var DEFAULT_PORT = 27017;
+var DEFAULT_DB = 'test';
+var ADMIN_DB = 'admin';
+
+/**
+ * Muri
+ */
+
+module.exports = exports = function muri (str) {
+ if (!/^mongodb:\/\//.test(str)) {
+ throw new Error('Invalid mongodb uri. Must begin with "mongodb://"'
+ + '\n Received: ' + str);
+ }
+
+ var ret = {
+ hosts: []
+ , db: DEFAULT_DB
+ , options: {}
+ }
+
+ var match = /^mongodb:\/\/([^?]+)(\??.*)$/.exec(str);
+ if (!match || '/' == match[1]) {
+ throw new Error('Invalid mongodb uri. Missing hostname');
+ }
+
+ var uris = match[1];
+ var path = match[2];
+ var db;
+
+ uris.split(',').forEach(function (uri) {
+ var o = parse(uri);
+
+ if (o.host) {
+ ret.hosts.push({
+ host: o.host
+ , port: parseInt(o.port, 10)
+ })
+
+ if (!db && o.db) {
+ db = o.db;
+ }
+ } else if (o.ipc) {
+ ret.hosts.push({ ipc: o.ipc });
+ }
+
+ if (o.auth) {
+ ret.auth = {
+ user: o.auth.user
+ , pass: o.auth.pass
+ }
+ }
+ })
+
+ if (!ret.hosts.length) {
+ throw new Error('Invalid mongodb uri. Missing hostname');
+ }
+
+ var parts = path.split('?');
+
+ if (!db) {
+ if (parts[0]) {
+ db = parts[0].replace(/^\//, '');
+ } else {
+ // deal with ipc formats
+ db = /\/([^\.]+)$/.exec(match[1]);
+ if (db && db[1]) {
+ db = db[1];
+ }
+ }
+ }
+
+ if (db) {
+ ret.db = db;
+ } else if (ret.auth) {
+ ret.db = ADMIN_DB;
+ }
+
+ if (parts[1]) {
+ ret.options = options(parts[1]);
+ }
+
+ return ret;
+}
+
+/**
+ * Parse str into key/val pairs casting values appropriately.
+ */
+
+function options (str) {
+ var sep = /;/.test(str)
+ ? ';'
+ : '&';
+
+ var ret = qs.parse(str, sep);
+
+ Object.keys(ret).forEach(function (key) {
+ var val = ret[key];
+ if ('readPreferenceTags' == key) {
+ val = readPref(val);
+ if (val) {
+ ret[key] = Array.isArray(val)
+ ? val
+ : [val];
+ }
+ } else {
+ ret[key] = format(val);
+ }
+ });
+
+ return ret;
+}
+
+function format (val) {
+ var num;
+
+ if ('true' == val) {
+ return true;
+ } else if ('false' == val) {
+ return false;
+ } else {
+ num = parseInt(+val, 10);
+ if (!isNaN(num)) {
+ return num;
+ }
+ }
+
+ return val;
+}
+
+function readPref (val) {
+ var ret;
+
+ if (Array.isArray(val)) {
+ ret = val.map(readPref).filter(Boolean);
+ return ret.length
+ ? ret
+ : undefined
+ }
+
+ var pair = val.split(',');
+ var hasKeys;
+ ret = {};
+
+ pair.forEach(function (kv) {
+ kv = (kv || '').trim();
+ if (!kv) return;
+ hasKeys = true;
+ var split = kv.split(':');
+ ret[split[0]] = format(split[1]);
+ });
+
+ return hasKeys && ret;
+}
+
+var ipcRgx = /\.sock/;
+
+function parse (uriString) {
+ // do not use require('url').parse b/c it can't handle # in username or pwd
+ // mongo uris are strange
+
+ var uri = uriString;
+ var ret = {};
+ var parts;
+ var auth;
+ var ipcs;
+
+ // skip protocol
+ uri = uri.replace(/^mongodb:\/\//, '');
+
+ // auth
+ if (/@/.test(uri)) {
+ parts = uri.split(/@/);
+ auth = parts[0];
+ uri = parts[1];
+
+ parts = auth.split(':');
+ ret.auth = {};
+ ret.auth.user = parts[0];
+ ret.auth.pass = parts[1];
+ }
+
+ // unix domain sockets
+ if (ipcRgx.test(uri)) {
+ ipcs = uri.split(ipcRgx);
+ ret.ipc = ipcs[0] + '.sock';
+
+ // included a database?
+ if (ipcs[1]) {
+ // strip leading / from database name
+ ipcs[1] = ipcs[1].replace(/^\//, '');
+
+ if (ipcs[1]) {
+ ret.db = ipcs[1];
+ }
+ }
+
+ return ret;
+ }
+
+ // database name
+ parts = uri.split('/');
+ if (parts[1]) ret.db = parts[1];
+
+ // ipv6, [ip]:host
+ if (/^\[[^\]]+\]:\d+/.test(parts[0])) {
+ ret.host = parts[0].substring(1, parts[0].indexOf(']:'));
+ ret.port = parts[0].substring(parts[0].indexOf(']:') + ']:'.length);
+ } else {
+ // host:port
+ parts = parts[0].split(':');
+ ret.host = parts[0];
+ ret.port = parts[1] || DEFAULT_PORT;
+ }
+
+ return ret;
+}
+
+/**
+ * Version
+ */
+
+module.exports.version = JSON.parse(
+ require('fs').readFileSync(__dirname + '/../package.json', 'utf8')
+).version;
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/package.json
new file mode 100644
index 0000000..998f4ff
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/package.json
@@ -0,0 +1,60 @@
+{
+ "name": "muri",
+ "version": "1.1.1",
+ "description": "MongoDB URI parser",
+ "main": "index.js",
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/muri.git"
+ },
+ "keywords": [
+ "mongodb",
+ "uri",
+ "parser"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "1.21.5"
+ },
+ "gitHead": "21e47551051dfed98a441c152066a5ab3229a1ce",
+ "bugs": {
+ "url": "https://github.com/aheckmann/muri/issues"
+ },
+ "homepage": "https://github.com/aheckmann/muri#readme",
+ "_id": "muri@1.1.1",
+ "_shasum": "64bd904eaf8ff89600c994441fad3c5195905ac2",
+ "_from": "muri@1.1.1",
+ "_npmVersion": "3.9.5",
+ "_nodeVersion": "6.2.2",
+ "_npmUser": {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ "dist": {
+ "shasum": "64bd904eaf8ff89600c994441fad3c5195905ac2",
+ "tarball": "https://registry.npmjs.org/muri/-/muri-1.1.1.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-16-east.internal.npmjs.com",
+ "tmp": "tmp/muri-1.1.1.tgz_1474924467144_0.3518297451082617"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/muri/-/muri-1.1.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/test/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/test/index.js
new file mode 100644
index 0000000..7fc1e3e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/muri/test/index.js
@@ -0,0 +1,328 @@
+
+var muri = require('../')
+var assert = require('assert')
+
+describe('muri', function(){
+ it('must begin with mongodb://', function(done){
+ assert.throws(function () {
+ muri('localhost:27017');
+ }, /Invalid mongodb uri/);
+ assert.doesNotThrow(function () {
+ muri('mongodb://localhost:27017');
+ })
+ done();
+ })
+
+ describe('user:password', function(done){
+ it('is optional', function(done){
+ var uri = 'mongodb://local:27017';
+ var val = muri(uri);
+ assert.ok(!val.auth);
+ done();
+ })
+
+ it('parses properly', function(done){
+ var uri = 'mongodb://user:password@local:27017';
+ var val = muri(uri);
+ assert.ok(val.auth);
+ assert.equal('user', val.auth.user);
+ assert.equal('password', val.auth.pass);
+ done();
+ })
+
+ it('handles # in the username', function(done){
+ var uri = 'mongodb://us#er:password@local:27017';
+ var val = muri(uri);
+ assert.ok(val.auth);
+ assert.equal('us#er', val.auth.user);
+ assert.equal('password', val.auth.pass);
+ done();
+ })
+
+ it('handles # in the password', function(done){
+ var uri = 'mongodb://user:pa#ssword@local:27017';
+ var val = muri(uri);
+ assert.ok(val.auth);
+ assert.equal('user', val.auth.user);
+ assert.equal('pa#ssword', val.auth.pass);
+ done();
+ })
+ })
+
+ describe('host', function(){
+ it('must be specified', function(done){
+ assert.throws(function () {
+ muri('mongodb://');
+ }, /Missing host/)
+ assert.throws(function () {
+ muri('mongodb:///fake');
+ }, /Missing host/)
+ assert.throws(function () {
+ muri('mongodb://?yep');
+ }, /Missing host/)
+ assert.throws(function () {
+ muri('mongodb:///?yep');
+ }, /Missing host/)
+
+ var val = muri('mongodb://local');
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(1, val.hosts.length);
+ assert.equal('local', val.hosts[0].host);
+ done();
+ })
+
+ it('supports replica sets', function(done){
+ var val = muri('mongodb://local:27017,remote:27018,japan:99999');
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(3, val.hosts.length);
+ assert.equal('local', val.hosts[0].host);
+ assert.equal(27017, val.hosts[0].port);
+ assert.equal('remote', val.hosts[1].host);
+ assert.equal(27018, val.hosts[1].port);
+ assert.equal('japan', val.hosts[2].host);
+ assert.equal(99999, val.hosts[2].port);
+ done();
+ })
+ })
+
+ describe('port', function(){
+
+ describe('with single host', function(){
+ it('defaults to 27017 if not specified', function(done){
+ var val = muri('mongodb://local/');
+ assert.equal(27017, val.hosts[0].port);
+ done();
+ })
+
+ it('uses what is specified', function(done){
+ var val = muri('mongodb://local:27018');
+ assert.equal(27018, val.hosts[0].port);
+ done();
+ })
+ })
+
+ describe('with replica sets', function(){
+ var val;
+
+ before(function(){
+ val = muri('mongodb://local,remote:27018,another');
+ })
+
+ it('defaults to 27017 if not specified', function(done){
+ assert.equal(27017, val.hosts[0].port);
+ assert.equal(27017, val.hosts[2].port);
+ done();
+ })
+
+ it('uses what is specified', function(done){
+ assert.equal(27018, val.hosts[1].port);
+ done();
+ })
+ })
+ })
+
+ describe('database', function(){
+ it('default', function(done){
+ var val = muri('mongodb://localhost/');
+ assert.equal('test', val.db);
+ var val = muri('mongodb://localhost');
+ assert.equal('test', val.db);
+ done();
+ })
+ it('is overridable', function(done){
+ var val = muri('mongodb://localhost,a,x:34343,b/muri');
+ assert.equal('muri', val.db);
+ done();
+ })
+ it('works with multiple specified protocols', function(done){
+ var uri = 'mongodb://localhost:27020/testing,mongodb://localhost:27019,mongodb://localhost:27018'
+ var val = muri(uri);
+ assert.equal('testing', val.db);
+ done();
+ })
+ })
+
+ describe('querystring separator', function(){
+ it('can be ; ', function(done){
+ var val = muri('mongodb://muri/?replicaSet=myreplset;slaveOk=true;x=1');
+ assert.ok(val.options);
+ assert.equal(true, val.options.slaveOk);
+ assert.equal('myreplset', val.options.replicaSet);
+ assert.equal(1, val.options.x);
+ done();
+ })
+ it('can be & ', function(done){
+ var val = muri('mongodb://muri/?replicaSet=myreplset&slaveOk=true&x=1');
+ assert.ok(val.options);
+ assert.equal(true, val.options.slaveOk);
+ assert.equal('myreplset', val.options.replicaSet);
+ assert.equal(1, val.options.x);
+ done();
+ })
+ })
+
+ describe('readPref tags', function(){
+ describe('with & ', function(){
+ it('mongodb://localhost/?readPreferenceTags=dc:ny', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny');
+ assert.equal('test', val.db);
+ assert.deepEqual([{ dc: 'ny' }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=', function(done){
+ var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
+ done();
+ })
+ })
+ describe('with ; ', function(){
+ it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=', function(done){
+ var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
+ done();
+ })
+ it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=', function(done){
+ var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=');
+ assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
+ done();
+ })
+ })
+ })
+
+ describe('unix domain sockets', function(){
+ it('without auth', function(done){
+ var val = muri('mongodb:///tmp/mongodb-27017.sock?safe=false');
+ assert.equal(val.db, 'test')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(1, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ it('without auth with a database name', function(done){
+ var val = muri('mongodb:///tmp/mongodb-27017.sock/tester?safe=false');
+ assert.equal(val.db, 'tester')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(1, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ it('with auth', function(done){
+ var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock?safe=false');
+ assert.equal(val.db, 'admin')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(1, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ it('with auth with a db name', function(done){
+ var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock/tester?safe=false');
+ assert.equal(val.db, 'tester')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(1, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ it('with auth + repl sets', function(done){
+ var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock?safe=false');
+ assert.equal(val.db, 'admin')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(2, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
+ assert.equal(val.hosts[1].host, undefined);
+ assert.equal(val.hosts[1].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ it('with auth + repl sets with a db name', function(done){
+ var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock/tester?safe=false');
+ assert.equal(val.db, 'tester')
+ assert.ok(Array.isArray(val.hosts));
+ assert.equal(2, val.hosts.length);
+ assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
+ assert.equal(val.hosts[0].host, undefined);
+ assert.equal(val.hosts[0].port, undefined);
+ assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
+ assert.equal(val.hosts[1].host, undefined);
+ assert.equal(val.hosts[1].port, undefined);
+ assert.equal(false, val.options.safe);
+ done();
+ })
+ })
+
+ it('all together now', function(done){
+ var uri = 'mongodb://u#ser:pas#s@local,remote:27018,japan:27019/neatdb'
+ uri += '?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50'
+ var val = muri(uri);
+
+ assert.equal('u#ser', val.auth.user);
+ assert.equal('pas#s', val.auth.pass);
+ assert.equal('neatdb', val.db);
+ assert.equal(3, val.hosts.length);
+ assert.equal('local', val.hosts[0].host);
+ assert.strictEqual(27017, val.hosts[0].port);
+ assert.equal('remote', val.hosts[1].host);
+ assert.strictEqual(27018, val.hosts[1].port);
+ assert.equal('japan', val.hosts[2].host);
+ assert.strictEqual(27019, val.hosts[2].port);
+ assert.equal('myreplset', val.options.replicaSet);
+ assert.equal(true, val.options.journal);
+ assert.equal(50, val.options.wtimeoutMS);
+ done();
+ });
+
+ it('ipv6', function(done) {
+ var uri = 'mongodb://[::1]:27017/test';
+ var val = muri(uri);
+ assert.equal(1, val.hosts.length);
+ assert.equal('::1', val.hosts[0].host);
+ assert.equal(27017, val.hosts[0].port);
+ done();
+ });
+
+ it('has a version', function(done){
+ assert.ok(muri.version);
+ done();
+ })
+
+ it('replica set name with a leading number', function(done){
+ var uri = 'mongodb://localhost:27017/test?replicaSet=1800-shard-0';
+ var val = muri(uri);
+ assert.equal('1800-shard-0', val.options.replicaSet);
+ done()
+ })
+})
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.npmignore b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.npmignore
new file mode 100644
index 0000000..be106ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.npmignore
@@ -0,0 +1,2 @@
+*.sw*
+node_modules/
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.travis.yml b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.travis.yml
new file mode 100644
index 0000000..58f2371
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
+ - 0.10
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/History.md
new file mode 100644
index 0000000..0beedfc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/History.md
@@ -0,0 +1,5 @@
+
+0.0.1 / 2013-04-17
+==================
+
+ * initial commit
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/LICENSE
new file mode 100644
index 0000000..98c7c89
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2013 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/Makefile b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/Makefile
new file mode 100644
index 0000000..6c8fb75
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/Makefile
@@ -0,0 +1,5 @@
+
+test:
+ @./node_modules/.bin/mocha $(T) --async-only $(TESTS)
+
+.PHONY: test
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/README.md
new file mode 100644
index 0000000..2aabe5c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/README.md
@@ -0,0 +1,18 @@
+#regexp-clone
+==============
+
+Clones RegExps with flag preservation
+
+```js
+var regexpClone = require('regexp-clone');
+
+var a = /somethin/g;
+console.log(a.global); // true
+
+var b = regexpClone(a);
+console.log(b.global); // true
+```
+
+## License
+
+[MIT](https://github.com/aheckmann/regexp-clone/blob/master/LICENSE)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/index.js
new file mode 100644
index 0000000..e5850ca
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/index.js
@@ -0,0 +1,20 @@
+
+var toString = Object.prototype.toString;
+
+function isRegExp (o) {
+ return 'object' == typeof o
+ && '[object RegExp]' == toString.call(o);
+}
+
+module.exports = exports = function (regexp) {
+ if (!isRegExp(regexp)) {
+ throw new TypeError('Not a RegExp');
+ }
+
+ var flags = [];
+ if (regexp.global) flags.push('g');
+ if (regexp.multiline) flags.push('m');
+ if (regexp.ignoreCase) flags.push('i');
+ return new RegExp(regexp.source, flags.join(''));
+}
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/package.json
new file mode 100644
index 0000000..6b5f72c
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "regexp-clone",
+ "version": "0.0.1",
+ "description": "Clone RegExps with options",
+ "main": "index.js",
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/regexp-clone.git"
+ },
+ "keywords": [
+ "RegExp",
+ "clone"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "1.8.1"
+ },
+ "readme": "#regexp-clone\n==============\n\nClones RegExps with flag preservation\n\n```js\nvar regexpClone = require('regexp-clone');\n\nvar a = /somethin/g;\nconsole.log(a.global); // true\n\nvar b = regexpClone(a);\nconsole.log(b.global); // true\n```\n\n## License\n\n[MIT](https://github.com/aheckmann/regexp-clone/blob/master/LICENSE)\n",
+ "readmeFilename": "README.md",
+ "_id": "regexp-clone@0.0.1",
+ "dist": {
+ "shasum": "a7c2e09891fdbf38fbb10d376fb73003e68ac589",
+ "tarball": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz"
+ },
+ "_from": "regexp-clone@0.0.1",
+ "_npmVersion": "1.2.14",
+ "_npmUser": {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "a7c2e09891fdbf38fbb10d376fb73003e68ac589",
+ "_resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/test/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/test/index.js
new file mode 100644
index 0000000..264a776
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/regexp-clone/test/index.js
@@ -0,0 +1,112 @@
+
+var assert = require('assert')
+var clone = require('../');
+
+describe('regexp-clone', function(){
+ function hasEqualSource (a, b) {
+ assert.ok(a !== b);
+ assert.equal(a.source, b.source);
+ }
+
+ function isInsensitive (a) {
+ assert.ok(a.ignoreCase);
+ }
+
+ function isGlobal (a) {
+ assert.ok(a.global);
+ }
+
+ function isMultiline (a) {
+ assert.ok(a.multiline);
+ }
+
+ function insensitiveFlag (a) {
+ var b = clone(a);
+ hasEqualSource(a, b);
+ isInsensitive(a);
+ isInsensitive(b);
+ }
+
+ function globalFlag (a) {
+ var b = clone(a);
+ hasEqualSource(a, b);
+ isGlobal(a);
+ isGlobal(b);
+ }
+
+ function multilineFlag (a) {
+ var b = clone(a);
+ hasEqualSource(a, b);
+ isMultiline(a);
+ isMultiline(b);
+ }
+
+ describe('literals', function(){
+ it('insensitive flag', function(done){
+ var a = /hello/i;
+ insensitiveFlag(a);
+ done();
+ })
+ it('global flag', function(done){
+ var a = /hello/g;
+ globalFlag(a);
+ done();
+ })
+ it('multiline flag', function(done){
+ var a = /hello/m;
+ multilineFlag(a);
+ done();
+ })
+ it('no flags', function(done){
+ var a = /hello/;
+ var b = clone(a);
+ hasEqualSource(a, b);
+ assert.ok(!a.insensitive);
+ assert.ok(!a.global);
+ assert.ok(!a.global);
+ done();
+ })
+ it('all flags', function(done){
+ var a = /hello/gim;
+ insensitiveFlag(a);
+ globalFlag(a);
+ multilineFlag(a);
+ done();
+ })
+ })
+
+ describe('instances', function(){
+ it('insensitive flag', function(done){
+ var a = new RegExp('hello', 'i');
+ insensitiveFlag(a);
+ done();
+ })
+ it('global flag', function(done){
+ var a = new RegExp('hello', 'g');
+ globalFlag(a);
+ done();
+ })
+ it('multiline flag', function(done){
+ var a = new RegExp('hello', 'm');
+ multilineFlag(a);
+ done();
+ })
+ it('no flags', function(done){
+ var a = new RegExp('hmm');
+ var b = clone(a);
+ hasEqualSource(a, b);
+ assert.ok(!a.insensitive);
+ assert.ok(!a.global);
+ assert.ok(!a.global);
+ done();
+ })
+ it('all flags', function(done){
+ var a = new RegExp('hello', 'gim');
+ insensitiveFlag(a);
+ globalFlag(a);
+ multilineFlag(a);
+ done();
+ })
+ })
+})
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/History.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/History.md
new file mode 100644
index 0000000..e45cefe
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/History.md
@@ -0,0 +1,41 @@
+
+1.0.1 / 2015-07-14
+==================
+
+ * fixed; missing file introduced in 4f5cea1
+
+1.0.0 / 2015-07-12
+==================
+
+ * Remove unnecessary files from npm package - #6 via joaquimserafim
+ * updated readme stats
+
+0.0.5 / 2013-02-05
+==================
+
+ * optimization: remove use of arguments [jkroso](https://github.com/jkroso)
+ * add scripts to component.json [jkroso](https://github.com/jkroso)
+ * tests; remove time for travis
+
+0.0.4 / 2013-01-07
+==================
+
+ * added component.json #1 [jkroso](https://github.com/jkroso)
+ * reversed array loop #1 [jkroso](https://github.com/jkroso)
+ * remove fn params
+
+0.0.3 / 2012-09-29
+==================
+
+ * faster with negative start args
+
+0.0.2 / 2012-09-29
+==================
+
+ * support full [].slice semantics
+
+0.0.1 / 2012-09-29
+===================
+
+ * initial release
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/LICENSE b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/LICENSE
new file mode 100644
index 0000000..38c529d
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.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/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/README.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/README.md
new file mode 100644
index 0000000..b6ff85e
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/README.md
@@ -0,0 +1,62 @@
+#sliced
+==========
+
+A faster alternative to `[].slice.call(arguments)`.
+
+[![Build Status](https://secure.travis-ci.org/aheckmann/sliced.png)](http://travis-ci.org/aheckmann/sliced)
+
+Example output from [benchmark.js](https://github.com/bestiejs/benchmark.js)
+
+ Array.prototype.slice.call x 1,401,820 ops/sec ±2.16% (90 runs sampled)
+ [].slice.call x 1,313,116 ops/sec ±2.04% (96 runs sampled)
+ cached slice.call x 10,297,910 ops/sec ±1.81% (96 runs sampled)
+ sliced x 19,906,019 ops/sec ±1.23% (89 runs sampled)
+ fastest is sliced
+
+ Array.prototype.slice.call(arguments, 1) x 1,373,238 ops/sec ±1.84% (95 runs sampled)
+ [].slice.call(arguments, 1) x 1,395,336 ops/sec ±1.36% (93 runs sampled)
+ cached slice.call(arguments, 1) x 9,926,018 ops/sec ±1.67% (92 runs sampled)
+ sliced(arguments, 1) x 20,747,990 ops/sec ±1.16% (93 runs sampled)
+ fastest is sliced(arguments, 1)
+
+ Array.prototype.slice.call(arguments, -1) x 1,319,908 ops/sec ±2.12% (91 runs sampled)
+ [].slice.call(arguments, -1) x 1,336,170 ops/sec ±1.33% (97 runs sampled)
+ cached slice.call(arguments, -1) x 10,078,718 ops/sec ±1.21% (98 runs sampled)
+ sliced(arguments, -1) x 20,471,474 ops/sec ±1.81% (92 runs sampled)
+ fastest is sliced(arguments, -1)
+
+ Array.prototype.slice.call(arguments, -2, -10) x 1,369,246 ops/sec ±1.68% (97 runs sampled)
+ [].slice.call(arguments, -2, -10) x 1,387,935 ops/sec ±1.70% (95 runs sampled)
+ cached slice.call(arguments, -2, -10) x 9,593,428 ops/sec ±1.23% (97 runs sampled)
+ sliced(arguments, -2, -10) x 23,178,931 ops/sec ±1.70% (92 runs sampled)
+ fastest is sliced(arguments, -2, -10)
+
+ Array.prototype.slice.call(arguments, -2, -1) x 1,441,300 ops/sec ±1.26% (98 runs sampled)
+ [].slice.call(arguments, -2, -1) x 1,410,326 ops/sec ±1.96% (93 runs sampled)
+ cached slice.call(arguments, -2, -1) x 9,854,419 ops/sec ±1.02% (97 runs sampled)
+ sliced(arguments, -2, -1) x 22,550,801 ops/sec ±1.86% (91 runs sampled)
+ fastest is sliced(arguments, -2, -1)
+
+_Benchmark [source](https://github.com/aheckmann/sliced/blob/master/bench.js)._
+
+##Usage
+
+`sliced` accepts the same arguments as `Array#slice` so you can easily swap it out.
+
+```js
+function zing () {
+ var slow = [].slice.call(arguments, 1, 8);
+ var args = slice(arguments, 1, 8);
+
+ var slow = Array.prototype.slice.call(arguments);
+ var args = slice(arguments);
+ // etc
+}
+```
+
+## install
+
+ npm install sliced
+
+
+[LICENSE](https://github.com/aheckmann/sliced/blob/master/LICENSE)
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/index.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/index.js
new file mode 100644
index 0000000..d88c85b
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/index.js
@@ -0,0 +1,33 @@
+
+/**
+ * An Array.prototype.slice.call(arguments) alternative
+ *
+ * @param {Object} args something with a length
+ * @param {Number} slice
+ * @param {Number} sliceEnd
+ * @api public
+ */
+
+module.exports = function (args, slice, sliceEnd) {
+ var ret = [];
+ var len = args.length;
+
+ if (0 === len) return ret;
+
+ var start = slice < 0
+ ? Math.max(0, slice + len)
+ : slice || 0;
+
+ if (sliceEnd !== undefined) {
+ len = sliceEnd < 0
+ ? sliceEnd + len
+ : sliceEnd
+ }
+
+ while (len-- > start) {
+ ret[len - start] = args[len];
+ }
+
+ return ret;
+}
+
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/package.json
new file mode 100644
index 0000000..1d8cffc
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/node_modules/sliced/package.json
@@ -0,0 +1,59 @@
+{
+ "name": "sliced",
+ "version": "1.0.1",
+ "description": "A faster Node.js alternative to Array.prototype.slice.call(arguments)",
+ "main": "index.js",
+ "files": [
+ "LICENSE",
+ "README.md",
+ "index.js"
+ ],
+ "scripts": {
+ "test": "make test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/aheckmann/sliced"
+ },
+ "keywords": [
+ "arguments",
+ "slice",
+ "array"
+ ],
+ "author": {
+ "name": "Aaron Heckmann",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "1.5.0",
+ "benchmark": "~1.0.0"
+ },
+ "dependencies": {},
+ "gitHead": "e7c989016d2062995cd102322b65784ba8977ee3",
+ "bugs": {
+ "url": "https://github.com/aheckmann/sliced/issues"
+ },
+ "homepage": "https://github.com/aheckmann/sliced",
+ "_id": "sliced@1.0.1",
+ "_shasum": "0b3a662b5d04c3177b1926bea82b03f837a2ef41",
+ "_from": "sliced@1.0.1",
+ "_npmVersion": "2.8.3",
+ "_nodeVersion": "1.8.1",
+ "_npmUser": {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "0b3a662b5d04c3177b1926bea82b03f837a2ef41",
+ "tarball": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/package.json b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/package.json
new file mode 100644
index 0000000..33534f1
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/package.json
@@ -0,0 +1,135 @@
+{
+ "name": "mongoose",
+ "description": "Mongoose MongoDB ODM",
+ "version": "4.7.1",
+ "author": {
+ "name": "Guillermo Rauch",
+ "email": "guillermo@learnboost.com"
+ },
+ "keywords": [
+ "mongodb",
+ "document",
+ "model",
+ "schema",
+ "database",
+ "odm",
+ "data",
+ "datastore",
+ "query",
+ "nosql",
+ "orm",
+ "db"
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "async": "2.1.2",
+ "bson": "~0.5.4",
+ "hooks-fixed": "1.2.0",
+ "kareem": "1.1.3",
+ "mongodb": "2.2.11",
+ "mpath": "0.2.1",
+ "mpromise": "0.5.5",
+ "mquery": "2.0.0",
+ "ms": "0.7.1",
+ "muri": "1.1.1",
+ "regexp-clone": "0.0.1",
+ "sliced": "1.0.1"
+ },
+ "devDependencies": {
+ "acquit": "0.4.1",
+ "acquit-ignore": "0.0.3",
+ "bluebird": "3.4.6",
+ "co": "4.6.0",
+ "dox": "0.3.1",
+ "eslint": "2.4.0",
+ "highlight.js": "7.0.1",
+ "istanbul": "0.4.4",
+ "jade": "0.26.3",
+ "lodash": "4.16.6",
+ "markdown": "0.3.1",
+ "marked": "0.3.6",
+ "mocha": "3.1.2",
+ "mongoose-long": "0.1.1",
+ "node-static": "0.7.7",
+ "power-assert": "1.4.1",
+ "q": "1.4.1",
+ "tbd": "0.6.4",
+ "uglify-js": "2.7.0",
+ "uuid": "2.0.3",
+ "validator": "5.4.0"
+ },
+ "browserDependencies": {
+ "browserify": "4.1.10",
+ "chai": "3.5.0",
+ "karma": "0.12.16",
+ "karma-chai": "0.1.0",
+ "karma-mocha": "0.1.4",
+ "karma-chrome-launcher": "0.1.4",
+ "karma-sauce-launcher": "0.2.8"
+ },
+ "directories": {
+ "lib": "./lib/mongoose"
+ },
+ "scripts": {
+ "fix-lint": "eslint . --fix",
+ "install-browser": "npm install `node format_deps.js`",
+ "test": "mocha test/*.test.js test/**/*.test.js",
+ "posttest": "eslint . --quiet",
+ "test-cov": "istanbul cover --report text --report html _mocha test/*.test.js"
+ },
+ "main": "./index.js",
+ "engines": {
+ "node": ">=0.6.19"
+ },
+ "bugs": {
+ "url": "https://github.com/Automattic/mongoose/issues/new",
+ "email": "mongoose-orm@googlegroups.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Automattic/mongoose.git"
+ },
+ "homepage": "http://mongoosejs.com",
+ "browser": "lib/browser.js",
+ "gitHead": "8fabb12172b006624081bae32a76b49af7dcd415",
+ "_id": "mongoose@4.7.1",
+ "_shasum": "3842df23f5eb5db31d27311d2a3fb4cca2b5cd9e",
+ "_from": "mongoose@>=4.0.0 <5.0.0",
+ "_npmVersion": "3.10.8",
+ "_nodeVersion": "6.9.0",
+ "_npmUser": {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ "dist": {
+ "shasum": "3842df23f5eb5db31d27311d2a3fb4cca2b5cd9e",
+ "tarball": "https://registry.npmjs.org/mongoose/-/mongoose-4.7.1.tgz"
+ },
+ "maintainers": [
+ {
+ "name": "rauchg",
+ "email": "rauchg@gmail.com"
+ },
+ {
+ "name": "tjholowaychuk",
+ "email": "tj@vision-media.ca"
+ },
+ {
+ "name": "aaron",
+ "email": "aaron.heckmann+github@gmail.com"
+ },
+ {
+ "name": "vkarpov15",
+ "email": "val@karpov.io"
+ },
+ {
+ "name": "defunctzombie",
+ "email": "shtylman@gmail.com"
+ }
+ ],
+ "_npmOperationalInternal": {
+ "host": "packages-18-east.internal.npmjs.com",
+ "tmp": "tmp/mongoose-4.7.1.tgz_1480555349621_0.35412858170457184"
+ },
+ "_resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.7.1.tgz"
+}
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/release-items.md b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/release-items.md
new file mode 100644
index 0000000..4d0471a
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/release-items.md
@@ -0,0 +1,29 @@
+## mongoose release procedure
+
+1. tests must pass
+2. update package.json version
+3. update History.md using `git changelog` or similar. list the related ticket(s) #<TICKET_NUMBER> as well as a link to the github user who fixed it if applicable.
+4. git commit -m 'release x.x.x'
+5. git tag x.x.x
+6. git push origin BRANCH --tags && npm publish
+7. update mongoosejs.com (see "updating the website" below)
+8. tweet changelog link from [@mongoosejs](https://twitter.com/mongoosejs)
+9. Announce on mongoosejsteam slack channel
+10. change package.json version to next patch version suffixed with '-pre' and commit "now working on x.x.x"
+11. if this is a legacy release, `git merge` changes into master.
+
+## updating the website
+
+For 4.x
+
+0. Change to the master branch
+1. execute `make docs` (when this process completes you'll be on the gh-pages branch)
+2. `git commit -a -m 'docs: release 4.x.x'`
+3. `git push origin gh-pages`
+
+For 3.8.x:
+
+0. Change to the 3.8.x branch
+1. execute `make docs_legacy` (when this process completes you'll be on the gh-pages branch)
+2. `git commit -a -m 'website; regen <x.x.x>'`
+3. `git push origin gh-pages`
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/static.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/static.js
new file mode 100644
index 0000000..d84e59f
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/static.js
@@ -0,0 +1,24 @@
+
+var static = require('node-static');
+var server = new static.Server('.', {cache: 0});
+
+require('http').createServer(function(req, res) {
+ if (req.url === '/favicon.ico') {
+ req.destroy();
+ res.statusCode = 204;
+ return res.end();
+ }
+
+ req.on('end', function() {
+ server.serve(req, res, function(err) {
+ if (err) {
+ console.error(err, req.url);
+ res.writeHead(err.status, err.headers);
+ res.end();
+ }
+ });
+ });
+ req.resume();
+}).listen(8088);
+
+console.error('now listening on http://localhost:8088');
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/website.js b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/website.js
new file mode 100644
index 0000000..a1186a5
--- /dev/null
+++ b/common/src/main/webapp/usageguide/appserver/node_modules/mongoose/website.js
@@ -0,0 +1,87 @@
+var fs = require('fs');
+var jade = require('jade');
+var package = require('./package');
+var hl = require('./docs/helpers/highlight');
+var linktype = require('./docs/helpers/linktype');
+var href = require('./docs/helpers/href');
+var klass = require('./docs/helpers/klass');
+
+// add custom jade filters
+require('./docs/helpers/filters')(jade);
+
+function getVersion() {
+ var hist = fs.readFileSync('./History.md', 'utf8').replace(/\r/g, '\n').split('\n');
+ for (var i = 0; i < hist.length; ++i) {
+ var line = (hist[i] || '').trim();
+ if (!line) {
+ continue;
+ }
+ var match = /^\s*([^\s]+)\s/.exec(line);
+ if (match && match[1]) {
+ return match[1];
+ }
+ }
+ throw new Error('no match found');
+}
+
+function getUnstable(ver) {
+ ver = ver.replace('-pre');
+ var spl = ver.split('.');
+ spl = spl.map(function(i) {
+ return parseInt(i, 10);
+ });
+ spl[1]++;
+ spl[2] = 'x';
+ return spl.join('.');
+}
+
+// use last release
+package.version = getVersion();
+package.unstable = getUnstable(package.version);
+
+var filemap = require('./docs/source');
+var files = Object.keys(filemap);
+
+function jadeify(filename, options, newfile) {
+ options = options || {};
+ options.package = package;
+ options.hl = hl;
+ options.linktype = linktype;
+ options.href = href;
+ options.klass = klass;
+ jade.renderFile(filename, options, function(err, str) {
+ if (err) {
+ console.error(err.stack);
+ return;
+ }
+
+ newfile = newfile || filename.replace('.jade', '.html');
+ fs.writeFile(newfile, str, function(err) {
+ if (err) {
+ console.error('could not write', err.stack);
+ } else {
+ console.log('%s : rendered ', new Date, newfile);
+ }
+ });
+ });
+}
+
+files.forEach(function(file) {
+ var filename = __dirname + '/' + file;
+ jadeify(filename, filemap[file]);
+
+ if (process.argv[2] === '--watch') {
+ fs.watchFile(filename, {interval: 1000}, function(cur, prev) {
+ if (cur.mtime > prev.mtime) {
+ jadeify(filename, filemap[file]);
+ }
+ });
+ }
+});
+
+var acquit = require('./docs/source/acquit');
+var acquitFiles = Object.keys(acquit);
+acquitFiles.forEach(function(file) {
+ var filename = __dirname + '/docs/acquit.jade';
+ jadeify(filename, acquit[file], __dirname + '/docs/' + file);
+});