From a086604f8f78f6b7096a0d5590a415c8a9575bf3 Mon Sep 17 00:00:00 2001
From: hectorcoronado
Date: Sun, 15 Jul 2018 18:14:37 -0700
Subject: [PATCH 01/95] test: remove 3rd arg from to assert.strictEqual()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
prevents AssertionError from reporting string literal,
instead displays values of first 2 args passed to
assert.strictEqual()
PR-URL: https://github.com/nodejs/node/pull/21828
Reviewed-By: Rich Trott
Reviewed-By: Colin Ihrig
Reviewed-By: Tobias Nießen
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: James M Snell
---
.../test-stream-transform-final-sync.js | 30 ++++++++++++-------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/test/parallel/test-stream-transform-final-sync.js b/test/parallel/test-stream-transform-final-sync.js
index 7dbd06d60c3625..666c1dce9996d1 100644
--- a/test/parallel/test-stream-transform-final-sync.js
+++ b/test/parallel/test-stream-transform-final-sync.js
@@ -59,42 +59,52 @@ The order things are called
const t = new stream.Transform({
objectMode: true,
transform: common.mustCall(function(chunk, _, next) {
- assert.strictEqual(++state, chunk, 'transformCallback part 1');
+ // transformCallback part 1
+ assert.strictEqual(++state, chunk);
this.push(state);
- assert.strictEqual(++state, chunk + 2, 'transformCallback part 2');
+ // transformCallback part 2
+ assert.strictEqual(++state, chunk + 2);
process.nextTick(next);
}, 3),
final: common.mustCall(function(done) {
state++;
- assert.strictEqual(state, 10, 'finalCallback part 1');
+ // finalCallback part 1
+ assert.strictEqual(state, 10);
state++;
- assert.strictEqual(state, 11, 'finalCallback part 2');
+ // finalCallback part 2
+ assert.strictEqual(state, 11);
done();
}, 1),
flush: common.mustCall(function(done) {
state++;
- assert.strictEqual(state, 12, 'flushCallback part 1');
+ // fluchCallback part 1
+ assert.strictEqual(state, 12);
process.nextTick(function() {
state++;
- assert.strictEqual(state, 15, 'flushCallback part 2');
+ // fluchCallback part 2
+ assert.strictEqual(state, 15);
done();
});
}, 1)
});
t.on('finish', common.mustCall(function() {
state++;
- assert.strictEqual(state, 13, 'finishListener');
+ // finishListener
+ assert.strictEqual(state, 13);
}, 1));
t.on('end', common.mustCall(function() {
state++;
- assert.strictEqual(state, 16, 'end event');
+ // endEvent
+ assert.strictEqual(state, 16);
}, 1));
t.on('data', common.mustCall(function(d) {
- assert.strictEqual(++state, d + 1, 'dataListener');
+ // dataListener
+ assert.strictEqual(++state, d + 1);
}, 3));
t.write(1);
t.write(4);
t.end(7, common.mustCall(function() {
state++;
- assert.strictEqual(state, 14, 'endMethodCallback');
+ // endMethodCallback
+ assert.strictEqual(state, 14);
}, 1));
From a5928712c909641c34088b0fe98d4adabc91db03 Mon Sep 17 00:00:00 2001
From: Petras <15868923+kimberlake@users.noreply.github.com>
Date: Wed, 11 Jul 2018 11:35:30 +0100
Subject: [PATCH 02/95] http: name anonymous function in _http_common.js
Refs: https://github.com/nodejs/node/issues/8913
PR-URL: https://github.com/nodejs/node/pull/21755
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
Reviewed-By: Jon Moss
Reviewed-By: Colin Ihrig
---
lib/_http_common.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/_http_common.js b/lib/_http_common.js
index 32fc782331e2bd..faa6fe629ae416 100644
--- a/lib/_http_common.js
+++ b/lib/_http_common.js
@@ -148,7 +148,7 @@ function parserOnMessageComplete() {
}
-const parsers = new FreeList('parsers', 1000, function() {
+const parsers = new FreeList('parsers', 1000, function parsersCb() {
const parser = new HTTPParser(HTTPParser.REQUEST);
parser._headers = [];
From 0f70017f3554e36f2296a4949e4a7cde13b7741a Mon Sep 17 00:00:00 2001
From: Kevin Lacabane <5239883+klacabane@users.noreply.github.com>
Date: Wed, 11 Jul 2018 11:36:33 +0100
Subject: [PATCH 03/95] tls: name anonymous function in tls.js
Refs: https://github.com/nodejs/node/issues/8913
PR-URL: https://github.com/nodejs/node/pull/21754
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
Reviewed-By: Jon Moss
---
lib/tls.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tls.js b/lib/tls.js
index f4b72851907862..ddc84aab8bb03d 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -85,7 +85,7 @@ exports.convertNPNProtocols = internalUtil.deprecate(function(protocols, out) {
}
}, 'tls.convertNPNProtocols() is deprecated.', 'DEP0107');
-exports.convertALPNProtocols = function(protocols, out) {
+exports.convertALPNProtocols = function convertALPNProtocols(protocols, out) {
// If protocols is Array - translate it into buffer
if (Array.isArray(protocols)) {
out.ALPNProtocols = convertProtocols(protocols);
From c45623a548812463927d7408c1167cac21c7f23c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?=
Date: Mon, 16 Jul 2018 15:17:54 +0200
Subject: [PATCH 04/95] src: avoid unnecessarily formatting a warning
ProcessEmitWarning will already format the message, there is no
need to call snprintf here.
PR-URL: https://github.com/nodejs/node/pull/21832
Reviewed-By: Anatoli Papirovski
Reviewed-By: Colin Ihrig
Reviewed-By: Gus Caplan
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Anna Henningsen
Reviewed-By: Luigi Pinca
Reviewed-By: James M Snell
---
src/node_file.cc | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/node_file.cc b/src/node_file.cc
index f08833b201b19d..c62697cf312b0a 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -172,13 +172,11 @@ inline void FileHandle::Close() {
// to notify that the file descriptor was gc'd. We want to be noisy about
// this because not explicitly closing the FileHandle is a bug.
env()->SetUnrefImmediate([](Environment* env, void* data) {
- char msg[70];
err_detail* detail = static_cast(data);
- snprintf(msg, arraysize(msg),
- "Closing file descriptor %d on garbage collection",
- detail->fd);
+ ProcessEmitWarning(env,
+ "Closing file descriptor %d on garbage collection",
+ detail->fd);
delete detail;
- ProcessEmitWarning(env, msg);
}, detail);
}
From d0c16f4b2a9f8abdf61e948655fa1db2b3ffb5bb Mon Sep 17 00:00:00 2001
From: "Simionescu, Radu"
Date: Wed, 11 Jul 2018 11:38:52 +0100
Subject: [PATCH 05/95] stream: named anonymous functions in
_stream_readable.js
PR-URL: https://github.com/nodejs/node/pull/21750
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
---
lib/_stream_readable.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 31b129facd3a38..0b5cac6b8376e3 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -721,7 +721,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
};
function pipeOnDrain(src) {
- return function() {
+ return function pipeOnDrainFunctionResult() {
var state = src._readableState;
debug('pipeOnDrain', state.awaitDrain);
if (state.awaitDrain)
@@ -951,8 +951,8 @@ Readable.prototype.wrap = function(stream) {
// 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() {
+ this[i] = function methodWrap(method) {
+ return function methodWrapReturnFunction() {
return stream[method].apply(stream, arguments);
};
}(i);
From 6af4f1f515501d485d0c9ae5aa60c311282aa77d Mon Sep 17 00:00:00 2001
From: mariotsi
Date: Thu, 12 Jul 2018 10:59:57 +0100
Subject: [PATCH 06/95] stream: name anonymous function in _stream_writable.js
PR-URL: https://github.com/nodejs/node/pull/21753
Refs: https://github.com/nodejs/node/issues/8913
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Anna Henningsen
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
Reviewed-By: Jon Moss
Reviewed-By: Colin Ihrig
---
lib/_stream_writable.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index 2f69ba931afa4b..3bad957912b323 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -168,7 +168,7 @@ WritableState.prototype.getBuffer = function getBuffer() {
};
Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function() {
+ get: internalUtil.deprecate(function writableStateBufferGetter() {
return this.getBuffer();
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' +
'instead.', 'DEP0003')
From d7edee4954f2bcdd204944986b5c7c45a3b4efdb Mon Sep 17 00:00:00 2001
From: James M Snell
Date: Thu, 12 Jul 2018 12:22:54 -0700
Subject: [PATCH 07/95] trace_events: add more process metadata
Now that TracedValue has landed, add more detailed
process `__metadata` including versions, arch, platform,
release detail, and argv/execArgv to the trace event
log.
PR-URL: https://github.com/nodejs/node/pull/21785
Reviewed-By: Anna Henningsen
---
src/node.cc | 110 +++++++++++++++++---
test/parallel/test-trace-events-metadata.js | 44 ++++++--
2 files changed, 132 insertions(+), 22 deletions(-)
diff --git a/src/node.cc b/src/node.cc
index 627f4958e0278c..a31bcacc1f7ffa 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -30,6 +30,7 @@
#include "node_debug_options.h"
#include "node_perf.h"
#include "node_context_data.h"
+#include "tracing/traced_value.h"
#if defined HAVE_PERFCTR
#include "node_counters.h"
@@ -289,11 +290,106 @@ static v8::Isolate* node_isolate;
DebugOptions debug_options;
+// Ensures that __metadata trace events are only emitted
+// when tracing is enabled.
+class NodeTraceStateObserver :
+ public v8::TracingController::TraceStateObserver {
+ public:
+ void OnTraceEnabled() override {
+ char name_buffer[512];
+ if (uv_get_process_title(name_buffer, sizeof(name_buffer)) == 0) {
+ // Only emit the metadata event if the title can be retrieved
+ // successfully. Ignore it otherwise.
+ TRACE_EVENT_METADATA1("__metadata", "process_name",
+ "name", TRACE_STR_COPY(name_buffer));
+ }
+ TRACE_EVENT_METADATA1("__metadata", "version",
+ "node", NODE_VERSION_STRING);
+ TRACE_EVENT_METADATA1("__metadata", "thread_name",
+ "name", "JavaScriptMainThread");
+
+ auto trace_process = tracing::TracedValue::Create();
+ trace_process->BeginDictionary("versions");
+
+ const char http_parser_version[] =
+ NODE_STRINGIFY(HTTP_PARSER_VERSION_MAJOR)
+ "."
+ NODE_STRINGIFY(HTTP_PARSER_VERSION_MINOR)
+ "."
+ NODE_STRINGIFY(HTTP_PARSER_VERSION_PATCH);
+
+ const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION);
+ const char node_modules_version[] = NODE_STRINGIFY(NODE_MODULE_VERSION);
+
+ trace_process->SetString("http_parser", http_parser_version);
+ trace_process->SetString("node", NODE_VERSION_STRING);
+ trace_process->SetString("v8", V8::GetVersion());
+ trace_process->SetString("uv", uv_version_string());
+ trace_process->SetString("zlib", ZLIB_VERSION);
+ trace_process->SetString("ares", ARES_VERSION_STR);
+ trace_process->SetString("modules", node_modules_version);
+ trace_process->SetString("nghttp2", NGHTTP2_VERSION);
+ trace_process->SetString("napi", node_napi_version);
+
+#if HAVE_OPENSSL
+ // Stupid code to slice out the version string.
+ { // NOLINT(whitespace/braces)
+ size_t i, j, k;
+ int c;
+ for (i = j = 0, k = sizeof(OPENSSL_VERSION_TEXT) - 1; i < k; ++i) {
+ c = OPENSSL_VERSION_TEXT[i];
+ if ('0' <= c && c <= '9') {
+ for (j = i + 1; j < k; ++j) {
+ c = OPENSSL_VERSION_TEXT[j];
+ if (c == ' ')
+ break;
+ }
+ break;
+ }
+ }
+ trace_process->SetString("openssl",
+ std::string(&OPENSSL_VERSION_TEXT[i], j - i));
+ }
+#endif
+ trace_process->EndDictionary();
+
+ trace_process->SetString("arch", NODE_ARCH);
+ trace_process->SetString("platform", NODE_PLATFORM);
+
+ trace_process->BeginDictionary("release");
+ trace_process->SetString("name", NODE_RELEASE);
+#if NODE_VERSION_IS_LTS
+ trace_process->SetString("lts", NODE_VERSION_LTS_CODENAME);
+#endif
+ trace_process->EndDictionary();
+ TRACE_EVENT_METADATA1("__metadata", "node",
+ "process", std::move(trace_process));
+
+ // This only runs the first time tracing is enabled
+ controller_->RemoveTraceStateObserver(this);
+ delete this;
+ }
+
+ void OnTraceDisabled() override {
+ // Do nothing here. This should never be called because the
+ // observer removes itself when OnTraceEnabled() is called.
+ UNREACHABLE();
+ }
+
+ explicit NodeTraceStateObserver(v8::TracingController* controller) :
+ controller_(controller) {}
+ ~NodeTraceStateObserver() override {}
+
+ private:
+ v8::TracingController* controller_;
+};
+
static struct {
#if NODE_USE_V8_PLATFORM
void Initialize(int thread_pool_size) {
tracing_agent_.reset(new tracing::Agent(trace_file_pattern));
auto controller = tracing_agent_->GetTracingController();
+ controller->AddTraceStateObserver(new NodeTraceStateObserver(controller));
tracing::TraceEventHelper::SetTracingController(controller);
StartTracingAgent();
platform_ = new NodePlatform(thread_pool_size, controller);
@@ -1992,7 +2088,6 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(versions,
"http_parser",
FIXED_ONE_BYTE_STRING(env->isolate(), http_parser_version));
-
// +1 to get rid of the leading 'v'
READONLY_PROPERTY(versions,
"node",
@@ -2015,11 +2110,9 @@ void SetupProcessObject(Environment* env,
versions,
"modules",
FIXED_ONE_BYTE_STRING(env->isolate(), node_modules_version));
-
READONLY_PROPERTY(versions,
"nghttp2",
FIXED_ONE_BYTE_STRING(env->isolate(), NGHTTP2_VERSION));
-
const char node_napi_version[] = NODE_STRINGIFY(NAPI_VERSION);
READONLY_PROPERTY(
versions,
@@ -3550,17 +3643,6 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
Environment env(isolate_data, context, v8_platform.GetTracingAgent());
env.Start(argc, argv, exec_argc, exec_argv, v8_is_profiling);
- char name_buffer[512];
- if (uv_get_process_title(name_buffer, sizeof(name_buffer)) == 0) {
- // Only emit the metadata event if the title can be retrieved successfully.
- // Ignore it otherwise.
- TRACE_EVENT_METADATA1("__metadata", "process_name", "name",
- TRACE_STR_COPY(name_buffer));
- }
- TRACE_EVENT_METADATA1("__metadata", "version", "node", NODE_VERSION_STRING);
- TRACE_EVENT_METADATA1("__metadata", "thread_name", "name",
- "JavaScriptMainThread");
-
const char* path = argc > 1 ? argv[1] : nullptr;
StartInspector(&env, path, debug_options);
diff --git a/test/parallel/test-trace-events-metadata.js b/test/parallel/test-trace-events-metadata.js
index 7f9ccc3c7378d5..01e019c1906956 100644
--- a/test/parallel/test-trace-events-metadata.js
+++ b/test/parallel/test-trace-events-metadata.js
@@ -23,25 +23,53 @@ const proc = cp.spawn(process.execPath,
proc.once('exit', common.mustCall(() => {
assert(common.fileExists(FILE_NAME));
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
- const traces = JSON.parse(data.toString()).traceEvents;
+ const traces = JSON.parse(data.toString()).traceEvents
+ .filter((trace) => trace.cat === '__metadata');
assert(traces.length > 0);
assert(traces.some((trace) =>
- trace.cat === '__metadata' && trace.name === 'thread_name' &&
+ trace.name === 'thread_name' &&
trace.args.name === 'JavaScriptMainThread'));
assert(traces.some((trace) =>
- trace.cat === '__metadata' && trace.name === 'thread_name' &&
+ trace.name === 'thread_name' &&
trace.args.name === 'BackgroundTaskRunner'));
assert(traces.some((trace) =>
- trace.cat === '__metadata' && trace.name === 'version' &&
+ trace.name === 'version' &&
trace.args.node === process.versions.node));
+
+ assert(traces.some((trace) =>
+ trace.name === 'node' &&
+ trace.args.process.versions.http_parser ===
+ process.versions.http_parser &&
+ trace.args.process.versions.node ===
+ process.versions.node &&
+ trace.args.process.versions.v8 ===
+ process.versions.v8 &&
+ trace.args.process.versions.uv ===
+ process.versions.uv &&
+ trace.args.process.versions.zlib ===
+ process.versions.zlib &&
+ trace.args.process.versions.ares ===
+ process.versions.ares &&
+ trace.args.process.versions.modules ===
+ process.versions.modules &&
+ trace.args.process.versions.nghttp2 ===
+ process.versions.nghttp2 &&
+ trace.args.process.versions.napi ===
+ process.versions.napi &&
+ trace.args.process.versions.openssl ===
+ process.versions.openssl &&
+ trace.args.process.arch === process.arch &&
+ trace.args.process.platform === process.platform &&
+ trace.args.process.release.name === process.release.name &&
+ (!process.release.lts ||
+ trace.args.process.release.lts === process.release.lts)));
+
if (!common.isSunOS) {
// Changing process.title is currently unsupported on SunOS/SmartOS
assert(traces.some((trace) =>
- trace.cat === '__metadata' && trace.name === 'process_name' &&
- trace.args.name === 'foo'));
+ trace.name === 'process_name' && trace.args.name === 'foo'));
assert(traces.some((trace) =>
- trace.cat === '__metadata' && trace.name === 'process_name' &&
- trace.args.name === 'bar'));
+ trace.name === 'process_name' && trace.args.name === 'bar'));
}
}));
}));
From 580071dde4104fd51fd7973f538cc72d4f13e347 Mon Sep 17 00:00:00 2001
From: prayag21 <10997858+prayag21@users.noreply.github.com>
Date: Wed, 11 Jul 2018 16:06:36 +0530
Subject: [PATCH 08/95] tls: named anonymous functions in _tls_wrap.js
PR-URL: https://github.com/nodejs/node/pull/21756
Refs: https://github.com/nodejs/node/issues/8913
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
---
lib/_tls_wrap.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index 603eca78df6422..775bdbefdb201e 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -907,7 +907,7 @@ function Server(options, listener) {
util.inherits(Server, net.Server);
exports.Server = Server;
-exports.createServer = function(options, listener) {
+exports.createServer = function createServer(options, listener) {
return new Server(options, listener);
};
@@ -1093,7 +1093,8 @@ function onConnectEnd() {
}
}
-exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
+// Arguments: [port,] [host,] [options,] [cb]
+exports.connect = function connect(...args) {
args = normalizeConnectArgs(args);
var options = args[0];
var cb = args[1];
From b510cdc756d049e34f50cbb69c625a4afac3e3e5 Mon Sep 17 00:00:00 2001
From: "Sakthipriyan Vairamani (thefourtheye)"
Date: Sat, 23 Jun 2018 17:10:10 +0530
Subject: [PATCH 09/95] doc: fix worker example to receive message
`require('worker_threads')` is not an instance of `EventEmitter`. So
`on` method would not be in it. The correct way to receive the message
would be to attach a listener to the `message` event on the
`parentPort`.
PR-URL: https://github.com/nodejs/node/pull/21486
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Vse Mozhet Byt
Reviewed-By: James M Snell
Reviewed-By: Colin Ihrig
Reviewed-By: Anna Henningsen
Reviewed-By: Ruben Bridgewater
---
doc/api/worker_threads.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md
index 8b301f42a87620..025a8c9a3ab2cf 100644
--- a/doc/api/worker_threads.md
+++ b/doc/api/worker_threads.md
@@ -377,7 +377,7 @@ added: v10.5.0
* `transferList` {Object[]}
Send a message to the worker that will be received via
-[`require('worker_threads').on('message')`][].
+[`require('worker_threads').parentPort.on('message')`][].
See [`port.postMessage()`][] for more details.
### worker.ref()
@@ -480,7 +480,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
[`process.stdout`]: process.html#process_process_stdout
[`process.title`]: process.html#process_process_title
[`require('worker_threads').workerData`]: #worker_threads_worker_workerdata
-[`require('worker_threads').on('message')`]: #worker_threads_event_message_1
+[`require('worker_threads').parentPort.on('message')`]: #worker_threads_event_message
[`require('worker_threads').postMessage()`]: #worker_threads_worker_postmessage_value_transferlist
[`require('worker_threads').isMainThread`]: #worker_threads_worker_ismainthread
[`require('worker_threads').parentPort`]: #worker_threads_worker_parentport
From 292aa42bd1c1056f1d35acaf0d728eca55eb7487 Mon Sep 17 00:00:00 2001
From: Gus Caplan
Date: Thu, 24 May 2018 19:32:50 -0500
Subject: [PATCH 10/95] test: fix faulty relpath test
PR-URL: https://github.com/nodejs/node/pull/20954
Reviewed-By: Luigi Pinca
Reviewed-By: Ruben Bridgewater
Reviewed-By: James M Snell
---
test/parallel/test-fs-realpath-native.js | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/test/parallel/test-fs-realpath-native.js b/test/parallel/test-fs-realpath-native.js
index 93b5a278cf4f1e..089572442d62f5 100644
--- a/test/parallel/test-fs-realpath-native.js
+++ b/test/parallel/test-fs-realpath-native.js
@@ -3,11 +3,17 @@ const common = require('../common');
const assert = require('assert');
const fs = require('fs');
-if (!common.isOSX) common.skip('MacOS-only test.');
+const filename = __filename.toLowerCase();
-assert.strictEqual(fs.realpathSync.native('/users'), '/Users');
-fs.realpath.native('/users', common.mustCall(function(err, res) {
- assert.ifError(err);
- assert.strictEqual(res, '/Users');
- assert.strictEqual(this, undefined);
-}));
+assert.strictEqual(
+ fs.realpathSync.native('./test/parallel/test-fs-realpath-native.js')
+ .toLowerCase(),
+ filename);
+
+fs.realpath.native(
+ './test/parallel/test-fs-realpath-native.js',
+ common.mustCall(function(err, res) {
+ assert.ifError(err);
+ assert.strictEqual(res.toLowerCase(), filename);
+ assert.strictEqual(this, undefined);
+ }));
From ab0da57150cc0c9c02ebeb0c35bcb16cfac3a706 Mon Sep 17 00:00:00 2001
From: Rich Trott
Date: Tue, 17 Jul 2018 22:23:56 -0700
Subject: [PATCH 11/95] doc: make minor improvements to collab guide
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
PR-URL: https://github.com/nodejs/node/pull/21862
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Gus Caplan
Reviewed-By: Michaël Zasso
Reviewed-By: Trivikram Kamat
Reviewed-By: James M Snell
Reviewed-By: Ruben Bridgewater
---
COLLABORATOR_GUIDE.md | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md
index 8d50589afdd11d..818fd7cc967443 100644
--- a/COLLABORATOR_GUIDE.md
+++ b/COLLABORATOR_GUIDE.md
@@ -67,7 +67,7 @@ For first-time contributors, check if the commit author is the same as the
pull request author, and ask if they have configured their git
username and email to their liking as per [this guide][git-username].
This is to make sure they would be promoted to "contributor" once
-their pull request gets landed.
+their pull request lands.
### Closing Issues and Pull Requests
@@ -82,32 +82,31 @@ necessary.
### Author ready pull requests
A pull request that is still awaiting the minimum review time is considered
-`author-ready` as soon as the CI has been started, it has at least one approval,
+_author ready_ as soon as the CI has been started, it has at least one approval,
and it has no outstanding review comments. Please always make sure to add the
-appropriate `author-ready` label to the PR in that case and remove it again as
-soon as that condition is not met anymore.
+`author ready` label to the PR in that case and remove it again as soon as that
+condition is not met anymore.
### Handling own pull requests
-If you as a Collaborator open a pull request, it is recommended to start a CI
-right after (see [testing and CI](#testing-and-ci) for further information on
-how to do that) and to post the link to it as well. Starting a new CI after each
-update is also recommended (due to e.g., a change request in a review or due to
-rebasing).
+When you open a pull request, it is recommended to start a CI right away (see
+[testing and CI](#testing-and-ci) for instructions) and to post the link to it
+in a comment in the pull request. Starting a new CI after each update is also
+recommended (for example, after an additional code change or after rebasing).
-As soon as the PR is ready to land, please go ahead and do so on your own.
-Landing your own pull requests distributes the work load for each Collaborator
-equally. If it is still awaiting the
-[minimum time to land](#waiting-for-approvals), please add the `author-ready`
-label to it so it is obvious that the PR can land as soon as the time ends.
+As soon as the PR is ready to land, please do so. Landing your own pull requests
+allows other Collaborators to focus on other pull requests. If your pull request
+is still awaiting the [minimum time to land](#waiting-for-approvals), add the
+`author ready` label so other Collaborators know it can land as soon as the time
+ends.
## Accepting Modifications
All modifications to the Node.js code and documentation should be performed via
GitHub pull requests, including modifications by Collaborators and TSC members.
A pull request must be reviewed, and must also be tested with CI, before being
-landed into the codebase. There may be exception to the latter (the changed code
-can not be tested with a CI or similar). If that is the case, please leave a
+landed into the codebase. There may be exceptions to the latter (the changed
+code cannot be tested with a CI or similar). If that is the case, please leave a
comment that explains why the PR does not require a CI run.
### Code Reviews
@@ -140,7 +139,7 @@ the CI outcome.
If there is no disagreement amongst Collaborators, a pull request should be
landed given appropriate review, a green CI, and the minimum
[waiting time](#waiting-for-approvals) for a PR. If it is still awaiting the
-[minimum time to land](#waiting-for-approvals), please add the `author-ready`
+[minimum time to land](#waiting-for-approvals), please add the `author ready`
label to it so it is obvious that the PR can land as soon as the time ends.
Where there is discussion amongst Collaborators, consensus should be sought if
From 4d78a21d8ca0460fe978bf9f74967196b439fc9c Mon Sep 17 00:00:00 2001
From: Kevin Simper
Date: Tue, 17 Jul 2018 15:26:04 -0700
Subject: [PATCH 12/95] doc: add missing `require` to example in http2.md
PR-URL: https://github.com/nodejs/node/pull/21858
Reviewed-By: Gus Caplan
Reviewed-By: Rich Trott
Reviewed-By: Daijiro Wachi
Reviewed-By: James M Snell
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Trivikram Kamat
---
doc/api/http2.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/api/http2.md b/doc/api/http2.md
index 9f702de02b03cf..0cc4d073a06975 100644
--- a/doc/api/http2.md
+++ b/doc/api/http2.md
@@ -1921,6 +1921,7 @@ instances.
```js
const http2 = require('http2');
+const fs = require('fs');
const options = {
key: fs.readFileSync('server-key.pem'),
From 335575e49bb6e57d646887a240caeebd3358e9f3 Mon Sep 17 00:00:00 2001
From: Peter Marshall
Date: Mon, 16 Jul 2018 13:59:09 +0200
Subject: [PATCH 13/95] benchmark: remove arrays benchmark
PR-URL: https://github.com/nodejs/node/pull/21831
Reviewed-By: Anatoli Papirovski
Reviewed-By: Ruben Bridgewater
Reviewed-By: Rich Trott
Reviewed-By: Luigi Pinca
Reviewed-By: Yang Guo
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
---
benchmark/arrays/var-int.js | 35 --------------------------
benchmark/arrays/zero-float.js | 35 --------------------------
benchmark/arrays/zero-int.js | 35 --------------------------
test/parallel/test-benchmark-arrays.js | 7 ------
4 files changed, 112 deletions(-)
delete mode 100644 benchmark/arrays/var-int.js
delete mode 100644 benchmark/arrays/zero-float.js
delete mode 100644 benchmark/arrays/zero-int.js
delete mode 100644 test/parallel/test-benchmark-arrays.js
diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js
deleted file mode 100644
index 430737856313e4..00000000000000
--- a/benchmark/arrays/var-int.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: [
- 'Array',
- 'Buffer',
- 'Int8Array',
- 'Uint8Array',
- 'Int16Array',
- 'Uint16Array',
- 'Int32Array',
- 'Uint32Array',
- 'Float32Array',
- 'Float64Array'
- ],
- n: [25e6]
-});
-
-function main({ type, n }) {
- const clazz = global[type];
-
- bench.start();
- const arr = new clazz(n);
- for (var i = 0; i < 10; ++i) {
- run();
- }
- bench.end(n);
-
- function run() {
- for (var j = 0, k = arr.length; j < k; ++j) {
- arr[j] = (j ^ k) & 127;
- }
- }
-}
diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js
deleted file mode 100644
index de2e9bdba69474..00000000000000
--- a/benchmark/arrays/zero-float.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: [
- 'Array',
- 'Buffer',
- 'Int8Array',
- 'Uint8Array',
- 'Int16Array',
- 'Uint16Array',
- 'Int32Array',
- 'Uint32Array',
- 'Float32Array',
- 'Float64Array'
- ],
- n: [25e6]
-});
-
-function main({ type, n }) {
- const clazz = global[type];
-
- bench.start();
- const arr = new clazz(n);
- for (var i = 0; i < 10; ++i) {
- run();
- }
- bench.end(n);
-
- function run() {
- for (var j = 0, k = arr.length; j < k; ++j) {
- arr[j] = 0.0;
- }
- }
-}
diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js
deleted file mode 100644
index 548691d3739e70..00000000000000
--- a/benchmark/arrays/zero-int.js
+++ /dev/null
@@ -1,35 +0,0 @@
-'use strict';
-const common = require('../common.js');
-
-const bench = common.createBenchmark(main, {
- type: [
- 'Array',
- 'Buffer',
- 'Int8Array',
- 'Uint8Array',
- 'Int16Array',
- 'Uint16Array',
- 'Int32Array',
- 'Uint32Array',
- 'Float32Array',
- 'Float64Array'
- ],
- n: [25e6]
-});
-
-function main({ type, n }) {
- const clazz = global[type];
-
- bench.start();
- const arr = new clazz(n);
- for (var i = 0; i < 10; ++i) {
- run();
- }
- bench.end(n);
-
- function run() {
- for (var j = 0, k = arr.length; j < k; ++j) {
- arr[j] = 0;
- }
- }
-}
diff --git a/test/parallel/test-benchmark-arrays.js b/test/parallel/test-benchmark-arrays.js
deleted file mode 100644
index 6e11d9743e0dac..00000000000000
--- a/test/parallel/test-benchmark-arrays.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-require('../common');
-
-const runBenchmark = require('../common/benchmark');
-
-runBenchmark('arrays', ['n=1', 'type=Array']);
From 756dff498ab43775989a2594dd481a4f8d26eaec Mon Sep 17 00:00:00 2001
From: Bruno Pinho
Date: Mon, 16 Jul 2018 10:53:02 -0300
Subject: [PATCH 14/95] test: refactor test-module-loading assertions
When there are three arguments in strictEqual() call and
AssertionError exists, the previous two values are not printed.
This improves debugging messages visibility
when there is a fail.
The messages were removed where the instruction
is self-explanatory.
PR-URL: https://github.com/nodejs/node/pull/21833
Reviewed-By: Rich Trott
Reviewed-By: Luigi Pinca
Reviewed-By: Colin Ihrig
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
---
test/sequential/test-module-loading.js | 40 +++++++++++---------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js
index abea73c4aa616c..c71f9d1edf4d5b 100644
--- a/test/sequential/test-module-loading.js
+++ b/test/sequential/test-module-loading.js
@@ -31,11 +31,10 @@ const backslash = /\\/g;
console.error('load test-module-loading.js');
-// assert that this is the main module.
-assert.strictEqual(require.main.id, '.', 'main module should have id of \'.\'');
-assert.strictEqual(require.main, module, 'require.main should === module');
-assert.strictEqual(process.mainModule, module,
- 'process.mainModule should === module');
+assert.strictEqual(require.main.id, '.');
+assert.strictEqual(require.main, module);
+assert.strictEqual(process.mainModule, module);
+
// assert that it's *not* the main module in the required module.
require('../fixtures/not-main-module.js');
@@ -102,12 +101,9 @@ const d2 = require('../fixtures/b/d');
assert.notStrictEqual(threeFolder, three);
}
-assert.strictEqual(require('../fixtures/packages/index').ok, 'ok',
- 'Failed loading package');
-assert.strictEqual(require('../fixtures/packages/main').ok, 'ok',
- 'Failed loading package');
-assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok',
- 'Failed loading package with index.js in main subdir');
+assert.strictEqual(require('../fixtures/packages/index').ok, 'ok');
+assert.strictEqual(require('../fixtures/packages/main').ok, 'ok');
+assert.strictEqual(require('../fixtures/packages/main-index').ok, 'ok');
{
console.error('test cycles containing a .. path');
@@ -165,8 +161,7 @@ require.extensions['.test'] = function(module) {
assert.strictEqual(require('../fixtures/registerExt2').custom, 'passed');
-assert.strictEqual(require('../fixtures/foo').foo, 'ok',
- 'require module with no extension');
+assert.strictEqual(require('../fixtures/foo').foo, 'ok');
// Should not attempt to load a directory
try {
@@ -181,13 +176,12 @@ try {
console.error('load order');
const loadOrder = '../fixtures/module-load-order/';
- const msg = 'Load order incorrect.';
require.extensions['.reg'] = require.extensions['.js'];
require.extensions['.reg2'] = require.extensions['.js'];
- assert.strictEqual(require(`${loadOrder}file1`).file1, 'file1', msg);
- assert.strictEqual(require(`${loadOrder}file2`).file2, 'file2.js', msg);
+ assert.strictEqual(require(`${loadOrder}file1`).file1, 'file1');
+ assert.strictEqual(require(`${loadOrder}file2`).file2, 'file2.js');
try {
require(`${loadOrder}file3`);
} catch (e) {
@@ -197,9 +191,10 @@ try {
else
assert.ok(/file3\.node/.test(e.message.replace(backslash, '/')));
}
- assert.strictEqual(require(`${loadOrder}file4`).file4, 'file4.reg', msg);
- assert.strictEqual(require(`${loadOrder}file5`).file5, 'file5.reg2', msg);
- assert.strictEqual(require(`${loadOrder}file6`).file6, 'file6/index.js', msg);
+
+ assert.strictEqual(require(`${loadOrder}file4`).file4, 'file4.reg');
+ assert.strictEqual(require(`${loadOrder}file5`).file5, 'file5.reg2');
+ assert.strictEqual(require(`${loadOrder}file6`).file6, 'file6/index.js');
try {
require(`${loadOrder}file7`);
} catch (e) {
@@ -208,10 +203,9 @@ try {
else
assert.ok(/file7\/index\.node/.test(e.message.replace(backslash, '/')));
}
- assert.strictEqual(require(`${loadOrder}file8`).file8, 'file8/index.reg',
- msg);
- assert.strictEqual(require(`${loadOrder}file9`).file9, 'file9/index.reg2',
- msg);
+
+ assert.strictEqual(require(`${loadOrder}file8`).file8, 'file8/index.reg');
+ assert.strictEqual(require(`${loadOrder}file9`).file9, 'file9/index.reg2');
}
{
From 41ff1bb9c7f6b06e809ca9c46794a4765eeb00dc Mon Sep 17 00:00:00 2001
From: Benedikt Meurer
Date: Thu, 5 Jul 2018 09:42:52 +0200
Subject: [PATCH 15/95] src: prepare for V8 Swallowed Rejection Hook
This is done in preparation for landing
https://chromium-review.googlesource.com/c/v8/v8/+/1126099
on the V8 side, which extends the existing PromiseRejectEvent mechanism
with new hooks for reject/resolve after a Promise was previously
resolved already.
Refs: https://github.com/nodejs/promises-debugging/issues/8
Design: https://goo.gl/2stLUY
PR-URL: https://github.com/nodejs/node/pull/21838
Reviewed-By: Gus Caplan
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: James M Snell
Reviewed-By: Yang Guo
Reviewed-By: Benedikt Meurer
---
src/bootstrapper.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 8bcc0493f5be6d..5f40d62a82fdef 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -69,7 +69,7 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
callback = env->promise_reject_handled_function();
value = Undefined(isolate);
} else {
- UNREACHABLE();
+ return;
}
Local args[] = { promise, value };
From c23e8b51ea30ce63a0bccb121a1f65bb7abd6cee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?=
Date: Mon, 16 Jul 2018 21:57:05 +0200
Subject: [PATCH 16/95] deps: cherry-pick 2075910 from upstream V8
Original commit message:
[turbofan] Remove optimization of default Promise capability functions.
The JSCallReducer could in theory inline the default resolve and reject
functions passed to the executor in the Promise constructor. But that
inlining is almost never triggered because we don't have SFI based feedback
in the CallIC. Also the use of the Promise constructor is discouraged,
so we shouldn't really need to squeeze the last bit of performance out
of this even in the future.
Getting rid of this optimization will make significantly easier to
implement the Swallowed Rejection Hook, as there's less churn on the
TurboFan side then.
Bug: v8:7919
Change-Id: If0c54f1c6c7ce95686cd74232be6b8693ac688c9
Reviewed-on: https://chromium-review.googlesource.com/1125926
Commit-Queue: Benedikt Meurer
Reviewed-by: Jaroslav Sevcik
Cr-Commit-Position: refs/heads/master@{#54210}
Refs: https://github.com/v8/v8/commit/2075910f3d070159bebd80e128dd09fdd87be56e
PR-URL: https://github.com/nodejs/node/pull/21838
Refs: https://github.com/nodejs/promises-debugging/issues/8
Reviewed-By: Gus Caplan
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: James M Snell
Reviewed-By: Yang Guo
Reviewed-By: Benedikt Meurer
---
common.gypi | 2 +-
deps/v8/src/compiler/js-call-reducer.cc | 118 ------------------------
deps/v8/src/compiler/js-call-reducer.h | 2 -
3 files changed, 1 insertion(+), 121 deletions(-)
diff --git a/common.gypi b/common.gypi
index a782cfbecb85e2..17948b9da3b7c6 100644
--- a/common.gypi
+++ b/common.gypi
@@ -28,7 +28,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
- 'v8_embedder_string': '-node.15',
+ 'v8_embedder_string': '-node.16',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
diff --git a/deps/v8/src/compiler/js-call-reducer.cc b/deps/v8/src/compiler/js-call-reducer.cc
index 451ec80a8d4f87..8e5034cde07d64 100644
--- a/deps/v8/src/compiler/js-call-reducer.cc
+++ b/deps/v8/src/compiler/js-call-reducer.cc
@@ -3519,10 +3519,6 @@ Reduction JSCallReducer::ReduceJSCall(Node* node,
return ReduceAsyncFunctionPromiseCreate(node);
case Builtins::kAsyncFunctionPromiseRelease:
return ReduceAsyncFunctionPromiseRelease(node);
- case Builtins::kPromiseCapabilityDefaultReject:
- return ReducePromiseCapabilityDefaultReject(node);
- case Builtins::kPromiseCapabilityDefaultResolve:
- return ReducePromiseCapabilityDefaultResolve(node);
case Builtins::kPromiseInternalConstructor:
return ReducePromiseInternalConstructor(node);
case Builtins::kPromiseInternalReject:
@@ -5252,120 +5248,6 @@ Reduction JSCallReducer::ReduceAsyncFunctionPromiseRelease(Node* node) {
return Replace(value);
}
-// ES section #sec-promise-reject-functions
-Reduction JSCallReducer::ReducePromiseCapabilityDefaultReject(Node* node) {
- DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
- Node* target = NodeProperties::GetValueInput(node, 0);
- Node* resolution = node->op()->ValueInputCount() > 2
- ? NodeProperties::GetValueInput(node, 2)
- : jsgraph()->UndefinedConstant();
- Node* frame_state = NodeProperties::GetFrameStateInput(node);
- Node* effect = NodeProperties::GetEffectInput(node);
- Node* control = NodeProperties::GetControlInput(node);
-
- // We need to execute in the {target}s context.
- Node* context = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
- effect, control);
-
- // Grab the promise closed over by {target}.
- Node* promise = effect =
- graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
- PromiseBuiltinsAssembler::kPromiseSlot)),
- context, effect, control);
-
- // Check if the {promise} is still pending or already settled.
- Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
- jsgraph()->UndefinedConstant());
- Node* branch =
- graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
-
- Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
- Node* etrue = effect;
-
- Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
- Node* efalse = effect;
- {
- // Mark the {promise} as settled.
- efalse = graph()->NewNode(
- simplified()->StoreField(AccessBuilder::ForContextSlot(
- PromiseBuiltinsAssembler::kPromiseSlot)),
- context, jsgraph()->UndefinedConstant(), efalse, if_false);
-
- // Check if we should emit a debug event.
- Node* debug_event = efalse =
- graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
- PromiseBuiltinsAssembler::kDebugEventSlot)),
- context, efalse, if_false);
-
- // Actually reject the {promise}.
- efalse =
- graph()->NewNode(javascript()->RejectPromise(), promise, resolution,
- debug_event, context, frame_state, efalse, if_false);
- }
-
- control = graph()->NewNode(common()->Merge(2), if_true, if_false);
- effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
-
- Node* value = jsgraph()->UndefinedConstant();
- ReplaceWithValue(node, value, effect, control);
- return Replace(value);
-}
-
-// ES section #sec-promise-resolve-functions
-Reduction JSCallReducer::ReducePromiseCapabilityDefaultResolve(Node* node) {
- DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
- Node* target = NodeProperties::GetValueInput(node, 0);
- Node* resolution = node->op()->ValueInputCount() > 2
- ? NodeProperties::GetValueInput(node, 2)
- : jsgraph()->UndefinedConstant();
- Node* frame_state = NodeProperties::GetFrameStateInput(node);
- Node* effect = NodeProperties::GetEffectInput(node);
- Node* control = NodeProperties::GetControlInput(node);
-
- // We need to execute in the {target}s context.
- Node* context = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForJSFunctionContext()), target,
- effect, control);
-
- // Grab the promise closed over by {target}.
- Node* promise = effect =
- graph()->NewNode(simplified()->LoadField(AccessBuilder::ForContextSlot(
- PromiseBuiltinsAssembler::kPromiseSlot)),
- context, effect, control);
-
- // Check if the {promise} is still pending or already settled.
- Node* check = graph()->NewNode(simplified()->ReferenceEqual(), promise,
- jsgraph()->UndefinedConstant());
- Node* branch =
- graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control);
-
- Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
- Node* etrue = effect;
-
- Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
- Node* efalse = effect;
- {
- // Mark the {promise} as settled.
- efalse = graph()->NewNode(
- simplified()->StoreField(AccessBuilder::ForContextSlot(
- PromiseBuiltinsAssembler::kPromiseSlot)),
- context, jsgraph()->UndefinedConstant(), efalse, if_false);
-
- // Actually resolve the {promise}.
- efalse =
- graph()->NewNode(javascript()->ResolvePromise(), promise, resolution,
- context, frame_state, efalse, if_false);
- }
-
- control = graph()->NewNode(common()->Merge(2), if_true, if_false);
- effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
-
- Node* value = jsgraph()->UndefinedConstant();
- ReplaceWithValue(node, value, effect, control);
- return Replace(value);
-}
-
Node* JSCallReducer::CreateArtificialFrameState(
Node* node, Node* outer_frame_state, int parameter_count,
BailoutId bailout_id, FrameStateType frame_state_type,
diff --git a/deps/v8/src/compiler/js-call-reducer.h b/deps/v8/src/compiler/js-call-reducer.h
index 36a5ac2e7a5da7..e2810dc34c7402 100644
--- a/deps/v8/src/compiler/js-call-reducer.h
+++ b/deps/v8/src/compiler/js-call-reducer.h
@@ -130,8 +130,6 @@ class V8_EXPORT_PRIVATE JSCallReducer final : public AdvancedReducer {
Reduction ReduceAsyncFunctionPromiseCreate(Node* node);
Reduction ReduceAsyncFunctionPromiseRelease(Node* node);
- Reduction ReducePromiseCapabilityDefaultReject(Node* node);
- Reduction ReducePromiseCapabilityDefaultResolve(Node* node);
Reduction ReducePromiseConstructor(Node* node);
Reduction ReducePromiseInternalConstructor(Node* node);
Reduction ReducePromiseInternalReject(Node* node);
From ec0ff7008a75d0cffef44bc5fde2267566a93fea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?=
Date: Mon, 16 Jul 2018 22:03:01 +0200
Subject: [PATCH 17/95] deps: cherry-pick 907d7bc from upstream V8
Original commit message:
[promise] Implement Swallowed Rejection Hook.
This extends the current Promise Rejection Hook with two new events
kPromiseRejectAfterResolved
kPromiseResolveAfterResolved
which are used to detect (and signal) misuse of the Promise constructor.
Specifically the common bug like
new Promise((res, rej) => {
res(1);
throw new Error("something")
});
where the error is silently swallowed by the Promise constructor without
the user ever noticing can be caught via this hook.
Doc: https://goo.gl/2stLUY
Bug: v8:7919
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I890a7e766cdd1be88db94844fb744f72823dba33
Reviewed-on: https://chromium-review.googlesource.com/1126099
Reviewed-by: Maya Lekova
Reviewed-by: Benedikt Meurer
Reviewed-by: Yang Guo
Commit-Queue: Benedikt Meurer
Cr-Commit-Position: refs/heads/master@{#54309}
Refs: https://github.com/v8/v8/commit/907d7bcd18c13a04a14eea6699e54167494bf9f9
PR-URL: https://github.com/nodejs/node/pull/21838
Refs: https://github.com/nodejs/promises-debugging/issues/8
Reviewed-By: Gus Caplan
Reviewed-By: Benjamin Gruenbaum
Reviewed-By: James M Snell
Reviewed-By: Yang Guo
Reviewed-By: Benedikt Meurer
---
common.gypi | 2 +-
deps/v8/include/v8.h | 4 +-
deps/v8/src/builtins/builtins-promise-gen.cc | 34 +++++-
deps/v8/src/builtins/builtins-promise-gen.h | 7 +-
deps/v8/src/compiler/js-call-reducer.cc | 4 +
deps/v8/src/isolate.cc | 3 +-
deps/v8/src/runtime/runtime-promise.cc | 20 ++++
deps/v8/src/runtime/runtime.h | 4 +-
deps/v8/test/cctest/test-api.cc | 116 ++++++++++++++-----
9 files changed, 149 insertions(+), 45 deletions(-)
diff --git a/common.gypi b/common.gypi
index 17948b9da3b7c6..447ff992b46745 100644
--- a/common.gypi
+++ b/common.gypi
@@ -28,7 +28,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
- 'v8_embedder_string': '-node.16',
+ 'v8_embedder_string': '-node.17',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h
index fe8f5a383952f7..389a7c01b0583a 100644
--- a/deps/v8/include/v8.h
+++ b/deps/v8/include/v8.h
@@ -6394,7 +6394,9 @@ typedef void (*PromiseHook)(PromiseHookType type, Local promise,
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
kPromiseRejectWithNoHandler = 0,
- kPromiseHandlerAddedAfterReject = 1
+ kPromiseHandlerAddedAfterReject = 1,
+ kPromiseRejectAfterResolved = 2,
+ kPromiseResolveAfterResolved = 3,
};
class PromiseRejectMessage {
diff --git a/deps/v8/src/builtins/builtins-promise-gen.cc b/deps/v8/src/builtins/builtins-promise-gen.cc
index 868b45a8316ff5..0a94139fed4945 100644
--- a/deps/v8/src/builtins/builtins-promise-gen.cc
+++ b/deps/v8/src/builtins/builtins-promise-gen.cc
@@ -247,6 +247,8 @@ Node* PromiseBuiltinsAssembler::CreatePromiseResolvingFunctionsContext(
Node* const context =
CreatePromiseContext(native_context, kPromiseContextLength);
StoreContextElementNoWriteBarrier(context, kPromiseSlot, promise);
+ StoreContextElementNoWriteBarrier(context, kAlreadyResolvedSlot,
+ FalseConstant());
StoreContextElementNoWriteBarrier(context, kDebugEventSlot, debug_event);
return context;
}
@@ -733,17 +735,27 @@ TF_BUILTIN(PromiseCapabilityDefaultReject, PromiseBuiltinsAssembler) {
Node* const promise = LoadContextElement(context, kPromiseSlot);
// 3. Let alreadyResolved be F.[[AlreadyResolved]].
+ Label if_already_resolved(this, Label::kDeferred);
+ Node* const already_resolved =
+ LoadContextElement(context, kAlreadyResolvedSlot);
+
// 4. If alreadyResolved.[[Value]] is true, return undefined.
- // We use undefined as a marker for the [[AlreadyResolved]] state.
- ReturnIf(IsUndefined(promise), UndefinedConstant());
+ GotoIf(IsTrue(already_resolved), &if_already_resolved);
// 5. Set alreadyResolved.[[Value]] to true.
- StoreContextElementNoWriteBarrier(context, kPromiseSlot, UndefinedConstant());
+ StoreContextElementNoWriteBarrier(context, kAlreadyResolvedSlot,
+ TrueConstant());
// 6. Return RejectPromise(promise, reason).
Node* const debug_event = LoadContextElement(context, kDebugEventSlot);
Return(CallBuiltin(Builtins::kRejectPromise, context, promise, reason,
debug_event));
+
+ BIND(&if_already_resolved);
+ {
+ Return(CallRuntime(Runtime::kPromiseRejectAfterResolved, context, promise,
+ reason));
+ }
}
// ES #sec-promise-resolve-functions
@@ -755,16 +767,26 @@ TF_BUILTIN(PromiseCapabilityDefaultResolve, PromiseBuiltinsAssembler) {
Node* const promise = LoadContextElement(context, kPromiseSlot);
// 3. Let alreadyResolved be F.[[AlreadyResolved]].
+ Label if_already_resolved(this, Label::kDeferred);
+ Node* const already_resolved =
+ LoadContextElement(context, kAlreadyResolvedSlot);
+
// 4. If alreadyResolved.[[Value]] is true, return undefined.
- // We use undefined as a marker for the [[AlreadyResolved]] state.
- ReturnIf(IsUndefined(promise), UndefinedConstant());
+ GotoIf(IsTrue(already_resolved), &if_already_resolved);
// 5. Set alreadyResolved.[[Value]] to true.
- StoreContextElementNoWriteBarrier(context, kPromiseSlot, UndefinedConstant());
+ StoreContextElementNoWriteBarrier(context, kAlreadyResolvedSlot,
+ TrueConstant());
// The rest of the logic (and the catch prediction) is
// encapsulated in the dedicated ResolvePromise builtin.
Return(CallBuiltin(Builtins::kResolvePromise, context, promise, resolution));
+
+ BIND(&if_already_resolved);
+ {
+ Return(CallRuntime(Runtime::kPromiseResolveAfterResolved, context, promise,
+ resolution));
+ }
}
TF_BUILTIN(PromiseConstructorLazyDeoptContinuation, PromiseBuiltinsAssembler) {
diff --git a/deps/v8/src/builtins/builtins-promise-gen.h b/deps/v8/src/builtins/builtins-promise-gen.h
index 694cea28c06b5a..0920c33cf886a5 100644
--- a/deps/v8/src/builtins/builtins-promise-gen.h
+++ b/deps/v8/src/builtins/builtins-promise-gen.h
@@ -17,11 +17,12 @@ typedef compiler::CodeAssemblerState CodeAssemblerState;
class PromiseBuiltinsAssembler : public CodeStubAssembler {
public:
enum PromiseResolvingFunctionContextSlot {
- // The promise which resolve/reject callbacks fulfill. If this is
- // undefined, then we've already visited this callback and it
- // should be a no-op.
+ // The promise which resolve/reject callbacks fulfill.
kPromiseSlot = Context::MIN_CONTEXT_SLOTS,
+ // Whether the callback was already invoked.
+ kAlreadyResolvedSlot,
+
// Whether to trigger a debug event or not. Used in catch
// prediction.
kDebugEventSlot,
diff --git a/deps/v8/src/compiler/js-call-reducer.cc b/deps/v8/src/compiler/js-call-reducer.cc
index 8e5034cde07d64..f226c7bd5dbd4f 100644
--- a/deps/v8/src/compiler/js-call-reducer.cc
+++ b/deps/v8/src/compiler/js-call-reducer.cc
@@ -5345,6 +5345,10 @@ Reduction JSCallReducer::ReducePromiseConstructor(Node* node) {
graph()->NewNode(simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kPromiseSlot)),
promise_context, promise, effect, control);
+ effect = graph()->NewNode(
+ simplified()->StoreField(AccessBuilder::ForContextSlot(
+ PromiseBuiltinsAssembler::kAlreadyResolvedSlot)),
+ promise_context, jsgraph()->FalseConstant(), effect, control);
effect = graph()->NewNode(
simplified()->StoreField(AccessBuilder::ForContextSlot(
PromiseBuiltinsAssembler::kDebugEventSlot)),
diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc
index 7ef0214f4a6462..849e4ba5be0a3d 100644
--- a/deps/v8/src/isolate.cc
+++ b/deps/v8/src/isolate.cc
@@ -3875,10 +3875,9 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) {
void Isolate::ReportPromiseReject(Handle promise,
Handle value,
v8::PromiseRejectEvent event) {
- DCHECK_EQ(v8::Promise::kRejected, promise->status());
if (promise_reject_callback_ == nullptr) return;
Handle stack_trace;
- if (event == v8::kPromiseRejectWithNoHandler && value->IsJSObject()) {
+ if (event != v8::kPromiseHandlerAddedAfterReject && value->IsJSObject()) {
stack_trace = GetDetailedStackTrace(Handle::cast(value));
}
promise_reject_callback_(v8::PromiseRejectMessage(
diff --git a/deps/v8/src/runtime/runtime-promise.cc b/deps/v8/src/runtime/runtime-promise.cc
index f5b9db3c028b0e..6c4f7d69eb7dbe 100644
--- a/deps/v8/src/runtime/runtime-promise.cc
+++ b/deps/v8/src/runtime/runtime-promise.cc
@@ -38,6 +38,26 @@ RUNTIME_FUNCTION(Runtime_PromiseRejectEventFromStack) {
return isolate->heap()->undefined_value();
}
+RUNTIME_FUNCTION(Runtime_PromiseRejectAfterResolved) {
+ DCHECK_EQ(2, args.length());
+ HandleScope scope(isolate);
+ CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, reason, 1);
+ isolate->ReportPromiseReject(promise, reason,
+ v8::kPromiseRejectAfterResolved);
+ return isolate->heap()->undefined_value();
+}
+
+RUNTIME_FUNCTION(Runtime_PromiseResolveAfterResolved) {
+ DCHECK_EQ(2, args.length());
+ HandleScope scope(isolate);
+ CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, resolution, 1);
+ isolate->ReportPromiseReject(promise, resolution,
+ v8::kPromiseResolveAfterResolved);
+ return isolate->heap()->undefined_value();
+}
+
RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) {
DCHECK_EQ(1, args.length());
HandleScope scope(isolate);
diff --git a/deps/v8/src/runtime/runtime.h b/deps/v8/src/runtime/runtime.h
index 37ce74e8250f2c..184b9c5ca44535 100644
--- a/deps/v8/src/runtime/runtime.h
+++ b/deps/v8/src/runtime/runtime.h
@@ -433,7 +433,9 @@ namespace internal {
F(PromiseRevokeReject, 1, 1) \
F(PromiseStatus, 1, 1) \
F(RejectPromise, 3, 1) \
- F(ResolvePromise, 2, 1)
+ F(ResolvePromise, 2, 1) \
+ F(PromiseRejectAfterResolved, 2, 1) \
+ F(PromiseResolveAfterResolved, 2, 1)
#define FOR_EACH_INTRINSIC_PROXY(F) \
F(CheckProxyGetSetTrapResult, 2, 1) \
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc
index 637dc7d2062f9a..793711fa80c93d 100644
--- a/deps/v8/test/cctest/test-api.cc
+++ b/deps/v8/test/cctest/test-api.cc
@@ -17625,6 +17625,8 @@ TEST(RethrowBogusErrorStackTrace) {
v8::PromiseRejectEvent reject_event = v8::kPromiseRejectWithNoHandler;
int promise_reject_counter = 0;
int promise_revoke_counter = 0;
+int promise_reject_after_resolved_counter = 0;
+int promise_resolve_after_resolved_counter = 0;
int promise_reject_msg_line_number = -1;
int promise_reject_msg_column_number = -1;
int promise_reject_line_number = -1;
@@ -17634,40 +17636,56 @@ int promise_reject_frame_count = -1;
void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
v8::Local global = CcTest::global();
v8::Local context = CcTest::isolate()->GetCurrentContext();
- CHECK_EQ(v8::Promise::PromiseState::kRejected,
+ CHECK_NE(v8::Promise::PromiseState::kPending,
reject_message.GetPromise()->State());
- if (reject_message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
- promise_reject_counter++;
- global->Set(context, v8_str("rejected"), reject_message.GetPromise())
- .FromJust();
- global->Set(context, v8_str("value"), reject_message.GetValue()).FromJust();
- v8::Local message = v8::Exception::CreateMessage(
- CcTest::isolate(), reject_message.GetValue());
- v8::Local stack_trace = message->GetStackTrace();
-
- promise_reject_msg_line_number = message->GetLineNumber(context).FromJust();
- promise_reject_msg_column_number =
- message->GetStartColumn(context).FromJust() + 1;
-
- if (!stack_trace.IsEmpty()) {
- promise_reject_frame_count = stack_trace->GetFrameCount();
- if (promise_reject_frame_count > 0) {
- CHECK(stack_trace->GetFrame(0)
- ->GetScriptName()
- ->Equals(context, v8_str("pro"))
- .FromJust());
- promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber();
- promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn();
- } else {
- promise_reject_line_number = -1;
- promise_reject_column_number = -1;
+ switch (reject_message.GetEvent()) {
+ case v8::kPromiseRejectWithNoHandler: {
+ promise_reject_counter++;
+ global->Set(context, v8_str("rejected"), reject_message.GetPromise())
+ .FromJust();
+ global->Set(context, v8_str("value"), reject_message.GetValue())
+ .FromJust();
+ v8::Local message = v8::Exception::CreateMessage(
+ CcTest::isolate(), reject_message.GetValue());
+ v8::Local stack_trace = message->GetStackTrace();
+
+ promise_reject_msg_line_number =
+ message->GetLineNumber(context).FromJust();
+ promise_reject_msg_column_number =
+ message->GetStartColumn(context).FromJust() + 1;
+
+ if (!stack_trace.IsEmpty()) {
+ promise_reject_frame_count = stack_trace->GetFrameCount();
+ if (promise_reject_frame_count > 0) {
+ CHECK(stack_trace->GetFrame(0)
+ ->GetScriptName()
+ ->Equals(context, v8_str("pro"))
+ .FromJust());
+ promise_reject_line_number =
+ stack_trace->GetFrame(0)->GetLineNumber();
+ promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn();
+ } else {
+ promise_reject_line_number = -1;
+ promise_reject_column_number = -1;
+ }
}
+ break;
+ }
+ case v8::kPromiseHandlerAddedAfterReject: {
+ promise_revoke_counter++;
+ global->Set(context, v8_str("revoked"), reject_message.GetPromise())
+ .FromJust();
+ CHECK(reject_message.GetValue().IsEmpty());
+ break;
+ }
+ case v8::kPromiseRejectAfterResolved: {
+ promise_reject_after_resolved_counter++;
+ break;
+ }
+ case v8::kPromiseResolveAfterResolved: {
+ promise_resolve_after_resolved_counter++;
+ break;
}
- } else {
- promise_revoke_counter++;
- global->Set(context, v8_str("revoked"), reject_message.GetPromise())
- .FromJust();
- CHECK(reject_message.GetValue().IsEmpty());
}
}
@@ -17690,6 +17708,8 @@ v8::Local RejectValue() {
void ResetPromiseStates() {
promise_reject_counter = 0;
promise_revoke_counter = 0;
+ promise_reject_after_resolved_counter = 0;
+ promise_resolve_after_resolved_counter = 0;
promise_reject_msg_line_number = -1;
promise_reject_msg_column_number = -1;
promise_reject_line_number = -1;
@@ -17915,6 +17935,40 @@ TEST(PromiseRejectCallback) {
CHECK_EQ(0, promise_revoke_counter);
CHECK(RejectValue()->Equals(env.local(), v8_str("sss")).FromJust());
+ ResetPromiseStates();
+
+ // Swallowed exceptions in the Promise constructor.
+ CompileRun(
+ "var v0 = new Promise(\n"
+ " function(res, rej) {\n"
+ " res(1);\n"
+ " throw new Error();\n"
+ " }\n"
+ ");\n");
+ CHECK(!GetPromise("v0")->HasHandler());
+ CHECK_EQ(0, promise_reject_counter);
+ CHECK_EQ(0, promise_revoke_counter);
+ CHECK_EQ(1, promise_reject_after_resolved_counter);
+ CHECK_EQ(0, promise_resolve_after_resolved_counter);
+
+ ResetPromiseStates();
+
+ // Duplication resolve.
+ CompileRun(
+ "var r;\n"
+ "var y0 = new Promise(\n"
+ " function(res, rej) {\n"
+ " r = res;\n"
+ " throw new Error();\n"
+ " }\n"
+ ");\n"
+ "r(1);\n");
+ CHECK(!GetPromise("y0")->HasHandler());
+ CHECK_EQ(1, promise_reject_counter);
+ CHECK_EQ(0, promise_revoke_counter);
+ CHECK_EQ(0, promise_reject_after_resolved_counter);
+ CHECK_EQ(1, promise_resolve_after_resolved_counter);
+
// Test stack frames.
env->GetIsolate()->SetCaptureStackTraceForUncaughtExceptions(true);
From 484140e22379db1fb458ed3a42778b5b66668748 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?=
Date: Thu, 12 Jul 2018 09:45:05 +0200
Subject: [PATCH 18/95] fs: stop lazy loading stream constructors
Fixes: https://github.com/nodejs/node/issues/21489
PR-URL: https://github.com/nodejs/node/pull/21776
Reviewed-By: Joyee Cheung
Reviewed-By: Ruben Bridgewater
Reviewed-By: Colin Ihrig
---
lib/fs.js | 60 +++++---------------------------------
lib/internal/fs/streams.js | 18 ++++++++----
2 files changed, 19 insertions(+), 59 deletions(-)
diff --git a/lib/fs.js b/lib/fs.js
index 9683748ba91efe..0cfd175d7b3d99 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -52,6 +52,7 @@ const {
} = errors.codes;
const { FSReqWrap, statValues } = binding;
+const { ReadStream, WriteStream } = require('internal/fs/streams');
const internalFS = require('internal/fs/utils');
const { getPathFromURL } = require('internal/url');
const internalUtil = require('internal/util');
@@ -91,13 +92,6 @@ let fs;
let promises;
let watchers;
let ReadFileContext;
-let ReadStream;
-let WriteStream;
-
-// These have to be separate because of how graceful-fs happens to do it's
-// monkeypatching.
-let FileReadStream;
-let FileWriteStream;
const isWindows = process.platform === 'win32';
@@ -1697,20 +1691,11 @@ function copyFileSync(src, dest, flags) {
handleErrorFromBinding(ctx);
}
-function lazyLoadStreams() {
- if (!ReadStream) {
- ({ ReadStream, WriteStream } = require('internal/fs/streams'));
- [ FileReadStream, FileWriteStream ] = [ ReadStream, WriteStream ];
- }
-}
-
function createReadStream(path, options) {
- lazyLoadStreams();
return new ReadStream(path, options);
}
function createWriteStream(path, options) {
- lazyLoadStreams();
return new WriteStream(path, options);
}
@@ -1793,43 +1778,12 @@ module.exports = fs = {
writeSync,
Stats,
- get ReadStream() {
- lazyLoadStreams();
- return ReadStream;
- },
-
- set ReadStream(val) {
- ReadStream = val;
- },
-
- get WriteStream() {
- lazyLoadStreams();
- return WriteStream;
- },
-
- set WriteStream(val) {
- WriteStream = val;
- },
-
- // Legacy names... these have to be separate because of how graceful-fs
- // (and possibly other) modules monkey patch the values.
- get FileReadStream() {
- lazyLoadStreams();
- return FileReadStream;
- },
-
- set FileReadStream(val) {
- FileReadStream = val;
- },
-
- get FileWriteStream() {
- lazyLoadStreams();
- return FileWriteStream;
- },
-
- set FileWriteStream(val) {
- FileWriteStream = val;
- },
+ // Stream constructors
+ ReadStream,
+ WriteStream,
+ // Legacy names...
+ FileReadStream: ReadStream,
+ FileWriteStream: WriteStream,
// For tests
_toUnixTimestamp: toUnixTimestamp
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js
index e3fa83fd26f406..2761c19ac74065 100644
--- a/lib/internal/fs/streams.js
+++ b/lib/internal/fs/streams.js
@@ -8,7 +8,6 @@ const {
ERR_INVALID_ARG_TYPE,
ERR_OUT_OF_RANGE
} = require('internal/errors').codes;
-const fs = require('fs');
const { Buffer } = require('buffer');
const {
copyObject,
@@ -18,6 +17,13 @@ const { Readable, Writable } = require('stream');
const { getPathFromURL } = require('internal/url');
const util = require('util');
+let fs;
+function lazyFs() {
+ if (fs === undefined)
+ fs = require('fs');
+ return fs;
+}
+
const kMinPoolSpace = 128;
let pool;
@@ -92,7 +98,7 @@ function ReadStream(path, options) {
util.inherits(ReadStream, Readable);
ReadStream.prototype.open = function() {
- fs.open(this.path, this.flags, this.mode, (er, fd) => {
+ lazyFs().open(this.path, this.flags, this.mode, (er, fd) => {
if (er) {
if (this.autoClose) {
this.destroy();
@@ -142,7 +148,7 @@ ReadStream.prototype._read = function(n) {
return this.push(null);
// the actual read.
- fs.read(this.fd, pool, pool.used, toRead, this.pos, (er, bytesRead) => {
+ lazyFs().read(this.fd, pool, pool.used, toRead, this.pos, (er, bytesRead) => {
if (er) {
if (this.autoClose) {
this.destroy();
@@ -177,7 +183,7 @@ ReadStream.prototype._destroy = function(err, cb) {
};
function closeFsStream(stream, cb, err) {
- fs.close(stream.fd, (er) => {
+ lazyFs().close(stream.fd, (er) => {
er = er || err;
cb(er);
stream.closed = true;
@@ -242,7 +248,7 @@ WriteStream.prototype._final = function(callback) {
};
WriteStream.prototype.open = function() {
- fs.open(this.path, this.flags, this.mode, (er, fd) => {
+ lazyFs().open(this.path, this.flags, this.mode, (er, fd) => {
if (er) {
if (this.autoClose) {
this.destroy();
@@ -270,7 +276,7 @@ WriteStream.prototype._write = function(data, encoding, cb) {
});
}
- fs.write(this.fd, data, 0, data.length, this.pos, (er, bytes) => {
+ lazyFs().write(this.fd, data, 0, data.length, this.pos, (er, bytes) => {
if (er) {
if (this.autoClose) {
this.destroy();
From ff5c6dcd1ba832fdc2cda097facf789211f53a58 Mon Sep 17 00:00:00 2001
From: Michael Achenbach
Date: Mon, 30 Apr 2018 14:08:28 +0200
Subject: [PATCH 19/95] tools: properly convert .gypi in install.py
It was breaking during install when .gypi strings had quotes in
them. e.g.: 'foo': 'bar="baz"'
---
tools/install.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/install.py b/tools/install.py
index 2aeed773bb08b3..ce9ceeee1dd578 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
+import ast
import errno
-import json
import os
import re
import shutil
@@ -20,9 +20,7 @@ def abspath(*args):
def load_config():
s = open('config.gypi').read()
- s = re.sub(r'#.*?\n', '', s) # strip comments
- s = re.sub(r'\'', '"', s) # convert quotes
- return json.loads(s)
+ return ast.literal_eval(s)
def try_unlink(path):
try:
From d0f8af021f5b7aaf2c872ce2616d2e76d5d9cc5e Mon Sep 17 00:00:00 2001
From: Anna Henningsen
Date: Mon, 16 Jul 2018 22:31:28 +0200
Subject: [PATCH 20/95] src: use offset calc. instead of `req->data` in
node_file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A small refactor – this removes one layer of pointer indirection.
(The performance gain is likely negligible, the main point here
being that this encapsulates libuv request management a bit more.)
PR-URL: https://github.com/nodejs/node/pull/21839
Reviewed-By: Eugene Ostroukhov
Reviewed-By: Colin Ihrig
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Gus Caplan
Reviewed-By: James M Snell
Reviewed-By: Tobias Nießen
Reviewed-By: Jon Moss
---
src/node_file.cc | 16 ++++++++--------
src/node_file.h | 8 ++++++++
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/node_file.cc b/src/node_file.cc
index c62697cf312b0a..8414a22ad4cd5f 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -221,7 +221,7 @@ inline MaybeLocal FileHandle::ClosePromise() {
closing_ = true;
CloseReq* req = new CloseReq(env(), promise, object());
auto AfterClose = uv_fs_callback_t{[](uv_fs_t* req) {
- CloseReq* close = static_cast(req->data);
+ CloseReq* close = CloseReq::from_req(req);
CHECK_NOT_NULL(close);
close->file_handle()->AfterClose();
Isolate* isolate = close->env()->isolate();
@@ -475,7 +475,7 @@ bool FSReqAfterScope::Proceed() {
}
void AfterNoArgs(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
if (after.Proceed())
@@ -483,7 +483,7 @@ void AfterNoArgs(uv_fs_t* req) {
}
void AfterStat(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
if (after.Proceed()) {
@@ -492,7 +492,7 @@ void AfterStat(uv_fs_t* req) {
}
void AfterInteger(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
if (after.Proceed())
@@ -500,7 +500,7 @@ void AfterInteger(uv_fs_t* req) {
}
void AfterOpenFileHandle(uv_fs_t* req) {
- FSReqWrap* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
if (after.Proceed()) {
@@ -510,7 +510,7 @@ void AfterOpenFileHandle(uv_fs_t* req) {
}
void AfterStringPath(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
MaybeLocal link;
@@ -529,7 +529,7 @@ void AfterStringPath(uv_fs_t* req) {
}
void AfterStringPtr(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
MaybeLocal link;
@@ -548,7 +548,7 @@ void AfterStringPtr(uv_fs_t* req) {
}
void AfterScanDir(uv_fs_t* req) {
- FSReqBase* req_wrap = static_cast(req->data);
+ FSReqBase* req_wrap = FSReqBase::from_req(req);
FSReqAfterScope after(req_wrap, req);
if (after.Proceed()) {
diff --git a/src/node_file.h b/src/node_file.h
index 6b45dc881750a7..141d1d42d744a2 100644
--- a/src/node_file.h
+++ b/src/node_file.h
@@ -68,6 +68,10 @@ class FSReqBase : public ReqWrap {
bool use_bigint() const { return use_bigint_; }
+ static FSReqBase* from_req(uv_fs_t* req) {
+ return static_cast(ReqWrap::from_req(req));
+ }
+
private:
enum encoding encoding_ = UTF8;
bool has_data_ = false;
@@ -284,6 +288,10 @@ class FileHandle : public AsyncWrap, public StreamBase {
void Reject(Local reason);
+ static CloseReq* from_req(uv_fs_t* req) {
+ return static_cast(ReqWrap::from_req(req));
+ }
+
private:
Persistent promise_;
Persistent ref_;
From 6b925ebabad659e23bb6617f7fc2e1d6c02f6b1b Mon Sep 17 00:00:00 2001
From: silverwind
Date: Wed, 18 Jul 2018 18:26:21 +0200
Subject: [PATCH 21/95] tools: make getnodeversion.py python3-compatible
PR-URL: https://github.com/nodejs/node/pull/21872
Reviewed-By: James M Snell
Reviewed-By: Rich Trott
Reviewed-By: Anna Henningsen
Reviewed-By: Colin Ihrig
Reviewed-By: Trivikram Kamat
---
tools/getnodeversion.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/getnodeversion.py b/tools/getnodeversion.py
index f2032cccefe936..59f8aabe49eceb 100644
--- a/tools/getnodeversion.py
+++ b/tools/getnodeversion.py
@@ -17,4 +17,4 @@
if re.match('^#define NODE_PATCH_VERSION', line):
patch = line.split()[2]
-print '%(major)s.%(minor)s.%(patch)s'% locals()
+print('%(major)s.%(minor)s.%(patch)s'% locals())
From 1e155818234211bfbf96492d7aa9b8b1a8947d03 Mon Sep 17 00:00:00 2001
From: Anna Henningsen
Date: Sun, 15 Jul 2018 23:58:13 +0200
Subject: [PATCH 22/95] http2: remove unused nghttp2 error list
Remove a list of HTTP2 errors as well as `nghttp2_errname()`
that converted an integer nghttp2 error code to a string
representation.
We already use `nghttp2_strerror()` for this, which
is provided by nghttp2 returns a better error string anyway.
PR-URL: https://github.com/nodejs/node/pull/21827
Reviewed-By: Colin Ihrig
Reviewed-By: Trivikram Kamat
Reviewed-By: Matteo Collina
Reviewed-By: James M Snell
Reviewed-By: Luigi Pinca
---
src/node_http2.h | 52 ------------------------------------------------
1 file changed, 52 deletions(-)
diff --git a/src/node_http2.h b/src/node_http2.h
index cbed2a267d171e..a30ee581751bb5 100644
--- a/src/node_http2.h
+++ b/src/node_http2.h
@@ -326,58 +326,6 @@ enum padding_strategy_type {
PADDING_STRATEGY_CALLBACK
};
-// These are the error codes provided by the underlying nghttp2 implementation.
-#define NGHTTP2_ERROR_CODES(V) \
- V(NGHTTP2_ERR_INVALID_ARGUMENT) \
- V(NGHTTP2_ERR_BUFFER_ERROR) \
- V(NGHTTP2_ERR_UNSUPPORTED_VERSION) \
- V(NGHTTP2_ERR_WOULDBLOCK) \
- V(NGHTTP2_ERR_PROTO) \
- V(NGHTTP2_ERR_INVALID_FRAME) \
- V(NGHTTP2_ERR_EOF) \
- V(NGHTTP2_ERR_DEFERRED) \
- V(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE) \
- V(NGHTTP2_ERR_STREAM_CLOSED) \
- V(NGHTTP2_ERR_STREAM_CLOSING) \
- V(NGHTTP2_ERR_STREAM_SHUT_WR) \
- V(NGHTTP2_ERR_INVALID_STREAM_ID) \
- V(NGHTTP2_ERR_INVALID_STREAM_STATE) \
- V(NGHTTP2_ERR_DEFERRED_DATA_EXIST) \
- V(NGHTTP2_ERR_START_STREAM_NOT_ALLOWED) \
- V(NGHTTP2_ERR_GOAWAY_ALREADY_SENT) \
- V(NGHTTP2_ERR_INVALID_HEADER_BLOCK) \
- V(NGHTTP2_ERR_INVALID_STATE) \
- V(NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) \
- V(NGHTTP2_ERR_FRAME_SIZE_ERROR) \
- V(NGHTTP2_ERR_HEADER_COMP) \
- V(NGHTTP2_ERR_FLOW_CONTROL) \
- V(NGHTTP2_ERR_INSUFF_BUFSIZE) \
- V(NGHTTP2_ERR_PAUSE) \
- V(NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS) \
- V(NGHTTP2_ERR_PUSH_DISABLED) \
- V(NGHTTP2_ERR_DATA_EXIST) \
- V(NGHTTP2_ERR_SESSION_CLOSING) \
- V(NGHTTP2_ERR_HTTP_HEADER) \
- V(NGHTTP2_ERR_HTTP_MESSAGING) \
- V(NGHTTP2_ERR_REFUSED_STREAM) \
- V(NGHTTP2_ERR_INTERNAL) \
- V(NGHTTP2_ERR_CANCEL) \
- V(NGHTTP2_ERR_FATAL) \
- V(NGHTTP2_ERR_NOMEM) \
- V(NGHTTP2_ERR_CALLBACK_FAILURE) \
- V(NGHTTP2_ERR_BAD_CLIENT_MAGIC) \
- V(NGHTTP2_ERR_FLOODED)
-
-const char* nghttp2_errname(int rv) {
- switch (rv) {
-#define V(code) case code: return #code;
- NGHTTP2_ERROR_CODES(V)
-#undef V
- default:
- return "NGHTTP2_UNKNOWN_ERROR";
- }
-}
-
enum session_state_flags {
SESSION_STATE_NONE = 0x0,
SESSION_STATE_HAS_SCOPE = 0x1,
From 4c5fc5c7ce585bc9bbb02cd7bbcc607f3a0efbab Mon Sep 17 00:00:00 2001
From: Rich Trott
Date: Fri, 13 Jul 2018 14:37:56 -0700
Subject: [PATCH 23/95] build: move to `npm ci` where possible
Recent events (involving a maliciously published version of a popular
module's dependency) have reinvigorated my interest in seeing us move to
`npm ci` instead of `npm install`. This moves us to `npm ci` where
possible in Makefile and vcbuild.bat.
PR-URL: https://github.com/nodejs/node/pull/21802
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Richard Lau
Reviewed-By: Refael Ackermann
Reviewed-By: James M Snell
---
Makefile | 5 +++--
vcbuild.bat | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 168dd27ea03d6d..cb9edb125241b0 100644
--- a/Makefile
+++ b/Makefile
@@ -659,6 +659,7 @@ available-node = \
fi;
run-npm-install = $(PWD)/$(NPM) install --production --no-package-lock
+run-npm-ci = $(PWD)/$(NPM) ci
tools/doc/node_modules/js-yaml/package.json:
cd tools/doc && $(call available-node,$(run-npm-install))
@@ -1068,12 +1069,12 @@ lint-md-clean:
tools/remark-cli/node_modules: tools/remark-cli/package.json
@echo "Markdown linter: installing remark-cli into tools/"
- @cd tools/remark-cli && $(call available-node,$(run-npm-install))
+ @cd tools/remark-cli && $(call available-node,$(run-npm-ci))
tools/remark-preset-lint-node/node_modules: \
tools/remark-preset-lint-node/package.json
@echo "Markdown linter: installing remark-preset-lint-node into tools/"
- @cd tools/remark-preset-lint-node && $(call available-node,$(run-npm-install))
+ @cd tools/remark-preset-lint-node && $(call available-node,$(run-npm-ci))
.PHONY: lint-md-build
lint-md-build: tools/remark-cli/node_modules \
diff --git a/vcbuild.bat b/vcbuild.bat
index 368112edf9a02c..fa14e321e6f09d 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -614,12 +614,12 @@ if not defined lint_md_build goto lint-md
SETLOCAL
echo Markdown linter: installing remark-cli into tools\
cd tools\remark-cli
-%npm_exe% install
+%npm_exe% ci
cd ..\..
if errorlevel 1 goto lint-md-build-failed
echo Markdown linter: installing remark-preset-lint-node into tools\
cd tools\remark-preset-lint-node
-%npm_exe% install
+%npm_exe% ci
cd ..\..
if errorlevel 1 goto lint-md-build-failed
ENDLOCAL
From 4f00562ef093833c54698ea0bc60a5d2522a2b38 Mon Sep 17 00:00:00 2001
From: Kenny Yuan
Date: Fri, 13 Jul 2018 15:00:19 +0800
Subject: [PATCH 24/95] build: add new benchmark targets
Adding new build targets: 'bench-addons' & 'bench-addons-clean'. With
these two, it will be easier to manage the dependencies among targets
and easier to build/clean the addons which are being used in
benchmarking.
PR-URL: https://github.com/nodejs/node/pull/20905
Reviewed-By: Rich Trott
Reviewed-By: Anna Henningsen
---
Makefile | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index cb9edb125241b0..0fe18f5dfc6d50 100644
--- a/Makefile
+++ b/Makefile
@@ -141,6 +141,7 @@ clean: ## Remove build artifacts.
$(RM) -r test/tmp*
$(RM) -r test/.tmp*
$(MAKE) test-addons-clean
+ $(MAKE) bench-addons-clean
.PHONY: distclean
distclean:
@@ -1054,13 +1055,23 @@ ifeq ($(XZ), 0)
endif
.PHONY: bench-all
-bench-all:
+bench-all: bench-addons-build
@echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."
.PHONY: bench
-bench:
+bench: bench-addons-build
@echo "Please use benchmark/run.js or benchmark/compare.js to run the benchmarks."
+# Build required addons for benchmark before running it.
+.PHONY: bench-addons-build
+bench-addons-build: benchmark/napi/function_call/build/Release/binding.node \
+ benchmark/napi/function_args/build/Release/binding.node
+
+.PHONY: bench-addons-clean
+bench-addons-clean:
+ $(RM) -r benchmark/napi/function_call/build
+ $(RM) -r benchmark/napi/function_args/build
+
.PHONY: lint-md-clean
lint-md-clean:
$(RM) -r tools/remark-cli/node_modules
From af1530e06d1c7557c1748c3447fc1151cc7f08e3 Mon Sep 17 00:00:00 2001
From: cjihrig
Date: Thu, 19 Jul 2018 22:08:39 -0400
Subject: [PATCH 25/95] doc: add cjihrig pronouns
PR-URL: https://github.com/nodejs/node/pull/21901
Reviewed-By: Anatoli Papirovski
Reviewed-By: James M Snell
Reviewed-By: Gus Caplan
Reviewed-By: Jon Moss
Reviewed-By: Rich Trott
Reviewed-By: Yuta Hiroto
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index ce03c7d4c04269..9fdd34575331e8 100644
--- a/README.md
+++ b/README.md
@@ -240,7 +240,7 @@ For more information about the governance of the Node.js project, see
* [ChALkeR](https://github.com/ChALkeR) -
**Сковорода Никита Андреевич** <chalkerx@gmail.com> (he/him)
* [cjihrig](https://github.com/cjihrig) -
-**Colin Ihrig** <cjihrig@gmail.com>
+**Colin Ihrig** <cjihrig@gmail.com> (he/him)
* [danbev](https://github.com/danbev) -
**Daniel Bevenius** <daniel.bevenius@gmail.com>
* [fhinkel](https://github.com/fhinkel) -
@@ -342,7 +342,7 @@ For more information about the governance of the Node.js project, see
* [chrisdickinson](https://github.com/chrisdickinson) -
**Chris Dickinson** <christopher.s.dickinson@gmail.com>
* [cjihrig](https://github.com/cjihrig) -
-**Colin Ihrig** <cjihrig@gmail.com>
+**Colin Ihrig** <cjihrig@gmail.com> (he/him)
* [claudiorodriguez](https://github.com/claudiorodriguez) -
**Claudio Rodriguez** <cjrodr@yahoo.com>
* [codebytere](https://github.com/codebytere) -
From f89d194debe3f7daa29698dafdaa45ddeb1fe350 Mon Sep 17 00:00:00 2001
From: Rich Trott
Date: Sat, 14 Jul 2018 19:28:53 -0700
Subject: [PATCH 26/95] tools: improve update-eslint.sh
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Pin version numbers when using `npx`. This means we can be careful
about updating what we run. (Thinking about the recent eslint-scope
thing.)
* Add removeNPMAbsolutePaths to get rid of unused fields in package.json
files. These unused fields can cause unnecessary churn, as at least
one contains an absolute path that will be different for each
developer.
PR-URL: https://github.com/nodejs/node/pull/21819
Reviewed-By: Yuta Hiroto
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Michaël Zasso
Reviewed-By: Richard Lau
Reviewed-By: Luigi Pinca
Reviewed-By: Colin Ihrig
Reviewed-By: Trivikram Kamat
Reviewed-By: Roman Reiss
---
tools/update-eslint.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/update-eslint.sh b/tools/update-eslint.sh
index 3663ecf74283c0..8092b7f0b8e93f 100755
--- a/tools/update-eslint.sh
+++ b/tools/update-eslint.sh
@@ -20,7 +20,10 @@ npm install --no-bin-links --production --no-package-lock eslint-plugin-markdown
cd ../..
# Use dmn to remove some unneeded files.
-npx dmn -f clean
+npx dmn@1.0.10 -f clean
+# Use removeNPMAbsolutePaths to remove unused data in package.json.
+# This avoids churn as absolute paths can change from one dev to another.
+npx removeNPMAbsolutePaths@1.0.4 .
cd ..
mv eslint-tmp/node_modules/eslint node_modules/eslint
From 46d14fc0e84f2adc7e53cc2a3bae40392a5dba6b Mon Sep 17 00:00:00 2001
From: Rich Trott
Date: Tue, 17 Jul 2018 22:40:55 -0700
Subject: [PATCH 27/95] test: refactor cluster-net-listen-relative-path
Refactor test-cluster-net-listen-relative-path:
* Use arrow funcitons for callbacks.
* Move skip-test code closer to start of file.
* Use assert.ok() where appropriate.
* Capitalize and punctuate comments.
PR-URL: https://github.com/nodejs/node/pull/21863
Reviewed-By: Trivikram Kamat
Reviewed-By: Anna Henningsen
Reviewed-By: James M Snell
Reviewed-By: Jon Moss
Reviewed-By: Luigi Pinca
---
.../test-cluster-net-listen-relative-path.js | 36 +++++++++----------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/test/parallel/test-cluster-net-listen-relative-path.js b/test/parallel/test-cluster-net-listen-relative-path.js
index 7e61cf83da7882..0e1c3f7cf7cf4a 100644
--- a/test/parallel/test-cluster-net-listen-relative-path.js
+++ b/test/parallel/test-cluster-net-listen-relative-path.js
@@ -1,12 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
-const cluster = require('cluster');
-const net = require('net');
-const path = require('path');
-const fs = require('fs');
-
-const tmpdir = require('../common/tmpdir');
if (common.isWindows)
common.skip('On Windows named pipes live in their own ' +
@@ -14,35 +7,40 @@ if (common.isWindows)
if (!common.isMainThread)
common.skip('process.chdir is not available in Workers');
+const assert = require('assert');
+const cluster = require('cluster');
+const fs = require('fs');
+const net = require('net');
+const path = require('path');
+
+const tmpdir = require('../common/tmpdir');
+
// Choose a socket name such that the absolute path would exceed 100 bytes.
const socketDir = './unix-socket-dir';
const socketName = 'A'.repeat(100 - socketDir.length - 1);
-// Make sure we're not in a weird environment
-assert.strictEqual(path.resolve(socketDir, socketName).length > 100, true,
- 'absolute socket path should be longer than 100 bytes');
+// Make sure we're not in a weird environment.
+assert.ok(path.resolve(socketDir, socketName).length > 100,
+ 'absolute socket path should be longer than 100 bytes');
if (cluster.isMaster) {
- // ensure that the worker exits peacefully
+ // Ensure that the worker exits peacefully.
tmpdir.refresh();
process.chdir(tmpdir.path);
fs.mkdirSync(socketDir);
- cluster.fork().on('exit', common.mustCall(function(statusCode) {
+ cluster.fork().on('exit', common.mustCall((statusCode) => {
assert.strictEqual(statusCode, 0);
- assert.strictEqual(
- fs.existsSync(path.join(socketDir, socketName)), false,
- 'Socket should be removed when the worker exits');
+ assert.ok(!fs.existsSync(path.join(socketDir, socketName)),
+ 'Socket should be removed when the worker exits');
}));
} else {
process.chdir(socketDir);
const server = net.createServer(common.mustNotCall());
- server.listen(socketName, common.mustCall(function() {
- assert.strictEqual(
- fs.existsSync(socketName), true,
- 'Socket created in CWD');
+ server.listen(socketName, common.mustCall(() => {
+ assert.ok(fs.existsSync(socketName), 'Socket created in CWD');
process.disconnect();
}));
From fd5a0c7a1fd924ac8a7f3262358d97f3456f1fcc Mon Sep 17 00:00:00 2001
From: Anto Aravinth
Date: Fri, 20 Jul 2018 19:30:40 +0530
Subject: [PATCH 28/95] doc: fix incorrect method name
PR-URL: https://github.com/nodejs/node/pull/21908
Reviewed-By: Colin Ihrig
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Lance Ball
Reviewed-By: James M Snell
---
doc/api/vm.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/api/vm.md b/doc/api/vm.md
index 7d14293ac4e45b..f294e7301bd799 100644
--- a/doc/api/vm.md
+++ b/doc/api/vm.md
@@ -198,7 +198,7 @@ const contextifiedSandbox = vm.createContext({ secret: 42 });
});
// Since module has no dependencies, the linker function will never be called.
await module.link(() => {});
- module.initialize();
+ module.instantiate();
await module.evaluate();
// Now, Object.prototype.secret will be equal to 42.
From bd352f0298fc6b9e0ac8b718f58a2c8bfc711ae6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?=
Date: Tue, 19 Jun 2018 09:46:50 +0200
Subject: [PATCH 29/95] doc: update and improve the release guide
PR-URL: https://github.com/nodejs/node/pull/21868
Reviewed-By: Anna Henningsen
Reviewed-By: James M Snell
Reviewed-By: Jon Moss
Reviewed-By: Ruben Bridgewater
Reviewed-By: Colin Ihrig
Reviewed-By: Luigi Pinca
---
doc/releases.md | 173 +++++++++++++++++++++++++++++++-----------------
1 file changed, 111 insertions(+), 62 deletions(-)
diff --git a/doc/releases.md b/doc/releases.md
index bbf70bbbfbee22..051df2b03a7ec3 100644
--- a/doc/releases.md
+++ b/doc/releases.md
@@ -78,8 +78,9 @@ Notes:
- Dates listed below as _"YYYY-MM-DD"_ should be the date of the release **as
UTC**. Use `date -u +'%Y-%m-%d'` to find out what this is.
-- Version strings are listed below as _"vx.y.z"_. Substitute for the release
- version.
+- Version strings are listed below as _"vx.y.z"_ or _"x.y.z"_. Substitute for
+ the release version.
+- Examples will use the fictional release version `1.2.3`.
### 0. Pre-release steps
@@ -98,29 +99,54 @@ of the `nodejs-private/node-private` repository a day or so before the
[CI lockdown procedure][] begins. This is to confirm that Jenkins can properly
access the private repository.
-### 1. Cherry-picking from `master` and other branches
+### 1. Update the staging branch
-Create a new branch named _"vx.y.z-proposal"_, or something similar. Using `git
-cherry-pick`, bring the appropriate commits into your new branch. To determine
-the relevant commits, use [`branch-diff`](https://github.com/rvagg/branch-diff)
-and [`changelog-maker`](https://github.com/rvagg/changelog-maker/) (both are
-available on npm and should be installed globally). These tools depend on our
-commit metadata, as well as the `semver-minor` and `semver-major` GitHub labels.
-One drawback is that when the `PR-URL` metadata is accidentally omitted from a
-commit, the commit will show up because it's unsure if it's a duplicate or not.
+Checkout the staging branch locally.
-For a list of commits that could be landed in a patch release on v5.x:
+```console
+$ git remote update
+$ git checkout v1.x-staging
+$ git reset --hard upstream/v1.x-staging
+```
+
+If the staging branch is not up to date relative to `master`, bring the
+appropriate commits into it. To determine the relevant commits, use
+[`branch-diff`](https://github.com/nodejs/branch-diff). The tool is available on
+npm and should be installed globally or run with `npx`. It depends on our commit
+metadata, as well as the GitHub labels such as `semver-minor` and
+`semver-major`. One drawback is that when the `PR-URL` metadata is accidentally
+omitted from a commit, the commit will show up because it's unsure if it's a
+duplicate or not.
+
+For a list of commits that could be landed in a patch release on v1.x:
```console
-$ branch-diff v5.x master --exclude-label=semver-major,semver-minor,dont-land-on-v5.x --filter-release --format=simple
+$ branch-diff v1.x-staging master --exclude-label=semver-major,semver-minor,dont-land-on-v1.x,backport-requested-v1.x --filter-release --format=simple
```
Carefully review the list of commits looking for errors (incorrect `PR-URL`,
-incorrect semver, etc.). Commits labeled as semver minor or semver major should
-only be cherry-picked when appropriate for the type of release being made.
-Previous release commits and version bumps do not need to be cherry-picked.
+incorrect semver, etc.). Commits labeled as `semver-minor` or `semver-major`
+should only be cherry-picked when appropriate for the type of release being
+made. Previous release commits and version bumps do not need to be
+cherry-picked.
+
+If commits were cherry-picked in this step, push to the staging branch to keep
+it up-to-date.
+
+```console
+$ git push upstream v1.x-staging
+```
+
+### 2. Create a new branch for the release
+
+Create a new branch named `vx.y.z-proposal`, off the corresponding staging
+branch.
+
+```console
+$ git checkout -b v1.2.3-proposal upstream/v1.x-staging
+```
-### 2. Update `src/node_version.h`
+### 3. Update `src/node_version.h`
Set the version for the proposed release using the following macros, which are
already defined in `src/node_version.h`:
@@ -160,12 +186,12 @@ informed perspective, such as a member of the NAN team.
see a need to bump `NODE_MODULE_VERSION` then you should consult the TSC.
Commits may need to be reverted or a major version bump may need to happen.
-### 3. Update the Changelog
+### 4. Update the Changelog
-#### Step 1: Collecting the formatted list of changes:
+#### Step 1: Collect the formatted list of changes
Collect a formatted list of commits since the last release. Use
-[`changelog-maker`](https://github.com/rvagg/changelog-maker) to do this:
+[`changelog-maker`](https://github.com/nodejs/changelog-maker) to do this:
```console
$ changelog-maker --group
@@ -176,12 +202,12 @@ in the repository was not on the current branch you may have to supply a
`--start-ref` argument:
```console
-$ changelog-maker --group --start-ref v2.3.1
+$ changelog-maker --group --start-ref v1.2.2
```
#### Step 2: Update the appropriate doc/changelogs/CHANGELOG_*.md file
-There is a separate `CHANGELOG_*.md` file for each major Node.js release line.
+There is a separate `CHANGELOG_Vx.md` file for each major Node.js release line.
These are located in the `doc/changelogs/` directory. Once the formatted list of
changes is collected, it must be added to the top of the relevant changelog file
in the release branch (e.g. a release for Node.js v4 would be added to the
@@ -210,18 +236,22 @@ The new entry should take the following form:
The release type should be either Current, LTS, or Maintenance, depending on the
type of release being produced.
+You can use `branch-diff` to get a list of commits with the `notable-change`
+label:
+
+```console
+$ branch-diff upstream/v1.x v1.2.3-proposal --require-label=notable-change -format=simple
+```
+
Be sure that the `` tag, as well as the two headings, are not indented at
all.
-At the top of each `CHANGELOG_*.md` file, and in the root `CHANGELOG.md` file,
-there is a table indexing all releases in each major release line. A link to the
-new release needs to be added to each. Follow the existing examples and be sure
-to add the release to the *top* of the list.
-
-In the root `CHANGELOG.md` file, the most recent release for each release line
-is shown in **bold** in the index. When updating the index, please make sure to
-update the display accordingly by removing the bold styling from the previous
-release.
+At the top of the root `CHANGELOG.md` file, there is a table indexing all
+releases in each major release line. A link to the new release needs to be added
+to it. Follow the existing examples and be sure to add the release to the *top*
+of the list. The most recent release for each release line is shown in **bold**
+in the index. When updating the index, please make sure to update the display
+accordingly by removing the bold styling from the previous release.
#### Step 3: Update any REPLACEME and DEP00XX tags in the docs
@@ -239,12 +269,12 @@ If this release includes any new deprecations it is necessary to ensure that
those are assigned a proper static deprecation code. These are listed in the
docs (see `doc/api/deprecations.md`) and in the source as `DEP00XX`. The code
must be assigned a number (e.g. `DEP0012`). Note that this assignment should
-occur when the PR is landed, but a check will be made when the release built is
+occur when the PR is landed, but a check will be made when the release build is
run.
-### 4. Create Release Commit
+### 5. Create Release Commit
-The `CHANGELOG.md`, `doc/changelogs/CHANGELOG_*.md`, `src/node_version.h`, and
+The `CHANGELOG.md`, `doc/changelogs/CHANGELOG_Vx.md`, `src/node_version.h`, and
`REPLACEME` changes should be the final commit that will be tagged for the
release. When committing these to git, use the following message format:
@@ -256,14 +286,14 @@ Notable changes:
* Copy the notable changes list here, reformatted for plain-text
```
-### 5. Propose Release on GitHub
+### 6. Propose Release on GitHub
Push the release branch to `nodejs/node`, not to your own fork. This allows
release branches to more easily be passed between members of the release team if
necessary.
Create a pull request targeting the correct release line. For example, a
-v5.3.0-proposal PR should target v5.x, not master. Paste the CHANGELOG
+`v5.3.0-proposal` PR should target `v5.x`, not master. Paste the CHANGELOG
modifications into the body of the PR so that collaborators can see what is
changing. These PRs should be left open for at least 24 hours, and can be
updated as new commits land.
@@ -271,23 +301,25 @@ updated as new commits land.
If you need any additional information about any of the commits, this PR is a
good place to @-mention the relevant contributors.
-This is also a good time to update the release commit to include `PR-URL`
-metadata.
+After opening the PR, update the release commit to include `PR-URL` metadata and
+force-push the proposal.
-### 6. Ensure that the Release Branch is Stable
+### 7. Ensure that the Release Branch is Stable
-Run a
-**[node-test-pull-request](https://ci.nodejs.org/job/node-test-pull-request/)**
+Run a **[`node-test-pull-request`](https://ci.nodejs.org/job/node-test-pull-request/)**
test run to ensure that the build is stable and the HEAD commit is ready for
release.
-Perform some smoke-testing. We have [citgm](https://github.com/nodejs/citgm) for
-this. You can also manually test important modules from the ecosystem. Remember
-that node-gyp and npm both take a `--nodedir` flag to point to your local
-repository so that you can test unreleased versions without needing node-gyp to
-download headers for you.
+Also run a **[`node-test-commit-v8-linux`](https://ci.nodejs.org/job/node-test-commit-v8-linux/)**
+test run if the release contains changes to `deps/v8`.
-### 7. Produce a Nightly Build _(optional)_
+Perform some smoke-testing. There is the
+**[`citgm-smoker`](https://ci.nodejs.org/job/citgm-smoker/)** CI job for this
+purpose. Run it once with the base `vx.x` branch as a reference and with the
+proposal branch to check if new regressions could be introduced in the
+ecosystem.
+
+### 8. Produce a Nightly Build _(optional)_
If there is a reason to produce a test release for the purpose of having others
try out installers or specifics of builds, produce a nightly build using
@@ -299,7 +331,7 @@ enter a proper length commit SHA, enter a date string, and select "nightly" for
This is particularly recommended if there has been recent work relating to the
macOS or Windows installers as they are not tested in any way by CI.
-### 8. Produce Release Builds
+### 9. Produce Release Builds
Use **[iojs+release](https://ci-release.nodejs.org/job/iojs+release/)** to
produce release artifacts. Enter the commit that you want to build from and
@@ -345,19 +377,19 @@ can use the
build in the release CI to re-run the build only for ARMv6. When launching the
build make sure to use the same commit hash as for the original release.
-### 9. Test the Build
+### 10. Test the Build
Jenkins collects the artifacts from the builds, allowing you to download and
install the new build. Make sure that the build appears correct. Check the
version numbers, and perform some basic checks to confirm that all is well with
the build before moving forward.
-### 10. Tag and Sign the Release Commit
+### 11. Tag and Sign the Release Commit
Once you have produced builds that you're happy with, create a new tag. By
waiting until this stage to create tags, you can discard a proposed release if
something goes wrong or additional commits are required. Once you have created a
-tag and pushed it to GitHub, you ***should not*** delete and re-tag. If you make
+tag and pushed it to GitHub, you ***must not*** delete and re-tag. If you make
a mistake after tagging then you'll have to version-bump and start again and
count that tag/version as lost.
@@ -388,7 +420,7 @@ following command:
$ git push
```
-### 11. Set Up For the Next Release
+### 12. Set Up For the Next Release
On release proposal branch, edit `src/node_version.h` again and:
@@ -407,17 +439,26 @@ This sets up the branch so that nightly builds are produced with the next
version number _and_ a pre-release tag.
Merge your release proposal branch into the stable branch that you are releasing
-from (e.g. `v8.x`), and rebase the corresponding staging branch (`v8.x-staging`)
-on top of that.
+from and rebase the corresponding staging branch on top of that.
+
+```console
+$ git checkout v1.x
+$ git merge --ff-only v1.2.3-proposal
+$ git push upstream v1.x
+$ git checkout v1.x-staging
+$ git rebase v1.x
+$ git push upstream v1.x-staging
+```
Cherry-pick the release commit to `master`. After cherry-picking, edit
`src/node_version.h` to ensure the version macros contain whatever values were
-previously on `master`. `NODE_VERSION_IS_RELEASE` should be `0`.
+previously on `master`. `NODE_VERSION_IS_RELEASE` should be `0`. **Do not**
+cherry-pick the "Working on vx.y.z" commit to `master`.
Run `make lint-md-build; make lint` before pushing to `master`, to make sure the
Changelog formatting passes the lint rules on `master`.
-### 12. Promote and Sign the Release Builds
+### 13. Promote and Sign the Release Builds
**It is important that the same individual who signed the release tag be the one
to promote the builds as the SHASUMS256.txt file needs to be signed with the
@@ -469,7 +510,7 @@ be prompted to re-sign SHASUMS256.txt.
*Note*: It is possible to only sign a release by running `./tools/release.sh -s
vX.Y.Z`.
-### 13. Check the Release
+### 14. Check the Release
Your release should be available at `https://nodejs.org/dist/vx.y.z/` and
. Check that the appropriate files are in
@@ -478,7 +519,7 @@ have the right internal version strings. Check that the API docs are available
at . Check that the release catalog files are correct
at and .
-### 14. Create a Blog Post
+### 15. Create a Blog Post
There is an automatic build that is kicked off when you promote new builds, so
within a few minutes nodejs.org will be listing your new version as the latest
@@ -512,7 +553,7 @@ This script will use the promoted builds and changelog to generate the post. Run
- Changes to `master` on the nodejs.org repo will trigger a new build of
nodejs.org so your changes should appear in a few minutes after pushing.
-### 15. Announce
+### 16. Announce
The nodejs.org website will automatically rebuild and include the new version.
To announce the build on Twitter through the official @nodejs account, email
@@ -527,11 +568,19 @@ To ensure communication goes out with the timing of the blog post, please allow
will be shared with the community in the email to coordinate these
announcements.
-### 16. Cleanup
+### 17. Create the release on GitHub
+
+- Got to the [New release page](https://github.com/nodejs/node/releases/new).
+- Select the tag version you pushed earlier.
+- For release title, copy the title from the changelog.
+- For the description, copy the rest of the changelog entry.
+- Click on the "Publish release" button.
+
+### 18. Cleanup
-Close your release proposal PR and remove the proposal branch.
+Close your release proposal PR and delete the proposal branch.
-### 17. Celebrate
+### 19. Celebrate
_In whatever form you do this..._
From 5606f0b1f2b55fe1be3e47555ba9c637ac660a6f Mon Sep 17 00:00:00 2001
From: Sam Ruby
Date: Sat, 23 Jun 2018 15:42:12 -0400
Subject: [PATCH 30/95] tools: create HTML docs with unified/remark/rehype
PR-URL: https://github.com/nodejs/node/pull/21490
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Rich Trott
---
LICENSE | 51 +
Makefile | 9 +-
test/doctool/test-doctool-html.js | 14 +-
tools/doc/html.js | 333 +-
tools/doc/node_modules/.bin/esparse | 1 +
tools/doc/node_modules/.bin/esvalidate | 1 +
tools/doc/node_modules/.bin/js-yaml | 1 +
tools/doc/node_modules/argparse/LICENSE | 21 +
tools/doc/node_modules/argparse/README.md | 255 +
tools/doc/node_modules/argparse/index.js | 3 +
tools/doc/node_modules/argparse/lib/action.js | 146 +
.../argparse/lib/action/append.js | 53 +
.../argparse/lib/action/append/constant.js | 47 +
.../node_modules/argparse/lib/action/count.js | 40 +
.../node_modules/argparse/lib/action/help.js | 47 +
.../node_modules/argparse/lib/action/store.js | 50 +
.../argparse/lib/action/store/constant.js | 43 +
.../argparse/lib/action/store/false.js | 27 +
.../argparse/lib/action/store/true.js | 26 +
.../argparse/lib/action/subparsers.js | 149 +
.../argparse/lib/action/version.js | 47 +
.../argparse/lib/action_container.js | 482 ++
.../doc/node_modules/argparse/lib/argparse.js | 14 +
.../argparse/lib/argument/error.js | 50 +
.../argparse/lib/argument/exclusive.js | 53 +
.../argparse/lib/argument/group.js | 74 +
.../argparse/lib/argument_parser.js | 1161 +++
tools/doc/node_modules/argparse/lib/const.js | 21 +
.../argparse/lib/help/added_formatters.js | 87 +
.../argparse/lib/help/formatter.js | 795 ++
.../node_modules/argparse/lib/namespace.js | 76 +
tools/doc/node_modules/argparse/lib/utils.js | 57 +
tools/doc/node_modules/argparse/package.json | 74 +
tools/doc/node_modules/esprima/LICENSE.BSD | 21 +
tools/doc/node_modules/esprima/README.md | 46 +
tools/doc/node_modules/esprima/bin/esparse.js | 139 +
.../node_modules/esprima/bin/esvalidate.js | 236 +
.../doc/node_modules/esprima/dist/esprima.js | 6700 +++++++++++++++++
tools/doc/node_modules/esprima/package.json | 141 +
tools/doc/node_modules/js-yaml/LICENSE | 21 +
tools/doc/node_modules/js-yaml/README.md | 313 +
tools/doc/node_modules/js-yaml/bin/js-yaml.js | 132 +
.../doc/node_modules/js-yaml/dist/js-yaml.js | 3905 ++++++++++
.../node_modules/js-yaml/dist/js-yaml.min.js | 1 +
tools/doc/node_modules/js-yaml/index.js | 7 +
tools/doc/node_modules/js-yaml/lib/js-yaml.js | 39 +
.../js-yaml/lib/js-yaml/common.js | 59 +
.../js-yaml/lib/js-yaml/dumper.js | 819 ++
.../js-yaml/lib/js-yaml/exception.js | 43 +
.../js-yaml/lib/js-yaml/loader.js | 1598 ++++
.../node_modules/js-yaml/lib/js-yaml/mark.js | 76 +
.../js-yaml/lib/js-yaml/schema.js | 108 +
.../js-yaml/lib/js-yaml/schema/core.js | 18 +
.../lib/js-yaml/schema/default_full.js | 25 +
.../lib/js-yaml/schema/default_safe.js | 28 +
.../js-yaml/lib/js-yaml/schema/failsafe.js | 17 +
.../js-yaml/lib/js-yaml/schema/json.js | 25 +
.../node_modules/js-yaml/lib/js-yaml/type.js | 61 +
.../js-yaml/lib/js-yaml/type/binary.js | 138 +
.../js-yaml/lib/js-yaml/type/bool.js | 35 +
.../js-yaml/lib/js-yaml/type/float.js | 116 +
.../js-yaml/lib/js-yaml/type/int.js | 173 +
.../js-yaml/lib/js-yaml/type/js/function.js | 86 +
.../js-yaml/lib/js-yaml/type/js/regexp.js | 60 +
.../js-yaml/lib/js-yaml/type/js/undefined.js | 28 +
.../js-yaml/lib/js-yaml/type/map.js | 8 +
.../js-yaml/lib/js-yaml/type/merge.js | 12 +
.../js-yaml/lib/js-yaml/type/null.js | 34 +
.../js-yaml/lib/js-yaml/type/omap.js | 44 +
.../js-yaml/lib/js-yaml/type/pairs.js | 53 +
.../js-yaml/lib/js-yaml/type/seq.js | 8 +
.../js-yaml/lib/js-yaml/type/set.js | 29 +
.../js-yaml/lib/js-yaml/type/str.js | 8 +
.../js-yaml/lib/js-yaml/type/timestamp.js | 88 +
tools/doc/node_modules/js-yaml/package.json | 96 +
tools/doc/node_modules/marked/.npmignore | 2 -
tools/doc/node_modules/marked/.travis.yml | 5 -
tools/doc/node_modules/marked/Gulpfile.js | 22 -
tools/doc/node_modules/marked/bower.json | 24 -
tools/doc/node_modules/marked/component.json | 10 -
tools/doc/node_modules/marked/doc/broken.md | 426 --
tools/doc/node_modules/marked/doc/todo.md | 2 -
tools/doc/node_modules/sprintf-js/LICENSE | 24 +
tools/doc/node_modules/sprintf-js/README.md | 88 +
.../sprintf-js/dist/angular-sprintf.min.js | 4 +
.../dist/angular-sprintf.min.js.map | 1 +
.../sprintf-js/dist/angular-sprintf.min.map | 1 +
.../sprintf-js/dist/sprintf.min.js | 4 +
.../sprintf-js/dist/sprintf.min.js.map | 1 +
.../sprintf-js/dist/sprintf.min.map | 1 +
.../doc/node_modules/sprintf-js/package.json | 58 +
.../sprintf-js/src/angular-sprintf.js | 18 +
.../node_modules/sprintf-js/src/sprintf.js | 208 +
tools/doc/package-lock.json | 1314 ++++
tools/doc/package.json | 9 +-
tools/license-builder.sh | 4 +-
vcbuild.bat | 31 +-
97 files changed, 21501 insertions(+), 658 deletions(-)
create mode 120000 tools/doc/node_modules/.bin/esparse
create mode 120000 tools/doc/node_modules/.bin/esvalidate
create mode 120000 tools/doc/node_modules/.bin/js-yaml
create mode 100644 tools/doc/node_modules/argparse/LICENSE
create mode 100644 tools/doc/node_modules/argparse/README.md
create mode 100644 tools/doc/node_modules/argparse/index.js
create mode 100644 tools/doc/node_modules/argparse/lib/action.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/append.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/append/constant.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/count.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/help.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/store.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/store/constant.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/store/false.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/store/true.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/subparsers.js
create mode 100644 tools/doc/node_modules/argparse/lib/action/version.js
create mode 100644 tools/doc/node_modules/argparse/lib/action_container.js
create mode 100644 tools/doc/node_modules/argparse/lib/argparse.js
create mode 100644 tools/doc/node_modules/argparse/lib/argument/error.js
create mode 100644 tools/doc/node_modules/argparse/lib/argument/exclusive.js
create mode 100644 tools/doc/node_modules/argparse/lib/argument/group.js
create mode 100644 tools/doc/node_modules/argparse/lib/argument_parser.js
create mode 100644 tools/doc/node_modules/argparse/lib/const.js
create mode 100644 tools/doc/node_modules/argparse/lib/help/added_formatters.js
create mode 100644 tools/doc/node_modules/argparse/lib/help/formatter.js
create mode 100644 tools/doc/node_modules/argparse/lib/namespace.js
create mode 100644 tools/doc/node_modules/argparse/lib/utils.js
create mode 100644 tools/doc/node_modules/argparse/package.json
create mode 100644 tools/doc/node_modules/esprima/LICENSE.BSD
create mode 100644 tools/doc/node_modules/esprima/README.md
create mode 100755 tools/doc/node_modules/esprima/bin/esparse.js
create mode 100755 tools/doc/node_modules/esprima/bin/esvalidate.js
create mode 100644 tools/doc/node_modules/esprima/dist/esprima.js
create mode 100644 tools/doc/node_modules/esprima/package.json
create mode 100644 tools/doc/node_modules/js-yaml/LICENSE
create mode 100644 tools/doc/node_modules/js-yaml/README.md
create mode 100755 tools/doc/node_modules/js-yaml/bin/js-yaml.js
create mode 100644 tools/doc/node_modules/js-yaml/dist/js-yaml.js
create mode 100644 tools/doc/node_modules/js-yaml/dist/js-yaml.min.js
create mode 100644 tools/doc/node_modules/js-yaml/index.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/common.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/dumper.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/exception.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/loader.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/mark.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema/core.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/schema/json.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/binary.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/bool.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/float.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/int.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/function.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/map.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/merge.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/null.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/omap.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/pairs.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/seq.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/set.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/str.js
create mode 100644 tools/doc/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
create mode 100644 tools/doc/node_modules/js-yaml/package.json
delete mode 100644 tools/doc/node_modules/marked/.npmignore
delete mode 100644 tools/doc/node_modules/marked/.travis.yml
delete mode 100644 tools/doc/node_modules/marked/Gulpfile.js
delete mode 100644 tools/doc/node_modules/marked/bower.json
delete mode 100644 tools/doc/node_modules/marked/component.json
delete mode 100644 tools/doc/node_modules/marked/doc/broken.md
delete mode 100644 tools/doc/node_modules/marked/doc/todo.md
create mode 100644 tools/doc/node_modules/sprintf-js/LICENSE
create mode 100644 tools/doc/node_modules/sprintf-js/README.md
create mode 100644 tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js
create mode 100644 tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map
create mode 100644 tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map
create mode 100644 tools/doc/node_modules/sprintf-js/dist/sprintf.min.js
create mode 100644 tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map
create mode 100644 tools/doc/node_modules/sprintf-js/dist/sprintf.min.map
create mode 100644 tools/doc/node_modules/sprintf-js/package.json
create mode 100644 tools/doc/node_modules/sprintf-js/src/angular-sprintf.js
create mode 100644 tools/doc/node_modules/sprintf-js/src/sprintf.js
diff --git a/LICENSE b/LICENSE
index d768eb3e2dab1b..c0546eea9dbab6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1197,6 +1197,57 @@ The externally maintained libraries used by Node.js are:
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
+- unified, located at deps/unified, is licensed as follows:
+ """
+ (The MIT License)
+
+ Copyright (c) 2015 Titus Wormer
+
+ 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.
+ """
+
+- remark-rehype, located at deps/remark-rehype, is licensed as follows:
+ """
+ (The MIT License)
+
+ Copyright (c) 2016 Titus Wormer
+
+ 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.
+ """
+
- remark-cli, located at tools/remark-cli, is licensed as follows:
"""
(The MIT License)
diff --git a/Makefile b/Makefile
index 0fe18f5dfc6d50..ae957e118d0eaf 100644
--- a/Makefile
+++ b/Makefile
@@ -266,7 +266,6 @@ test: all ## Runs default tests, linters, and builds docs.
# can be displayed together
$(MAKE) -s build-addons
$(MAKE) -s build-addons-napi
- $(MAKE) -s test-doc
$(MAKE) -s cctest
$(MAKE) -s jstest
@@ -618,7 +617,8 @@ apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
.PHONY: doc-only
-doc-only: $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
+doc-only: tools/doc/node_modules \
+ $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
# If it's a source tarball, assets are already in doc/api/assets,
# no need to install anything, we have already copied the docs over
if [ ! -d doc/api/assets ]; then \
@@ -1089,8 +1089,13 @@ tools/remark-preset-lint-node/node_modules: \
.PHONY: lint-md-build
lint-md-build: tools/remark-cli/node_modules \
+ tools/doc/node_modules \
tools/remark-preset-lint-node/node_modules
+.PHONY: tools/doc/node_modules
+tools/doc/node_modules:
+ @cd tools/doc && $(call available-node,$(run-npm-install))
+
.PHONY: lint-md
ifneq ("","$(wildcard tools/remark-cli/node_modules/)")
diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js
index a6119c16903a74..c895df087c4bfa 100644
--- a/test/doctool/test-doctool-html.js
+++ b/test/doctool/test-doctool-html.js
@@ -21,8 +21,8 @@ const toHTML = require('../../tools/doc/html.js');
const testData = [
{
file: fixtures.path('sample_document.md'),
- html: 'fish fish
Redfish
' +
- 'Bluefish '
+ html: 'fish fish ' +
+ ''
},
{
file: fixtures.path('order_of_end_tags_5873.md'),
@@ -31,7 +31,7 @@ const testData = [
'id="foo_class_method_buffer_from_array"># ' +
''
+ 'Reference/Global_Objects/Array" class="type"><Array>'
},
{
file: fixtures.path('doc_with_yaml.md'),
@@ -45,11 +45,11 @@ const testData = [
'Foobar II# ' +
'Describe Foobar II
in more detail here.' +
'fg(1)' +
'
-```
-
-
-```
-$ marked
- * item1
-
- * item2
-
- text
-^D
-
-```
-
-Which looks correct to you?
-
-- - -
-
-```
-$ markdown.pl
-* hello
- > world
-^D
-
-
-```
-
-```
-$ marked
-* hello
- > world
-^D
-
-```
-
-Again, which looks correct to you?
-
-- - -
-
-EXAMPLE:
-
-```
-$ markdown.pl
-* hello
- * world
- * hi
- code
-^D
-
-```
-
-The code isn't a code block even though it's after the bullet margin. I know,
-lets give it two more spaces, effectively making it 8 spaces past the bullet.
-
-```
-$ markdown.pl
-* hello
- * world
- * hi
- code
-^D
-
-```
-
-And, it's still not a code block. Did you also notice that the 3rd item isn't
-even its own list? Markdown screws that up too because of its indentation
-unaware parsing.
-
-- - -
-
-Let's look at some more examples of markdown's list parsing:
-
-```
-$ markdown.pl
-
- * item1
-
- * item2
-
- text
-^D
-
-```
-
-Misnested tags.
-
-
-```
-$ marked
- * item1
-
- * item2
-
- text
-^D
-
-```
-
-Which looks correct to you?
-
-- - -
-
-```
-$ markdown.pl
-* hello
- > world
-^D
-
-
-```
-
-More misnested tags.
-
-
-```
-$ marked
-* hello
- > world
-^D
-
-```
-
-Again, which looks correct to you?
-
-- - -
-
-# Why quality matters - Part 2
-
-``` bash
-$ markdown.pl
-* hello
- > world
-^D
-
-
-```
-
-``` bash
-$ sundown # upskirt
-* hello
- > world
-^D
-
-```
-
-``` bash
-$ marked
-* hello
- > world
-^D
-
-```
-
-Which looks correct to you?
-
-- - -
-
-See: https://github.com/evilstreak/markdown-js/issues/23
-
-``` bash
-$ markdown.pl # upskirt/markdown.js/discount
-* hello
- var a = 1;
-* world
-^D
-
-hello
-var a = 1;
-world
-
-```
-
-``` bash
-$ marked
-* hello
- var a = 1;
-* world
-^D
-hello
-code>var a = 1;
-world
-```
-
-Which looks more reasonable? Why shouldn't code blocks be able to appear in
-list items in a sane way?
-
-- - -
-
-``` bash
-$ markdown.js
-hello
-
-hello
-^D
-<div>hello</div>
-
-<span>hello</span>
-```
-
-``` bash
-$ marked
-hello
-
-hello
-^D
-hello
-
-
-hello
-
-```
-
-- - -
-
-See: https://github.com/evilstreak/markdown-js/issues/27
-
-``` bash
-$ markdown.js
-[![an image](/image)](/link)
-^D
-![an image
-```
-
-``` bash
-$ marked
-[![an image](/image)](/link)
-^D
-
-
-```
-
-- - -
-
-See: https://github.com/evilstreak/markdown-js/issues/24
-
-``` bash
-$ markdown.js
-> a
-
-> b
-
-> c
-^D
-a
bundefined> c
-```
-
-``` bash
-$ marked
-> a
-
-> b
-
-> c
-^D
-a
-
-
-b
-
-
-c
-
-```
-
-- - -
-
-``` bash
-$ markdown.pl
-* hello
- * world
- how
-
- are
- you
-
- * today
-* hi
-^D
-
-hello
-
-
-
-are
-you
-
-
-hi
-
-```
-
-``` bash
-$ marked
-* hello
- * world
- how
-
- are
- you
-
- * today
-* hi
-^D
-
-hello
-
-world
-how
-are
-you
-
-today
-
-
-
-hi
-
-```
diff --git a/tools/doc/node_modules/marked/doc/todo.md b/tools/doc/node_modules/marked/doc/todo.md
deleted file mode 100644
index 2e60b162aef82d..00000000000000
--- a/tools/doc/node_modules/marked/doc/todo.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# Todo
-
diff --git a/tools/doc/node_modules/sprintf-js/LICENSE b/tools/doc/node_modules/sprintf-js/LICENSE
new file mode 100644
index 00000000000000..663ac52e4d8cd9
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2007-2014, Alexandru Marasteanu
+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 this software 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 AUTHORS OR COPYRIGHT HOLDERS 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.
diff --git a/tools/doc/node_modules/sprintf-js/README.md b/tools/doc/node_modules/sprintf-js/README.md
new file mode 100644
index 00000000000000..83863561b29199
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/README.md
@@ -0,0 +1,88 @@
+# sprintf.js
+**sprintf.js** is a complete open source JavaScript sprintf implementation for the *browser* and *node.js*.
+
+Its prototype is simple:
+
+ string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
+
+The placeholders in the format string are marked by `%` and are followed by one or more of these elements, in this order:
+
+* An optional number followed by a `$` sign that selects which argument index to use for the value. If not specified, arguments will be placed in the same order as the placeholders in the input string.
+* An optional `+` sign that forces to preceed the result with a plus or minus sign on numeric values. By default, only the `-` sign is used on negative numbers.
+* An optional padding specifier that says what character to use for padding (if specified). Possible values are `0` or any other character precedeed by a `'` (single quote). The default is to pad with *spaces*.
+* An optional `-` sign, that causes sprintf to left-align the result of this placeholder. The default is to right-align the result.
+* An optional number, that says how many characters the result should have. If the value to be returned is shorter than this number, the result will be padded. When used with the `j` (JSON) type specifier, the padding length specifies the tab size used for indentation.
+* An optional precision modifier, consisting of a `.` (dot) followed by a number, that says how many digits should be displayed for floating point numbers. When used with the `g` type specifier, it specifies the number of significant digits. When used on a string, it causes the result to be truncated.
+* A type specifier that can be any of:
+ * `%` — yields a literal `%` character
+ * `b` — yields an integer as a binary number
+ * `c` — yields an integer as the character with that ASCII value
+ * `d` or `i` — yields an integer as a signed decimal number
+ * `e` — yields a float using scientific notation
+ * `u` — yields an integer as an unsigned decimal number
+ * `f` — yields a float as is; see notes on precision above
+ * `g` — yields a float as is; see notes on precision above
+ * `o` — yields an integer as an octal number
+ * `s` — yields a string as is
+ * `x` — yields an integer as a hexadecimal number (lower-case)
+ * `X` — yields an integer as a hexadecimal number (upper-case)
+ * `j` — yields a JavaScript object or array as a JSON encoded string
+
+## JavaScript `vsprintf`
+`vsprintf` is the same as `sprintf` except that it accepts an array of arguments, rather than a variable number of arguments:
+
+ vsprintf("The first 4 letters of the english alphabet are: %s, %s, %s and %s", ["a", "b", "c", "d"])
+
+## Argument swapping
+You can also swap the arguments. That is, the order of the placeholders doesn't have to match the order of the arguments. You can do that by simply indicating in the format string which arguments the placeholders refer to:
+
+ sprintf("%2$s %3$s a %1$s", "cracker", "Polly", "wants")
+And, of course, you can repeat the placeholders without having to increase the number of arguments.
+
+## Named arguments
+Format strings may contain replacement fields rather than positional placeholders. Instead of referring to a certain argument, you can now refer to a certain key within an object. Replacement fields are surrounded by rounded parentheses - `(` and `)` - and begin with a keyword that refers to a key:
+
+ var user = {
+ name: "Dolly"
+ }
+ sprintf("Hello %(name)s", user) // Hello Dolly
+Keywords in replacement fields can be optionally followed by any number of keywords or indexes:
+
+ var users = [
+ {name: "Dolly"},
+ {name: "Molly"},
+ {name: "Polly"}
+ ]
+ sprintf("Hello %(users[0].name)s, %(users[1].name)s and %(users[2].name)s", {users: users}) // Hello Dolly, Molly and Polly
+Note: mixing positional and named placeholders is not (yet) supported
+
+## Computed values
+You can pass in a function as a dynamic value and it will be invoked (with no arguments) in order to compute the value on-the-fly.
+
+ sprintf("Current timestamp: %d", Date.now) // Current timestamp: 1398005382890
+ sprintf("Current date and time: %s", function() { return new Date().toString() })
+
+# AngularJS
+You can now use `sprintf` and `vsprintf` (also aliased as `fmt` and `vfmt` respectively) in your AngularJS projects. See `demo/`.
+
+# Installation
+
+## Via Bower
+
+ bower install sprintf
+
+## Or as a node.js module
+
+ npm install sprintf-js
+
+### Usage
+
+ var sprintf = require("sprintf-js").sprintf,
+ vsprintf = require("sprintf-js").vsprintf
+
+ sprintf("%2$s %3$s a %1$s", "cracker", "Polly", "wants")
+ vsprintf("The first 4 letters of the english alphabet are: %s, %s, %s and %s", ["a", "b", "c", "d"])
+
+# License
+
+**sprintf.js** is licensed under the terms of the 3-clause BSD license.
diff --git a/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js
new file mode 100644
index 00000000000000..dbaf744d83c214
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js
@@ -0,0 +1,4 @@
+/*! sprintf-js | Alexandru Marasteanu (http://alexei.ro/) | BSD-3-Clause */
+
+angular.module("sprintf",[]).filter("sprintf",function(){return function(){return sprintf.apply(null,arguments)}}).filter("fmt",["$filter",function(a){return a("sprintf")}]).filter("vsprintf",function(){return function(a,b){return vsprintf(a,b)}}).filter("vfmt",["$filter",function(a){return a("vsprintf")}]);
+//# sourceMappingURL=angular-sprintf.min.map
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map
new file mode 100644
index 00000000000000..055964c624c1ac
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"angular-sprintf.min.js","sources":["../src/angular-sprintf.js"],"names":["angular","module","filter","sprintf","apply","arguments","$filter","format","argv","vsprintf"],"mappings":";;AAAAA,QACIC,OAAO,cACPC,OAAO,UAAW,WACd,MAAO,YACH,MAAOC,SAAQC,MAAM,KAAMC,cAGnCH,OAAO,OAAQ,UAAW,SAASI,GAC/B,MAAOA,GAAQ,cAEnBJ,OAAO,WAAY,WACf,MAAO,UAASK,EAAQC,GACpB,MAAOC,UAASF,EAAQC,MAGhCN,OAAO,QAAS,UAAW,SAASI,GAChC,MAAOA,GAAQ"}
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map
new file mode 100644
index 00000000000000..055964c624c1ac
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map
@@ -0,0 +1 @@
+{"version":3,"file":"angular-sprintf.min.js","sources":["../src/angular-sprintf.js"],"names":["angular","module","filter","sprintf","apply","arguments","$filter","format","argv","vsprintf"],"mappings":";;AAAAA,QACIC,OAAO,cACPC,OAAO,UAAW,WACd,MAAO,YACH,MAAOC,SAAQC,MAAM,KAAMC,cAGnCH,OAAO,OAAQ,UAAW,SAASI,GAC/B,MAAOA,GAAQ,cAEnBJ,OAAO,WAAY,WACf,MAAO,UAASK,EAAQC,GACpB,MAAOC,UAASF,EAAQC,MAGhCN,OAAO,QAAS,UAAW,SAASI,GAChC,MAAOA,GAAQ"}
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js
new file mode 100644
index 00000000000000..dc61e51add29bb
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js
@@ -0,0 +1,4 @@
+/*! sprintf-js | Alexandru Marasteanu (http://alexei.ro/) | BSD-3-Clause */
+
+!function(a){function b(){var a=arguments[0],c=b.cache;return c[a]&&c.hasOwnProperty(a)||(c[a]=b.parse(a)),b.format.call(null,c[a],arguments)}function c(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function d(a,b){return Array(b+1).join(a)}var e={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};b.format=function(a,f){var g,h,i,j,k,l,m,n=1,o=a.length,p="",q=[],r=!0,s="";for(h=0;o>h;h++)if(p=c(a[h]),"string"===p)q[q.length]=a[h];else if("array"===p){if(j=a[h],j[2])for(g=f[n],i=0;i=0),j[8]){case"b":g=g.toString(2);break;case"c":g=String.fromCharCode(g);break;case"d":case"i":g=parseInt(g,10);break;case"j":g=JSON.stringify(g,null,j[6]?parseInt(j[6]):0);break;case"e":g=j[7]?g.toExponential(j[7]):g.toExponential();break;case"f":g=j[7]?parseFloat(g).toFixed(j[7]):parseFloat(g);break;case"g":g=j[7]?parseFloat(g).toPrecision(j[7]):parseFloat(g);break;case"o":g=g.toString(8);break;case"s":g=(g=String(g))&&j[7]?g.substring(0,j[7]):g;break;case"u":g>>>=0;break;case"x":g=g.toString(16);break;case"X":g=g.toString(16).toUpperCase()}e.json.test(j[8])?q[q.length]=g:(!e.number.test(j[8])||r&&!j[3]?s="":(s=r?"+":"-",g=g.toString().replace(e.sign,"")),l=j[4]?"0"===j[4]?"0":j[4].charAt(1):" ",m=j[6]-(s+g).length,k=j[6]&&m>0?d(l,m):"",q[q.length]=j[5]?s+g+k:"0"===l?s+k+g:k+s+g)}return q.join("")},b.cache={},b.parse=function(a){for(var b=a,c=[],d=[],f=0;b;){if(null!==(c=e.text.exec(b)))d[d.length]=c[0];else if(null!==(c=e.modulo.exec(b)))d[d.length]="%";else{if(null===(c=e.placeholder.exec(b)))throw new SyntaxError("[sprintf] unexpected placeholder");if(c[2]){f|=1;var g=[],h=c[2],i=[];if(null===(i=e.key.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(g[g.length]=i[1];""!==(h=h.substring(i[0].length));)if(null!==(i=e.key_access.exec(h)))g[g.length]=i[1];else{if(null===(i=e.index_access.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");g[g.length]=i[1]}c[2]=g}else f|=2;if(3===f)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d[d.length]=c}b=b.substring(c[0].length)}return d};var f=function(a,c,d){return d=(c||[]).slice(0),d.splice(0,0,a),b.apply(null,d)};"undefined"!=typeof exports?(exports.sprintf=b,exports.vsprintf=f):(a.sprintf=b,a.vsprintf=f,"function"==typeof define&&define.amd&&define(function(){return{sprintf:b,vsprintf:f}}))}("undefined"==typeof window?this:window);
+//# sourceMappingURL=sprintf.min.map
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map
new file mode 100644
index 00000000000000..369dbafab157ae
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"sprintf.min.js","sources":["../src/sprintf.js"],"names":["window","sprintf","key","arguments","cache","hasOwnProperty","parse","format","call","get_type","variable","Object","prototype","toString","slice","toLowerCase","str_repeat","input","multiplier","Array","join","re","not_string","number","json","not_json","text","modulo","placeholder","key_access","index_access","sign","parse_tree","argv","arg","i","k","match","pad","pad_character","pad_length","cursor","tree_length","length","node_type","output","is_positive","Error","test","isNaN","TypeError","String","fromCharCode","parseInt","JSON","stringify","toExponential","parseFloat","toFixed","substring","toUpperCase","replace","charAt","fmt","_fmt","arg_names","exec","SyntaxError","field_list","replacement_field","field_match","vsprintf","_argv","splice","apply","exports","define","amd","this"],"mappings":";;CAAA,SAAUA,GAeN,QAASC,KACL,GAAIC,GAAMC,UAAU,GAAIC,EAAQH,EAAQG,KAIxC,OAHMA,GAAMF,IAAQE,EAAMC,eAAeH,KACrCE,EAAMF,GAAOD,EAAQK,MAAMJ,IAExBD,EAAQM,OAAOC,KAAK,KAAMJ,EAAMF,GAAMC,WA4JjD,QAASM,GAASC,GACd,MAAOC,QAAOC,UAAUC,SAASL,KAAKE,GAAUI,MAAM,EAAG,IAAIC,cAGjE,QAASC,GAAWC,EAAOC,GACvB,MAAOC,OAAMD,EAAa,GAAGE,KAAKH,GApLtC,GAAII,IACAC,WAAY,OACZC,OAAQ,SACRC,KAAM,MACNC,SAAU,OACVC,KAAM,YACNC,OAAQ,WACRC,YAAa,yFACb1B,IAAK,sBACL2B,WAAY,wBACZC,aAAc,aACdC,KAAM,UAWV9B,GAAQM,OAAS,SAASyB,EAAYC,GAClC,GAAiEC,GAAkBC,EAAGC,EAAGC,EAAOC,EAAKC,EAAeC,EAAhHC,EAAS,EAAGC,EAAcV,EAAWW,OAAQC,EAAY,GAASC,KAA0DC,GAAc,EAAMf,EAAO,EAC3J,KAAKI,EAAI,EAAOO,EAAJP,EAAiBA,IAEzB,GADAS,EAAYnC,EAASuB,EAAWG,IACd,WAAdS,EACAC,EAAOA,EAAOF,QAAUX,EAAWG,OAElC,IAAkB,UAAdS,EAAuB,CAE5B,GADAP,EAAQL,EAAWG,GACfE,EAAM,GAEN,IADAH,EAAMD,EAAKQ,GACNL,EAAI,EAAGA,EAAIC,EAAM,GAAGM,OAAQP,IAAK,CAClC,IAAKF,EAAI7B,eAAegC,EAAM,GAAGD,IAC7B,KAAM,IAAIW,OAAM9C,EAAQ,yCAA0CoC,EAAM,GAAGD,IAE/EF,GAAMA,EAAIG,EAAM,GAAGD,QAIvBF,GADKG,EAAM,GACLJ,EAAKI,EAAM,IAGXJ,EAAKQ,IAOf,IAJqB,YAAjBhC,EAASyB,KACTA,EAAMA,KAGNb,EAAGC,WAAW0B,KAAKX,EAAM,KAAOhB,EAAGI,SAASuB,KAAKX,EAAM,KAAyB,UAAjB5B,EAASyB,IAAoBe,MAAMf,GAClG,KAAM,IAAIgB,WAAUjD,EAAQ,0CAA2CQ,EAASyB,IAOpF,QAJIb,EAAGE,OAAOyB,KAAKX,EAAM,MACrBS,EAAcZ,GAAO,GAGjBG,EAAM,IACV,IAAK,IACDH,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,EAAMiB,OAAOC,aAAalB,EAC9B,MACA,KAAK,IACL,IAAK,IACDA,EAAMmB,SAASnB,EAAK,GACxB,MACA,KAAK,IACDA,EAAMoB,KAAKC,UAAUrB,EAAK,KAAMG,EAAM,GAAKgB,SAAShB,EAAM,IAAM,EACpE,MACA,KAAK,IACDH,EAAMG,EAAM,GAAKH,EAAIsB,cAAcnB,EAAM,IAAMH,EAAIsB,eACvD,MACA,KAAK,IACDtB,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKwB,QAAQrB,EAAM,IAAMoB,WAAWvB,EACpE,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,GAAQA,EAAMiB,OAAOjB,KAASG,EAAM,GAAKH,EAAIyB,UAAU,EAAGtB,EAAM,IAAMH,CAC1E,MACA,KAAK,IACDA,KAAc,CAClB,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,GACvB,MACA,KAAK,IACDqB,EAAMA,EAAIrB,SAAS,IAAI+C,cAG3BvC,EAAGG,KAAKwB,KAAKX,EAAM,IACnBQ,EAAOA,EAAOF,QAAUT,IAGpBb,EAAGE,OAAOyB,KAAKX,EAAM,KAASS,IAAeT,EAAM,GAKnDN,EAAO,IAJPA,EAAOe,EAAc,IAAM,IAC3BZ,EAAMA,EAAIrB,WAAWgD,QAAQxC,EAAGU,KAAM,KAK1CQ,EAAgBF,EAAM,GAAkB,MAAbA,EAAM,GAAa,IAAMA,EAAM,GAAGyB,OAAO,GAAK,IACzEtB,EAAaH,EAAM,IAAMN,EAAOG,GAAKS,OACrCL,EAAMD,EAAM,IAAMG,EAAa,EAAIxB,EAAWuB,EAAeC,GAAoB,GACjFK,EAAOA,EAAOF,QAAUN,EAAM,GAAKN,EAAOG,EAAMI,EAAyB,MAAlBC,EAAwBR,EAAOO,EAAMJ,EAAMI,EAAMP,EAAOG,GAI3H,MAAOW,GAAOzB,KAAK,KAGvBnB,EAAQG,SAERH,EAAQK,MAAQ,SAASyD,GAErB,IADA,GAAIC,GAAOD,EAAK1B,KAAYL,KAAiBiC,EAAY,EAClDD,GAAM,CACT,GAAqC,QAAhC3B,EAAQhB,EAAGK,KAAKwC,KAAKF,IACtBhC,EAAWA,EAAWW,QAAUN,EAAM,OAErC,IAAuC,QAAlCA,EAAQhB,EAAGM,OAAOuC,KAAKF,IAC7BhC,EAAWA,EAAWW,QAAU,QAE/B,CAAA,GAA4C,QAAvCN,EAAQhB,EAAGO,YAAYsC,KAAKF,IAgClC,KAAM,IAAIG,aAAY,mCA/BtB,IAAI9B,EAAM,GAAI,CACV4B,GAAa,CACb,IAAIG,MAAiBC,EAAoBhC,EAAM,GAAIiC,IACnD,IAAuD,QAAlDA,EAAcjD,EAAGnB,IAAIgE,KAAKG,IAe3B,KAAM,IAAIF,aAAY,+CAbtB,KADAC,EAAWA,EAAWzB,QAAU2B,EAAY,GACwC,MAA5ED,EAAoBA,EAAkBV,UAAUW,EAAY,GAAG3B,UACnE,GAA8D,QAAzD2B,EAAcjD,EAAGQ,WAAWqC,KAAKG,IAClCD,EAAWA,EAAWzB,QAAU2B,EAAY,OAE3C,CAAA,GAAgE,QAA3DA,EAAcjD,EAAGS,aAAaoC,KAAKG,IAIzC,KAAM,IAAIF,aAAY,+CAHtBC,GAAWA,EAAWzB,QAAU2B,EAAY,GAUxDjC,EAAM,GAAK+B,MAGXH,IAAa,CAEjB,IAAkB,IAAdA,EACA,KAAM,IAAIlB,OAAM,4EAEpBf,GAAWA,EAAWW,QAAUN,EAKpC2B,EAAOA,EAAKL,UAAUtB,EAAM,GAAGM,QAEnC,MAAOX,GAGX,IAAIuC,GAAW,SAASR,EAAK9B,EAAMuC,GAG/B,MAFAA,IAASvC,OAAYnB,MAAM,GAC3B0D,EAAMC,OAAO,EAAG,EAAGV,GACZ9D,EAAQyE,MAAM,KAAMF,GAiBR,oBAAZG,UACPA,QAAQ1E,QAAUA,EAClB0E,QAAQJ,SAAWA,IAGnBvE,EAAOC,QAAUA,EACjBD,EAAOuE,SAAWA,EAEI,kBAAXK,SAAyBA,OAAOC,KACvCD,OAAO,WACH,OACI3E,QAASA,EACTsE,SAAUA,OAKT,mBAAXvE,QAAyB8E,KAAO9E"}
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/dist/sprintf.min.map b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.map
new file mode 100644
index 00000000000000..ee011aaa5aa56f
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/dist/sprintf.min.map
@@ -0,0 +1 @@
+{"version":3,"file":"sprintf.min.js","sources":["../src/sprintf.js"],"names":["window","sprintf","key","arguments","cache","hasOwnProperty","parse","format","call","get_type","variable","Object","prototype","toString","slice","toLowerCase","str_repeat","input","multiplier","Array","join","re","not_string","number","json","not_json","text","modulo","placeholder","key_access","index_access","sign","parse_tree","argv","arg","i","k","match","pad","pad_character","pad_length","cursor","tree_length","length","node_type","output","is_positive","Error","test","isNaN","TypeError","String","fromCharCode","parseInt","JSON","stringify","toExponential","parseFloat","toFixed","toPrecision","substring","toUpperCase","replace","charAt","fmt","_fmt","arg_names","exec","SyntaxError","field_list","replacement_field","field_match","vsprintf","_argv","splice","apply","exports","define","amd","this"],"mappings":";;CAAA,SAAUA,GAeN,QAASC,KACL,GAAIC,GAAMC,UAAU,GAAIC,EAAQH,EAAQG,KAIxC,OAHMA,GAAMF,IAAQE,EAAMC,eAAeH,KACrCE,EAAMF,GAAOD,EAAQK,MAAMJ,IAExBD,EAAQM,OAAOC,KAAK,KAAMJ,EAAMF,GAAMC,WA+JjD,QAASM,GAASC,GACd,MAAOC,QAAOC,UAAUC,SAASL,KAAKE,GAAUI,MAAM,EAAG,IAAIC,cAGjE,QAASC,GAAWC,EAAOC,GACvB,MAAOC,OAAMD,EAAa,GAAGE,KAAKH,GAvLtC,GAAII,IACAC,WAAY,OACZC,OAAQ,UACRC,KAAM,MACNC,SAAU,OACVC,KAAM,YACNC,OAAQ,WACRC,YAAa,yFACb1B,IAAK,sBACL2B,WAAY,wBACZC,aAAc,aACdC,KAAM,UAWV9B,GAAQM,OAAS,SAASyB,EAAYC,GAClC,GAAiEC,GAAkBC,EAAGC,EAAGC,EAAOC,EAAKC,EAAeC,EAAhHC,EAAS,EAAGC,EAAcV,EAAWW,OAAQC,EAAY,GAASC,KAA0DC,GAAc,EAAMf,EAAO,EAC3J,KAAKI,EAAI,EAAOO,EAAJP,EAAiBA,IAEzB,GADAS,EAAYnC,EAASuB,EAAWG,IACd,WAAdS,EACAC,EAAOA,EAAOF,QAAUX,EAAWG,OAElC,IAAkB,UAAdS,EAAuB,CAE5B,GADAP,EAAQL,EAAWG,GACfE,EAAM,GAEN,IADAH,EAAMD,EAAKQ,GACNL,EAAI,EAAGA,EAAIC,EAAM,GAAGM,OAAQP,IAAK,CAClC,IAAKF,EAAI7B,eAAegC,EAAM,GAAGD,IAC7B,KAAM,IAAIW,OAAM9C,EAAQ,yCAA0CoC,EAAM,GAAGD,IAE/EF,GAAMA,EAAIG,EAAM,GAAGD,QAIvBF,GADKG,EAAM,GACLJ,EAAKI,EAAM,IAGXJ,EAAKQ,IAOf,IAJqB,YAAjBhC,EAASyB,KACTA,EAAMA,KAGNb,EAAGC,WAAW0B,KAAKX,EAAM,KAAOhB,EAAGI,SAASuB,KAAKX,EAAM,KAAyB,UAAjB5B,EAASyB,IAAoBe,MAAMf,GAClG,KAAM,IAAIgB,WAAUjD,EAAQ,0CAA2CQ,EAASyB,IAOpF,QAJIb,EAAGE,OAAOyB,KAAKX,EAAM,MACrBS,EAAcZ,GAAO,GAGjBG,EAAM,IACV,IAAK,IACDH,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,EAAMiB,OAAOC,aAAalB,EAC9B,MACA,KAAK,IACL,IAAK,IACDA,EAAMmB,SAASnB,EAAK,GACxB,MACA,KAAK,IACDA,EAAMoB,KAAKC,UAAUrB,EAAK,KAAMG,EAAM,GAAKgB,SAAShB,EAAM,IAAM,EACpE,MACA,KAAK,IACDH,EAAMG,EAAM,GAAKH,EAAIsB,cAAcnB,EAAM,IAAMH,EAAIsB,eACvD,MACA,KAAK,IACDtB,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKwB,QAAQrB,EAAM,IAAMoB,WAAWvB,EACpE,MACA,KAAK,IACDA,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKyB,YAAYtB,EAAM,IAAMoB,WAAWvB,EACxE,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,GAAQA,EAAMiB,OAAOjB,KAASG,EAAM,GAAKH,EAAI0B,UAAU,EAAGvB,EAAM,IAAMH,CAC1E,MACA,KAAK,IACDA,KAAc,CAClB,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,GACvB,MACA,KAAK,IACDqB,EAAMA,EAAIrB,SAAS,IAAIgD,cAG3BxC,EAAGG,KAAKwB,KAAKX,EAAM,IACnBQ,EAAOA,EAAOF,QAAUT,IAGpBb,EAAGE,OAAOyB,KAAKX,EAAM,KAASS,IAAeT,EAAM,GAKnDN,EAAO,IAJPA,EAAOe,EAAc,IAAM,IAC3BZ,EAAMA,EAAIrB,WAAWiD,QAAQzC,EAAGU,KAAM,KAK1CQ,EAAgBF,EAAM,GAAkB,MAAbA,EAAM,GAAa,IAAMA,EAAM,GAAG0B,OAAO,GAAK,IACzEvB,EAAaH,EAAM,IAAMN,EAAOG,GAAKS,OACrCL,EAAMD,EAAM,IAAMG,EAAa,EAAIxB,EAAWuB,EAAeC,GAAoB,GACjFK,EAAOA,EAAOF,QAAUN,EAAM,GAAKN,EAAOG,EAAMI,EAAyB,MAAlBC,EAAwBR,EAAOO,EAAMJ,EAAMI,EAAMP,EAAOG,GAI3H,MAAOW,GAAOzB,KAAK,KAGvBnB,EAAQG,SAERH,EAAQK,MAAQ,SAAS0D,GAErB,IADA,GAAIC,GAAOD,EAAK3B,KAAYL,KAAiBkC,EAAY,EAClDD,GAAM,CACT,GAAqC,QAAhC5B,EAAQhB,EAAGK,KAAKyC,KAAKF,IACtBjC,EAAWA,EAAWW,QAAUN,EAAM,OAErC,IAAuC,QAAlCA,EAAQhB,EAAGM,OAAOwC,KAAKF,IAC7BjC,EAAWA,EAAWW,QAAU,QAE/B,CAAA,GAA4C,QAAvCN,EAAQhB,EAAGO,YAAYuC,KAAKF,IAgClC,KAAM,IAAIG,aAAY,mCA/BtB,IAAI/B,EAAM,GAAI,CACV6B,GAAa,CACb,IAAIG,MAAiBC,EAAoBjC,EAAM,GAAIkC,IACnD,IAAuD,QAAlDA,EAAclD,EAAGnB,IAAIiE,KAAKG,IAe3B,KAAM,IAAIF,aAAY,+CAbtB,KADAC,EAAWA,EAAW1B,QAAU4B,EAAY,GACwC,MAA5ED,EAAoBA,EAAkBV,UAAUW,EAAY,GAAG5B,UACnE,GAA8D,QAAzD4B,EAAclD,EAAGQ,WAAWsC,KAAKG,IAClCD,EAAWA,EAAW1B,QAAU4B,EAAY,OAE3C,CAAA,GAAgE,QAA3DA,EAAclD,EAAGS,aAAaqC,KAAKG,IAIzC,KAAM,IAAIF,aAAY,+CAHtBC,GAAWA,EAAW1B,QAAU4B,EAAY,GAUxDlC,EAAM,GAAKgC,MAGXH,IAAa,CAEjB,IAAkB,IAAdA,EACA,KAAM,IAAInB,OAAM,4EAEpBf,GAAWA,EAAWW,QAAUN,EAKpC4B,EAAOA,EAAKL,UAAUvB,EAAM,GAAGM,QAEnC,MAAOX,GAGX,IAAIwC,GAAW,SAASR,EAAK/B,EAAMwC,GAG/B,MAFAA,IAASxC,OAAYnB,MAAM,GAC3B2D,EAAMC,OAAO,EAAG,EAAGV,GACZ/D,EAAQ0E,MAAM,KAAMF,GAiBR,oBAAZG,UACPA,QAAQ3E,QAAUA,EAClB2E,QAAQJ,SAAWA,IAGnBxE,EAAOC,QAAUA,EACjBD,EAAOwE,SAAWA,EAEI,kBAAXK,SAAyBA,OAAOC,KACvCD,OAAO,WACH,OACI5E,QAASA,EACTuE,SAAUA,OAKT,mBAAXxE,QAAyB+E,KAAO/E"}
\ No newline at end of file
diff --git a/tools/doc/node_modules/sprintf-js/package.json b/tools/doc/node_modules/sprintf-js/package.json
new file mode 100644
index 00000000000000..3ec22029daacd2
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/package.json
@@ -0,0 +1,58 @@
+{
+ "_args": [
+ [
+ "sprintf-js@1.0.3",
+ "/Users/rubys/git/node/tools/doc"
+ ]
+ ],
+ "_development": true,
+ "_from": "sprintf-js@1.0.3",
+ "_id": "sprintf-js@1.0.3",
+ "_inBundle": false,
+ "_integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
+ "_location": "/sprintf-js",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "sprintf-js@1.0.3",
+ "name": "sprintf-js",
+ "escapedName": "sprintf-js",
+ "rawSpec": "1.0.3",
+ "saveSpec": null,
+ "fetchSpec": "1.0.3"
+ },
+ "_requiredBy": [
+ "/argparse"
+ ],
+ "_resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
+ "_spec": "1.0.3",
+ "_where": "/Users/rubys/git/node/tools/doc",
+ "author": {
+ "name": "Alexandru Marasteanu",
+ "email": "hello@alexei.ro",
+ "url": "http://alexei.ro/"
+ },
+ "bugs": {
+ "url": "https://github.com/alexei/sprintf.js/issues"
+ },
+ "description": "JavaScript sprintf implementation",
+ "devDependencies": {
+ "grunt": "*",
+ "grunt-contrib-uglify": "*",
+ "grunt-contrib-watch": "*",
+ "mocha": "*"
+ },
+ "homepage": "https://github.com/alexei/sprintf.js#readme",
+ "license": "BSD-3-Clause",
+ "main": "src/sprintf.js",
+ "name": "sprintf-js",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/alexei/sprintf.js.git"
+ },
+ "scripts": {
+ "test": "mocha test/test.js"
+ },
+ "version": "1.0.3"
+}
diff --git a/tools/doc/node_modules/sprintf-js/src/angular-sprintf.js b/tools/doc/node_modules/sprintf-js/src/angular-sprintf.js
new file mode 100644
index 00000000000000..9c69123bea291a
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/src/angular-sprintf.js
@@ -0,0 +1,18 @@
+angular.
+ module("sprintf", []).
+ filter("sprintf", function() {
+ return function() {
+ return sprintf.apply(null, arguments)
+ }
+ }).
+ filter("fmt", ["$filter", function($filter) {
+ return $filter("sprintf")
+ }]).
+ filter("vsprintf", function() {
+ return function(format, argv) {
+ return vsprintf(format, argv)
+ }
+ }).
+ filter("vfmt", ["$filter", function($filter) {
+ return $filter("vsprintf")
+ }])
diff --git a/tools/doc/node_modules/sprintf-js/src/sprintf.js b/tools/doc/node_modules/sprintf-js/src/sprintf.js
new file mode 100644
index 00000000000000..c0fc7c08b2e6fe
--- /dev/null
+++ b/tools/doc/node_modules/sprintf-js/src/sprintf.js
@@ -0,0 +1,208 @@
+(function(window) {
+ var re = {
+ not_string: /[^s]/,
+ number: /[diefg]/,
+ json: /[j]/,
+ not_json: /[^j]/,
+ text: /^[^\x25]+/,
+ modulo: /^\x25{2}/,
+ placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,
+ key: /^([a-z_][a-z_\d]*)/i,
+ key_access: /^\.([a-z_][a-z_\d]*)/i,
+ index_access: /^\[(\d+)\]/,
+ sign: /^[\+\-]/
+ }
+
+ function sprintf() {
+ var key = arguments[0], cache = sprintf.cache
+ if (!(cache[key] && cache.hasOwnProperty(key))) {
+ cache[key] = sprintf.parse(key)
+ }
+ return sprintf.format.call(null, cache[key], arguments)
+ }
+
+ sprintf.format = function(parse_tree, argv) {
+ var cursor = 1, tree_length = parse_tree.length, node_type = "", arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = ""
+ for (i = 0; i < tree_length; i++) {
+ node_type = get_type(parse_tree[i])
+ if (node_type === "string") {
+ output[output.length] = parse_tree[i]
+ }
+ else if (node_type === "array") {
+ match = parse_tree[i] // convenience purposes only
+ if (match[2]) { // keyword argument
+ arg = argv[cursor]
+ for (k = 0; k < match[2].length; k++) {
+ if (!arg.hasOwnProperty(match[2][k])) {
+ throw new Error(sprintf("[sprintf] property '%s' does not exist", match[2][k]))
+ }
+ arg = arg[match[2][k]]
+ }
+ }
+ else if (match[1]) { // positional argument (explicit)
+ arg = argv[match[1]]
+ }
+ else { // positional argument (implicit)
+ arg = argv[cursor++]
+ }
+
+ if (get_type(arg) == "function") {
+ arg = arg()
+ }
+
+ if (re.not_string.test(match[8]) && re.not_json.test(match[8]) && (get_type(arg) != "number" && isNaN(arg))) {
+ throw new TypeError(sprintf("[sprintf] expecting number but found %s", get_type(arg)))
+ }
+
+ if (re.number.test(match[8])) {
+ is_positive = arg >= 0
+ }
+
+ switch (match[8]) {
+ case "b":
+ arg = arg.toString(2)
+ break
+ case "c":
+ arg = String.fromCharCode(arg)
+ break
+ case "d":
+ case "i":
+ arg = parseInt(arg, 10)
+ break
+ case "j":
+ arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
+ break
+ case "e":
+ arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential()
+ break
+ case "f":
+ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
+ break
+ case "g":
+ arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg)
+ break
+ case "o":
+ arg = arg.toString(8)
+ break
+ case "s":
+ arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg)
+ break
+ case "u":
+ arg = arg >>> 0
+ break
+ case "x":
+ arg = arg.toString(16)
+ break
+ case "X":
+ arg = arg.toString(16).toUpperCase()
+ break
+ }
+ if (re.json.test(match[8])) {
+ output[output.length] = arg
+ }
+ else {
+ if (re.number.test(match[8]) && (!is_positive || match[3])) {
+ sign = is_positive ? "+" : "-"
+ arg = arg.toString().replace(re.sign, "")
+ }
+ else {
+ sign = ""
+ }
+ pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " "
+ pad_length = match[6] - (sign + arg).length
+ pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : ""
+ output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg)
+ }
+ }
+ }
+ return output.join("")
+ }
+
+ sprintf.cache = {}
+
+ sprintf.parse = function(fmt) {
+ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0
+ while (_fmt) {
+ if ((match = re.text.exec(_fmt)) !== null) {
+ parse_tree[parse_tree.length] = match[0]
+ }
+ else if ((match = re.modulo.exec(_fmt)) !== null) {
+ parse_tree[parse_tree.length] = "%"
+ }
+ else if ((match = re.placeholder.exec(_fmt)) !== null) {
+ if (match[2]) {
+ arg_names |= 1
+ var field_list = [], replacement_field = match[2], field_match = []
+ if ((field_match = re.key.exec(replacement_field)) !== null) {
+ field_list[field_list.length] = field_match[1]
+ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
+ if ((field_match = re.key_access.exec(replacement_field)) !== null) {
+ field_list[field_list.length] = field_match[1]
+ }
+ else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
+ field_list[field_list.length] = field_match[1]
+ }
+ else {
+ throw new SyntaxError("[sprintf] failed to parse named argument key")
+ }
+ }
+ }
+ else {
+ throw new SyntaxError("[sprintf] failed to parse named argument key")
+ }
+ match[2] = field_list
+ }
+ else {
+ arg_names |= 2
+ }
+ if (arg_names === 3) {
+ throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported")
+ }
+ parse_tree[parse_tree.length] = match
+ }
+ else {
+ throw new SyntaxError("[sprintf] unexpected placeholder")
+ }
+ _fmt = _fmt.substring(match[0].length)
+ }
+ return parse_tree
+ }
+
+ var vsprintf = function(fmt, argv, _argv) {
+ _argv = (argv || []).slice(0)
+ _argv.splice(0, 0, fmt)
+ return sprintf.apply(null, _argv)
+ }
+
+ /**
+ * helpers
+ */
+ function get_type(variable) {
+ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase()
+ }
+
+ function str_repeat(input, multiplier) {
+ return Array(multiplier + 1).join(input)
+ }
+
+ /**
+ * export to either browser or node.js
+ */
+ if (typeof exports !== "undefined") {
+ exports.sprintf = sprintf
+ exports.vsprintf = vsprintf
+ }
+ else {
+ window.sprintf = sprintf
+ window.vsprintf = vsprintf
+
+ if (typeof define === "function" && define.amd) {
+ define(function() {
+ return {
+ sprintf: sprintf,
+ vsprintf: vsprintf
+ }
+ })
+ }
+ }
+})(typeof window === "undefined" ? this : window);
diff --git a/tools/doc/package-lock.json b/tools/doc/package-lock.json
index 5da2020a1a3a4a..c89617c7200b9b 100644
--- a/tools/doc/package-lock.json
+++ b/tools/doc/package-lock.json
@@ -4,6 +4,40 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@types/node": {
+ "version": "10.3.5",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.5.tgz",
+ "integrity": "sha512-6lRwZN0Y3TuglwaaZN2XPocobmzLlhxcqDjKFjNYSsXG/TFAGYkCqkzZh4+ms8iTHHQE6gJXLHPV7TziVGeWhg=="
+ },
+ "abab": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz",
+ "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4="
+ },
+ "acorn": {
+ "version": "5.7.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz",
+ "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ=="
+ },
+ "acorn-globals": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz",
+ "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==",
+ "requires": {
+ "acorn": "^5.0.0"
+ }
+ },
+ "ajv": {
+ "version": "5.5.2",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
+ "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
+ "requires": {
+ "co": "^4.6.0",
+ "fast-deep-equal": "^1.0.0",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.3.0"
+ }
+ },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@@ -13,12 +47,507 @@
"sprintf-js": "~1.0.2"
}
},
+ "array-equal": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
+ "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM="
+ },
+ "asn1": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
+ "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y="
+ },
+ "assert-plus": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
+ },
+ "async-limiter": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
+ "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
+ },
+ "asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
+ },
+ "aws-sign2": {
+ "version": "0.7.0",
+ "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
+ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
+ },
+ "aws4": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz",
+ "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w=="
+ },
+ "bail": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.3.tgz",
+ "integrity": "sha512-1X8CnjFVQ+a+KW36uBNMTU5s8+v5FzeqrP7hTG5aTb4aPreSbZJlhwPon9VKMuEVgV++JM+SQrALY3kr7eswdg=="
+ },
+ "bcrypt-pbkdf": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
+ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
+ "optional": true,
+ "requires": {
+ "tweetnacl": "^0.14.3"
+ }
+ },
+ "browser-process-hrtime": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz",
+ "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44="
+ },
+ "camelcase": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz",
+ "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo="
+ },
+ "caseless": {
+ "version": "0.12.0",
+ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
+ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
+ },
+ "ccount": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.3.tgz",
+ "integrity": "sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw=="
+ },
+ "character-entities": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.2.tgz",
+ "integrity": "sha512-sMoHX6/nBiy3KKfC78dnEalnpn0Az0oSNvqUWYTtYrhRI5iUIYsROU48G+E+kMFQzqXaJ8kHJZ85n7y6/PHgwQ=="
+ },
+ "character-entities-html4": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.2.tgz",
+ "integrity": "sha512-sIrXwyna2+5b0eB9W149izTPJk/KkJTg6mEzDGibwBUkyH1SbDa+nf515Ppdi3MaH35lW0JFJDWeq9Luzes1Iw=="
+ },
+ "character-entities-legacy": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.2.tgz",
+ "integrity": "sha512-9NB2VbXtXYWdXzqrvAHykE/f0QJxzaKIpZ5QzNZrrgQ7Iyxr2vnfS8fCBNVW9nUEZE0lo57nxKRqnzY/dKrwlA=="
+ },
+ "character-reference-invalid": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.2.tgz",
+ "integrity": "sha512-7I/xceXfKyUJmSAn/jw8ve/9DyOP7XxufNYLI9Px7CmsKgEUaZLUTax6nZxGQtaoiZCjpu6cHPj20xC/vqRReQ=="
+ },
+ "co": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
+ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
+ },
+ "collapse-white-space": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.4.tgz",
+ "integrity": "sha512-YfQ1tAUZm561vpYD+5eyWN8+UsceQbSrqqlc/6zDY2gtAE+uZLSdkkovhnGpmCThsvKBFakq4EdY/FF93E8XIw=="
+ },
+ "combined-stream": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
+ "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
+ "requires": {
+ "delayed-stream": "~1.0.0"
+ }
+ },
+ "comma-separated-tokens": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.5.tgz",
+ "integrity": "sha512-Cg90/fcK93n0ecgYTAz1jaA3zvnQ0ExlmKY1rdbyHqAx6BHxwoJc+J7HDu0iuQ7ixEs1qaa+WyQ6oeuBpYP1iA==",
+ "requires": {
+ "trim": "0.0.1"
+ }
+ },
+ "core-util-is": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
+ },
+ "cssom": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.2.tgz",
+ "integrity": "sha1-uANhcMefB6kP8vFuIihAJ6JDhIs="
+ },
+ "cssstyle": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.3.1.tgz",
+ "integrity": "sha512-tNvaxM5blOnxanyxI6panOsnfiyLRj3HV4qjqqS45WPNS1usdYWRUQjqTEEELK73lpeP/1KoIGYUwrBn/VcECA==",
+ "requires": {
+ "cssom": "0.3.x"
+ }
+ },
+ "dashdash": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
+ "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
+ "requires": {
+ "assert-plus": "^1.0.0"
+ }
+ },
+ "data-urls": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-1.0.0.tgz",
+ "integrity": "sha512-ai40PPQR0Fn1lD2PPie79CibnlMN2AYiDhwFX/rZHVsxbs5kNJSjegqXIprhouGXlRdEnfybva7kqRGnB6mypA==",
+ "requires": {
+ "abab": "^1.0.4",
+ "whatwg-mimetype": "^2.0.0",
+ "whatwg-url": "^6.4.0"
+ }
+ },
+ "deep-is": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
+ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ="
+ },
+ "define-properties": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
+ "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
+ "requires": {
+ "foreach": "^2.0.5",
+ "object-keys": "^1.0.8"
+ }
+ },
+ "delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
+ },
+ "detab": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/detab/-/detab-2.0.1.tgz",
+ "integrity": "sha512-/hhdqdQc5thGrqzjyO/pz76lDZ5GSuAs6goxOaKTsvPk7HNnzAyFN5lyHgqpX4/s1i66K8qMGj+VhA9504x7DQ==",
+ "requires": {
+ "repeat-string": "^1.5.4"
+ }
+ },
+ "domexception": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz",
+ "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==",
+ "requires": {
+ "webidl-conversions": "^4.0.2"
+ }
+ },
+ "ecc-jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
+ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
+ "optional": true,
+ "requires": {
+ "jsbn": "~0.1.0"
+ }
+ },
+ "escodegen": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.10.0.tgz",
+ "integrity": "sha512-fjUOf8johsv23WuIKdNQU4P9t9jhQ4Qzx6pC2uW890OloK3Zs1ZAoCNpg/2larNF501jLl3UNy0kIRcF6VI22g==",
+ "requires": {
+ "esprima": "^3.1.3",
+ "estraverse": "^4.2.0",
+ "esutils": "^2.0.2",
+ "optionator": "^0.8.1",
+ "source-map": "~0.6.1"
+ },
+ "dependencies": {
+ "esprima": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz",
+ "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM="
+ }
+ }
+ },
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"dev": true
},
+ "estraverse": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
+ "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM="
+ },
+ "esutils": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
+ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
+ },
+ "extend": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
+ "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ="
+ },
+ "extsprintf": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
+ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU="
+ },
+ "fast-deep-equal": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
+ "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ="
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
+ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
+ },
+ "fast-levenshtein": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
+ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
+ },
+ "foreach": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
+ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
+ },
+ "forever-agent": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
+ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
+ },
+ "form-data": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
+ "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
+ "requires": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "1.0.6",
+ "mime-types": "^2.1.12"
+ }
+ },
+ "function-bind": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ },
+ "getpass": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
+ "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
+ "requires": {
+ "assert-plus": "^1.0.0"
+ }
+ },
+ "har-schema": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
+ "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
+ },
+ "har-validator": {
+ "version": "5.0.3",
+ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
+ "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
+ "requires": {
+ "ajv": "^5.1.0",
+ "har-schema": "^2.0.0"
+ }
+ },
+ "has": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "requires": {
+ "function-bind": "^1.1.1"
+ }
+ },
+ "hast-to-hyperscript": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/hast-to-hyperscript/-/hast-to-hyperscript-3.1.0.tgz",
+ "integrity": "sha512-/At2y6sQLTAcL6y+3hRQFcaBoRlKrmHSpvvdOZqRz6uI2YyjrU8rJ7e1LbmLtWUmzaIqKEdNSku+AJC0pt4+aw==",
+ "requires": {
+ "comma-separated-tokens": "^1.0.0",
+ "is-nan": "^1.2.1",
+ "kebab-case": "^1.0.0",
+ "property-information": "^3.0.0",
+ "space-separated-tokens": "^1.0.0",
+ "trim": "0.0.1",
+ "unist-util-is": "^2.0.0"
+ }
+ },
+ "hast-util-from-parse5": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-2.1.0.tgz",
+ "integrity": "sha1-9hI9g9NoljCwl+E+Qw0W2dG9iIQ=",
+ "requires": {
+ "camelcase": "^3.0.0",
+ "hastscript": "^3.0.0",
+ "property-information": "^3.1.0",
+ "vfile-location": "^2.0.0"
+ }
+ },
+ "hast-util-is-element": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.0.1.tgz",
+ "integrity": "sha512-s/ggaNehYVqmLgTXEv12Lbb72bsOD2r5DhAqPgtDdaI/YFNXVzz0zHFVJnhjIjn7Nak8GbL4nzT2q0RA5div+A=="
+ },
+ "hast-util-parse-selector": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.1.1.tgz",
+ "integrity": "sha512-FlrdvixBzVHYSqtvGAl0wjH1hiCY5NEfs+zfFNAZNWKMVj4pH6x+uPPyrhvzU3NrwOqYVX6Essv4d5n+0b6faA=="
+ },
+ "hast-util-raw": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-2.0.2.tgz",
+ "integrity": "sha512-ujytXSAZC85bvh38f8ALzfE2IZDdCwB9XeHUs9l20C1p4/1YeAoZqq9z9U17vWQ9hMmqbVaROuSK8feL3wTCJg==",
+ "requires": {
+ "hast-util-from-parse5": "^2.0.0",
+ "hast-util-to-parse5": "^2.0.0",
+ "html-void-elements": "^1.0.1",
+ "parse5": "^3.0.3",
+ "unist-util-position": "^3.0.0",
+ "web-namespaces": "^1.0.0",
+ "zwitch": "^1.0.0"
+ }
+ },
+ "hast-util-to-html": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-3.1.0.tgz",
+ "integrity": "sha1-iCyZhJ5AEw6ZHAQuRW1FPZXDbP8=",
+ "requires": {
+ "ccount": "^1.0.0",
+ "comma-separated-tokens": "^1.0.1",
+ "hast-util-is-element": "^1.0.0",
+ "hast-util-whitespace": "^1.0.0",
+ "html-void-elements": "^1.0.0",
+ "kebab-case": "^1.0.0",
+ "property-information": "^3.1.0",
+ "space-separated-tokens": "^1.0.0",
+ "stringify-entities": "^1.0.1",
+ "unist-util-is": "^2.0.0",
+ "xtend": "^4.0.1"
+ }
+ },
+ "hast-util-to-parse5": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-2.2.0.tgz",
+ "integrity": "sha512-Eg1mrf0VTT/PipFN5z1+mVi+4GNhinKk/i/HKeX1h17IYiMdm3G8vgA0FU04XCuD1cWV58f5zziFKcBkr+WuKw==",
+ "requires": {
+ "hast-to-hyperscript": "^3.0.0",
+ "mapz": "^1.0.0",
+ "web-namespaces": "^1.0.0",
+ "xtend": "^4.0.1",
+ "zwitch": "^1.0.0"
+ }
+ },
+ "hast-util-whitespace": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.1.tgz",
+ "integrity": "sha512-Mfx2ZnmVMTAopZ8as42nKrNt650tCZYhy/MPeO1Imdg/cmCWK6GUSnFrrE3ezGjVifn7x5zMfu8jrjwIGyImSw=="
+ },
+ "hastscript": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-3.1.0.tgz",
+ "integrity": "sha512-8V34dMSDT1Ik+ZSgTzCLdyp89MrWxcxctXPxhmb72GQj1Xkw1aHPM9UaHCWewvH2Q+PVkYUm4ZJVw4T0dgEGNA==",
+ "requires": {
+ "camelcase": "^3.0.0",
+ "comma-separated-tokens": "^1.0.0",
+ "hast-util-parse-selector": "^2.0.0",
+ "property-information": "^3.0.0",
+ "space-separated-tokens": "^1.0.0"
+ }
+ },
+ "html-encoding-sniffer": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz",
+ "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==",
+ "requires": {
+ "whatwg-encoding": "^1.0.1"
+ }
+ },
+ "html-void-elements": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.3.tgz",
+ "integrity": "sha512-SaGhCDPXJVNrQyKMtKy24q6IMdXg5FCPN3z+xizxw9l+oXQw5fOoaj/ERU5KqWhSYhXtW5bWthlDbTDLBhJQrA=="
+ },
+ "http-signature": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
+ "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
+ "requires": {
+ "assert-plus": "^1.0.0",
+ "jsprim": "^1.2.2",
+ "sshpk": "^1.7.0"
+ }
+ },
+ "iconv-lite": {
+ "version": "0.4.19",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
+ "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
+ },
+ "inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
+ },
+ "is-alphabetical": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.2.tgz",
+ "integrity": "sha512-V0xN4BYezDHcBSKb1QHUFMlR4as/XEuCZBzMJUU4n7+Cbt33SmUnSol+pnXFvLxSHNq2CemUXNdaXV6Flg7+xg=="
+ },
+ "is-alphanumerical": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.2.tgz",
+ "integrity": "sha512-pyfU/0kHdISIgslFfZN9nfY1Gk3MquQgUm1mJTjdkEPpkAKNWuBTSqFwewOpR7N351VkErCiyV71zX7mlQQqsg==",
+ "requires": {
+ "is-alphabetical": "^1.0.0",
+ "is-decimal": "^1.0.0"
+ }
+ },
+ "is-buffer": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
+ "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
+ },
+ "is-decimal": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.2.tgz",
+ "integrity": "sha512-TRzl7mOCchnhchN+f3ICUCzYvL9ul7R+TYOsZ8xia++knyZAJfv/uA1FvQXsAnYIl1T3B2X5E/J7Wb1QXiIBXg=="
+ },
+ "is-hexadecimal": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.2.tgz",
+ "integrity": "sha512-but/G3sapV3MNyqiDBLrOi4x8uCIw0RY3o/Vb5GT0sMFHrVV7731wFSVy41T5FO1og7G0gXLJh0MkgPRouko/A=="
+ },
+ "is-nan": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.2.1.tgz",
+ "integrity": "sha1-n69ltvttskt/XAYoR16nH5iEAeI=",
+ "requires": {
+ "define-properties": "^1.1.1"
+ }
+ },
+ "is-plain-obj": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
+ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
+ },
+ "is-typedarray": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
+ },
+ "is-whitespace-character": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz",
+ "integrity": "sha512-SzM+T5GKUCtLhlHFKt2SDAX2RFzfS6joT91F2/WSi9LxgFdsnhfPK/UIA+JhRR2xuyLdrCys2PiFDrtn1fU5hQ=="
+ },
+ "is-word-character": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.2.tgz",
+ "integrity": "sha512-T3FlsX8rCHAH8e7RE7PfOPZVFQlcV3XRF9eOOBQ1uf70OxO7CjjSOjeImMPCADBdYWcStAbVbYvJ1m2D3tb+EA=="
+ },
+ "isstream": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
+ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
+ },
"js-yaml": {
"version": "3.11.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz",
@@ -29,16 +558,801 @@
"esprima": "^4.0.0"
}
},
+ "jsbn": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
+ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
+ "optional": true
+ },
+ "jsdom": {
+ "version": "11.11.0",
+ "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.11.0.tgz",
+ "integrity": "sha512-ou1VyfjwsSuWkudGxb03FotDajxAto6USAlmMZjE2lc0jCznt7sBWkhfRBRaWwbnmDqdMSTKTLT5d9sBFkkM7A==",
+ "requires": {
+ "abab": "^1.0.4",
+ "acorn": "^5.3.0",
+ "acorn-globals": "^4.1.0",
+ "array-equal": "^1.0.0",
+ "cssom": ">= 0.3.2 < 0.4.0",
+ "cssstyle": ">= 0.3.1 < 0.4.0",
+ "data-urls": "^1.0.0",
+ "domexception": "^1.0.0",
+ "escodegen": "^1.9.0",
+ "html-encoding-sniffer": "^1.0.2",
+ "left-pad": "^1.2.0",
+ "nwsapi": "^2.0.0",
+ "parse5": "4.0.0",
+ "pn": "^1.1.0",
+ "request": "^2.83.0",
+ "request-promise-native": "^1.0.5",
+ "sax": "^1.2.4",
+ "symbol-tree": "^3.2.2",
+ "tough-cookie": "^2.3.3",
+ "w3c-hr-time": "^1.0.1",
+ "webidl-conversions": "^4.0.2",
+ "whatwg-encoding": "^1.0.3",
+ "whatwg-mimetype": "^2.1.0",
+ "whatwg-url": "^6.4.1",
+ "ws": "^4.0.0",
+ "xml-name-validator": "^3.0.0"
+ },
+ "dependencies": {
+ "parse5": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz",
+ "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA=="
+ }
+ }
+ },
+ "json-schema": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
+ "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
+ },
+ "json-schema-traverse": {
+ "version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
+ "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A="
+ },
+ "json-stringify-safe": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
+ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
+ },
+ "jsprim": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
+ "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
+ "requires": {
+ "assert-plus": "1.0.0",
+ "extsprintf": "1.3.0",
+ "json-schema": "0.2.3",
+ "verror": "1.10.0"
+ }
+ },
+ "kebab-case": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.0.tgz",
+ "integrity": "sha1-P55JkK3K0MaGwOcB92RYaPdfkes="
+ },
+ "left-pad": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
+ "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA=="
+ },
+ "levn": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
+ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
+ "requires": {
+ "prelude-ls": "~1.1.2",
+ "type-check": "~0.3.2"
+ }
+ },
+ "lodash": {
+ "version": "4.17.10",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
+ "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
+ },
+ "lodash.iteratee": {
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/lodash.iteratee/-/lodash.iteratee-4.7.0.tgz",
+ "integrity": "sha1-vkF32yiajMw8CZDx2ya1si/BVUw="
+ },
+ "lodash.sortby": {
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
+ "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg="
+ },
+ "longest-streak": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-1.0.0.tgz",
+ "integrity": "sha1-0GWXxNTDG1LMsfXY+P5xSOr9aWU="
+ },
+ "mapz": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/mapz/-/mapz-1.0.2.tgz",
+ "integrity": "sha512-NuY43BoHy5K4jVg3/oD+g8ysNwdXY3HB5UankVWoikxT9YMqgCYC77pNRENTm/DfslLxPFEOyJUw9h9isRty6w==",
+ "requires": {
+ "x-is-array": "^0.1.0"
+ }
+ },
+ "markdown-escapes": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.2.tgz",
+ "integrity": "sha512-lbRZ2mE3Q9RtLjxZBZ9+IMl68DKIXaVAhwvwn9pmjnPLS0h/6kyBMgNhqi1xFJ/2yv6cSyv0jbiZavZv93JkkA=="
+ },
+ "markdown-table": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-0.4.0.tgz",
+ "integrity": "sha1-iQwsGzv+g/sA5BKbjkz+ZFJw+dE="
+ },
"marked": {
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz",
"integrity": "sha1-ssbGGPzOzk74bE/Gy4p8v1rtqNc="
},
+ "mdast-util-definitions": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-1.2.2.tgz",
+ "integrity": "sha512-9NloPSwaB9f1PKcGqaScfqRf6zKOEjTIXVIbPOmgWI/JKxznlgVXC5C+8qgl3AjYg2vJBRgLYfLICaNiac89iA==",
+ "requires": {
+ "unist-util-visit": "^1.0.0"
+ }
+ },
+ "mdast-util-to-hast": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-3.0.1.tgz",
+ "integrity": "sha512-+eimV/12kdg0/T0EEfcK7IsDbSu2auVm92z5jdSEQ3DHF2HiU4OHmX9ir5wpQajr73nwabdxrUoxREvW2zVFFw==",
+ "requires": {
+ "collapse-white-space": "^1.0.0",
+ "detab": "^2.0.0",
+ "mdast-util-definitions": "^1.2.0",
+ "mdurl": "^1.0.1",
+ "trim": "0.0.1",
+ "trim-lines": "^1.0.0",
+ "unist-builder": "^1.0.1",
+ "unist-util-generated": "^1.1.0",
+ "unist-util-position": "^3.0.0",
+ "unist-util-visit": "^1.1.0",
+ "xtend": "^4.0.1"
+ }
+ },
+ "mdurl": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
+ "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
+ },
+ "mime-db": {
+ "version": "1.33.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
+ "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ=="
+ },
+ "mime-types": {
+ "version": "2.1.18",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
+ "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
+ "requires": {
+ "mime-db": "~1.33.0"
+ }
+ },
+ "nwsapi": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.4.tgz",
+ "integrity": "sha512-Zt6HRR6RcJkuj5/N9zeE7FN6YitRW//hK2wTOwX274IBphbY3Zf5+yn5mZ9v/SzAOTMjQNxZf9KkmPLWn0cV4g=="
+ },
+ "oauth-sign": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
+ "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
+ },
+ "object-keys": {
+ "version": "1.0.12",
+ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
+ "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag=="
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "requires": {
+ "wrappy": "1"
+ }
+ },
+ "optionator": {
+ "version": "0.8.2",
+ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
+ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
+ "requires": {
+ "deep-is": "~0.1.3",
+ "fast-levenshtein": "~2.0.4",
+ "levn": "~0.3.0",
+ "prelude-ls": "~1.1.2",
+ "type-check": "~0.3.2",
+ "wordwrap": "~1.0.0"
+ }
+ },
+ "parse-entities": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.1.2.tgz",
+ "integrity": "sha512-5N9lmQ7tmxfXf+hO3X6KRG6w7uYO/HL9fHalSySTdyn63C3WNvTM/1R8tn1u1larNcEbo3Slcy2bsVDQqvEpUg==",
+ "requires": {
+ "character-entities": "^1.0.0",
+ "character-entities-legacy": "^1.0.0",
+ "character-reference-invalid": "^1.0.0",
+ "is-alphanumerical": "^1.0.0",
+ "is-decimal": "^1.0.0",
+ "is-hexadecimal": "^1.0.0"
+ }
+ },
+ "parse5": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz",
+ "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==",
+ "requires": {
+ "@types/node": "*"
+ }
+ },
+ "performance-now": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
+ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
+ },
+ "pn": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz",
+ "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA=="
+ },
+ "prelude-ls": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
+ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ="
+ },
+ "property-information": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/property-information/-/property-information-3.2.0.tgz",
+ "integrity": "sha1-/RSDyPusYYCPX+NZ52k6H0ilgzE="
+ },
+ "psl": {
+ "version": "1.1.28",
+ "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.28.tgz",
+ "integrity": "sha512-+AqO1Ae+N/4r7Rvchrdm432afjT9hqJRyBN3DQv9At0tPz4hIFSGKbq64fN9dVoCow4oggIIax5/iONx0r9hZw=="
+ },
+ "punycode": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
+ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
+ },
+ "qs": {
+ "version": "6.5.2",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
+ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
+ },
+ "rehype-raw": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-2.0.0.tgz",
+ "integrity": "sha1-Vjep/O7zSAD9fFfKMv2dWSf9Kqo=",
+ "requires": {
+ "hast-util-raw": "^2.0.0"
+ }
+ },
+ "rehype-stringify": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-3.0.0.tgz",
+ "integrity": "sha1-n+8IaCE8Lc4veAt289BIjIXoGes=",
+ "requires": {
+ "hast-util-to-html": "^3.0.0",
+ "xtend": "^4.0.1"
+ }
+ },
+ "remark": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/remark/-/remark-5.1.0.tgz",
+ "integrity": "sha1-y0Y709vLS5l5STXu4c9x16jjBow=",
+ "requires": {
+ "remark-parse": "^1.1.0",
+ "remark-stringify": "^1.1.0",
+ "unified": "^4.1.1"
+ },
+ "dependencies": {
+ "remark-parse": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-1.1.0.tgz",
+ "integrity": "sha1-w8oQ+ajaBGFcKPCapOMEUQUm7CE=",
+ "requires": {
+ "collapse-white-space": "^1.0.0",
+ "extend": "^3.0.0",
+ "parse-entities": "^1.0.2",
+ "repeat-string": "^1.5.4",
+ "trim": "0.0.1",
+ "trim-trailing-lines": "^1.0.0",
+ "unherit": "^1.0.4",
+ "unist-util-remove-position": "^1.0.0",
+ "vfile-location": "^2.0.0"
+ }
+ },
+ "unified": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/unified/-/unified-4.2.1.tgz",
+ "integrity": "sha1-dv9Dqo2kMPbn5KVchOusKtLPzS4=",
+ "requires": {
+ "bail": "^1.0.0",
+ "extend": "^3.0.0",
+ "has": "^1.0.1",
+ "once": "^1.3.3",
+ "trough": "^1.0.0",
+ "vfile": "^1.0.0"
+ }
+ },
+ "vfile": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/vfile/-/vfile-1.4.0.tgz",
+ "integrity": "sha1-wP1vpIT43r23cfaMMe112I2pf+c="
+ }
+ }
+ },
+ "remark-parse": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-5.0.0.tgz",
+ "integrity": "sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA==",
+ "requires": {
+ "collapse-white-space": "^1.0.2",
+ "is-alphabetical": "^1.0.0",
+ "is-decimal": "^1.0.0",
+ "is-whitespace-character": "^1.0.0",
+ "is-word-character": "^1.0.0",
+ "markdown-escapes": "^1.0.0",
+ "parse-entities": "^1.1.0",
+ "repeat-string": "^1.5.4",
+ "state-toggle": "^1.0.0",
+ "trim": "0.0.1",
+ "trim-trailing-lines": "^1.0.0",
+ "unherit": "^1.0.4",
+ "unist-util-remove-position": "^1.0.0",
+ "vfile-location": "^2.0.0",
+ "xtend": "^4.0.1"
+ }
+ },
+ "remark-rehype": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-3.0.0.tgz",
+ "integrity": "sha512-WUinfb6vi34f4VYs2XS4HvuYNd0tCu68HOlG4aMp1dfFyVuVfL3aiL9WPw+Q6W99xTTHyxwr7BGO94jF0psoEA==",
+ "requires": {
+ "mdast-util-to-hast": "^3.0.0"
+ }
+ },
+ "remark-stringify": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-1.1.0.tgz",
+ "integrity": "sha1-pxBeJbnuK/mkm3XSxCPxGwauIJI=",
+ "requires": {
+ "ccount": "^1.0.0",
+ "extend": "^3.0.0",
+ "longest-streak": "^1.0.0",
+ "markdown-table": "^0.4.0",
+ "parse-entities": "^1.0.2",
+ "repeat-string": "^1.5.4",
+ "stringify-entities": "^1.0.1",
+ "unherit": "^1.0.4"
+ }
+ },
+ "repeat-string": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
+ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
+ },
+ "replace-ext": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
+ "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
+ },
+ "request": {
+ "version": "2.87.0",
+ "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz",
+ "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==",
+ "requires": {
+ "aws-sign2": "~0.7.0",
+ "aws4": "^1.6.0",
+ "caseless": "~0.12.0",
+ "combined-stream": "~1.0.5",
+ "extend": "~3.0.1",
+ "forever-agent": "~0.6.1",
+ "form-data": "~2.3.1",
+ "har-validator": "~5.0.3",
+ "http-signature": "~1.2.0",
+ "is-typedarray": "~1.0.0",
+ "isstream": "~0.1.2",
+ "json-stringify-safe": "~5.0.1",
+ "mime-types": "~2.1.17",
+ "oauth-sign": "~0.8.2",
+ "performance-now": "^2.1.0",
+ "qs": "~6.5.1",
+ "safe-buffer": "^5.1.1",
+ "tough-cookie": "~2.3.3",
+ "tunnel-agent": "^0.6.0",
+ "uuid": "^3.1.0"
+ },
+ "dependencies": {
+ "punycode": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
+ },
+ "tough-cookie": {
+ "version": "2.3.4",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
+ "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
+ "requires": {
+ "punycode": "^1.4.1"
+ }
+ }
+ }
+ },
+ "request-promise-core": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
+ "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=",
+ "requires": {
+ "lodash": "^4.13.1"
+ }
+ },
+ "request-promise-native": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz",
+ "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=",
+ "requires": {
+ "request-promise-core": "1.1.1",
+ "stealthy-require": "^1.1.0",
+ "tough-cookie": ">=2.3.3"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ },
+ "safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "sax": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
+ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
+ },
+ "source-map": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+ "optional": true
+ },
+ "space-separated-tokens": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.2.tgz",
+ "integrity": "sha512-G3jprCEw+xFEs0ORweLmblJ3XLymGGr6hxZYTYZjIlvDti9vOBUjRQa1Rzjt012aRrocKstHwdNi+F7HguPsEA==",
+ "requires": {
+ "trim": "0.0.1"
+ }
+ },
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true
+ },
+ "sshpk": {
+ "version": "1.14.2",
+ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
+ "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=",
+ "requires": {
+ "asn1": "~0.2.3",
+ "assert-plus": "^1.0.0",
+ "bcrypt-pbkdf": "^1.0.0",
+ "dashdash": "^1.12.0",
+ "ecc-jsbn": "~0.1.1",
+ "getpass": "^0.1.1",
+ "jsbn": "~0.1.0",
+ "safer-buffer": "^2.0.2",
+ "tweetnacl": "~0.14.0"
+ }
+ },
+ "state-toggle": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.1.tgz",
+ "integrity": "sha512-Qe8QntFrrpWTnHwvwj2FZTgv+PKIsp0B9VxLzLLbSpPXWOgRgc5LVj/aTiSfK1RqIeF9jeC1UeOH8Q8y60A7og=="
+ },
+ "stealthy-require": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
+ "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
+ },
+ "stringify-entities": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.2.tgz",
+ "integrity": "sha512-nrBAQClJAPN2p+uGCVJRPIPakKeKWZ9GtBCmormE7pWOSlHat7+x5A8gx85M7HM5Dt0BP3pP5RhVW77WdbJJ3A==",
+ "requires": {
+ "character-entities-html4": "^1.0.0",
+ "character-entities-legacy": "^1.0.0",
+ "is-alphanumerical": "^1.0.0",
+ "is-hexadecimal": "^1.0.0"
+ }
+ },
+ "symbol-tree": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
+ "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
+ },
+ "tough-cookie": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.2.tgz",
+ "integrity": "sha512-vahm+X8lSV/KjXziec8x5Vp0OTC9mq8EVCOApIsRAooeuMPSO8aT7PFACYkaL0yZ/3hVqw+8DzhCJwl8H2Ad6w==",
+ "requires": {
+ "psl": "^1.1.24",
+ "punycode": "^1.4.1"
+ },
+ "dependencies": {
+ "punycode": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
+ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
+ }
+ }
+ },
+ "tr46": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz",
+ "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=",
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "trim": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz",
+ "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0="
+ },
+ "trim-lines": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-1.1.1.tgz",
+ "integrity": "sha512-X+eloHbgJGxczUk1WSjIvn7aC9oN3jVE3rQfRVKcgpavi3jxtCn0VVKtjOBj64Yop96UYn/ujJRpTbCdAF1vyg=="
+ },
+ "trim-trailing-lines": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.1.tgz",
+ "integrity": "sha512-bWLv9BbWbbd7mlqqs2oQYnLD/U/ZqeJeJwbO0FG2zA1aTq+HTvxfHNKFa/HGCVyJpDiioUYaBhfiT6rgk+l4mg=="
+ },
+ "trough": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.2.tgz",
+ "integrity": "sha512-FHkoUZvG6Egrv9XZAyYGKEyb1JMsFphgPjoczkZC2y6W93U1jswcVURB8MUvtsahEPEVACyxD47JAL63vF4JsQ=="
+ },
+ "tunnel-agent": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
+ "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
+ "requires": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "tweetnacl": {
+ "version": "0.14.5",
+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
+ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
+ "optional": true
+ },
+ "type-check": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
+ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
+ "requires": {
+ "prelude-ls": "~1.1.2"
+ }
+ },
+ "unherit": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz",
+ "integrity": "sha512-+XZuV691Cn4zHsK0vkKYwBEwB74T3IZIcxrgn2E4rKwTfFyI1zCh7X7grwh9Re08fdPlarIdyWgI8aVB3F5A5g==",
+ "requires": {
+ "inherits": "^2.0.1",
+ "xtend": "^4.0.1"
+ }
+ },
+ "unified": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/unified/-/unified-7.0.0.tgz",
+ "integrity": "sha512-j+Sm7upmmt3RXPBeA+KFGYBlHBxClnby2DtxezFKwMfhWTAklY4WbEdhwRo6c6GpuHdi04YDsyPKY/kh5a/xnQ==",
+ "requires": {
+ "bail": "^1.0.0",
+ "extend": "^3.0.0",
+ "is-plain-obj": "^1.1.0",
+ "trough": "^1.0.0",
+ "vfile": "^3.0.0",
+ "x-is-string": "^0.1.0"
+ }
+ },
+ "unist-builder": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-1.0.2.tgz",
+ "integrity": "sha1-jDuZA+9kvPsRfdfPal2Y/Bs7J7Y=",
+ "requires": {
+ "object-assign": "^4.1.0"
+ }
+ },
+ "unist-util-find": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/unist-util-find/-/unist-util-find-1.0.1.tgz",
+ "integrity": "sha1-EGK7tpKMepfGrcibU3RdTEbCIqI=",
+ "requires": {
+ "lodash.iteratee": "^4.5.0",
+ "remark": "^5.0.1",
+ "unist-util-visit": "^1.1.0"
+ }
+ },
+ "unist-util-generated": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.2.tgz",
+ "integrity": "sha512-1HcwiEO62dr0XWGT+abVK4f0aAm8Ik8N08c5nAYVmuSxfvpA9rCcNyX/le8xXj1pJK5nBrGlZefeWB6bN8Pstw=="
+ },
+ "unist-util-is": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.2.tgz",
+ "integrity": "sha512-YkXBK/H9raAmG7KXck+UUpnKiNmUdB+aBGrknfQ4EreE1banuzrKABx3jP6Z5Z3fMSPMQQmeXBlKpCbMwBkxVw=="
+ },
+ "unist-util-position": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.1.tgz",
+ "integrity": "sha512-05QfJDPI7PE1BIUtAxeSV+cDx21xP7+tUZgSval5CA7tr0pHBwybF7OnEa1dOFqg6BfYH/qiMUnWwWj+Frhlww=="
+ },
+ "unist-util-remove-position": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.2.tgz",
+ "integrity": "sha512-XxoNOBvq1WXRKXxgnSYbtCF76TJrRoe5++pD4cCBsssSiWSnPEktyFrFLE8LTk3JW5mt9hB0Sk5zn4x/JeWY7Q==",
+ "requires": {
+ "unist-util-visit": "^1.1.0"
+ }
+ },
+ "unist-util-stringify-position": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz",
+ "integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ=="
+ },
+ "unist-util-visit": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.3.1.tgz",
+ "integrity": "sha512-0fdB9EQJU0tho5tK0VzOJzAQpPv2LyLZ030b10GxuzAWEfvd54mpY7BMjQ1L69k2YNvL+SvxRzH0yUIehOO8aA==",
+ "requires": {
+ "unist-util-is": "^2.1.1"
+ }
+ },
+ "uuid": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
+ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
+ },
+ "verror": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
+ "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
+ "requires": {
+ "assert-plus": "^1.0.0",
+ "core-util-is": "1.0.2",
+ "extsprintf": "^1.2.0"
+ }
+ },
+ "vfile": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.0.tgz",
+ "integrity": "sha512-X2DiPHL9Nxgfyu5DNVgtTkZtD4d4Zzf7rVBVI+uXP2pWWIQG8Ri+xAP9KdH/sB6SS0a1niWp5bRF88n4ciwhoA==",
+ "requires": {
+ "is-buffer": "^2.0.0",
+ "replace-ext": "1.0.0",
+ "unist-util-stringify-position": "^1.0.0",
+ "vfile-message": "^1.0.0"
+ }
+ },
+ "vfile-location": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.3.tgz",
+ "integrity": "sha512-zM5/l4lfw1CBoPx3Jimxoc5RNDAHHpk6AM6LM0pTIkm5SUSsx8ZekZ0PVdf0WEZ7kjlhSt7ZlqbRL6Cd6dBs6A=="
+ },
+ "vfile-message": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.0.1.tgz",
+ "integrity": "sha512-vSGCkhNvJzO6VcWC6AlJW4NtYOVtS+RgCaqFIYUjoGIlHnFL+i0LbtYvonDWOMcB97uTPT4PRsyYY7REWC9vug==",
+ "requires": {
+ "unist-util-stringify-position": "^1.1.1"
+ }
+ },
+ "w3c-hr-time": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz",
+ "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=",
+ "requires": {
+ "browser-process-hrtime": "^0.1.2"
+ }
+ },
+ "web-namespaces": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.2.tgz",
+ "integrity": "sha512-II+n2ms4mPxK+RnIxRPOw3zwF2jRscdJIUE9BfkKHm4FYEg9+biIoTMnaZF5MpemE3T+VhMLrhbyD4ilkPCSbg=="
+ },
+ "webidl-conversions": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
+ "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg=="
+ },
+ "whatwg-encoding": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz",
+ "integrity": "sha512-jLBwwKUhi8WtBfsMQlL4bUUcT8sMkAtQinscJAe/M4KHCkHuUJAF6vuB0tueNIw4c8ziO6AkRmgY+jL3a0iiPw==",
+ "requires": {
+ "iconv-lite": "0.4.19"
+ }
+ },
+ "whatwg-mimetype": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz",
+ "integrity": "sha512-FKxhYLytBQiUKjkYteN71fAUA3g6KpNXoho1isLiLSB3N1G4F35Q5vUxWfKFhBwi5IWF27VE6WxhrnnC+m0Mew=="
+ },
+ "whatwg-url": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz",
+ "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==",
+ "requires": {
+ "lodash.sortby": "^4.7.0",
+ "tr46": "^1.0.1",
+ "webidl-conversions": "^4.0.2"
+ }
+ },
+ "wordwrap": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
+ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
+ },
+ "ws": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
+ "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
+ "requires": {
+ "async-limiter": "~1.0.0",
+ "safe-buffer": "~5.1.0"
+ }
+ },
+ "x-is-array": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/x-is-array/-/x-is-array-0.1.0.tgz",
+ "integrity": "sha1-3lIBcdR7P0FvVYfWKbidJrEtwp0="
+ },
+ "x-is-string": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz",
+ "integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI="
+ },
+ "xml-name-validator": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
+ "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw=="
+ },
+ "xtend": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
+ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
+ },
+ "zwitch": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.3.tgz",
+ "integrity": "sha512-aynRpmJDw7JIq6X4NDWJoiK1yVSiG57ArWSg4HLC1SFupX5/bo0Cf4jpX0ifwuzBfxpYBuNSyvMlWNNRuy3cVA=="
}
}
}
diff --git a/tools/doc/package.json b/tools/doc/package.json
index d33943eacddbbd..7a8e60f443b3ef 100644
--- a/tools/doc/package.json
+++ b/tools/doc/package.json
@@ -7,7 +7,14 @@
"node": ">=6"
},
"dependencies": {
- "marked": "^0.3.5"
+ "marked": "^0.3.5",
+ "rehype-raw": "^2.0.0",
+ "rehype-stringify": "^3.0.0",
+ "remark-parse": "^5.0.0",
+ "remark-rehype": "^3.0.0",
+ "unified": "^7.0.0",
+ "unist-util-find": "^1.0.1",
+ "unist-util-visit": "^1.3.1"
},
"devDependencies": {
"js-yaml": "^3.5.2"
diff --git a/tools/license-builder.sh b/tools/license-builder.sh
index 672e7c4f4cd5f5..e394175090c89c 100755
--- a/tools/license-builder.sh
+++ b/tools/license-builder.sh
@@ -84,7 +84,9 @@ addlicense "gtest" "deps/gtest" "$(cat ${rootdir}/deps/gtest/LICENSE)"
# nghttp2
addlicense "nghttp2" "deps/nghttp2" "$(cat ${rootdir}/deps/nghttp2/COPYING)"
-# remark-cli
+# remark
+addlicense "unified" "deps/unified" "$(cat ${rootdir}/tools/doc/node_modules/unified/LICENSE)"
+addlicense "remark-rehype" "deps/remark-rehype" "$(cat ${rootdir}/tools/doc/node_modules/remark-rehype/LICENSE)"
addlicense "remark-cli" "tools/remark-cli" "$(cat ${rootdir}/tools/remark-cli/LICENSE)"
# node-inspect
diff --git a/vcbuild.bat b/vcbuild.bat
index fa14e321e6f09d..7c88c25ed1c259 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -255,7 +255,7 @@ goto exit
:wix-not-found
echo Build skipped. To generate installer, you need to install Wix.
-goto build-doc
+goto install-doctools
:msbuild-found
@@ -385,7 +385,7 @@ exit /b 1
:msi
@rem Skip msi generation if not requested
-if not defined msi goto build-doc
+if not defined msi goto install-doctools
:msibuild
echo Building node-v%FULLVERSION%-%target_arch%.msi
@@ -400,7 +400,7 @@ if errorlevel 1 echo Failed to sign msi&goto exit
:upload
@rem Skip upload if not requested
-if not defined upload goto build-doc
+if not defined upload goto install-doctools
if not defined SSHCONFIG (
echo SSHCONFIG is not set for upload
@@ -428,6 +428,23 @@ ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/no
if errorlevel 1 goto exit
+:install-doctools
+REM only install if building doc OR testing doctool
+if not defined doc (
+ echo.%test_args% | findstr doctool 1>nul
+ if errorlevel 1 goto :skip-install-doctools
+)
+if exist "tools\doc\node_modules\unified\package.json" goto skip-install-doctools
+SETLOCAL
+cd tools\doc
+%npm_exe% install
+cd ..\..
+if errorlevel 1 goto exit
+ENDLOCAL
+:skip-install-doctools
+@rem Clear errorlevel from echo.%test_args% | findstr doctool 1>nul
+cd .
+
:build-doc
@rem Build documentation if requested
if not defined doc goto run
@@ -439,14 +456,6 @@ mkdir %config%\doc
robocopy /e doc\api %config%\doc\api
robocopy /e doc\api_assets %config%\doc\api\assets
-if exist "tools\doc\node_modules\js-yaml\package.json" goto doc-skip-js-yaml
-SETLOCAL
-cd tools\doc
-%npm_exe% install
-cd ..\..
-if errorlevel 1 goto exit
-ENDLOCAL
-:doc-skip-js-yaml
for %%F in (%config%\doc\api\*.md) do (
%node_exe% tools\doc\generate.js --format=json %%F > %%~dF%%~pF%%~nF.json
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% --format=html --analytics=%DOCS_ANALYTICS% %%F > %%~dF%%~pF%%~nF.html
From 81915632e4ae6d780cfdae66df07ebcd060c74ef Mon Sep 17 00:00:00 2001
From: Helio Frota <00hf11@gmail.com>
Date: Fri, 20 Jul 2018 12:08:26 -0300
Subject: [PATCH 31/95] test: allow tests to pass without internet
PR-URL: https://github.com/nodejs/node/pull/21909
Reviewed-By: Colin Ihrig
Reviewed-By: Lance Ball
Reviewed-By: Trivikram Kamat
Reviewed-By: James M Snell
Reviewed-By: Luigi Pinca
Reviewed-By: Richard Lau
---
test/{parallel => internet}/test-dns-promises-resolve.js | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename test/{parallel => internet}/test-dns-promises-resolve.js (100%)
diff --git a/test/parallel/test-dns-promises-resolve.js b/test/internet/test-dns-promises-resolve.js
similarity index 100%
rename from test/parallel/test-dns-promises-resolve.js
rename to test/internet/test-dns-promises-resolve.js
From eabe907e03e47e585aa2a1ac04e398d70e3539a7 Mon Sep 17 00:00:00 2001
From: Tim Ruffles
Date: Wed, 11 Jul 2018 10:10:42 +0100
Subject: [PATCH 32/95] doc: fix descriptions of sync methods in fs.md
PR-URL: https://github.com/nodejs/node/pull/21747
Reviewed-By: Anna Henningsen
Reviewed-By: Luigi Pinca
Reviewed-By: Jon Moss
Reviewed-By: James M Snell
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Colin Ihrig
Reviewed-By: Ruben Bridgewater
Reviewed-By: Trivikram Kamat
---
doc/api/fs.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/api/fs.md b/doc/api/fs.md
index dafda61124ec00..57aabee7035fe7 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -2331,7 +2331,7 @@ Synchronous readdir(3).
The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use for
-the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
+the filenames returned. If the `encoding` is set to `'buffer'`,
the filenames returned will be passed as `Buffer` objects.
## fs.readFile(path[, options], callback)
@@ -2503,7 +2503,7 @@ Synchronous readlink(2). Returns the symbolic link's string value.
The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use for
-the link path passed to the callback. If the `encoding` is set to `'buffer'`,
+the link path returned. If the `encoding` is set to `'buffer'`,
the link path returned will be passed as a `Buffer` object.
## fs.readSync(fd, buffer, offset, length, position)
@@ -2661,7 +2661,7 @@ Only paths that can be converted to UTF8 strings are supported.
The optional `options` argument can be a string specifying an encoding, or an
object with an `encoding` property specifying the character encoding to use for
-the path passed to the callback. If the `encoding` is set to `'buffer'`,
+the path returned. If the `encoding` is set to `'buffer'`,
the path returned will be passed as a `Buffer` object.
On Linux, when Node.js is linked against musl libc, the procfs file system must
From b98bf829d0d772884262fd11b45686e34e3dba48 Mon Sep 17 00:00:00 2001
From: Sam Ruby
Date: Sat, 21 Jul 2018 08:20:11 -0400
Subject: [PATCH 33/95] tools: build API TOC using raw headers
Markdown interprets the syntax for optional arguments as a form
of a link, so instead of trying to build up the contents using
the node value, use grab the raw original markup instead.
Fixes regression noted in
https://github.com/nodejs/node/pull/21490#issuecomment-406785023
PR-URL: https://github.com/nodejs/node/pull/21922
Reviewed-By: Anna Henningsen
Reviewed-By: Vse Mozhet Byt
Reviewed-By: Rich Trott
---
tools/doc/html.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/doc/html.js b/tools/doc/html.js
index 8aaced7424e7fe..fa7cb7b81bcdec 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -340,8 +340,10 @@ function buildToc({ filename }) {
depth = node.depth;
const realFilename = path.basename(realFilenames[0], '.md');
- const headingText = node.children.map((child) => child.value)
- .join().trim();
+ const headingText = node.children.map((child) =>
+ file.contents.slice(child.position.start.offset,
+ child.position.end.offset)
+ ).join('').trim();
const id = getId(`${realFilename}_${headingText}`, idCounters);
const hasStability = node.stability !== undefined;
From 9817e405eefd1e119cde826fdb80d0cd57442298 Mon Sep 17 00:00:00 2001
From: Ruben Bridgewater
Date: Sat, 19 May 2018 00:25:07 +0200
Subject: [PATCH 34/95] lib,src: replace all C++ promises with JS promises
C++ promises can not be properly optimized by V8. They also behave
a tiny bit different than "regular" promises.
PR-URL: https://github.com/nodejs/node/pull/20830
Reviewed-By: Anna Henningsen
Reviewed-By: Gus Caplan
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Benedikt Meurer
Reviewed-By: Benjamin Gruenbaum
Backport-PR-URL: https://github.com/nodejs/node/pull/21879
Reviewed-By: Ruben Bridgewater
Reviewed-By: Benjamin Gruenbaum
---
lib/child_process.js | 23 +++++------
lib/fs.js | 5 +--
lib/internal/http2/core.js | 9 ++--
lib/internal/util.js | 20 ++++-----
lib/timers.js | 17 +++-----
src/node_util.cc | 35 ----------------
.../test-promise-internal-creation.js | 41 -------------------
7 files changed, 27 insertions(+), 123 deletions(-)
delete mode 100644 test/parallel/test-promise-internal-creation.js
diff --git a/lib/child_process.js b/lib/child_process.js
index b2835b0a8f58be..d816bbf5f091a5 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -26,8 +26,6 @@ const {
deprecate, convertToValidSignal, getSystemErrorName
} = require('internal/util');
const { isUint8Array } = require('internal/util/types');
-const { createPromise,
- promiseResolve, promiseReject } = process.binding('util');
const debug = util.debuglog('child_process');
const { Buffer } = require('buffer');
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
@@ -152,18 +150,17 @@ exports.exec = function exec(command /* , options, callback */) {
const customPromiseExecFunction = (orig) => {
return (...args) => {
- const promise = createPromise();
-
- orig(...args, (err, stdout, stderr) => {
- if (err !== null) {
- err.stdout = stdout;
- err.stderr = stderr;
- promiseReject(promise, err);
- } else {
- promiseResolve(promise, { stdout, stderr });
- }
+ return new Promise((resolve, reject) => {
+ orig(...args, (err, stdout, stderr) => {
+ if (err !== null) {
+ err.stdout = stdout;
+ err.stderr = stderr;
+ reject(err);
+ } else {
+ resolve({ stdout, stderr });
+ }
+ });
});
- return promise;
};
};
diff --git a/lib/fs.js b/lib/fs.js
index 0cfd175d7b3d99..e0781161dfccbb 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -207,10 +207,7 @@ function exists(path, callback) {
Object.defineProperty(exists, internalUtil.promisify.custom, {
value: (path) => {
- const { createPromise, promiseResolve } = process.binding('util');
- const promise = createPromise();
- fs.exists(path, (exists) => promiseResolve(promise, exists));
- return promise;
+ return new Promise((resolve) => fs.exists(path, resolve));
}
});
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index db251caf5f73ef..be4545ecc3d70b 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -113,7 +113,6 @@ const { isArrayBufferView } = require('internal/util/types');
const { FileHandle } = process.binding('fs');
const binding = process.binding('http2');
const { ShutdownWrap } = process.binding('stream_wrap');
-const { createPromise, promiseResolve } = process.binding('util');
const { UV_EOF } = process.binding('uv');
const { StreamPipe } = internalBinding('stream_pipe');
@@ -2747,11 +2746,9 @@ function connect(authority, options, listener) {
// Support util.promisify
Object.defineProperty(connect, promisify.custom, {
value: (authority, options) => {
- const promise = createPromise();
- const server = connect(authority,
- options,
- () => promiseResolve(promise, server));
- return promise;
+ return new Promise((resolve) => {
+ const server = connect(authority, options, () => resolve(server));
+ });
}
});
diff --git a/lib/internal/util.js b/lib/internal/util.js
index bc513e7fedf79e..49dad0c6c35692 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -8,10 +8,7 @@ const {
const { signals } = process.binding('constants').os;
const {
- createPromise,
getHiddenValue,
- promiseResolve,
- promiseReject,
setHiddenValue,
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
decorated_private_symbol: kDecoratedPrivateSymbolIndex
@@ -276,24 +273,21 @@ function promisify(original) {
const argumentNames = original[kCustomPromisifyArgsSymbol];
function fn(...args) {
- const promise = createPromise();
- try {
+ return new Promise((resolve, reject) => {
original.call(this, ...args, (err, ...values) => {
if (err) {
- promiseReject(promise, err);
- } else if (argumentNames !== undefined && values.length > 1) {
+ return reject(err);
+ }
+ if (argumentNames !== undefined && values.length > 1) {
const obj = {};
for (var i = 0; i < argumentNames.length; i++)
obj[argumentNames[i]] = values[i];
- promiseResolve(promise, obj);
+ resolve(obj);
} else {
- promiseResolve(promise, values[0]);
+ resolve(values[0]);
}
});
- } catch (err) {
- promiseReject(promise, err);
- }
- return promise;
+ });
}
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
diff --git a/lib/timers.js b/lib/timers.js
index ff85a9f4b1d1e0..2459242a79f6cd 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -34,7 +34,6 @@ const {
validateTimerDuration
} = require('internal/timers');
const internalUtil = require('internal/util');
-const { createPromise, promiseResolve } = process.binding('util');
const assert = require('assert');
const util = require('util');
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;
@@ -407,11 +406,9 @@ function setTimeout(callback, after, arg1, arg2, arg3) {
}
setTimeout[internalUtil.promisify.custom] = function(after, value) {
- const promise = createPromise();
- const timeout = new Timeout(promise, after, [value], false, false);
- active(timeout);
-
- return promise;
+ return new Promise((resolve) => {
+ active(new Timeout(resolve, after, [value], false, false));
+ });
};
exports.setTimeout = setTimeout;
@@ -420,7 +417,7 @@ exports.setTimeout = setTimeout;
function ontimeout(timer, start) {
const args = timer._timerArgs;
if (typeof timer._onTimeout !== 'function')
- return promiseResolve(timer._onTimeout, args[0]);
+ return Promise.resolve(timer._onTimeout, args[0]);
if (start === undefined && timer._repeat)
start = TimerWrap.now();
if (!args)
@@ -691,7 +688,7 @@ function tryOnImmediate(immediate, oldTail, count, refCount) {
function runCallback(timer) {
const argv = timer._argv;
if (typeof timer._onImmediate !== 'function')
- return promiseResolve(timer._onImmediate, argv[0]);
+ return Promise.resolve(timer._onImmediate, argv[0]);
if (!argv)
return timer._onImmediate();
Reflect.apply(timer._onImmediate, timer, argv);
@@ -766,9 +763,7 @@ function setImmediate(callback, arg1, arg2, arg3) {
}
setImmediate[internalUtil.promisify.custom] = function(value) {
- const promise = createPromise();
- new Immediate(promise, [value]);
- return promise;
+ return new Promise((resolve) => new Immediate(resolve, [value]));
};
exports.setImmediate = setImmediate;
diff --git a/src/node_util.cc b/src/node_util.cc
index ef7dc8a818bf11..9f31786b32557f 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -9,7 +9,6 @@ using v8::Context;
using v8::FunctionCallbackInfo;
using v8::Integer;
using v8::Local;
-using v8::Maybe;
using v8::Object;
using v8::Private;
using v8::Promise;
@@ -127,36 +126,6 @@ void WatchdogHasPendingSigint(const FunctionCallbackInfo& args) {
args.GetReturnValue().Set(ret);
}
-
-void CreatePromise(const FunctionCallbackInfo& args) {
- Local context = args.GetIsolate()->GetCurrentContext();
- auto maybe_resolver = Promise::Resolver::New(context);
- if (!maybe_resolver.IsEmpty())
- args.GetReturnValue().Set(maybe_resolver.ToLocalChecked());
-}
-
-
-void PromiseResolve(const FunctionCallbackInfo& args) {
- Local context = args.GetIsolate()->GetCurrentContext();
- Local promise = args[0];
- CHECK(promise->IsPromise());
- if (promise.As()->State() != Promise::kPending) return;
- Local resolver = promise.As(); // sic
- Maybe ret = resolver->Resolve(context, args[1]);
- args.GetReturnValue().Set(ret.FromMaybe(false));
-}
-
-
-void PromiseReject(const FunctionCallbackInfo& args) {
- Local context = args.GetIsolate()->GetCurrentContext();
- Local promise = args[0];
- CHECK(promise->IsPromise());
- if (promise.As()->State() != Promise::kPending) return;
- Local resolver = promise.As(); // sic
- Maybe ret = resolver->Reject(context, args[1]);
- args.GetReturnValue().Set(ret.FromMaybe(false));
-}
-
void SafeGetenv(const FunctionCallbackInfo& args) {
CHECK(args[0]->IsString());
Utf8Value strenvtag(args.GetIsolate(), args[0]);
@@ -211,10 +180,6 @@ void Initialize(Local target,
env->SetMethodNoSideEffect(target, "watchdogHasPendingSigint",
WatchdogHasPendingSigint);
- env->SetMethodNoSideEffect(target, "createPromise", CreatePromise);
- env->SetMethod(target, "promiseResolve", PromiseResolve);
- env->SetMethod(target, "promiseReject", PromiseReject);
-
env->SetMethod(target, "safeGetenv", SafeGetenv);
}
diff --git a/test/parallel/test-promise-internal-creation.js b/test/parallel/test-promise-internal-creation.js
deleted file mode 100644
index 7142c872d9452e..00000000000000
--- a/test/parallel/test-promise-internal-creation.js
+++ /dev/null
@@ -1,41 +0,0 @@
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-const {
- createPromise, promiseResolve, promiseReject
-} = process.binding('util');
-const { inspect } = require('util');
-
-common.crashOnUnhandledRejection();
-
-{
- const promise = createPromise();
- assert.strictEqual(inspect(promise), 'Promise { }');
- promiseResolve(promise, 42);
- assert.strictEqual(inspect(promise), 'Promise { 42 }');
- promise.then(common.mustCall((value) => {
- assert.strictEqual(value, 42);
- }));
-}
-
-{
- const promise = createPromise();
- const error = new Error('foobar');
- promiseReject(promise, error);
- assert(inspect(promise).includes(' Error: foobar'));
- promise.catch(common.mustCall((value) => {
- assert.strictEqual(value, error);
- }));
-}
-
-{
- const promise = createPromise();
- const error = new Error('foobar');
- promiseReject(promise, error);
- assert(inspect(promise).includes(' Error: foobar'));
- promiseResolve(promise, 42);
- assert(inspect(promise).includes(' Error: foobar'));
- promise.catch(common.mustCall((value) => {
- assert.strictEqual(value, error);
- }));
-}
From bea1ee8e8e6dbbe61eec706d8e8ed4924c6a7d28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Zasso?=
Date: Tue, 17 Jul 2018 08:23:49 +0200
Subject: [PATCH 35/95] test: make crashOnUnhandleRejection opt-out
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.
To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for the rare cases where it's needed.
PR-URL: https://github.com/nodejs/node/pull/21849
Reviewed-By: Tobias Nießen
Reviewed-By: Colin Ihrig
Reviewed-By: Anna Henningsen
Reviewed-By: Gus Caplan
Reviewed-By: Ruben Bridgewater
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
---
doc/guides/writing-tests.md | 28 ++++++-------------
test/addons-napi/test_promise/test.js | 2 --
.../test_threadsafe_function/test.js | 2 --
.../callback-scope/test-resolve-async.js | 2 --
test/addons/make-callback-recurse/test.js | 2 --
...promise.chain-promise-before-init-hooks.js | 2 --
test/async-hooks/test-promise.js | 2 --
test/common/README.md | 15 +++++-----
test/common/index.js | 7 +++--
test/common/index.mjs | 4 +--
test/common/inspector-helper.js | 1 +
test/es-module/test-esm-dynamic-import.js | 2 --
test/es-module/test-esm-error-cache.js | 4 +--
...oader-missing-dynamic-instantiate-hook.mjs | 7 +----
test/es-module/test-esm-throw-undefined.mjs | 4 +--
test/internet/test-dns-any.js | 2 --
test/internet/test-dns-ipv4.js | 2 --
test/internet/test-dns-ipv6.js | 2 --
test/internet/test-dns-promises-resolve.js | 2 --
test/internet/test-dns-txt-sigsegv.js | 4 +--
test/internet/test-dns.js | 2 --
.../test-inspector-cluster-port-clash.js | 2 --
.../unhandled_promise_trace_warnings.js | 3 +-
test/parallel/test-assert-async.js | 2 --
...test-async-hooks-disable-during-promise.js | 1 -
.../test-async-hooks-enable-during-promise.js | 2 --
...test-async-hooks-promise-enable-disable.js | 2 --
.../test-async-hooks-promise-triggerid.js | 2 --
.../test-async-wrap-pop-id-during-load.js | 3 +-
.../test-async-wrap-promise-after-enabled.js | 2 --
test/parallel/test-c-ares.js | 2 --
.../test-child-process-promisified.js | 2 --
test/parallel/test-dns-lookup.js | 2 --
.../test-dns-resolveany-bad-ancount.js | 2 --
test/parallel/test-dns-resolveany.js | 2 --
test/parallel/test-dns-resolvens-typeerror.js | 2 --
test/parallel/test-dns.js | 2 --
test/parallel/test-domain-promise.js | 2 --
test/parallel/test-fs-lchown.js | 2 --
...est-fs-promises-file-handle-append-file.js | 1 -
.../test-fs-promises-file-handle-chmod.js | 1 -
.../test-fs-promises-file-handle-read.js | 1 -
.../test-fs-promises-file-handle-readFile.js | 1 -
.../test-fs-promises-file-handle-stat.js | 1 -
.../test-fs-promises-file-handle-sync.js | 4 +--
.../test-fs-promises-file-handle-truncate.js | 1 -
.../test-fs-promises-file-handle-write.js | 1 -
.../test-fs-promises-file-handle-writeFile.js | 1 -
.../test-fs-promises-readfile-empty.js | 4 +--
test/parallel/test-fs-promises-readfile.js | 2 --
test/parallel/test-fs-promises-writefile.js | 2 --
test/parallel/test-fs-promises.js | 5 +---
test/parallel/test-fs-promisified.js | 2 --
test/parallel/test-fs-stat-bigint.js | 1 -
test/parallel/test-http-agent.js | 1 -
test/parallel/test-http2-backpressure.js | 2 --
.../test-http2-client-promisify-connect.js | 2 --
test/parallel/test-http2-window-size.js | 1 -
...est-inspect-async-hook-setup-at-inspect.js | 1 -
test/parallel/test-inspector-esm.js | 2 --
.../test-inspector-multisession-js.js | 2 --
.../test-inspector-multisession-ws.js | 2 --
test/parallel/test-inspector-reported-host.js | 2 --
.../parallel/test-inspector-tracing-domain.js | 2 --
test/parallel/test-internal-module-wrap.js | 3 +-
...test-microtask-queue-integration-domain.js | 4 +--
.../test-microtask-queue-integration.js | 4 +--
.../test-microtask-queue-run-domain.js | 4 +--
...st-microtask-queue-run-immediate-domain.js | 4 +--
.../test-microtask-queue-run-immediate.js | 4 +--
test/parallel/test-microtask-queue-run.js | 4 +--
...-connections-close-makes-more-available.js | 8 +-----
...est-promises-unhandled-proxy-rejections.js | 2 ++
.../test-promises-unhandled-rejections.js | 4 ++-
...st-promises-unhandled-symbol-rejections.js | 2 ++
...promises-warning-on-unhandled-rejection.js | 2 ++
test/parallel/test-repl-load-multiline.js | 2 --
test/parallel/test-repl-top-level-await.js | 2 --
test/parallel/test-repl.js | 2 --
test/parallel/test-stream-finished.js | 2 --
test/parallel/test-stream-pipeline.js | 2 --
.../test-stream-readable-async-iterators.js | 2 --
test/parallel/test-timers-promisified.js | 2 --
test/parallel/test-util-inspect-namespace.js | 4 +--
test/parallel/test-util-promisify.js | 2 --
test/parallel/test-util-types.js | 4 +--
test/parallel/test-vm-module-basic.js | 2 --
.../parallel/test-vm-module-dynamic-import.js | 1 -
test/parallel/test-vm-module-errors.js | 1 -
test/parallel/test-vm-module-import-meta.js | 2 --
test/parallel/test-vm-module-link.js | 1 -
test/parallel/test-vm-module-reevaluate.js | 1 -
test/parallel/test-wasm-simple.js | 4 +--
test/parallel/test-zlib-empty-buffer.js | 4 +--
.../test-zlib-flush-multiple-scheduled.js | 2 --
test/sequential/test-async-wrap-getasyncid.js | 4 +--
.../test-inspector-async-call-stack-abort.js | 1 +
...spector-async-hook-setup-at-inspect-brk.js | 1 -
...st-inspector-async-hook-setup-at-signal.js | 1 -
...spector-async-stack-traces-promise-then.js | 1 -
...spector-async-stack-traces-set-interval.js | 1 -
test/sequential/test-inspector-bindings.js | 2 --
test/sequential/test-inspector-break-e.js | 1 -
.../test-inspector-break-when-eval.js | 1 -
test/sequential/test-inspector-console.js | 1 -
test/sequential/test-inspector-contexts.js | 1 -
.../test-inspector-debug-brk-flag.js | 1 -
test/sequential/test-inspector-debug-end.js | 2 --
test/sequential/test-inspector-exception.js | 2 --
.../sequential/test-inspector-ip-detection.js | 2 --
.../test-inspector-not-blocked-on-idle.js | 1 -
.../test-inspector-overwrite-config.js | 2 --
.../sequential/test-inspector-port-cluster.js | 1 -
.../test-inspector-scriptparsed-context.js | 1 -
.../test-inspector-stop-profile-after-done.js | 1 -
test/sequential/test-inspector-stress-http.js | 2 --
test/sequential/test-inspector.js | 2 --
117 files changed, 58 insertions(+), 241 deletions(-)
diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md
index e4a9e296ff46e7..2059a709ff8a95 100644
--- a/doc/guides/writing-tests.md
+++ b/doc/guides/writing-tests.md
@@ -225,34 +225,24 @@ countdown.dec(); // The countdown callback will be invoked now.
#### Testing promises
-When writing tests involving promises, either make sure that the
-`onFulfilled` or the `onRejected` handler is wrapped in
-`common.mustCall()` or `common.mustNotCall()` accordingly, or
-call `common.crashOnUnhandledRejection()` in the top level of the
-test to make sure that unhandled rejections would result in a test
-failure. For example:
+When writing tests involving promises, it is generally good to wrap the
+`onFulfilled` handler, otherwise the test could successfully finish if the
+promise never resolves (pending promises do not keep the event loop alive). The
+`common` module automatically adds a handler that makes the process crash - and
+hence, the test fail - in the case of an `unhandledRejection` event. It is
+possible to disable it with `common.disableCrashOnUnhandledRejection()` if
+needed.
```javascript
const common = require('../common');
const assert = require('assert');
const fs = require('fs').promises;
-// Use `common.crashOnUnhandledRejection()` to make sure unhandled rejections
-// will fail the test.
-common.crashOnUnhandledRejection();
-
-// Or, wrap the `onRejected` handler in `common.mustNotCall()`.
-fs.writeFile('test-file', 'test').catch(common.mustNotCall());
-
-// Or, wrap the `onFulfilled` handler in `common.mustCall()`.
-// If there are assertions in the `onFulfilled` handler, wrap
-// the next `onRejected` handler in `common.mustNotCall()`
-// to handle potential failures.
+// Wrap the `onFulfilled` handler in `common.mustCall()`.
fs.readFile('test-file').then(
common.mustCall(
(content) => assert.strictEqual(content.toString(), 'test2')
- ))
- .catch(common.mustNotCall());
+ ));
```
### Flags
diff --git a/test/addons-napi/test_promise/test.js b/test/addons-napi/test_promise/test.js
index 477ceb75969d51..feaa4ebfef688a 100644
--- a/test/addons-napi/test_promise/test.js
+++ b/test/addons-napi/test_promise/test.js
@@ -7,8 +7,6 @@ const common = require('../../common');
const assert = require('assert');
const test_promise = require(`./build/${common.buildType}/test_promise`);
-common.crashOnUnhandledRejection();
-
// A resolution
{
const expected_result = 42;
diff --git a/test/addons-napi/test_threadsafe_function/test.js b/test/addons-napi/test_threadsafe_function/test.js
index 8d8a6d9d8c6827..d998853559ddda 100644
--- a/test/addons-napi/test_threadsafe_function/test.js
+++ b/test/addons-napi/test_threadsafe_function/test.js
@@ -12,8 +12,6 @@ const expectedArray = (function(arrayLength) {
return result;
})(binding.ARRAY_LENGTH);
-common.crashOnUnhandledRejection();
-
// Handle the rapid teardown test case as the child process. We unref the
// thread-safe function after we have received two values. This causes the
// process to exit and the environment cleanup handler to be invoked.
diff --git a/test/addons/callback-scope/test-resolve-async.js b/test/addons/callback-scope/test-resolve-async.js
index 3e96234787c7b3..98e1910b49df7b 100644
--- a/test/addons/callback-scope/test-resolve-async.js
+++ b/test/addons/callback-scope/test-resolve-async.js
@@ -4,8 +4,6 @@ const common = require('../../common');
const assert = require('assert');
const { testResolveAsync } = require(`./build/${common.buildType}/binding`);
-common.crashOnUnhandledRejection();
-
let called = false;
testResolveAsync().then(() => { called = true; });
diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js
index 222a81b06b87eb..a1b41c8959b7f2 100644
--- a/test/addons/make-callback-recurse/test.js
+++ b/test/addons/make-callback-recurse/test.js
@@ -9,8 +9,6 @@ const makeCallback = binding.makeCallback;
// Make sure this is run in the future.
const mustCallCheckDomains = common.mustCall(checkDomains);
-common.crashOnUnhandledRejection();
-
// Make sure that using MakeCallback allows the error to propagate.
assert.throws(function() {
makeCallback({}, function() {
diff --git a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
index 873fd272cf2d29..9046bc3514abfc 100644
--- a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
+++ b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
@@ -8,8 +8,6 @@ const { checkInvocations } = require('./hook-checks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
-common.crashOnUnhandledRejection();
-
const p = new Promise(common.mustCall(function executor(resolve, reject) {
resolve(5);
}));
diff --git a/test/async-hooks/test-promise.js b/test/async-hooks/test-promise.js
index d3070b7cbd594d..729704b7928f7d 100644
--- a/test/async-hooks/test-promise.js
+++ b/test/async-hooks/test-promise.js
@@ -9,8 +9,6 @@ const { checkInvocations } = require('./hook-checks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
-common.crashOnUnhandledRejection();
-
const hooks = initHooks();
hooks.enable();
diff --git a/test/common/README.md b/test/common/README.md
index 41cc88aca10f59..3dee2f19704934 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -55,18 +55,19 @@ symlinks
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)).
On non-Windows platforms, this always returns `true`.
-### crashOnUnhandledRejection()
-
-Installs a `process.on('unhandledRejection')` handler that crashes the process
-after a tick. This is useful for tests that use Promises and need to make sure
-no unexpected rejections occur, because currently they result in silent
-failures.
-
### ddCommand(filename, kilobytes)
* return [<Object>]
Platform normalizes the `dd` command
+### disableCrashOnUnhandledRejection()
+
+Removes the `process.on('unhandledRejection')` handler that crashes the process
+after a tick. The handler is useful for tests that use Promises and need to make
+sure no unexpected rejections occur, because currently they result in silent
+failures. However, it is useful in some rare cases to disable it, for example if
+the `unhandledRejection` hook is directly used by the test.
+
### enoughTestMem
* [<boolean>]
diff --git a/test/common/index.js b/test/common/index.js
index cca289337ef4a2..21fead16eebe77 100644
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -815,9 +815,10 @@ exports.getBufferSources = function getBufferSources(buf) {
};
// Crash the process on unhandled rejections.
-exports.crashOnUnhandledRejection = function() {
- process.on('unhandledRejection',
- (err) => process.nextTick(() => { throw err; }));
+const crashOnUnhandledRejection = (err) => { throw err; };
+process.on('unhandledRejection', crashOnUnhandledRejection);
+exports.disableCrashOnUnhandledRejection = function() {
+ process.removeListener('unhandledRejection', crashOnUnhandledRejection);
};
exports.getTTYfd = function getTTYfd() {
diff --git a/test/common/index.mjs b/test/common/index.mjs
index f73a9d9be5c08e..8bf512f6b92f6e 100644
--- a/test/common/index.mjs
+++ b/test/common/index.mjs
@@ -52,7 +52,7 @@ const {
skipIf32Bits,
getArrayBufferViews,
getBufferSources,
- crashOnUnhandledRejection,
+ disableCrashOnUnhandledRejection,
getTTYfd,
runWithInvalidFD,
hijackStdout,
@@ -112,7 +112,7 @@ export {
skipIf32Bits,
getArrayBufferViews,
getBufferSources,
- crashOnUnhandledRejection,
+ disableCrashOnUnhandledRejection,
getTTYfd,
runWithInvalidFD,
hijackStdout,
diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js
index 13726049798f0e..84393c4281fa88 100644
--- a/test/common/inspector-helper.js
+++ b/test/common/inspector-helper.js
@@ -25,6 +25,7 @@ function spawnChildProcess(inspectorFlags, scriptContents, scriptFile) {
const handler = tearDown.bind(null, child);
process.on('exit', handler);
process.on('uncaughtException', handler);
+ common.disableCrashOnUnhandledRejection();
process.on('unhandledRejection', handler);
process.on('SIGINT', handler);
diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js
index 91757172880f67..6a80da49472b36 100644
--- a/test/es-module/test-esm-dynamic-import.js
+++ b/test/es-module/test-esm-dynamic-import.js
@@ -5,8 +5,6 @@ const assert = require('assert');
const { URL } = require('url');
const vm = require('vm');
-common.crashOnUnhandledRejection();
-
const relativePath = '../fixtures/es-modules/test-esm-ok.mjs';
const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs');
const targetURL = new URL('file:///');
diff --git a/test/es-module/test-esm-error-cache.js b/test/es-module/test-esm-error-cache.js
index 22ffa9abe96a37..98244615eff2c6 100644
--- a/test/es-module/test-esm-error-cache.js
+++ b/test/es-module/test-esm-error-cache.js
@@ -2,11 +2,9 @@
// Flags: --experimental-modules
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const file = '../fixtures/syntax/bad_syntax.js';
let error;
diff --git a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs
index 27447b3e436afe..f2b37f7e8a4db6 100644
--- a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs
+++ b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs
@@ -1,11 +1,6 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs
-import {
- crashOnUnhandledRejection,
- expectsError
-} from '../common';
-
-crashOnUnhandledRejection();
+import { expectsError } from '../common';
import('test').catch(expectsError({
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
diff --git a/test/es-module/test-esm-throw-undefined.mjs b/test/es-module/test-esm-throw-undefined.mjs
index 877728178762ba..541127eee5919f 100644
--- a/test/es-module/test-esm-throw-undefined.mjs
+++ b/test/es-module/test-esm-throw-undefined.mjs
@@ -1,6 +1,5 @@
// Flags: --experimental-modules
-/* eslint-disable node-core/required-modules */
-import common from '../common/index.js';
+import '../common';
import assert from 'assert';
async function doTest() {
@@ -12,5 +11,4 @@ async function doTest() {
);
}
-common.crashOnUnhandledRejection();
doTest();
diff --git a/test/internet/test-dns-any.js b/test/internet/test-dns-any.js
index be5fc4b1addefc..e8425a6ca5632d 100644
--- a/test/internet/test-dns-any.js
+++ b/test/internet/test-dns-any.js
@@ -9,8 +9,6 @@ const net = require('net');
let running = false;
const queue = [];
-common.crashOnUnhandledRejection();
-
const dnsPromises = dns.promises;
const isIPv4 = net.isIPv4;
const isIPv6 = net.isIPv6;
diff --git a/test/internet/test-dns-ipv4.js b/test/internet/test-dns-ipv4.js
index 837d45f2ad4128..1179cd6f5d6c7f 100644
--- a/test/internet/test-dns-ipv4.js
+++ b/test/internet/test-dns-ipv4.js
@@ -7,8 +7,6 @@ const net = require('net');
const util = require('util');
const isIPv4 = net.isIPv4;
-common.crashOnUnhandledRejection();
-
const dnsPromises = dns.promises;
let running = false;
const queue = [];
diff --git a/test/internet/test-dns-ipv6.js b/test/internet/test-dns-ipv6.js
index 283b182390ae72..b2cd6163e8007c 100644
--- a/test/internet/test-dns-ipv6.js
+++ b/test/internet/test-dns-ipv6.js
@@ -4,8 +4,6 @@ const { addresses } = require('../common/internet');
if (!common.hasIPv6)
common.skip('this test, no IPv6 support');
-common.crashOnUnhandledRejection();
-
const assert = require('assert');
const dns = require('dns');
const net = require('net');
diff --git a/test/internet/test-dns-promises-resolve.js b/test/internet/test-dns-promises-resolve.js
index fcaa8977a5ba18..430f4251379097 100644
--- a/test/internet/test-dns-promises-resolve.js
+++ b/test/internet/test-dns-promises-resolve.js
@@ -4,8 +4,6 @@ const assert = require('assert');
const dnsPromises = require('dns').promises;
-common.crashOnUnhandledRejection();
-
// Error when rrtype is invalid.
{
const rrtype = 'DUMMY';
diff --git a/test/internet/test-dns-txt-sigsegv.js b/test/internet/test-dns-txt-sigsegv.js
index b572c6bb7fb421..9f65b6ec24ffc0 100644
--- a/test/internet/test-dns-txt-sigsegv.js
+++ b/test/internet/test-dns-txt-sigsegv.js
@@ -1,11 +1,9 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
(async function() {
const result = await dnsPromises.resolveTxt('www.microsoft.com');
assert.strictEqual(result.length, 0);
diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js
index 593d621e82f5b1..4608713927abbd 100644
--- a/test/internet/test-dns.js
+++ b/test/internet/test-dns.js
@@ -30,8 +30,6 @@ const isIPv6 = net.isIPv6;
const util = require('util');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
let expected = 0;
let completed = 0;
let running = false;
diff --git a/test/known_issues/test-inspector-cluster-port-clash.js b/test/known_issues/test-inspector-cluster-port-clash.js
index 51ae94f59769ae..9fa2b483568c93 100644
--- a/test/known_issues/test-inspector-cluster-port-clash.js
+++ b/test/known_issues/test-inspector-cluster-port-clash.js
@@ -23,8 +23,6 @@ if (process.config.variables.v8_enable_inspector === 0) {
const cluster = require('cluster');
const net = require('net');
-common.crashOnUnhandledRejection();
-
const ports = [process.debugPort];
const clashPort = process.debugPort + 2;
function serialFork() {
diff --git a/test/message/unhandled_promise_trace_warnings.js b/test/message/unhandled_promise_trace_warnings.js
index 48450fb21e2169..d51a2cd3da2106 100644
--- a/test/message/unhandled_promise_trace_warnings.js
+++ b/test/message/unhandled_promise_trace_warnings.js
@@ -1,5 +1,6 @@
// Flags: --trace-warnings
'use strict';
-require('../common');
+const common = require('../common');
+common.disableCrashOnUnhandledRejection();
const p = Promise.reject(new Error('This was rejected'));
setImmediate(() => p.catch(() => {}));
diff --git a/test/parallel/test-assert-async.js b/test/parallel/test-assert-async.js
index 4b3664e0cbdf15..30c9a741c6ab10 100644
--- a/test/parallel/test-assert-async.js
+++ b/test/parallel/test-assert-async.js
@@ -5,8 +5,6 @@ const assert = require('assert');
// Test assert.rejects() and assert.doesNotReject() by checking their
// expected output and by verifying that they do not work sync
-common.crashOnUnhandledRejection();
-
// Run all tests in parallel and check their outcome at the end.
const promises = [];
diff --git a/test/parallel/test-async-hooks-disable-during-promise.js b/test/parallel/test-async-hooks-disable-during-promise.js
index ace9bca6799a13..6b9b53bd30f0f5 100644
--- a/test/parallel/test-async-hooks-disable-during-promise.js
+++ b/test/parallel/test-async-hooks-disable-during-promise.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
const async_hooks = require('async_hooks');
-common.crashOnUnhandledRejection();
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
diff --git a/test/parallel/test-async-hooks-enable-during-promise.js b/test/parallel/test-async-hooks-enable-during-promise.js
index 29d25de9805de6..ce3253b01c1279 100644
--- a/test/parallel/test-async-hooks-enable-during-promise.js
+++ b/test/parallel/test-async-hooks-enable-during-promise.js
@@ -2,8 +2,6 @@
const common = require('../common');
const async_hooks = require('async_hooks');
-common.crashOnUnhandledRejection();
-
Promise.resolve(1).then(common.mustCall(() => {
async_hooks.createHook({
init: common.mustCall(),
diff --git a/test/parallel/test-async-hooks-promise-enable-disable.js b/test/parallel/test-async-hooks-promise-enable-disable.js
index b7692c45cd9b2e..150ccc88b0dc52 100644
--- a/test/parallel/test-async-hooks-promise-enable-disable.js
+++ b/test/parallel/test-async-hooks-promise-enable-disable.js
@@ -8,8 +8,6 @@ let p_resource = null;
let p_er = null;
let p_inits = 0;
-common.crashOnUnhandledRejection();
-
// Not useful to place common.mustCall() around 'exit' event b/c it won't be
// able to check it anyway.
process.on('exit', (code) => {
diff --git a/test/parallel/test-async-hooks-promise-triggerid.js b/test/parallel/test-async-hooks-promise-triggerid.js
index 507a8a4ada2c7e..467fddd359d835 100644
--- a/test/parallel/test-async-hooks-promise-triggerid.js
+++ b/test/parallel/test-async-hooks-promise-triggerid.js
@@ -6,8 +6,6 @@ const async_hooks = require('async_hooks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
-common.crashOnUnhandledRejection();
-
const promiseAsyncIds = [];
async_hooks.createHook({
diff --git a/test/parallel/test-async-wrap-pop-id-during-load.js b/test/parallel/test-async-wrap-pop-id-during-load.js
index ff3f637b87c270..31d2113eabc163 100644
--- a/test/parallel/test-async-wrap-pop-id-during-load.js
+++ b/test/parallel/test-async-wrap-pop-id-during-load.js
@@ -1,8 +1,9 @@
'use strict';
-require('../common');
+const common = require('../common');
if (process.argv[2] === 'async') {
+ common.disableCrashOnUnhandledRejection();
async function fn() {
fn();
throw new Error();
diff --git a/test/parallel/test-async-wrap-promise-after-enabled.js b/test/parallel/test-async-wrap-promise-after-enabled.js
index 5df8f13c008e19..0d58cbd653868b 100644
--- a/test/parallel/test-async-wrap-promise-after-enabled.js
+++ b/test/parallel/test-async-wrap-promise-after-enabled.js
@@ -12,8 +12,6 @@ const async_hooks = require('async_hooks');
const seenEvents = [];
-common.crashOnUnhandledRejection();
-
const p = new Promise((resolve) => resolve(1));
p.then(() => seenEvents.push('then'));
diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js
index 59ae40b2b82568..8b1cf79868c328 100644
--- a/test/parallel/test-c-ares.js
+++ b/test/parallel/test-c-ares.js
@@ -23,8 +23,6 @@
const common = require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const dns = require('dns');
const dnsPromises = dns.promises;
diff --git a/test/parallel/test-child-process-promisified.js b/test/parallel/test-child-process-promisified.js
index 0fa9c68a92d884..877bf06662e4e0 100644
--- a/test/parallel/test-child-process-promisified.js
+++ b/test/parallel/test-child-process-promisified.js
@@ -4,8 +4,6 @@ const assert = require('assert');
const child_process = require('child_process');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
const exec = promisify(child_process.exec);
const execFile = promisify(child_process.execFile);
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js
index 5ee3bc7051e521..3413bcffd8abe9 100644
--- a/test/parallel/test-dns-lookup.js
+++ b/test/parallel/test-dns-lookup.js
@@ -5,8 +5,6 @@ const cares = process.binding('cares_wrap');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
// Stub `getaddrinfo` to *always* error.
cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
diff --git a/test/parallel/test-dns-resolveany-bad-ancount.js b/test/parallel/test-dns-resolveany-bad-ancount.js
index d48d9385b84b90..4b13421b316aee 100644
--- a/test/parallel/test-dns-resolveany-bad-ancount.js
+++ b/test/parallel/test-dns-resolveany-bad-ancount.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const dgram = require('dgram');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const server = dgram.createSocket('udp4');
server.on('message', common.mustCall((msg, { address, port }) => {
diff --git a/test/parallel/test-dns-resolveany.js b/test/parallel/test-dns-resolveany.js
index f9a6399cef52d0..46694f240336cf 100644
--- a/test/parallel/test-dns-resolveany.js
+++ b/test/parallel/test-dns-resolveany.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const dgram = require('dgram');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const answers = [
{ type: 'A', address: '1.2.3.4', ttl: 123 },
{ type: 'AAAA', address: '::42', ttl: 123 },
diff --git a/test/parallel/test-dns-resolvens-typeerror.js b/test/parallel/test-dns-resolvens-typeerror.js
index ec57bba6148742..5a72b540130e0c 100644
--- a/test/parallel/test-dns-resolvens-typeerror.js
+++ b/test/parallel/test-dns-resolvens-typeerror.js
@@ -29,8 +29,6 @@ const common = require('../common');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
common.expectsError(
() => dnsPromises.resolveNs([]), // bad name
{
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index 9acf18994e6fe7..3a44be92804746 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -26,8 +26,6 @@ const assert = require('assert');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const existing = dns.getServers();
assert(existing.length > 0);
diff --git a/test/parallel/test-domain-promise.js b/test/parallel/test-domain-promise.js
index f1c966d4afd4fd..1c6e62956085ce 100644
--- a/test/parallel/test-domain-promise.js
+++ b/test/parallel/test-domain-promise.js
@@ -5,8 +5,6 @@ const domain = require('domain');
const fs = require('fs');
const vm = require('vm');
-common.crashOnUnhandledRejection();
-
{
const d = domain.create();
diff --git a/test/parallel/test-fs-lchown.js b/test/parallel/test-fs-lchown.js
index 23469eb279aede..bf8673c0718769 100644
--- a/test/parallel/test-fs-lchown.js
+++ b/test/parallel/test-fs-lchown.js
@@ -7,8 +7,6 @@ const fs = require('fs');
const path = require('path');
const { promises } = fs;
-common.crashOnUnhandledRejection();
-
// Validate the path argument.
[false, 1, {}, [], null, undefined].forEach((i) => {
const err = { type: TypeError, code: 'ERR_INVALID_ARG_TYPE' };
diff --git a/test/parallel/test-fs-promises-file-handle-append-file.js b/test/parallel/test-fs-promises-file-handle-append-file.js
index 7766ac4c904642..f9abef359e0064 100644
--- a/test/parallel/test-fs-promises-file-handle-append-file.js
+++ b/test/parallel/test-fs-promises-file-handle-append-file.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateAppendBuffer() {
const filePath = path.resolve(tmpDir, 'tmp-append-file-buffer.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-chmod.js b/test/parallel/test-fs-promises-file-handle-chmod.js
index 8b9d8b1c0d193d..6b51639d410b3a 100644
--- a/test/parallel/test-fs-promises-file-handle-chmod.js
+++ b/test/parallel/test-fs-promises-file-handle-chmod.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateFilePermission() {
const filePath = path.resolve(tmpDir, 'tmp-chmod.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-read.js b/test/parallel/test-fs-promises-file-handle-read.js
index 621e63c075a256..13f8c277780d07 100644
--- a/test/parallel/test-fs-promises-file-handle-read.js
+++ b/test/parallel/test-fs-promises-file-handle-read.js
@@ -14,7 +14,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateRead() {
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-readFile.js b/test/parallel/test-fs-promises-file-handle-readFile.js
index 9e6fcc2784c49d..c31e175019a3fb 100644
--- a/test/parallel/test-fs-promises-file-handle-readFile.js
+++ b/test/parallel/test-fs-promises-file-handle-readFile.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateReadFile() {
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-stat.js b/test/parallel/test-fs-promises-file-handle-stat.js
index 7d44b8e3dae2b7..19ee365213d302 100644
--- a/test/parallel/test-fs-promises-file-handle-stat.js
+++ b/test/parallel/test-fs-promises-file-handle-stat.js
@@ -11,7 +11,6 @@ const tmpdir = require('../common/tmpdir');
const assert = require('assert');
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateStat() {
const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-sync.js b/test/parallel/test-fs-promises-file-handle-sync.js
index cf28df31cb2e0f..fc6d00c0b8fc13 100644
--- a/test/parallel/test-fs-promises-file-handle-sync.js
+++ b/test/parallel/test-fs-promises-file-handle-sync.js
@@ -1,5 +1,5 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
@@ -7,8 +7,6 @@ const tmpdir = require('../common/tmpdir');
const { access, copyFile, open } = require('fs').promises;
const path = require('path');
-common.crashOnUnhandledRejection();
-
async function validateSync() {
tmpdir.refresh();
const dest = path.resolve(tmpdir.path, 'baz.js');
diff --git a/test/parallel/test-fs-promises-file-handle-truncate.js b/test/parallel/test-fs-promises-file-handle-truncate.js
index 44d919a042e276..65f998db748567 100644
--- a/test/parallel/test-fs-promises-file-handle-truncate.js
+++ b/test/parallel/test-fs-promises-file-handle-truncate.js
@@ -7,7 +7,6 @@ const { open, readFile } = require('fs').promises;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateTruncate() {
const text = 'Hello world';
diff --git a/test/parallel/test-fs-promises-file-handle-write.js b/test/parallel/test-fs-promises-file-handle-write.js
index 49df2bf54f45ed..da8cfc0a4bf96b 100644
--- a/test/parallel/test-fs-promises-file-handle-write.js
+++ b/test/parallel/test-fs-promises-file-handle-write.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateWrite() {
const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-writeFile.js b/test/parallel/test-fs-promises-file-handle-writeFile.js
index a53384cc221645..e39c59f5cae80c 100644
--- a/test/parallel/test-fs-promises-file-handle-writeFile.js
+++ b/test/parallel/test-fs-promises-file-handle-writeFile.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateWriteFile() {
const filePathForHandle = path.resolve(tmpDir, 'tmp-write-file2.txt');
diff --git a/test/parallel/test-fs-promises-readfile-empty.js b/test/parallel/test-fs-promises-readfile-empty.js
index 24c17655c62135..ef15a2681123c6 100644
--- a/test/parallel/test-fs-promises-readfile-empty.js
+++ b/test/parallel/test-fs-promises-readfile-empty.js
@@ -1,5 +1,5 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const { promises: fs } = require('fs');
@@ -7,8 +7,6 @@ const fixtures = require('../common/fixtures');
const fn = fixtures.path('empty.txt');
-common.crashOnUnhandledRejection();
-
fs.readFile(fn)
.then(assert.ok);
diff --git a/test/parallel/test-fs-promises-readfile.js b/test/parallel/test-fs-promises-readfile.js
index b1186ad2172507..ff25be75b84ff0 100644
--- a/test/parallel/test-fs-promises-readfile.js
+++ b/test/parallel/test-fs-promises-readfile.js
@@ -10,8 +10,6 @@ tmpdir.refresh();
const fn = path.join(tmpdir.path, 'large-file');
-common.crashOnUnhandledRejection();
-
async function validateReadFile() {
// Creating large buffer with random content
const buffer = Buffer.from(
diff --git a/test/parallel/test-fs-promises-writefile.js b/test/parallel/test-fs-promises-writefile.js
index 1bb6945c6782da..858e90bc6291de 100644
--- a/test/parallel/test-fs-promises-writefile.js
+++ b/test/parallel/test-fs-promises-writefile.js
@@ -10,8 +10,6 @@ const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
-
const dest = path.resolve(tmpDir, 'tmp.txt');
const buffer = Buffer.from('abc'.repeat(1000));
const buffer2 = Buffer.from('xyz'.repeat(1000));
diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js
index 602f1191b7aef5..26e1f8d71c292f 100644
--- a/test/parallel/test-fs-promises.js
+++ b/test/parallel/test-fs-promises.js
@@ -32,16 +32,13 @@ const {
const tmpDir = tmpdir.path;
-common.crashOnUnhandledRejection();
-
// fs.promises should not be enumerable as long as it causes a warning to be
// emitted.
assert.strictEqual(Object.keys(fs).includes('promises'), false);
{
access(__filename, 'r')
- .then(common.mustCall())
- .catch(common.mustNotCall());
+ .then(common.mustCall());
access('this file does not exist', 'r')
.then(common.mustNotCall())
diff --git a/test/parallel/test-fs-promisified.js b/test/parallel/test-fs-promisified.js
index 13cf5e0e0f45f3..0744f62fd17fa5 100644
--- a/test/parallel/test-fs-promisified.js
+++ b/test/parallel/test-fs-promisified.js
@@ -5,8 +5,6 @@ const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
const read = promisify(fs.read);
const write = promisify(fs.write);
const exists = promisify(fs.exists);
diff --git a/test/parallel/test-fs-stat-bigint.js b/test/parallel/test-fs-stat-bigint.js
index 6d0a064def5d25..943c0d55d86ba8 100644
--- a/test/parallel/test-fs-stat-bigint.js
+++ b/test/parallel/test-fs-stat-bigint.js
@@ -8,7 +8,6 @@ const path = require('path');
const tmpdir = require('../common/tmpdir');
const { isDate } = require('util').types;
-common.crashOnUnhandledRejection();
tmpdir.refresh();
const fn = path.join(tmpdir.path, 'test-file');
diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js
index 6dc7f75ce0bc05..4ff781ecb95f91 100644
--- a/test/parallel/test-http-agent.js
+++ b/test/parallel/test-http-agent.js
@@ -24,7 +24,6 @@ const common = require('../common');
const Countdown = require('../common/countdown');
const assert = require('assert');
const http = require('http');
-common.crashOnUnhandledRejection();
const N = 4;
const M = 4;
diff --git a/test/parallel/test-http2-backpressure.js b/test/parallel/test-http2-backpressure.js
index 9b69dddbfd2e26..db58e8da33df33 100644
--- a/test/parallel/test-http2-backpressure.js
+++ b/test/parallel/test-http2-backpressure.js
@@ -9,8 +9,6 @@ const assert = require('assert');
const http2 = require('http2');
const makeDuplexPair = require('../common/duplexpair');
-common.crashOnUnhandledRejection();
-
{
let req;
const server = http2.createServer();
diff --git a/test/parallel/test-http2-client-promisify-connect.js b/test/parallel/test-http2-client-promisify-connect.js
index 2eb7da3b9cfd85..3e41bee49bb5c3 100644
--- a/test/parallel/test-http2-client-promisify-connect.js
+++ b/test/parallel/test-http2-client-promisify-connect.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
-common.crashOnUnhandledRejection();
if (!common.hasCrypto)
common.skip('missing crypto');
@@ -18,7 +17,6 @@ server.listen(0, common.mustCall(() => {
const connect = util.promisify(http2.connect);
connect(`http://localhost:${server.address().port}`)
- .catch(common.mustNotCall())
.then(common.mustCall((client) => {
assert(client);
const req = client.request();
diff --git a/test/parallel/test-http2-window-size.js b/test/parallel/test-http2-window-size.js
index 3d1c14de847e48..164a778e1f8c54 100644
--- a/test/parallel/test-http2-window-size.js
+++ b/test/parallel/test-http2-window-size.js
@@ -10,7 +10,6 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const h2 = require('http2');
-common.crashOnUnhandledRejection();
// Given a list of buffers and an initial window size, have a server write
// each buffer to the HTTP2 Writable stream, and let the client verify that
diff --git a/test/parallel/test-inspect-async-hook-setup-at-inspect.js b/test/parallel/test-inspect-async-hook-setup-at-inspect.js
index 6b1c875138ba01..48de93c061479b 100644
--- a/test/parallel/test-inspect-async-hook-setup-at-inspect.js
+++ b/test/parallel/test-inspect-async-hook-setup-at-inspect.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js
index 62f0feefade88d..d94f8d10bb08ca 100644
--- a/test/parallel/test-inspector-esm.js
+++ b/test/parallel/test-inspector-esm.js
@@ -110,6 +110,4 @@ async function runTest() {
assert.strictEqual((await child.expectShutdown()).exitCode, 55);
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/parallel/test-inspector-multisession-js.js b/test/parallel/test-inspector-multisession-js.js
index c899eeae713908..097b77e2c24231 100644
--- a/test/parallel/test-inspector-multisession-js.js
+++ b/test/parallel/test-inspector-multisession-js.js
@@ -54,8 +54,6 @@ async function test() {
console.log('Sessions were disconnected');
}
-common.crashOnUnhandledRejection();
-
const interval = setInterval(() => {}, 1000);
test().then(() => {
clearInterval(interval);
diff --git a/test/parallel/test-inspector-multisession-ws.js b/test/parallel/test-inspector-multisession-ws.js
index d17adab2f486cc..02fde12e1c1c2f 100644
--- a/test/parallel/test-inspector-multisession-ws.js
+++ b/test/parallel/test-inspector-multisession-ws.js
@@ -70,6 +70,4 @@ async function runTest() {
return child.expectShutdown();
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/parallel/test-inspector-reported-host.js b/test/parallel/test-inspector-reported-host.js
index f54ea16625d218..142003e49f747c 100644
--- a/test/parallel/test-inspector-reported-host.js
+++ b/test/parallel/test-inspector-reported-host.js
@@ -7,8 +7,6 @@ common.skipIfInspectorDisabled();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
-common.crashOnUnhandledRejection();
-
async function test() {
const madeUpHost = '111.111.111.111:11111';
const child = new NodeInstance(undefined, 'var a = 1');
diff --git a/test/parallel/test-inspector-tracing-domain.js b/test/parallel/test-inspector-tracing-domain.js
index 61a853a265780c..241e0dbec777f4 100644
--- a/test/parallel/test-inspector-tracing-domain.js
+++ b/test/parallel/test-inspector-tracing-domain.js
@@ -65,6 +65,4 @@ async function test() {
console.log('Success');
}
-common.crashOnUnhandledRejection();
-
test();
diff --git a/test/parallel/test-internal-module-wrap.js b/test/parallel/test-internal-module-wrap.js
index bb4a648ef7f684..99f1e9d6e70e69 100644
--- a/test/parallel/test-internal-module-wrap.js
+++ b/test/parallel/test-internal-module-wrap.js
@@ -2,8 +2,7 @@
// Flags: --expose-internals
-const common = require('../common');
-common.crashOnUnhandledRejection();
+require('../common');
const assert = require('assert');
const { ModuleWrap } = require('internal/test/binding');
diff --git a/test/parallel/test-microtask-queue-integration-domain.js b/test/parallel/test-microtask-queue-integration-domain.js
index 8a4a06f9ffbe5e..98da703ee51429 100644
--- a/test/parallel/test-microtask-queue-integration-domain.js
+++ b/test/parallel/test-microtask-queue-integration-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
const implementations = [
function(fn) {
Promise.resolve().then(fn);
diff --git a/test/parallel/test-microtask-queue-integration.js b/test/parallel/test-microtask-queue-integration.js
index a7241d99ee9395..57c384f8ba8177 100644
--- a/test/parallel/test-microtask-queue-integration.js
+++ b/test/parallel/test-microtask-queue-integration.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const implementations = [
function(fn) {
Promise.resolve().then(fn);
diff --git a/test/parallel/test-microtask-queue-run-domain.js b/test/parallel/test-microtask-queue-run-domain.js
index a895504fc2972a..39baf930232411 100644
--- a/test/parallel/test-microtask-queue-run-domain.js
+++ b/test/parallel/test-microtask-queue-run-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run-immediate-domain.js b/test/parallel/test-microtask-queue-run-immediate-domain.js
index 807affd0589861..60b17bc38c2670 100644
--- a/test/parallel/test-microtask-queue-run-immediate-domain.js
+++ b/test/parallel/test-microtask-queue-run-immediate-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run-immediate.js b/test/parallel/test-microtask-queue-run-immediate.js
index 1e26f4beebfbe4..4d998cf0b8a59c 100644
--- a/test/parallel/test-microtask-queue-run-immediate.js
+++ b/test/parallel/test-microtask-queue-run-immediate.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run.js b/test/parallel/test-microtask-queue-run.js
index ba9cf6731ef75b..85eb770da1e0ff 100644
--- a/test/parallel/test-microtask-queue-run.js
+++ b/test/parallel/test-microtask-queue-run.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
index eb045c704c637c..f607f28c10eaa2 100644
--- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js
+++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
@@ -1,9 +1,8 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const net = require('net');
-common.crashOnUnhandledRejection();
// Sets the server's maxConnections property to 1.
// Open 2 connections (connection 0 and connection 1).
@@ -84,8 +83,3 @@ process.on('exit', function() {
// ...but that only connections 0 and 2 were successful.
assert.deepStrictEqual(received, ['0', '2']);
});
-
-process.on('unhandledRejection', function() {
- console.error('promise rejected');
- assert.fail('A promise in the chain rejected');
-});
diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js
index dfd1ee322a6443..83062e9520165b 100644
--- a/test/parallel/test-promises-unhandled-proxy-rejections.js
+++ b/test/parallel/test-promises-unhandled-proxy-rejections.js
@@ -1,6 +1,8 @@
'use strict';
const common = require('../common');
+common.disableCrashOnUnhandledRejection();
+
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
'rejections that are not handled will ' +
diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js
index 1ade061994c3bb..92b6d7a96147a1 100644
--- a/test/parallel/test-promises-unhandled-rejections.js
+++ b/test/parallel/test-promises-unhandled-rejections.js
@@ -1,8 +1,10 @@
'use strict';
-require('../common');
+const common = require('../common');
const assert = require('assert');
const domain = require('domain');
+common.disableCrashOnUnhandledRejection();
+
const asyncTest = (function() {
let asyncTestsEnabled = false;
let asyncTestLastCheck;
diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js
index e5084b50c189fd..2102de81918bd7 100644
--- a/test/parallel/test-promises-unhandled-symbol-rejections.js
+++ b/test/parallel/test-promises-unhandled-symbol-rejections.js
@@ -1,6 +1,8 @@
'use strict';
const common = require('../common');
+common.disableCrashOnUnhandledRejection();
+
const expectedValueWarning = ['Symbol()', common.noWarnCode];
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js
index 3ac7d8698beb37..ba420157e72bbd 100644
--- a/test/parallel/test-promises-warning-on-unhandled-rejection.js
+++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js
@@ -7,6 +7,8 @@
const common = require('../common');
const assert = require('assert');
+common.disableCrashOnUnhandledRejection();
+
let b = 0;
process.on('warning', common.mustCall((warning) => {
diff --git a/test/parallel/test-repl-load-multiline.js b/test/parallel/test-repl-load-multiline.js
index 8ab878ae768ddd..fd58a3c21dd884 100644
--- a/test/parallel/test-repl-load-multiline.js
+++ b/test/parallel/test-repl-load-multiline.js
@@ -4,8 +4,6 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js
index 91f5758c210a36..762def7c003d78 100644
--- a/test/parallel/test-repl-top-level-await.js
+++ b/test/parallel/test-repl-top-level-await.js
@@ -5,8 +5,6 @@ const assert = require('assert');
const { stripVTControlCharacters } = require('internal/readline');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
// Flags: --expose-internals --experimental-repl-await
const PROMPT = 'await repl > ';
diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js
index 5459371f00c24d..35cd3e11afab53 100644
--- a/test/parallel/test-repl.js
+++ b/test/parallel/test-repl.js
@@ -26,8 +26,6 @@ const assert = require('assert');
const net = require('net');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
const message = 'Read, Eval, Print Loop';
const prompt_unix = 'node via Unix socket> ';
const prompt_tcp = 'node via TCP socket> ';
diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js
index 2b0c156eb06845..3aade5610c7045 100644
--- a/test/parallel/test-stream-finished.js
+++ b/test/parallel/test-stream-finished.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const fs = require('fs');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
{
const rs = new Readable({
read() {}
diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js
index 12733d88a7ac85..89cde367ad6f7b 100644
--- a/test/parallel/test-stream-pipeline.js
+++ b/test/parallel/test-stream-pipeline.js
@@ -9,8 +9,6 @@ const http = require('http');
const http2 = require('http2');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
{
let finished = false;
const processed = [];
diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js
index 39761b413260f1..d8eb83a58506d1 100644
--- a/test/parallel/test-stream-readable-async-iterators.js
+++ b/test/parallel/test-stream-readable-async-iterators.js
@@ -4,8 +4,6 @@ const common = require('../common');
const { Readable } = require('stream');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
async function tests() {
await (async function() {
console.log('read without for..await');
diff --git a/test/parallel/test-timers-promisified.js b/test/parallel/test-timers-promisified.js
index 1dad1d8cfc0d1c..85e7093cfa185f 100644
--- a/test/parallel/test-timers-promisified.js
+++ b/test/parallel/test-timers-promisified.js
@@ -6,8 +6,6 @@ const { promisify } = require('util');
/* eslint-disable no-restricted-syntax */
-common.crashOnUnhandledRejection();
-
const setTimeout = promisify(timers.setTimeout);
const setImmediate = promisify(timers.setImmediate);
diff --git a/test/parallel/test-util-inspect-namespace.js b/test/parallel/test-util-inspect-namespace.js
index fddbcdb34697d9..e73f475cff55cc 100644
--- a/test/parallel/test-util-inspect-namespace.js
+++ b/test/parallel/test-util-inspect-namespace.js
@@ -2,11 +2,9 @@
// Flags: --experimental-vm-modules
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const { Module } = require('vm');
const { inspect } = require('util');
diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js
index 5e1994a730d733..0bece0df426b7b 100644
--- a/test/parallel/test-util-promisify.js
+++ b/test/parallel/test-util-promisify.js
@@ -7,8 +7,6 @@ const vm = require('vm');
const { promisify } = require('util');
const { customPromisifyArgs } = require('internal/util');
-common.crashOnUnhandledRejection();
-
const stat = promisify(fs.stat);
{
diff --git a/test/parallel/test-util-types.js b/test/parallel/test-util-types.js
index de5a89ab4abc80..59a9dcceb59d6a 100644
--- a/test/parallel/test-util-types.js
+++ b/test/parallel/test-util-types.js
@@ -1,14 +1,12 @@
// Flags: --harmony-bigint --experimental-vm-modules
'use strict';
-const common = require('../common');
+require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const { types, inspect } = require('util');
const vm = require('vm');
const { JSStream } = process.binding('js_stream');
-common.crashOnUnhandledRejection();
-
const external = (new JSStream())._externalStream;
const wasmBuffer = fixtures.readSync('test.wasm');
diff --git a/test/parallel/test-vm-module-basic.js b/test/parallel/test-vm-module-basic.js
index 4bbe0a95ee6724..1f699ddf5b4334 100644
--- a/test/parallel/test-vm-module-basic.js
+++ b/test/parallel/test-vm-module-basic.js
@@ -6,8 +6,6 @@ const common = require('../common');
const assert = require('assert');
const { Module, createContext } = require('vm');
-common.crashOnUnhandledRejection();
-
(async function test1() {
const context = createContext({
foo: 'bar',
diff --git a/test/parallel/test-vm-module-dynamic-import.js b/test/parallel/test-vm-module-dynamic-import.js
index ca4dceb5def731..bb45337cf1a83c 100644
--- a/test/parallel/test-vm-module-dynamic-import.js
+++ b/test/parallel/test-vm-module-dynamic-import.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules --experimental-modules --harmony-dynamic-import
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
const { Module, createContext } = require('vm');
diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js
index 424d35e8aaf67a..720f28525b4d35 100644
--- a/test/parallel/test-vm-module-errors.js
+++ b/test/parallel/test-vm-module-errors.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
diff --git a/test/parallel/test-vm-module-import-meta.js b/test/parallel/test-vm-module-import-meta.js
index 835ef5b6eb5de0..5e97f1ac541d54 100644
--- a/test/parallel/test-vm-module-import-meta.js
+++ b/test/parallel/test-vm-module-import-meta.js
@@ -6,8 +6,6 @@ const common = require('../common');
const assert = require('assert');
const { Module } = require('vm');
-common.crashOnUnhandledRejection();
-
async function testBasic() {
const m = new Module('import.meta;', {
initializeImportMeta: common.mustCall((meta, module) => {
diff --git a/test/parallel/test-vm-module-link.js b/test/parallel/test-vm-module-link.js
index d9ee8e7767f43a..ead6721bd4564f 100644
--- a/test/parallel/test-vm-module-link.js
+++ b/test/parallel/test-vm-module-link.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
const { URL } = require('url');
diff --git a/test/parallel/test-vm-module-reevaluate.js b/test/parallel/test-vm-module-reevaluate.js
index e4f5858800e297..e08ab734501ff2 100644
--- a/test/parallel/test-vm-module-reevaluate.js
+++ b/test/parallel/test-vm-module-reevaluate.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
diff --git a/test/parallel/test-wasm-simple.js b/test/parallel/test-wasm-simple.js
index 02a97ec2c9455f..f00f10c436650a 100644
--- a/test/parallel/test-wasm-simple.js
+++ b/test/parallel/test-wasm-simple.js
@@ -1,11 +1,9 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
-common.crashOnUnhandledRejection();
-
const buffer = fixtures.readSync('test.wasm');
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
diff --git a/test/parallel/test-zlib-empty-buffer.js b/test/parallel/test-zlib-empty-buffer.js
index 8b299f8728282d..e351db54571732 100644
--- a/test/parallel/test-zlib-empty-buffer.js
+++ b/test/parallel/test-zlib-empty-buffer.js
@@ -1,12 +1,10 @@
'use strict';
-const common = require('../common');
+require('../common');
const zlib = require('zlib');
const { inspect, promisify } = require('util');
const assert = require('assert');
const emptyBuffer = Buffer.alloc(0);
-common.crashOnUnhandledRejection();
-
(async function() {
for (const [ compress, decompress, method ] of [
[ zlib.deflateRawSync, zlib.inflateRawSync, 'raw sync' ],
diff --git a/test/parallel/test-zlib-flush-multiple-scheduled.js b/test/parallel/test-zlib-flush-multiple-scheduled.js
index 19548672389fde..0b752557e441bc 100644
--- a/test/parallel/test-zlib-flush-multiple-scheduled.js
+++ b/test/parallel/test-zlib-flush-multiple-scheduled.js
@@ -8,8 +8,6 @@ const {
Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH
} = zlib.constants;
-common.crashOnUnhandledRejection();
-
async function getOutput(...sequenceOfFlushes) {
const zipper = zlib.createGzip({ highWaterMark: 16384 });
diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js
index 002ffcffd820c1..3843979c229661 100644
--- a/test/sequential/test-async-wrap-getasyncid.js
+++ b/test/sequential/test-async-wrap-getasyncid.js
@@ -11,8 +11,6 @@ const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { getSystemErrorName } = require('util');
-common.crashOnUnhandledRejection();
-
// Make sure that all Providers are tested.
{
const hooks = require('async_hooks').createHook({
@@ -198,7 +196,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
testInitialized(fd, 'FileHandle');
await fd.close();
}
- openTest().then(common.mustCall()).catch(common.mustNotCall());
+ openTest().then(common.mustCall());
}
{
diff --git a/test/sequential/test-inspector-async-call-stack-abort.js b/test/sequential/test-inspector-async-call-stack-abort.js
index 1ec46ab3cfeb9d..946d6dc1920d6b 100644
--- a/test/sequential/test-inspector-async-call-stack-abort.js
+++ b/test/sequential/test-inspector-async-call-stack-abort.js
@@ -9,6 +9,7 @@ const { strictEqual } = require('assert');
const eyecatcher = 'nou, houdoe he?';
if (process.argv[2] === 'child') {
+ common.disableCrashOnUnhandledRejection();
const { Session } = require('inspector');
const { promisify } = require('util');
const { registerAsyncHook } = process.binding('inspector');
diff --git a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js
index e0c3b4dcb86e37..9a2822e8f5740d 100644
--- a/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js
+++ b/test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
diff --git a/test/sequential/test-inspector-async-hook-setup-at-signal.js b/test/sequential/test-inspector-async-hook-setup-at-signal.js
index e0b87b0ebb162c..6f8ccfacb9964c 100644
--- a/test/sequential/test-inspector-async-hook-setup-at-signal.js
+++ b/test/sequential/test-inspector-async-hook-setup-at-signal.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
diff --git a/test/sequential/test-inspector-async-stack-traces-promise-then.js b/test/sequential/test-inspector-async-stack-traces-promise-then.js
index e803be7167f592..0acb603147b798 100644
--- a/test/sequential/test-inspector-async-stack-traces-promise-then.js
+++ b/test/sequential/test-inspector-async-stack-traces-promise-then.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper');
const assert = require('assert');
diff --git a/test/sequential/test-inspector-async-stack-traces-set-interval.js b/test/sequential/test-inspector-async-stack-traces-set-interval.js
index 326032d40b20e6..fd294296cb035d 100644
--- a/test/sequential/test-inspector-async-stack-traces-set-interval.js
+++ b/test/sequential/test-inspector-async-stack-traces-set-interval.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper');
const assert = require('assert');
diff --git a/test/sequential/test-inspector-bindings.js b/test/sequential/test-inspector-bindings.js
index c23c8520e0601d..bea8b552202087 100644
--- a/test/sequential/test-inspector-bindings.js
+++ b/test/sequential/test-inspector-bindings.js
@@ -115,8 +115,6 @@ async function testNoCrashConsoleLogBeforeThrow() {
session.disconnect();
}
-common.crashOnUnhandledRejection();
-
async function doTests() {
await testNoCrashWithExceptionInCallback();
testSampleDebugSession();
diff --git a/test/sequential/test-inspector-break-e.js b/test/sequential/test-inspector-break-e.js
index 8db403ad2cd0d0..567ef7911c446d 100644
--- a/test/sequential/test-inspector-break-e.js
+++ b/test/sequential/test-inspector-break-e.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
-common.crashOnUnhandledRejection();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
diff --git a/test/sequential/test-inspector-break-when-eval.js b/test/sequential/test-inspector-break-when-eval.js
index b14e01a30185ed..8be5285221d513 100644
--- a/test/sequential/test-inspector-break-when-eval.js
+++ b/test/sequential/test-inspector-break-when-eval.js
@@ -65,5 +65,4 @@ async function runTests() {
assert.strictEqual(0, (await child.expectShutdown()).exitCode);
}
-common.crashOnUnhandledRejection();
runTests();
diff --git a/test/sequential/test-inspector-console.js b/test/sequential/test-inspector-console.js
index 6a06c798881654..3d36e9328dd529 100644
--- a/test/sequential/test-inspector-console.js
+++ b/test/sequential/test-inspector-console.js
@@ -35,5 +35,4 @@ async function runTest() {
session.disconnect();
}
-common.crashOnUnhandledRejection();
runTest();
diff --git a/test/sequential/test-inspector-contexts.js b/test/sequential/test-inspector-contexts.js
index fb59e9dee14892..d2285e82536326 100644
--- a/test/sequential/test-inspector-contexts.js
+++ b/test/sequential/test-inspector-contexts.js
@@ -151,5 +151,4 @@ async function testBreakpointHit() {
await pausedPromise;
}
-common.crashOnUnhandledRejection();
testContextCreatedAndDestroyed().then(testBreakpointHit);
diff --git a/test/sequential/test-inspector-debug-brk-flag.js b/test/sequential/test-inspector-debug-brk-flag.js
index 61eb4f97c655dc..0e5df52560d2b1 100644
--- a/test/sequential/test-inspector-debug-brk-flag.js
+++ b/test/sequential/test-inspector-debug-brk-flag.js
@@ -37,5 +37,4 @@ async function runTests() {
assert.strictEqual(55, (await child.expectShutdown()).exitCode);
}
-common.crashOnUnhandledRejection();
runTests();
diff --git a/test/sequential/test-inspector-debug-end.js b/test/sequential/test-inspector-debug-end.js
index dadee26258d346..d73e7dccc1a8fe 100644
--- a/test/sequential/test-inspector-debug-end.js
+++ b/test/sequential/test-inspector-debug-end.js
@@ -42,6 +42,4 @@ async function runTest() {
await testSessionNoCrash();
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/sequential/test-inspector-exception.js b/test/sequential/test-inspector-exception.js
index 3f83b37c7265a8..ef67e1d9a57264 100644
--- a/test/sequential/test-inspector-exception.js
+++ b/test/sequential/test-inspector-exception.js
@@ -41,6 +41,4 @@ async function runTest() {
assert.strictEqual(1, (await child.expectShutdown()).exitCode);
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/sequential/test-inspector-ip-detection.js b/test/sequential/test-inspector-ip-detection.js
index 14be5e6824a4a2..4e0f9b871b8ab0 100644
--- a/test/sequential/test-inspector-ip-detection.js
+++ b/test/sequential/test-inspector-ip-detection.js
@@ -44,6 +44,4 @@ async function test() {
instance.kill();
}
-common.crashOnUnhandledRejection();
-
test();
diff --git a/test/sequential/test-inspector-not-blocked-on-idle.js b/test/sequential/test-inspector-not-blocked-on-idle.js
index 3b1befe35df199..b5a16316dece9f 100644
--- a/test/sequential/test-inspector-not-blocked-on-idle.js
+++ b/test/sequential/test-inspector-not-blocked-on-idle.js
@@ -18,5 +18,4 @@ async function runTests() {
node.kill();
}
-common.crashOnUnhandledRejection();
runTests();
diff --git a/test/sequential/test-inspector-overwrite-config.js b/test/sequential/test-inspector-overwrite-config.js
index 46cb922402f360..49f48a59a04b4f 100644
--- a/test/sequential/test-inspector-overwrite-config.js
+++ b/test/sequential/test-inspector-overwrite-config.js
@@ -36,8 +36,6 @@ async function testConsoleLog() {
session.disconnect();
}
-common.crashOnUnhandledRejection();
-
async function runTests() {
await testConsoleLog();
assert.ok(asserted, 'log statement did not reach the inspector');
diff --git a/test/sequential/test-inspector-port-cluster.js b/test/sequential/test-inspector-port-cluster.js
index dfaf59c711cd13..f7bebd926e9780 100644
--- a/test/sequential/test-inspector-port-cluster.js
+++ b/test/sequential/test-inspector-port-cluster.js
@@ -2,7 +2,6 @@
const common = require('../common');
-common.crashOnUnhandledRejection();
common.skipIfInspectorDisabled();
const assert = require('assert');
diff --git a/test/sequential/test-inspector-scriptparsed-context.js b/test/sequential/test-inspector-scriptparsed-context.js
index abffbfe5fc67f2..1e862e9174cb3f 100644
--- a/test/sequential/test-inspector-scriptparsed-context.js
+++ b/test/sequential/test-inspector-scriptparsed-context.js
@@ -2,7 +2,6 @@
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
diff --git a/test/sequential/test-inspector-stop-profile-after-done.js b/test/sequential/test-inspector-stop-profile-after-done.js
index 678f98a556c099..cde1a0256067fe 100644
--- a/test/sequential/test-inspector-stop-profile-after-done.js
+++ b/test/sequential/test-inspector-stop-profile-after-done.js
@@ -28,5 +28,4 @@ async function runTests() {
assert.strictEqual((await child.expectShutdown()).exitCode, 0);
}
-common.crashOnUnhandledRejection();
runTests();
diff --git a/test/sequential/test-inspector-stress-http.js b/test/sequential/test-inspector-stress-http.js
index 4787c35e32c899..fd168f29f7bb0f 100644
--- a/test/sequential/test-inspector-stress-http.js
+++ b/test/sequential/test-inspector-stress-http.js
@@ -29,6 +29,4 @@ async function runTest() {
return child.kill();
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/sequential/test-inspector.js b/test/sequential/test-inspector.js
index 0a9b2ccd1abd3d..ba1fce25a04fad 100644
--- a/test/sequential/test-inspector.js
+++ b/test/sequential/test-inspector.js
@@ -292,6 +292,4 @@ async function runTest() {
assert.strictEqual(55, (await child.expectShutdown()).exitCode);
}
-common.crashOnUnhandledRejection();
-
runTest();
From 4f8620e2b79220b65e8e16c4ef3c531ecfc84478 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?=
Date: Tue, 17 Jul 2018 16:49:59 +0200
Subject: [PATCH 36/95] src: fix formatting of PIDs
PR-URL: https://github.com/nodejs/node/pull/21852
Reviewed-By: James M Snell
Reviewed-By: Trivikram Kamat
Reviewed-By: Joyee Cheung
Reviewed-By: Luigi Pinca
Reviewed-By: Jon Moss
---
src/env.cc | 2 +-
src/util.cc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/env.cc b/src/env.cc
index fffe5d61d0685a..76d1b6dd86d43e 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -306,7 +306,7 @@ void Environment::PrintSyncTrace() const {
Local stack =
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed);
- fprintf(stderr, "(node:%u) WARNING: Detected use of sync API\n",
+ fprintf(stderr, "(node:%d) WARNING: Detected use of sync API\n",
uv_os_getpid());
for (int i = 0; i < stack->GetFrameCount() - 1; i++) {
diff --git a/src/util.cc b/src/util.cc
index 77824acb03a610..3e808e13fe87d8 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -115,7 +115,7 @@ std::string GetHumanReadableProcessName() {
void GetHumanReadableProcessName(char (*name)[1024]) {
char title[1024] = "Node.js";
uv_get_process_title(title, sizeof(title));
- snprintf(*name, sizeof(*name), "%s[%u]", title, uv_os_getpid());
+ snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid());
}
} // namespace node
From d9cd171a6bdc2672c16baf54be2050329731ceed Mon Sep 17 00:00:00 2001
From: Jon Moss
Date: Wed, 18 Jul 2018 17:45:19 -0400
Subject: [PATCH 37/95] src: remove unnecessary else
Argument is not used by the only caller.
PR-URL: https://github.com/nodejs/node/pull/21874
Reviewed-By: Anna Henningsen
Reviewed-By: Trivikram Kamat
Reviewed-By: James M Snell
Reviewed-By: Michael Dawson
Reviewed-By: Colin Ihrig
---
src/node_wrap.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/node_wrap.h b/src/node_wrap.h
index 67cea2e715f869..42caca2dc6452d 100644
--- a/src/node_wrap.h
+++ b/src/node_wrap.h
@@ -35,7 +35,7 @@ namespace node {
// TODO(addaleax): Use real inheritance for the JS object templates to avoid
// this unnecessary case switching.
-#define WITH_GENERIC_UV_STREAM(env, obj, BODY, ELSE) \
+#define WITH_GENERIC_UV_STREAM(env, obj, BODY) \
do { \
if (env->tcp_constructor_template().IsEmpty() == false && \
env->tcp_constructor_template()->HasInstance(obj)) { \
@@ -49,8 +49,6 @@ namespace node {
env->pipe_constructor_template()->HasInstance(obj)) { \
PipeWrap* const wrap = Unwrap(obj); \
BODY \
- } else { \
- ELSE \
} \
} while (0)
@@ -62,7 +60,7 @@ inline uv_stream_t* HandleToStream(Environment* env,
if (wrap == nullptr)
return nullptr;
return reinterpret_cast(wrap->UVHandle());
- }, {});
+ });
return nullptr;
}
From be757958684cca2d0f51b82baef1ab34ae8d21b9 Mon Sep 17 00:00:00 2001
From: Jon Moss
Date: Wed, 18 Jul 2018 19:54:38 -0400
Subject: [PATCH 38/95] src: don't store one-use strings in variable
Move strings that are used only once to their call-sites, don't store
in a variable.
PR-URL: https://github.com/nodejs/node/pull/21876
Reviewed-By: Gus Caplan
Reviewed-By: Anna Henningsen
Reviewed-By: Trivikram Kamat
Reviewed-By: Minwoo Jung
Reviewed-By: James M Snell
Reviewed-By: Tiancheng "Timothy" Gu
Reviewed-By: Colin Ihrig
---
src/cares_wrap.cc | 57 +++++++++++++++++------------------------------
1 file changed, 21 insertions(+), 36 deletions(-)
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 69a3d46668193a..604213a2c65934 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -856,23 +856,20 @@ int ParseMxReply(Environment* env,
return status;
}
- Local exchange_symbol = env->exchange_string();
- Local priority_symbol = env->priority_string();
- Local type_symbol = env->type_string();
- Local mx_symbol = env->dns_mx_string();
-
uint32_t offset = ret->Length();
ares_mx_reply* current = mx_start;
for (uint32_t i = 0; current != nullptr; ++i, current = current->next) {
Local mx_record = Object::New(env->isolate());
mx_record->Set(context,
- exchange_symbol,
+ env->exchange_string(),
OneByteString(env->isolate(), current->host)).FromJust();
mx_record->Set(context,
- priority_symbol,
+ env->priority_string(),
Integer::New(env->isolate(), current->priority)).FromJust();
if (need_type)
- mx_record->Set(context, type_symbol, mx_symbol).FromJust();
+ mx_record->Set(context,
+ env->type_string(),
+ env->dns_mx_string()).FromJust();
ret->Set(context, i + offset, mx_record).FromJust();
}
@@ -959,31 +956,26 @@ int ParseSrvReply(Environment* env,
return status;
}
- Local name_symbol = env->name_string();
- Local port_symbol = env->port_string();
- Local priority_symbol = env->priority_string();
- Local weight_symbol = env->weight_string();
- Local type_symbol = env->type_string();
- Local srv_symbol = env->dns_srv_string();
-
ares_srv_reply* current = srv_start;
int offset = ret->Length();
for (uint32_t i = 0; current != nullptr; ++i, current = current->next) {
Local srv_record = Object::New(env->isolate());
srv_record->Set(context,
- name_symbol,
+ env->name_string(),
OneByteString(env->isolate(), current->host)).FromJust();
srv_record->Set(context,
- port_symbol,
+ env->port_string(),
Integer::New(env->isolate(), current->port)).FromJust();
srv_record->Set(context,
- priority_symbol,
+ env->priority_string(),
Integer::New(env->isolate(), current->priority)).FromJust();
srv_record->Set(context,
- weight_symbol,
+ env->weight_string(),
Integer::New(env->isolate(), current->weight)).FromJust();
if (need_type)
- srv_record->Set(context, type_symbol, srv_symbol).FromJust();
+ srv_record->Set(context,
+ env->type_string(),
+ env->dns_srv_string()).FromJust();
ret->Set(context, i + offset, srv_record).FromJust();
}
@@ -1008,43 +1000,36 @@ int ParseNaptrReply(Environment* env,
return status;
}
- Local flags_symbol = env->flags_string();
- Local service_symbol = env->service_string();
- Local regexp_symbol = env->regexp_string();
- Local replacement_symbol = env->replacement_string();
- Local order_symbol = env->order_string();
- Local preference_symbol = env->preference_string();
- Local type_symbol = env->type_string();
- Local naptr_symbol = env->dns_naptr_string();
-
ares_naptr_reply* current = naptr_start;
int offset = ret->Length();
for (uint32_t i = 0; current != nullptr; ++i, current = current->next) {
Local naptr_record = Object::New(env->isolate());
naptr_record->Set(context,
- flags_symbol,
+ env->flags_string(),
OneByteString(env->isolate(), current->flags)).FromJust();
naptr_record->Set(context,
- service_symbol,
+ env->service_string(),
OneByteString(env->isolate(),
current->service)).FromJust();
naptr_record->Set(context,
- regexp_symbol,
+ env->regexp_string(),
OneByteString(env->isolate(),
current->regexp)).FromJust();
naptr_record->Set(context,
- replacement_symbol,
+ env->replacement_string(),
OneByteString(env->isolate(),
current->replacement)).FromJust();
naptr_record->Set(context,
- order_symbol,
+ env->order_string(),
Integer::New(env->isolate(), current->order)).FromJust();
naptr_record->Set(context,
- preference_symbol,
+ env->preference_string(),
Integer::New(env->isolate(),
current->preference)).FromJust();
if (need_type)
- naptr_record->Set(context, type_symbol, naptr_symbol).FromJust();
+ naptr_record->Set(context,
+ env->type_string(),
+ env->dns_naptr_string()).FromJust();
ret->Set(context, i + offset, naptr_record).FromJust();
}
From b56c8ad8794dd5cef03518aec8f09c9ffc26ee13 Mon Sep 17 00:00:00 2001
From: James M Snell
Date: Thu, 19 Jul 2018 16:37:41 -0700
Subject: [PATCH 39/95] deps: V8: Backport of 0dd3390 from upstream
Original commit message:
Reland "[builtins] Add %IsTraceCategoryEnabled and %Trace builtins"
This is a reland of 8d4572a
Original change's description:
> [builtins] Add %IsTraceCategoryEnabled and %Trace builtins
>
> Adds the builtin Trace and IsTraceCategoryEnabled functions
> exposed via extra bindings. These are intended to use by
> embedders to allow basic trace event support from JavaScript.
>
> ```js
> isTraceCategoryEnabled('v8.some-category')
>
> trace('e'.charCodeAt(0), 'v8.some-category',
> 'Foo', 0, { abc: 'xyz'})
> ```
>
> Bug: v8:7851
> Change-Id: I7bfb9bb059efdf87d92a56a0aae326650730c250
> Reviewed-on: chromium-review.googlesource.com/1103294
> Commit-Queue: Yang Guo
> Reviewed-by: Yang Guo
> Reviewed-by: Fadi Meawad
> Reviewed-by: Camillo Bruni
> Reviewed-by: Benedikt Meurer
> Cr-Commit-Position: refs/heads/master@{#54121}
TBR=cbruni@chromium.org
Bug: v8:7851
Change-Id: Id063754b2834b3b6a2b2654e76e8637bcd6aa5f8
Reviewed-on: chromium-review.googlesource.com/1137071
Commit-Queue: Yang Guo
Reviewed-by: Yang Guo
Reviewed-by: Camillo Bruni
Reviewed-by: Benedikt Meurer
Cr-Commit-Position: refs/heads/master@{#54532}
PR-URL: https://github.com/nodejs/node/pull/21899
Reviewed-By: Ali Ijaz Sheikh
---
common.gypi | 2 +-
deps/v8/AUTHORS | 1 +
deps/v8/BUILD.gn | 1 +
deps/v8/gypfiles/v8.gyp | 1 +
deps/v8/src/bootstrapper.cc | 9 +
deps/v8/src/builtins/builtins-definitions.h | 6 +-
deps/v8/src/builtins/builtins-trace.cc | 191 ++++++++++++++++++++
deps/v8/src/debug/debug-evaluate.cc | 3 +
deps/v8/src/messages.h | 9 +-
deps/v8/test/cctest/test-trace-event.cc | 134 +++++++++++++-
10 files changed, 353 insertions(+), 4 deletions(-)
create mode 100644 deps/v8/src/builtins/builtins-trace.cc
diff --git a/common.gypi b/common.gypi
index 447ff992b46745..14fd67e411bcb8 100644
--- a/common.gypi
+++ b/common.gypi
@@ -28,7 +28,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
- 'v8_embedder_string': '-node.17',
+ 'v8_embedder_string': '-node.18',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS
index 4b5163961d282e..d1df5403e9c7a0 100644
--- a/deps/v8/AUTHORS
+++ b/deps/v8/AUTHORS
@@ -82,6 +82,7 @@ Jan de Mooij
Jan Krems
Jay Freeman
James Pike
+James M Snell
Jianghua Yang
Joel Stanley
Johan Bergström
diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn
index 4b48f7d6874df9..1d42461ba73128 100644
--- a/deps/v8/BUILD.gn
+++ b/deps/v8/BUILD.gn
@@ -1420,6 +1420,7 @@ v8_source_set("v8_base") {
"src/builtins/builtins-sharedarraybuffer.cc",
"src/builtins/builtins-string.cc",
"src/builtins/builtins-symbol.cc",
+ "src/builtins/builtins-trace.cc",
"src/builtins/builtins-typedarray.cc",
"src/builtins/builtins-utils.h",
"src/builtins/builtins.cc",
diff --git a/deps/v8/gypfiles/v8.gyp b/deps/v8/gypfiles/v8.gyp
index 80ce748d1fecab..99f868d1d38077 100644
--- a/deps/v8/gypfiles/v8.gyp
+++ b/deps/v8/gypfiles/v8.gyp
@@ -626,6 +626,7 @@
'../src/builtins/builtins-intl.cc',
'../src/builtins/builtins-intl.h',
'../src/builtins/builtins-symbol.cc',
+ '../src/builtins/builtins-trace.cc',
'../src/builtins/builtins-typedarray.cc',
'../src/builtins/builtins-utils.h',
'../src/builtins/builtins.cc',
diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc
index 2138b9c73d7db7..bbb374918a966a 100644
--- a/deps/v8/src/bootstrapper.cc
+++ b/deps/v8/src/bootstrapper.cc
@@ -4947,6 +4947,15 @@ bool Genesis::InstallExtraNatives() {
Handle extras_binding =
factory()->NewJSObject(isolate()->object_function());
+
+ // binding.isTraceCategoryenabled(category)
+ SimpleInstallFunction(extras_binding, "isTraceCategoryEnabled",
+ Builtins::kIsTraceCategoryEnabled, 1, true);
+
+ // binding.trace(phase, category, name, id, data)
+ SimpleInstallFunction(extras_binding, "trace", Builtins::kTrace, 5,
+ true);
+
native_context()->set_extras_binding_object(*extras_binding);
for (int i = ExtraNatives::GetDebuggerCount();
diff --git a/deps/v8/src/builtins/builtins-definitions.h b/deps/v8/src/builtins/builtins-definitions.h
index 5f06abeceb0d76..6ef4878fa189b1 100644
--- a/deps/v8/src/builtins/builtins-definitions.h
+++ b/deps/v8/src/builtins/builtins-definitions.h
@@ -1247,7 +1247,11 @@ namespace internal {
/* #sec-%asyncfromsynciteratorprototype%.return */ \
TFJ(AsyncFromSyncIteratorPrototypeReturn, 1, kValue) \
/* #sec-async-iterator-value-unwrap-functions */ \
- TFJ(AsyncIteratorValueUnwrap, 1, kValue)
+ TFJ(AsyncIteratorValueUnwrap, 1, kValue) \
+ \
+ /* Trace */ \
+ CPP(IsTraceCategoryEnabled) \
+ CPP(Trace)
#ifdef V8_INTL_SUPPORT
#define BUILTIN_LIST(CPP, API, TFJ, TFC, TFS, TFH, ASM) \
diff --git a/deps/v8/src/builtins/builtins-trace.cc b/deps/v8/src/builtins/builtins-trace.cc
new file mode 100644
index 00000000000000..a10c1363387db8
--- /dev/null
+++ b/deps/v8/src/builtins/builtins-trace.cc
@@ -0,0 +1,191 @@
+// Copyright 2018 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/api.h"
+#include "src/builtins/builtins-utils.h"
+#include "src/builtins/builtins.h"
+#include "src/counters.h"
+#include "src/json-stringifier.h"
+#include "src/objects-inl.h"
+
+namespace v8 {
+namespace internal {
+
+namespace {
+
+using v8::tracing::TracedValue;
+
+#define MAX_STACK_LENGTH 100
+
+class MaybeUtf8 {
+ public:
+ explicit MaybeUtf8(Isolate* isolate, Handle string) : buf_(data_) {
+ string = String::Flatten(string);
+ int len;
+ if (string->IsOneByteRepresentation()) {
+ // Technically this allows unescaped latin1 characters but the trace
+ // events mechanism currently does the same and the current consuming
+ // tools are tolerant of it. A more correct approach here would be to
+ // escape non-ascii characters but this is easier and faster.
+ len = string->length();
+ AllocateSufficientSpace(len);
+ if (len > 0) {
+ // Why copy? Well, the trace event mechanism requires null-terminated
+ // strings, the bytes we get from SeqOneByteString are not. buf_ is
+ // guaranteed to be null terminated.
+ memcpy(buf_, Handle::cast(string)->GetChars(), len);
+ }
+ } else {
+ Local local = Utils::ToLocal(string);
+ len = local->Utf8Length();
+ AllocateSufficientSpace(len);
+ if (len > 0) {
+ local->WriteUtf8(reinterpret_cast(buf_));
+ }
+ }
+ buf_[len] = 0;
+ }
+ const char* operator*() const { return reinterpret_cast(buf_); }
+
+ private:
+ void AllocateSufficientSpace(int len) {
+ if (len + 1 > MAX_STACK_LENGTH) {
+ allocated_.reset(new uint8_t[len + 1]);
+ buf_ = allocated_.get();
+ }
+ }
+
+ // In the most common cases, the buffer here will be stack allocated.
+ // A heap allocation will only occur if the data is more than MAX_STACK_LENGTH
+ // Given that this is used primarily for trace event categories and names,
+ // the MAX_STACK_LENGTH should be more than enough.
+ uint8_t* buf_;
+ uint8_t data_[MAX_STACK_LENGTH];
+ std::unique_ptr allocated_;
+};
+
+class JsonTraceValue : public ConvertableToTraceFormat {
+ public:
+ explicit JsonTraceValue(Isolate* isolate, Handle object) {
+ // object is a JSON string serialized using JSON.stringify() from within
+ // the BUILTIN(Trace) method. This may (likely) contain UTF8 values so
+ // to grab the appropriate buffer data we have to serialize it out. We
+ // hold on to the bits until the AppendAsTraceFormat method is called.
+ MaybeUtf8 data(isolate, object);
+ data_ = *data;
+ }
+
+ void AppendAsTraceFormat(std::string* out) const override { *out += data_; }
+
+ private:
+ std::string data_;
+};
+
+const uint8_t* GetCategoryGroupEnabled(Isolate* isolate,
+ Handle string) {
+ MaybeUtf8 category(isolate, string);
+ return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(*category);
+}
+
+#undef MAX_STACK_LENGTH
+
+} // namespace
+
+// Builins::kIsTraceCategoryEnabled(category) : bool
+BUILTIN(IsTraceCategoryEnabled) {
+ HandleScope scope(isolate);
+ Handle category = args.atOrUndefined(isolate, 1);
+ if (!category->IsString()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventCategoryError));
+ }
+ return isolate->heap()->ToBoolean(
+ *GetCategoryGroupEnabled(isolate, Handle::cast(category)));
+}
+
+// Builtins::kTrace(phase, category, name, id, data) : bool
+BUILTIN(Trace) {
+ HandleScope handle_scope(isolate);
+
+ Handle phase_arg = args.atOrUndefined(isolate, 1);
+ Handle category = args.atOrUndefined(isolate, 2);
+ Handle name_arg = args.atOrUndefined(isolate, 3);
+ Handle id_arg = args.atOrUndefined(isolate, 4);
+ Handle data_arg = args.atOrUndefined(isolate, 5);
+
+ const uint8_t* category_group_enabled =
+ GetCategoryGroupEnabled(isolate, Handle::cast(category));
+
+ // Exit early if the category group is not enabled.
+ if (!*category_group_enabled) {
+ return isolate->heap()->false_value();
+ }
+
+ if (!phase_arg->IsNumber()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventPhaseError));
+ }
+ if (!category->IsString()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventCategoryError));
+ }
+ if (!name_arg->IsString()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventNameError));
+ }
+
+ uint32_t flags = TRACE_EVENT_FLAG_COPY;
+ int32_t id = 0;
+ if (!id_arg->IsNullOrUndefined(isolate)) {
+ if (!id_arg->IsNumber()) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventIDError));
+ }
+ flags |= TRACE_EVENT_FLAG_HAS_ID;
+ id = DoubleToInt32(id_arg->Number());
+ }
+
+ Handle name_str = Handle::cast(name_arg);
+ if (name_str->length() == 0) {
+ THROW_NEW_ERROR_RETURN_FAILURE(
+ isolate, NewTypeError(MessageTemplate::kTraceEventNameLengthError));
+ }
+ MaybeUtf8 name(isolate, name_str);
+
+ // We support passing one additional trace event argument with the
+ // name "data". Any JSON serializable value may be passed.
+ static const char* arg_name = "data";
+ int32_t num_args = 0;
+ uint8_t arg_type;
+ uint64_t arg_value;
+
+ if (!data_arg->IsUndefined(isolate)) {
+ // Serializes the data argument as a JSON string, which is then
+ // copied into an object. This eliminates duplicated code but
+ // could have perf costs. It is also subject to all the same
+ // limitations as JSON.stringify() as it relates to circular
+ // references and value limitations (e.g. BigInt is not supported).
+ JsonStringifier stringifier(isolate);
+ Handle result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ stringifier.Stringify(data_arg, isolate->factory()->undefined_value(),
+ isolate->factory()->undefined_value()));
+ std::unique_ptr traced_value;
+ traced_value.reset(
+ new JsonTraceValue(isolate, Handle::cast(result)));
+ tracing::SetTraceValue(std::move(traced_value), &arg_type, &arg_value);
+ num_args++;
+ }
+
+ TRACE_EVENT_API_ADD_TRACE_EVENT(
+ static_cast(DoubleToInt32(phase_arg->Number())),
+ category_group_enabled, *name, tracing::kGlobalScope, id, tracing::kNoId,
+ num_args, &arg_name, &arg_type, &arg_value, flags);
+
+ return isolate->heap()->true_value();
+}
+
+} // namespace internal
+} // namespace v8
diff --git a/deps/v8/src/debug/debug-evaluate.cc b/deps/v8/src/debug/debug-evaluate.cc
index be456678299f6a..8efb23962cdec0 100644
--- a/deps/v8/src/debug/debug-evaluate.cc
+++ b/deps/v8/src/debug/debug-evaluate.cc
@@ -621,6 +621,9 @@ bool BuiltinHasNoSideEffect(Builtins::Name id) {
case Builtins::kArrayMap:
case Builtins::kArrayReduce:
case Builtins::kArrayReduceRight:
+ // Trace builtins
+ case Builtins::kIsTraceCategoryEnabled:
+ case Builtins::kTrace:
// TypedArray builtins.
case Builtins::kTypedArrayConstructor:
case Builtins::kTypedArrayPrototypeBuffer:
diff --git a/deps/v8/src/messages.h b/deps/v8/src/messages.h
index 187bd4d308a010..b2ce5dfa875325 100644
--- a/deps/v8/src/messages.h
+++ b/deps/v8/src/messages.h
@@ -755,7 +755,14 @@ class ErrorUtils : public AllStatic {
T(DataCloneDeserializationError, "Unable to deserialize cloned data.") \
T(DataCloneDeserializationVersionError, \
"Unable to deserialize cloned data due to invalid or unsupported " \
- "version.")
+ "version.") \
+ /* Builtins-Trace Errors */ \
+ T(TraceEventCategoryError, "Trace event category must be a string.") \
+ T(TraceEventNameError, "Trace event name must be a string.") \
+ T(TraceEventNameLengthError, \
+ "Trace event name must not be an empty string.") \
+ T(TraceEventPhaseError, "Trace event phase must be a number.") \
+ T(TraceEventIDError, "Trace event id must be a number.")
class MessageTemplate {
public:
diff --git a/deps/v8/test/cctest/test-trace-event.cc b/deps/v8/test/cctest/test-trace-event.cc
index 471619062a02d3..d2f8b69aac3ef5 100644
--- a/deps/v8/test/cctest/test-trace-event.cc
+++ b/deps/v8/test/cctest/test-trace-event.cc
@@ -75,7 +75,7 @@ class MockTracingController : public v8::TracingController {
const char* name, uint64_t handle) override {}
const uint8_t* GetCategoryGroupEnabled(const char* name) override {
- if (strcmp(name, "v8-cat")) {
+ if (strncmp(name, "v8-cat", 6)) {
static uint8_t no = 0;
return &no;
} else {
@@ -274,3 +274,135 @@ TEST(TestEventWithTimestamp) {
CHECK_EQ(13832, GET_TRACE_OBJECT(2)->timestamp);
CHECK_EQ(2, GET_TRACE_OBJECT(2)->num_args);
}
+
+TEST(BuiltinsIsTraceCategoryEnabled) {
+ CcTest::InitializeVM();
+ MockTracingPlatform platform;
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ LocalContext env;
+
+ v8::Local binding = env->GetExtrasBindingObject();
+ CHECK(!binding.IsEmpty());
+
+ auto undefined = v8::Undefined(isolate);
+ auto isTraceCategoryEnabled =
+ binding->Get(env.local(), v8_str("isTraceCategoryEnabled"))
+ .ToLocalChecked()
+ .As();
+
+ {
+ // Test with an enabled category
+ v8::Local argv[] = {v8_str("v8-cat")};
+ auto result = isTraceCategoryEnabled->Call(env.local(), undefined, 1, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(result->BooleanValue());
+ }
+
+ {
+ // Test with a disabled category
+ v8::Local argv[] = {v8_str("cat")};
+ auto result = isTraceCategoryEnabled->Call(env.local(), undefined, 1, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(!result->BooleanValue());
+ }
+
+ {
+ // Test with an enabled utf8 category
+ v8::Local argv[] = {v8_str("v8-cat\u20ac")};
+ auto result = isTraceCategoryEnabled->Call(env.local(), undefined, 1, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(result->BooleanValue());
+ }
+}
+
+TEST(BuiltinsTrace) {
+ CcTest::InitializeVM();
+ MockTracingPlatform platform;
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ LocalContext env;
+
+ v8::Local binding = env->GetExtrasBindingObject();
+ CHECK(!binding.IsEmpty());
+
+ auto undefined = v8::Undefined(isolate);
+ auto trace = binding->Get(env.local(), v8_str("trace"))
+ .ToLocalChecked()
+ .As();
+
+ // Test with disabled category
+ {
+ v8::Local category = v8_str("cat");
+ v8::Local name = v8_str("name");
+ v8::Local argv[] = {
+ v8::Integer::New(isolate, 'b'), // phase
+ category, name, v8::Integer::New(isolate, 0), // id
+ undefined // data
+ };
+ auto result = trace->Call(env.local(), undefined, 5, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(!result->BooleanValue());
+ CHECK_EQ(0, GET_TRACE_OBJECTS_LIST->size());
+ }
+
+ // Test with enabled category
+ {
+ v8::Local category = v8_str("v8-cat");
+ v8::Local name = v8_str("name");
+ v8::Local context = isolate->GetCurrentContext();
+ v8::Local data = v8::Object::New(isolate);
+ data->Set(context, v8_str("foo"), v8_str("bar")).FromJust();
+ v8::Local argv[] = {
+ v8::Integer::New(isolate, 'b'), // phase
+ category, name, v8::Integer::New(isolate, 123), // id
+ data // data arg
+ };
+ auto result = trace->Call(env.local(), undefined, 5, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(result->BooleanValue());
+ CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->size());
+
+ CHECK_EQ(123, GET_TRACE_OBJECT(0)->id);
+ CHECK_EQ('b', GET_TRACE_OBJECT(0)->phase);
+ CHECK_EQ("name", GET_TRACE_OBJECT(0)->name);
+ CHECK_EQ(1, GET_TRACE_OBJECT(0)->num_args);
+ }
+
+ // Test with enabled utf8 category
+ {
+ v8::Local category = v8_str("v8-cat\u20ac");
+ v8::Local name = v8_str("name\u20ac");
+ v8::Local context = isolate->GetCurrentContext();
+ v8::Local data = v8::Object::New(isolate);
+ data->Set(context, v8_str("foo"), v8_str("bar")).FromJust();
+ v8::Local argv[] = {
+ v8::Integer::New(isolate, 'b'), // phase
+ category, name, v8::Integer::New(isolate, 123), // id
+ data // data arg
+ };
+ auto result = trace->Call(env.local(), undefined, 5, argv)
+ .ToLocalChecked()
+ .As();
+
+ CHECK(result->BooleanValue());
+ CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size());
+
+ CHECK_EQ(123, GET_TRACE_OBJECT(1)->id);
+ CHECK_EQ('b', GET_TRACE_OBJECT(1)->phase);
+ CHECK_EQ("name\u20ac", GET_TRACE_OBJECT(1)->name);
+ CHECK_EQ(1, GET_TRACE_OBJECT(1)->num_args);
+ }
+}
From cfeed2b1935f1a6c4565861d9211999ea492d3dd Mon Sep 17 00:00:00 2001
From: James M Snell
Date: Mon, 14 May 2018 09:25:50 -0700
Subject: [PATCH 40/95] trace_events: add support for builtin trace
PR-URL: https://github.com/nodejs/node/pull/21899
Reviewed-By: Ali Ijaz Sheikh
---
benchmark/misc/trace.js | 75 +++++++++++++++++++++++++
src/node_constants.cc | 35 ++++++++++++
src/node_trace_events.cc | 13 +++++
test/parallel/test-binding-constants.js | 6 +-
4 files changed, 126 insertions(+), 3 deletions(-)
create mode 100644 benchmark/misc/trace.js
diff --git a/benchmark/misc/trace.js b/benchmark/misc/trace.js
new file mode 100644
index 00000000000000..75c87d363a6b03
--- /dev/null
+++ b/benchmark/misc/trace.js
@@ -0,0 +1,75 @@
+'use strict';
+
+const common = require('../common.js');
+
+const bench = common.createBenchmark(main, {
+ n: [100000],
+ method: ['trace', 'emit', 'isTraceCategoryEnabled', 'categoryGroupEnabled']
+}, {
+ flags: ['--expose-internals', '--trace-event-categories', 'foo']
+});
+
+const {
+ trace,
+ isTraceCategoryEnabled,
+ emit,
+ categoryGroupEnabled
+} = process.binding('trace_events');
+
+const {
+ TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN: kBeforeEvent
+} = process.binding('constants').trace;
+
+function doEmit(n) {
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ emit(kBeforeEvent, 'foo', 'test', 0, 'arg1', 1);
+ }
+ bench.end(n);
+}
+
+function doTrace(n) {
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ trace(kBeforeEvent, 'foo', 'test', 0, 'test');
+ }
+ bench.end(n);
+}
+
+function doIsTraceCategoryEnabled(n) {
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ isTraceCategoryEnabled('foo');
+ isTraceCategoryEnabled('bar');
+ }
+ bench.end(n);
+}
+
+function doCategoryGroupEnabled(n) {
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ categoryGroupEnabled('foo');
+ categoryGroupEnabled('bar');
+ }
+ bench.end(n);
+}
+
+function main({ n, method }) {
+ switch (method) {
+ case '':
+ case 'trace':
+ doTrace(n);
+ break;
+ case 'emit':
+ doEmit(n);
+ break;
+ case 'isTraceCategoryEnabled':
+ doIsTraceCategoryEnabled(n);
+ break;
+ case 'categoryGroupEnabled':
+ doCategoryGroupEnabled(n);
+ break;
+ default:
+ throw new Error(`Unexpected method "${method}"`);
+ }
+}
diff --git a/src/node_constants.cc b/src/node_constants.cc
index c1e39244b359b4..61aa42a8efb6b2 100644
--- a/src/node_constants.cc
+++ b/src/node_constants.cc
@@ -1282,6 +1282,35 @@ void DefineDLOpenConstants(Local target) {
#endif
}
+void DefineTraceConstants(Local target) {
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_BEGIN);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_END);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_COMPLETE);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_INSTANT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_BEGIN);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_STEP_INTO);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_STEP_PAST);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ASYNC_END);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_END);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_BEGIN);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_STEP);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_FLOW_END);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_METADATA);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_COUNTER);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_SAMPLE);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_CREATE_OBJECT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_SNAPSHOT_OBJECT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_DELETE_OBJECT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_MEMORY_DUMP);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_MARK);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_CLOCK_SYNC);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_ENTER_CONTEXT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_LEAVE_CONTEXT);
+ NODE_DEFINE_CONSTANT(target, TRACE_EVENT_PHASE_LINK_IDS);
+}
+
} // anonymous namespace
void DefineConstants(v8::Isolate* isolate, Local target) {
@@ -1315,6 +1344,10 @@ void DefineConstants(v8::Isolate* isolate, Local target) {
CHECK(dlopen_constants->SetPrototype(env->context(),
Null(env->isolate())).FromJust());
+ Local trace_constants = Object::New(isolate);
+ CHECK(trace_constants->SetPrototype(env->context(),
+ Null(env->isolate())).FromJust());
+
DefineErrnoConstants(err_constants);
DefineWindowsErrorConstants(err_constants);
DefineSignalConstants(sig_constants);
@@ -1323,6 +1356,7 @@ void DefineConstants(v8::Isolate* isolate, Local target) {
DefineCryptoConstants(crypto_constants);
DefineZlibConstants(zlib_constants);
DefineDLOpenConstants(dlopen_constants);
+ DefineTraceConstants(trace_constants);
// Define libuv constants.
NODE_DEFINE_CONSTANT(os_constants, UV_UDP_REUSEADDR);
@@ -1334,6 +1368,7 @@ void DefineConstants(v8::Isolate* isolate, Local target) {
target->Set(OneByteString(isolate, "fs"), fs_constants);
target->Set(OneByteString(isolate, "crypto"), crypto_constants);
target->Set(OneByteString(isolate, "zlib"), zlib_constants);
+ target->Set(OneByteString(isolate, "trace"), trace_constants);
}
} // namespace node
diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc
index 0904311dad865b..a2f42249483cd7 100644
--- a/src/node_trace_events.cc
+++ b/src/node_trace_events.cc
@@ -232,6 +232,19 @@ void Initialize(Local target,
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "CategorySet"),
category_set->GetFunction());
+
+ Local isTraceCategoryEnabled =
+ FIXED_ONE_BYTE_STRING(env->isolate(), "isTraceCategoryEnabled");
+ Local trace = FIXED_ONE_BYTE_STRING(env->isolate(), "trace");
+
+ // Grab the trace and isTraceCategoryEnabled intrinsics from the binding
+ // object and expose those to our binding layer.
+ Local binding = context->GetExtrasBindingObject();
+ target->Set(context, isTraceCategoryEnabled,
+ binding->Get(context, isTraceCategoryEnabled).ToLocalChecked())
+ .FromJust();
+ target->Set(context, trace,
+ binding->Get(context, trace).ToLocalChecked()).FromJust();
}
} // namespace node
diff --git a/test/parallel/test-binding-constants.js b/test/parallel/test-binding-constants.js
index aaf0ebde5230a8..b8e852b3525ab8 100644
--- a/test/parallel/test-binding-constants.js
+++ b/test/parallel/test-binding-constants.js
@@ -5,7 +5,7 @@ const constants = process.binding('constants');
const assert = require('assert');
assert.deepStrictEqual(
- Object.keys(constants).sort(), ['crypto', 'fs', 'os', 'zlib']
+ Object.keys(constants).sort(), ['crypto', 'fs', 'os', 'trace', 'zlib']
);
assert.deepStrictEqual(
@@ -26,6 +26,6 @@ function test(obj) {
}
[
- constants, constants.crypto, constants.fs, constants.os, constants.zlib,
- constants.os.dlopen, constants.os.errno, constants.os.signals
+ constants, constants.crypto, constants.fs, constants.os, constants.trace,
+ constants.zlib, constants.os.dlopen, constants.os.errno, constants.os.signals
].forEach(test);
From 5e562fd792c5fb7482820a13307f42a6782fbf1d Mon Sep 17 00:00:00 2001
From: Vse Mozhet Byt
Date: Sun, 22 Jul 2018 13:09:30 +0300
Subject: [PATCH 41/95] doc: fix sorting in the `vm.Module` section
PR-URL: https://github.com/nodejs/node/pull/21931
Reviewed-By: Luigi Pinca
Reviewed-By: Benjamin Gruenbaum
---
doc/api/vm.md | 130 +++++++++++++++++++++++++-------------------------
1 file changed, 65 insertions(+), 65 deletions(-)
diff --git a/doc/api/vm.md b/doc/api/vm.md
index f294e7301bd799..6c127786a71fef 100644
--- a/doc/api/vm.md
+++ b/doc/api/vm.md
@@ -234,71 +234,6 @@ exception due to possible ambiguity with `throw undefined;`.
Corresponds to the `[[EvaluationError]]` field of [Source Text Module Record][]s
in the ECMAScript specification.
-### module.linkingStatus
-
-* {string}
-
-The current linking status of `module`. It will be one of the following values:
-
-- `'unlinked'`: `module.link()` has not yet been called.
-- `'linking'`: `module.link()` has been called, but not all Promises returned by
- the linker function have been resolved yet.
-- `'linked'`: `module.link()` has been called, and all its dependencies have
- been successfully linked.
-- `'errored'`: `module.link()` has been called, but at least one of its
- dependencies failed to link, either because the callback returned a `Promise`
- that is rejected, or because the `Module` the callback returned is invalid.
-
-### module.namespace
-
-* {Object}
-
-The namespace object of the module. This is only available after instantiation
-(`module.instantiate()`) has completed.
-
-Corresponds to the [GetModuleNamespace][] abstract operation in the ECMAScript
-specification.
-
-### module.status
-
-* {string}
-
-The current status of the module. Will be one of:
-
-- `'uninstantiated'`: The module is not instantiated. It may because of any of
- the following reasons:
-
- - The module was just created.
- - `module.instantiate()` has been called on this module, but it failed for
- some reason.
-
- This status does not convey any information regarding if `module.link()` has
- been called. See `module.linkingStatus` for that.
-
-- `'instantiating'`: The module is currently being instantiated through a
- `module.instantiate()` call on itself or a parent module.
-
-- `'instantiated'`: The module has been instantiated successfully, but
- `module.evaluate()` has not yet been called.
-
-- `'evaluating'`: The module is being evaluated through a `module.evaluate()` on
- itself or a parent module.
-
-- `'evaluated'`: The module has been successfully evaluated.
-
-- `'errored'`: The module has been evaluated, but an exception was thrown.
-
-Other than `'errored'`, this status string corresponds to the specification's
-[Source Text Module Record][]'s `[[Status]]` field. `'errored'` corresponds to
-`'evaluated'` in the specification, but with `[[EvaluationError]]` set to a
-value that is not `undefined`.
-
-### module.url
-
-* {string}
-
-The URL of the current module, as set in the constructor.
-
### module.evaluate([options])
* `options` {Object}
@@ -395,6 +330,71 @@ that point all modules would have been fully linked already, the
[HostResolveImportedModule][] implementation is fully synchronous per
specification.
+### module.linkingStatus
+
+* {string}
+
+The current linking status of `module`. It will be one of the following values:
+
+- `'unlinked'`: `module.link()` has not yet been called.
+- `'linking'`: `module.link()` has been called, but not all Promises returned by
+ the linker function have been resolved yet.
+- `'linked'`: `module.link()` has been called, and all its dependencies have
+ been successfully linked.
+- `'errored'`: `module.link()` has been called, but at least one of its
+ dependencies failed to link, either because the callback returned a `Promise`
+ that is rejected, or because the `Module` the callback returned is invalid.
+
+### module.namespace
+
+* {Object}
+
+The namespace object of the module. This is only available after instantiation
+(`module.instantiate()`) has completed.
+
+Corresponds to the [GetModuleNamespace][] abstract operation in the ECMAScript
+specification.
+
+### module.status
+
+* {string}
+
+The current status of the module. Will be one of:
+
+- `'uninstantiated'`: The module is not instantiated. It may because of any of
+ the following reasons:
+
+ - The module was just created.
+ - `module.instantiate()` has been called on this module, but it failed for
+ some reason.
+
+ This status does not convey any information regarding if `module.link()` has
+ been called. See `module.linkingStatus` for that.
+
+- `'instantiating'`: The module is currently being instantiated through a
+ `module.instantiate()` call on itself or a parent module.
+
+- `'instantiated'`: The module has been instantiated successfully, but
+ `module.evaluate()` has not yet been called.
+
+- `'evaluating'`: The module is being evaluated through a `module.evaluate()` on
+ itself or a parent module.
+
+- `'evaluated'`: The module has been successfully evaluated.
+
+- `'errored'`: The module has been evaluated, but an exception was thrown.
+
+Other than `'errored'`, this status string corresponds to the specification's
+[Source Text Module Record][]'s `[[Status]]` field. `'errored'` corresponds to
+`'evaluated'` in the specification, but with `[[EvaluationError]]` set to a
+value that is not `undefined`.
+
+### module.url
+
+* {string}
+
+The URL of the current module, as set in the constructor.
+
## Class: vm.Script
' is a single-line comment
- this.index += 3;
- var comment = this.skipSingleLineComment(3);
- if (this.trackComment) {
- comments = comments.concat(comment);
- }
- }
- else {
- break;
- }
- }
- else if (ch === 0x3C) {
- if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
- this.index += 4; // `' is a single-line comment
+ this.index += 3;
+ var comment = this.skipSingleLineComment(3);
+ if (this.trackComment) {
+ comments = comments.concat(comment);
+ }
+ }
+ else {
+ break;
+ }
+ }
+ else if (ch === 0x3C && !this.isModule) {
+ if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
+ this.index += 4; // `
-
-### supporting information:
-
- - `npm -v` prints:
- - `node -v` prints:
- - `npm config get registry` prints:
- - Windows, OS X/macOS, or Linux?:
- - Network issues:
- - Geographic location where npm was run:
- - [ ] I use a proxy to connect to the npm registry.
- - [ ] I use a proxy to connect to the web.
- - [ ] I use a proxy when downloading Git repos.
- - [ ] I access the npm registry via a VPN
- - [ ] I don't use a proxy, but have limited or unreliable internet access.
- - Container:
- - [ ] I develop using Vagrant on Windows.
- - [ ] I develop using Vagrant on OS X or Linux.
- - [ ] I develop / deploy using Docker.
- - [ ] I deploy to a PaaS (Triton, Heroku).
-
-
-
-
diff --git a/deps/npm/.npmignore b/deps/npm/.npmignore
index 6b9f1ecefbd9e8..1b32b033e23a72 100644
--- a/deps/npm/.npmignore
+++ b/deps/npm/.npmignore
@@ -1,6 +1,7 @@
*.swp
.*.swp
npm-debug.log
+/.github
/test
node_modules/marked
node_modules/ronn
diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS
index f0cae95e96e100..4b9b627102d6bc 100644
--- a/deps/npm/AUTHORS
+++ b/deps/npm/AUTHORS
@@ -570,3 +570,17 @@ Tieme van Veen
Finn Pauls
Jeremy Kahn
Mertcan Mermerkaya
+Will Yardley
+Matt Travi
+Solomon Victorino
+Rich Trott
+Maksym Kobieliev
+Thomas Reggi
+David Gilbertson
+Rob Lourens
+Karan Thakkar
+Howard T. Chiam
+Geoffrey Mattie
+Luis Lobo Borobia
+Aaron Tribou
+刘祺
diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md
index e292478eabf9c4..f07b39a2e5565a 100644
--- a/deps/npm/CHANGELOG.md
+++ b/deps/npm/CHANGELOG.md
@@ -1,3 +1,221 @@
+## v6.2.0 (2018-07-13):
+
+In case you missed it, [we
+moved!](https://blog.npmjs.org/post/175587538995/announcing-npmcommunity). We
+look forward to seeing future PRs landing in
+[npm/cli](https://github.com/npm/cli) in the future, and we'll be chatting with
+you all in [npm.community](https://npm.community). Go check it out!
+
+This final release of `npm@6.2.0` includes a couple of features that weren't
+quite ready on time but that we'd still like to include. Enjoy!
+
+### FEATURES
+
+* [`244b18380`](https://github.com/npm/npm/commit/244b18380ee55950b13c293722771130dbad70de)
+ [#20554](https://github.com/npm/npm/pull/20554)
+ add support for --parseable output
+ ([@luislobo](https://github.com/luislobo))
+* [`7984206e2`](https://github.com/npm/npm/commit/7984206e2f41b8d8361229cde88d68f0c96ed0b8)
+ [#12697](https://github.com/npm/npm/pull/12697)
+ Add new `sign-git-commit` config to control whether the git commit itself gets
+ signed, or just the tag (which is the default).
+ ([@tribou](https://github.com/tribou))
+
+### FIXES
+
+* [`4c32413a5`](https://github.com/npm/npm/commit/4c32413a5b42e18a34afb078cf00eed60f08e4ff)
+ [#19418](https://github.com/npm/npm/pull/19418)
+ Do not use `SET` to fetch the env in git-bash or Cygwin.
+ ([@gucong3000](https://github.com/gucong3000))
+
+### DEPENDENCY BUMPS
+
+* [`d9b2712a6`](https://github.com/npm/npm/commit/d9b2712a670e5e78334e83f89a5ed49616f1f3d3)
+ `request@2.81.0`: Downgraded to allow better deduplication. This does
+ introduce a bunch of `hoek`-related audit reports, but they don't affect npm
+ itself so we consider it safe. We'll upgrade `request` again once `node-gyp`
+ unpins it.
+ ([@simov](https://github.com/simov))
+* [`2ac48f863`](https://github.com/npm/npm/commit/2ac48f863f90166b2bbf2021ed4cc04343d2503c)
+ `node-gyp@3.7.0`
+ ([@MylesBorins](https://github.com/MylesBorins))
+* [`8dc6d7640`](https://github.com/npm/npm/commit/8dc6d76408f83ba35bda77a2ac1bdbde01937349)
+ `cli-table3@0.5.0`: `cli-table2` is unmaintained and required `lodash`. With
+ this dependency bump, we've removed `lodash` from our tree, which cut back
+ tarball size by another 300kb.
+ ([@Turbo87](https://github.com/Turbo87))
+* [`90c759fee`](https://github.com/npm/npm/commit/90c759fee6055cf61cf6709432a5e6eae6278096)
+ `npm-audit-report@1.3.1`
+ ([@zkat](https://github.com/zkat))
+* [`4231a0a1e`](https://github.com/npm/npm/commit/4231a0a1eb2be13931c3b71eba38c0709644302c)
+ Add `cli-table3` to bundleDeps.
+ ([@iarna](https://github.com/iarna))
+* [`322d9c2f1`](https://github.com/npm/npm/commit/322d9c2f107fd82a4cbe2f9d7774cea5fbf41b8d)
+ Make `standard` happy.
+ ([@iarna](https://github.com/iarna))
+
+### DOCS
+
+* [`5724983ea`](https://github.com/npm/npm/commit/5724983ea8f153fb122f9c0ccab6094a26dfc631)
+ [#21165](https://github.com/npm/npm/pull/21165)
+ Fix some markdown formatting in npm-disputes.md.
+ ([@hchiam](https://github.com/hchiam))
+* [`738178315`](https://github.com/npm/npm/commit/738178315fe48e463028657ea7ae541c3d63d171)
+ [#20920](https://github.com/npm/npm/pull/20920)
+ Explicitly state that republishing an unpublished package requires a 72h
+ waiting period.
+ ([@gmattie](https://github.com/gmattie))
+* [`f0a372b07`](https://github.com/npm/npm/commit/f0a372b074cc43ee0e1be28dbbcef0d556b3b36c)
+ Replace references to the old repo or issue tracker. We're at npm/cli now!
+ ([@zkat](https://github.com/zkat))
+
+## v6.2.0-next.1 (2018-07-05):
+
+This is a quick patch to the release to fix an issue that was preventing users
+from installing `npm@next`.
+
+* [`ecdcbd745`](https://github.com/npm/npm/commit/ecdcbd745ae1edd9bdd102dc3845a7bc76e1c5fb)
+ [#21129](https://github.com/npm/npm/pull/21129)
+ Remove postinstall script that depended on source files, thus preventing
+ `npm@next` from being installable from the registry.
+ ([@zkat](https://github.com/zkat))
+
+## v6.2.0-next.0 (2018-06-28):
+
+### NEW FEATURES
+
+* [`ce0793358`](https://github.com/npm/npm/commit/ce07933588ec2da1cc1980f93bdaa485d6028ae2)
+ [#20750](https://github.com/npm/npm/pull/20750)
+ You can now disable the update notifier entirely by using
+ `--no-update-notifier` or setting it in your config with `npm config set
+ update-notifier false`.
+ ([@travi](https://github.com/travi))
+* [`d2ad776f6`](https://github.com/npm/npm/commit/d2ad776f6dcd92ae3937465736dcbca171131343)
+ [#20879](https://github.com/npm/npm/pull/20879)
+ When `npm run-script
```
-This bundle can be used with different module systems; it creates global `Ajv` if no module system is found.
+This bundle can be used with different module systems or creates global `Ajv` if no module system is found.
The browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv).
@@ -188,7 +174,6 @@ CLI is available as a separate npm package [ajv-cli](https://github.com/jessedc/
- compiling JSON-schemas to test their validity
- BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/epoberezkin/ajv-pack))
-- migrate schemas to draft-06 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate))
- validating data file(s) against JSON-schema
- testing expected validity of data against JSON-schema
- referenced schemas
@@ -205,18 +190,20 @@ Ajv supports all validation keywords from draft 4 of JSON-schema standard:
- [type](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#type)
- [for numbers](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-numbers) - maximum, minimum, exclusiveMaximum, exclusiveMinimum, multipleOf
- [for strings](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-strings) - maxLength, minLength, pattern, format
-- [for arrays](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems, [contains](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#contains)
-- [for objects](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minProperties, required, properties, patternProperties, additionalProperties, dependencies, [propertyNames](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#propertynames)
-- [for all types](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, [const](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#const)
-- [compound keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#compound-keywords) - not, oneOf, anyOf, allOf
+- [for arrays](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems
+- [for objects](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minproperties, required, properties, patternProperties, additionalProperties, dependencies
+- [compound keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, not, oneOf, anyOf, allOf
-With [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package Ajv also supports validation keywords from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON-schema standard:
+With option `v5: true` Ajv also supports all validation keywords and [$data reference](#data-reference) from [v5 proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON-schema standard:
-- [switch](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#switch-proposed) - conditional validation with a sequence of if/then clauses
-- [patternRequired](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#patternrequired-proposed) - like `required` but with patterns that some property should match.
-- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-proposed) - setting limits for date, time, etc.
+- [switch](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#switch-v5-proposal) - conditional validation with a sequence of if/then clauses
+- [contains](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#contains-v5-proposal) - check that array contains a valid item
+- [constant](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#constant-v5-proposal) - check that data is equal to some value
+- [patternGroups](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#patterngroups-v5-proposal) - a more powerful alternative to patternProperties
+- [patternRequired](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#patternrequired-v5-proposal) - like `required` but with patterns that some property should match.
+- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-v5-proposal) - setting limits for date, time, etc.
-See [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md) for more details.
+See [JSON-Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md) for more details.
## Formats
@@ -227,10 +214,8 @@ The following formats are supported for string validation with "format" keyword:
- _time_: time with optional time-zone.
- _date-time_: date-time from the same source (time-zone is mandatory). `date`, `time` and `date-time` validate ranges in `full` mode and only regexp in `fast` mode (see [options](#options)).
- _uri_: full uri with optional protocol.
-- _url_: [URL record](https://url.spec.whatwg.org/#concept-url).
-- _uri-template_: URI template according to [RFC6570](https://tools.ietf.org/html/rfc6570)
- _email_: email address.
-- _hostname_: host name according to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5).
+- _hostname_: host name acording to [RFC1034](http://tools.ietf.org/html/rfc1034#section-3.5).
- _ipv4_: IP address v4.
- _ipv6_: IP address v6.
- _regex_: tests whether a string is a valid regular expression by passing it to RegExp constructor.
@@ -242,68 +227,16 @@ There are two modes of format validation: `fast` and `full`. This mode affects f
You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method.
-The option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can whitelist specific format(s) to be ignored. See [Options](#options) for details.
+The option `unknownFormats` allows to change the behaviour in case an unknown format is encountered - Ajv can either ignore them (default now) or fail schema compilation (will be the default in 5.0.0).
You can find patterns used for format validation and the sources that were used in [formats.js](https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js).
-## Combining schemas with $ref
-
-You can structure your validation logic across multiple schema files and have schemas reference each other using `$ref` keyword.
-
-Example:
-
-```javascript
-var schema = {
- "$id": "http://example.com/schemas/schema.json",
- "type": "object",
- "properties": {
- "foo": { "$ref": "defs.json#/definitions/int" },
- "bar": { "$ref": "defs.json#/definitions/str" }
- }
-};
-
-var defsSchema = {
- "$id": "http://example.com/schemas/defs.json",
- "definitions": {
- "int": { "type": "integer" },
- "str": { "type": "string" }
- }
-};
-```
-
-Now to compile your schema you can either pass all schemas to Ajv instance:
-
-```javascript
-var ajv = new Ajv({schemas: [schema, defsSchema]});
-var validate = ajv.getSchema('http://example.com/schemas/schema.json');
-```
-
-or use `addSchema` method:
-
-```javascript
-var ajv = new Ajv;
-var validate = ajv.addSchema(defsSchema)
- .compile(schema);
-```
-
-See [Options](#options) and [addSchema](#api) method.
-
-__Please note__:
-- `$ref` is resolved as the uri-reference using schema $id as the base URI (see the example).
-- References can be recursive (and mutually recursive) to implement the schemas for different data structures (such as linked lists, trees, graphs, etc.).
-- You don't have to host your schema files at the URIs that you use as schema $id. These URIs are only used to identify the schemas, and according to JSON Schema specification validators should not expect to be able to download the schemas from these URIs.
-- The actual location of the schema file in the file system is not used.
-- You can pass the identifier of the schema as the second parameter of `addSchema` method or as a property name in `schemas` option. This identifier can be used instead of (or in addition to) schema $id.
-- You cannot have the same $id (or the schema identifier) used for more than one schema - the exception will be thrown.
-- You can implement dynamic resolution of the referenced schemas using `compileAsync` method. In this way you can store schemas in any system (files, web, database, etc.) and reference them without explicitly adding to Ajv instance. See [Asynchronous schema compilation](#asynchronous-schema-compilation).
-
-
## $data reference
-With `$data` option you can use values from the validated data as the values for the schema keywords. See [proposal](https://github.com/json-schema/json-schema/wiki/$data-(v5-proposal)) for more information about how it works.
+With `v5` option you can use values from the validated data as the values for the schema keywords. See [v5 proposal](https://github.com/json-schema/json-schema/wiki/$data-(v5-proposal)) for more information about how it works.
-`$data` reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems.
+`$data` reference is supported in the keywords: constant, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems.
The value of "$data" should be a [JSON-pointer](https://tools.ietf.org/html/rfc6901) to the data (the root is always the top level data object, even if the $data reference is inside a referenced subschema) or a [relative JSON-pointer](http://tools.ietf.org/html/draft-luff-relative-json-pointer-00) (it is relative to the current point in data; if the $data reference is inside a referenced subschema it cannot point to the data outside of the root level for this subschema).
@@ -312,8 +245,6 @@ Examples.
This schema requires that the value in property `smaller` is less or equal than the value in the property larger:
```javascript
-var ajv = new Ajv({$data: true});
-
var schema = {
"properties": {
"smaller": {
@@ -328,8 +259,6 @@ var validData = {
smaller: 5,
larger: 7
};
-
-ajv.validate(schema, validData); // true
```
This schema requires that the properties have the same format as their field names:
@@ -348,12 +277,12 @@ var validData = {
}
```
-`$data` reference is resolved safely - it won't throw even if some property is undefined. If `$data` resolves to `undefined` the validation succeeds (with the exclusion of `const` keyword). If `$data` resolves to incorrect type (e.g. not "number" for maximum keyword) the validation fails.
+`$data` reference is resolved safely - it won't throw even if some property is undefined. If `$data` resolves to `undefined` the validation succeeds (with the exclusion of `constant` keyword). If `$data` resolves to incorrect type (e.g. not "number" for maximum keyword) the validation fails.
## $merge and $patch keywords
-With the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON-schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902).
+With v5 option and the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON-schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902).
To add keywords `$merge` and `$patch` to Ajv instance use this code:
@@ -419,7 +348,7 @@ See the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch
The advantages of using custom keywords are:
-- allow creating validation scenarios that cannot be expressed using JSON Schema
+- allow creating validation scenarios that cannot be expressed using JSON-Schema
- simplify your schemas
- help bringing a bigger part of the validation logic to your schemas
- make your schemas more expressive, less verbose and closer to your application domain
@@ -440,17 +369,14 @@ Ajv allows defining keywords with:
Example. `range` and `exclusiveRange` keywords using compiled schema:
```javascript
-ajv.addKeyword('range', {
- type: 'number',
- compile: function (sch, parentSchema) {
- var min = sch[0];
- var max = sch[1];
+ajv.addKeyword('range', { type: 'number', compile: function (sch, parentSchema) {
+ var min = sch[0];
+ var max = sch[1];
- return parentSchema.exclusiveRange === true
- ? function (data) { return data > min && data < max; }
- : function (data) { return data >= min && data <= max; }
- }
-});
+ return parentSchema.exclusiveRange === true
+ ? function (data) { return data > min && data < max; }
+ : function (data) { return data >= min && data <= max; }
+} });
var schema = { "range": [2, 4], "exclusiveRange": true };
var validate = ajv.compile(schema);
@@ -465,26 +391,27 @@ Several custom keywords (typeof, instanceof, range and propertyNames) are define
See [Defining custom keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md) for more details.
-## Asynchronous schema compilation
+## Asynchronous compilation
-During asynchronous compilation remote references are loaded using supplied function. See `compileAsync` [method](#api-compileAsync) and `loadSchema` [option](#options).
+During asynchronous compilation remote references are loaded using supplied function. See `compileAsync` method and `loadSchema` [option](#options).
Example:
```javascript
var ajv = new Ajv({ loadSchema: loadSchema });
-ajv.compileAsync(schema).then(function (validate) {
- var valid = validate(data);
- // ...
+ajv.compileAsync(schema, function (err, validate) {
+ if (err) return;
+ var valid = validate(data);
});
-function loadSchema(uri) {
- return request.json(uri).then(function (res) {
- if (res.statusCode >= 400)
- throw new Error('Loading error: ' + res.statusCode);
- return res.body;
- });
+function loadSchema(uri, callback) {
+ request.json(uri, function(err, res, body) {
+ if (err || res.statusCode >= 400)
+ callback(err || new Error('Loading error: ' + res.statusCode));
+ else
+ callback(null, body);
+ });
}
```
@@ -493,47 +420,37 @@ __Please note__: [Option](#options) `missingRefs` should NOT be set to `"ignore"
## Asynchronous validation
-Example in Node.js REPL: https://tonicdev.com/esp/ajv-asynchronous-validation
+Example in node REPL: https://tonicdev.com/esp/ajv-asynchronous-validation
-You can define custom formats and keywords that perform validation asynchronously by accessing database or some other service. You should add `async: true` in the keyword or format definition (see [addFormat](#api-addformat), [addKeyword](#api-addkeyword) and [Defining custom keywords](#defining-custom-keywords)).
+You can define custom formats and keywords that perform validation asyncronously by accessing database or some service. You should add `async: true` in the keyword or format defnition (see [addFormat](#api-addformat), [addKeyword](#api-addkeyword) and [Defining custom keywords](#defining-custom-keywords)).
If your schema uses asynchronous formats/keywords or refers to some schema that contains them it should have `"$async": true` keyword so that Ajv can compile it correctly. If asynchronous format/keyword or reference to asynchronous schema is used in the schema without `$async` keyword Ajv will throw an exception during schema compilation.
__Please note__: all asynchronous subschemas that are referenced from the current or other schemas should have `"$async": true` keyword as well, otherwise the schema compilation will fail.
-Validation function for an asynchronous custom format/keyword should return a promise that resolves with `true` or `false` (or rejects with `new Ajv.ValidationError(errors)` if you want to return custom errors from the keyword function). Ajv compiles asynchronous schemas to either [es7 async functions](http://tc39.github.io/ecmascript-asyncawait/) that can optionally be transpiled with [nodent](https://github.com/MatAtBread/nodent) or with [regenerator](https://github.com/facebook/regenerator) or to [generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) that can be optionally transpiled with regenerator as well. You can also supply any other transpiler as a function. See [Options](#options).
+Validation function for an asynchronous custom format/keyword should return a promise that resolves to `true` or `false` (or rejects with `new Ajv.ValidationError(errors)` if you want to return custom errors from the keyword function). Ajv compiles asynchronous schemas to either [generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) (default) that can be optionally transpiled with [regenerator](https://github.com/facebook/regenerator) or to [es7 async function](http://tc39.github.io/ecmascript-asyncawait/) that can be transpiled with [nodent](https://github.com/MatAtBread/nodent) or with regenerator as well. You can also supply any other transpiler as a function. See [Options](#options).
-The compiled validation function has `$async: true` property (if the schema is asynchronous), so you can differentiate these functions if you are using both synchronous and asynchronous schemas.
+The compiled validation function has `$async: true` property (if the schema is asynchronous), so you can differentiate these functions if you are using both syncronous and asynchronous schemas.
If you are using generators, the compiled validation function can be either wrapped with [co](https://github.com/tj/co) (default) or returned as generator function, that can be used directly, e.g. in [koa](http://koajs.com/) 1.0. `co` is a small library, it is included in Ajv (both as npm dependency and in the browser bundle).
-Async functions are currently supported in Chrome 55, Firefox 52, Node.js 7 (with --harmony-async-await) and MS Edge 13 (with flag).
-
-Generator functions are currently supported in Chrome, Firefox and Node.js.
+Generator functions are currently supported in Chrome, Firefox and node.js (0.11+); if you are using Ajv in other browsers or in older versions of node.js you should use one of available transpiling options. All provided async modes use global Promise class. If your platform does not have Promise you should use a polyfill that defines it.
-If you are using Ajv in other browsers or in older versions of Node.js you should use one of available transpiling options. All provided async modes use global Promise class. If your platform does not have Promise you should use a polyfill that defines it.
-
-Validation result will be a promise that resolves with validated data or rejects with an exception `Ajv.ValidationError` that contains the array of validation errors in `errors` property.
+Validation result will be a promise that resolves to `true` or rejects with an exception `Ajv.ValidationError` that has the array of validation errors in `errors` property.
Example:
```javascript
/**
- * Default mode is non-transpiled generator function wrapped with `co`.
- * Using package ajv-async (https://github.com/epoberezkin/ajv-async)
- * you can auto-detect the best async mode.
- * In this case, without "async" and "transpile" options
- * (or with option {async: true})
+ * without "async" and "transpile" options (or with option {async: true})
* Ajv will choose the first supported/installed option in this order:
- * 1. native async function
- * 2. native generator function wrapped with co
- * 3. es7 async functions transpiled with nodent
- * 4. es7 async functions transpiled with regenerator
+ * 1. native generator function wrapped with co
+ * 2. es7 async functions transpiled with nodent
+ * 3. es7 async functions transpiled with regenerator
*/
-var setupAsync = require('ajv-async');
-var ajv = setupAsync(new Ajv);
+var ajv = new Ajv;
ajv.addKeyword('idExists', {
async: true,
@@ -567,18 +484,20 @@ var schema = {
var validate = ajv.compile(schema);
-validate({ userId: 1, postId: 19 })
-.then(function (data) {
- console.log('Data is valid', data); // { userId: 1, postId: 19 }
+validate({ userId: 1, postId: 19 }))
+.then(function (valid) {
+ // "valid" is always true here
+ console.log('Data is valid');
})
.catch(function (err) {
if (!(err instanceof Ajv.ValidationError)) throw err;
// data is invalid
console.log('Validation errors:', err.errors);
});
+
```
-### Using transpilers with asynchronous validation functions.
+### Using transpilers with asyncronous validation functions.
To use a transpiler you should separately install it (or load its bundle in the browser).
@@ -588,9 +507,7 @@ Ajv npm package includes minified browser bundles of regenerator and nodent in d
#### Using nodent
```javascript
-var setupAsync = require('ajv-async');
var ajv = new Ajv({ /* async: 'es7', */ transpile: 'nodent' });
-setupAsync(ajv);
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```
@@ -601,9 +518,7 @@ validate(data).then(successFunc).catch(errorFunc);
#### Using regenerator
```javascript
-var setupAsync = require('ajv-async');
var ajv = new Ajv({ /* async: 'es7', */ transpile: 'regenerator' });
-setupAsync(ajv);
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```
@@ -614,7 +529,7 @@ validate(data).then(successFunc).catch(errorFunc);
#### Using other transpilers
```javascript
-var ajv = new Ajv({ async: 'es7', processCode: transpileFunc });
+var ajv = new Ajv({ async: 'es7', transpile: transpileFunc });
var validate = ajv.compile(schema); // transpiled es7 async function
validate(data).then(successFunc).catch(errorFunc);
```
@@ -626,21 +541,22 @@ See [Options](#options).
|mode|transpile speed*|run-time speed*|bundle size|
|---|:-:|:-:|:-:|
-|es7 async (native)|-|0.75|-|
|generators (native)|-|1.0|-|
-|es7.nodent|1.35|1.1|215Kb|
-|es7.regenerator|1.0|2.7|1109Kb|
-|regenerator|1.0|3.2|1109Kb|
+|es7.nodent|1.35|1.1|183Kb|
+|es7.regenerator|1.0|2.7|322Kb|
+|regenerator|1.0|3.2|322Kb|
-\* Relative performance in Node.js 7.x — smaller is better.
+\* Relative performance in node v.4, smaller is better.
[nodent](https://github.com/MatAtBread/nodent) has several advantages:
- much smaller browser bundle than regenerator
-- almost the same performance of generated code as native generators in Node.js and the latest Chrome
-- much better performance than native generators in other browsers
+- almost the same performance of generated code as native generators in nodejs and the latest Chrome
+- much better performace than native generators in other browsers
- works in IE 9 (regenerator does not)
+[regenerator](https://github.com/facebook/regenerator) is a more widely adopted alternative.
+
## Filtering data
@@ -815,7 +731,7 @@ console.log(data2); // { foo: { bar: 2 } }
- not in `properties` or `items` subschemas
- in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/epoberezkin/ajv/issues/42))
-- in `if` subschema of `switch` keyword
+- in `if` subschema of v5 `switch` keyword
- in schemas generated by custom macro keywords
@@ -879,6 +795,8 @@ See [Coercion rules](https://github.com/epoberezkin/ajv/blob/master/COERCION.md)
Create Ajv instance.
+All the instance methods below are bound to the instance, so they can be used without the instance.
+
##### .compile(Object schema) -> Function<Object data>
@@ -889,19 +807,17 @@ Validating function returns boolean and has properties `errors` with the errors
Unless the option `validateSchema` is false, the schema will be validated against meta-schema and if schema is invalid the error will be thrown. See [options](#options).
-##### .compileAsync(Object schema [, Boolean meta] [, Function callback]) -> Promise
-
-Asynchronous version of `compile` method that loads missing remote schemas using asynchronous function in `options.loadSchema`. This function returns a Promise that resolves to a validation function. An optional callback passed to `compileAsync` will be called with 2 parameters: error (or null) and validating function. The returned promise will reject (and the callback will be called with an error) when:
+##### .compileAsync(Object schema, Function callback)
-- missing schema can't be loaded (`loadSchema` returns a Promise that rejects).
-- a schema containing a missing reference is loaded, but the reference cannot be resolved.
-- schema (or some loaded/referenced schema) is invalid.
+Asyncronous version of `compile` method that loads missing remote schemas using asynchronous function in `options.loadSchema`. Callback will always be called with 2 parameters: error (or null) and validating function. Error will be not null in the following cases:
-The function compiles schema and loads the first missing schema (or meta-schema) until all missing schemas are loaded.
+- missing schema can't be loaded (`loadSchema` calls callback with error).
+- the schema containing missing reference is loaded, but the reference cannot be resolved.
+- schema (or some referenced schema) is invalid.
-You can asynchronously compile meta-schema by passing `true` as the second parameter.
+The function compiles schema and loads the first missing schema multiple times, until all missing schemas are loaded.
-See example in [Asynchronous compilation](#asynchronous-schema-compilation).
+See example in [Asynchronous compilation](#asynchronous-compilation).
##### .validate(Object schema|String key|String ref, data) -> Boolean
@@ -917,7 +833,7 @@ __Please note__: every time this method is called the errors are overwritten so
If the schema is asynchronous (has `$async` keyword on the top level) this method returns a Promise. See [Asynchronous validation](#asynchronous-validation).
-##### .addSchema(Array<Object>|Object schema [, String key]) -> Ajv
+##### .addSchema(Array<Object>|Object schema [, String key])
Add schema(s) to validator instance. This method does not compile schemas (but it still validates them). Because of that dependencies can be added in any order and circular dependencies are supported. It also prevents unnecessary compilation of schemas that are containers for other schemas but not used as a whole.
@@ -932,39 +848,35 @@ Although `addSchema` does not compile schemas, explicit compilation is not requi
By default the schema is validated against meta-schema before it is added, and if the schema does not pass validation the exception is thrown. This behaviour is controlled by `validateSchema` option.
-__Please note__: Ajv uses the [method chaining syntax](https://en.wikipedia.org/wiki/Method_chaining) for all methods with the prefix `add*` and `remove*`.
-This allows you to do nice things like the following.
-```javascript
-var validate = new Ajv().addSchema(schema).addFormat(name, regex).getSchema(uri);
-```
-
-##### .addMetaSchema(Array<Object>|Object schema [, String key]) -> Ajv
+##### .addMetaSchema(Array<Object>|Object schema [, String key])
Adds meta schema(s) that can be used to validate other schemas. That function should be used instead of `addSchema` because there may be instance options that would compile a meta schema incorrectly (at the moment it is `removeAdditional` option).
-There is no need to explicitly add draft 6 meta schema (http://json-schema.org/draft-06/schema and http://json-schema.org/schema) - it is added by default, unless option `meta` is set to `false`. You only need to use it if you have a changed meta-schema that you want to use to validate your schemas. See `validateSchema`.
+There is no need to explicitly add draft 4 meta schema (http://json-schema.org/draft-04/schema and http://json-schema.org/schema) - it is added by default, unless option `meta` is set to `false`. You only need to use it if you have a changed meta-schema that you want to use to validate your schemas. See `validateSchema`.
+
+With option `v5: true` [meta-schema that includes v5 keywords](https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json) also added.
##### .validateSchema(Object schema) -> Boolean
-Validates schema. This method should be used to validate schemas rather than `validate` due to the inconsistency of `uri` format in JSON Schema standard.
+Validates schema. This method should be used to validate schemas rather than `validate` due to the inconsistency of `uri` format in JSON-Schema standard.
By default this method is called automatically when the schema is added, so you rarely need to use it directly.
-If schema doesn't have `$schema` property, it is validated against draft 6 meta-schema (option `meta` should not be false).
+If schema doesn't have `$schema` property it is validated against draft 4 meta-schema (option `meta` should not be false) or against [v5 meta-schema](https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#) if option `v5` is true.
-If schema has `$schema` property, then the schema with this id (that should be previously added) is used to validate passed schema.
+If schema has `$schema` property then the schema with this id (that should be previously added) is used to validate passed schema.
Errors will be available at `ajv.errors`.
##### .getSchema(String key) -> Function<Object data>
-Retrieve compiled schema previously added with `addSchema` by the key passed to `addSchema` or by its full reference (id). The returned validating function has `schema` property with the reference to the original schema.
+Retrieve compiled schema previously added with `addSchema` by the key passed to `addSchema` or by its full reference (id). Returned validating function has `schema` property with the reference to the original schema.
-##### .removeSchema([Object schema|String key|String ref|RegExp pattern]) -> Ajv
+##### .removeSchema([Object schema|String key|String ref|RegExp pattern])
Remove added/cached schema. Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references.
@@ -977,9 +889,9 @@ Schema can be removed using:
If no parameter is passed all schemas but meta-schemas will be removed and the cache will be cleared.
-##### .addFormat(String name, String|RegExp|Function|Object format) -> Ajv
+##### .addFormat(String name, String|RegExp|Function|Object format)
-Add custom format to validate strings or numbers. It can also be used to replace pre-defined formats for Ajv instance.
+Add custom format to validate strings. It can also be used to replace pre-defined formats for Ajv instance.
Strings are converted to RegExp.
@@ -988,14 +900,13 @@ Function should return validation result as `true` or `false`.
If object is passed it should have properties `validate`, `compare` and `async`:
- _validate_: a string, RegExp or a function as described above.
-- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal.
+- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (from [v5 proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) - `v5` option should be used). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal.
- _async_: an optional `true` value if `validate` is an asynchronous function; in this case it should return a promise that resolves with a value `true` or `false`.
-- _type_: an optional type of data that the format applies to. It can be `"string"` (default) or `"number"` (see https://github.com/epoberezkin/ajv/issues/291#issuecomment-259923858). If the type of data is different, the validation will pass.
Custom formats can be also added via `formats` option.
-##### .addKeyword(String keyword, Object definition) -> Ajv
+##### .addKeyword(String keyword, Object definition)
Add custom validation keyword to Ajv instance.
@@ -1036,7 +947,7 @@ See [Defining custom keywords](#defining-custom-keywords) for more details.
Returns custom keyword definition, `true` for pre-defined keywords and `false` if the keyword is unknown.
-##### .removeKeyword(String keyword) -> Ajv
+##### .removeKeyword(String keyword)
Removes custom or pre-defined keyword so you can redefine them.
@@ -1059,7 +970,7 @@ Defaults:
```javascript
{
// validation and reporting options:
- $data: false,
+ v5: false,
allErrors: false,
verbose: false,
jsonPointers: false,
@@ -1067,21 +978,19 @@ Defaults:
unicode: true,
format: 'fast',
formats: {},
- unknownFormats: true,
+ unknownFormats: 'ignore',
schemas: {},
- logger: undefined,
// referenced schema options:
- schemaId: undefined // recommended '$id'
missingRefs: true,
- extendRefs: 'ignore', // recommended 'fail'
- loadSchema: undefined, // function(uri: string): Promise {}
+ extendRefs: true,
+ loadSchema: undefined, // function(uri, cb) { /* ... */ cb(err, schema); },
// options to modify validated data:
removeAdditional: false,
useDefaults: false,
coerceTypes: false,
// asynchronous validation options:
- async: 'co*',
- transpile: undefined, // requires ajv-async package
+ async: undefined,
+ transpile: undefined,
// advanced options:
meta: true,
validateSchema: true,
@@ -1092,49 +1001,41 @@ Defaults:
ownProperties: false,
multipleOfPrecision: false,
errorDataPath: 'object',
+ sourceCode: true,
messages: true,
- sourceCode: false,
- processCode: undefined, // function (str: string): string {}
- cache: new Cache,
- serialize: undefined
+ beautify: false,
+ cache: new Cache
}
```
##### Validation and reporting options
-- _$data_: support [$data references](#data-reference). Draft 6 meta-schema that is added by default will be extended to allow them. If you want to use another meta-schema you need to use $dataMetaSchema method to add support for $data reference. See [API](#api).
+- _v5_: add keywords `switch`, `constant`, `contains`, `patternGroups`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON-schema v5 proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals). With this option added schemas without `$schema` property are validated against [v5 meta-schema](https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#). `false` by default.
- _allErrors_: check all rules collecting all errors. Default is to return after the first error.
- _verbose_: include the reference to the part of the schema (`schema` and `parentSchema`) and validated data in errors (false by default).
-- _jsonPointers_: set `dataPath` property of errors using [JSON Pointers](https://tools.ietf.org/html/rfc6901) instead of JavaScript property access notation.
+- _jsonPointers_: set `dataPath` propery of errors using [JSON Pointers](https://tools.ietf.org/html/rfc6901) instead of JavaScript property access notation.
- _uniqueItems_: validate `uniqueItems` keyword (true by default).
- _unicode_: calculate correct length of strings with unicode pairs (true by default). Pass `false` to use `.length` of strings that is faster, but gives "incorrect" lengths of strings with unicode pairs - each unicode pair is counted as two characters.
- _format_: formats validation mode ('fast' by default). Pass 'full' for more correct and slow validation or `false` not to validate formats at all. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode.
- _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.
- _unknownFormats_: handling of unknown formats. Option values:
- - `true` (default) - if an unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [$data reference](#data-reference) and it is unknown the validation will fail.
- - `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if another unknown format is used. If `format` keyword value is [$data reference](#data-reference) and it is not in this array the validation will fail.
- - `"ignore"` - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. This behaviour is required by JSON-schema specification.
-- _schemas_: an array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method `addSchema(value, key)` will be called for each schema in this object.
-- _logger_: sets the logging method. Default is the global `console` object that should have methods `log`, `warn` and `error`. Option values:
- - custom logger - it should have methods `log`, `warn` and `error`. If any of these methods is missing an exception will be thrown.
- - `false` - logging is disabled.
+ - `true` (will be default in 5.0.0) - if the unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [v5 $data reference](#data-reference) and it is unknown the validation will fail.
+ - `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if some other unknown format is used. If `format` keyword value is [v5 $data reference](#data-reference) and it is not in this array the validation will fail.
+ - `"ignore"` (default now) - to log warning during schema compilation and always pass validation. This option is not recommended, as it allows to mistype format name. This behaviour is required by JSON-schema specification.
+- _schemas_: an array or object of schemas that will be added to the instance. If the order is important, pass array. In this case schemas must have IDs in them. Otherwise the object can be passed - `addSchema(value, key)` will be called for each schema in this object.
##### Referenced schema options
-- _schemaId_: this option defines which keywords are used as schema URI. Option value:
- - `"$id"` (recommended) - only use `$id` keyword as schema URI (as specified in JSON Schema draft-06), ignore `id` keyword (if it is present a warning will be logged).
- - `"id"` - only use `id` keyword as schema URI (as specified in JSON Schema draft-04), ignore `$id` keyword (if it is present a warning will be logged).
- - `undefined` (default) - use both `$id` and `id` keywords as schema URI. If both are present (in the same schema object) and different the exception will be thrown during schema compilation.
- _missingRefs_: handling of missing referenced schemas. Option values:
- `true` (default) - if the reference cannot be resolved during compilation the exception is thrown. The thrown error has properties `missingRef` (with hash fragment) and `missingSchema` (without it). Both properties are resolved relative to the current base id (usually schema id, unless it was substituted).
- `"ignore"` - to log error during compilation and always pass validation.
- `"fail"` - to log error and successfully compile schema but fail validation if this rule is checked.
- _extendRefs_: validation of other keywords when `$ref` is present in the schema. Option values:
- - `"ignore"` (default) - when `$ref` is used other keywords are ignored (as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3) standard). A warning will be logged during the schema compilation.
- - `"fail"` (recommended) - if other validation keywords are used together with `$ref` the exception will be thrown when the schema is compiled. This option is recommended to make sure schema has no keywords that are ignored, which can be confusing.
- - `true` - validate all keywords in the schemas with `$ref` (the default behaviour in versions before 5.0.0).
-- _loadSchema_: asynchronous function that will be used to load remote schemas when `compileAsync` [method](#api-compileAsync) is used and some reference is missing (option `missingRefs` should NOT be 'fail' or 'ignore'). This function should accept remote schema uri as a parameter and return a Promise that resolves to a schema. See example in [Asynchronous compilation](#asynchronous-schema-compilation).
+ - `true` (default) - validate all keywords in the schemas with `$ref`.
+ - `"ignore"` - when `$ref` is used other keywords are ignored (as per [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3) standard). A warning will be logged during the schema compilation.
+ - `"fail"` - if other validation keywords are used together with `$ref` the exception will be throw when the schema is compiled.
+- _loadSchema_: asynchronous function that will be used to load remote schemas when the method `compileAsync` is used and some reference is missing (option `missingRefs` should NOT be 'fail' or 'ignore'). This function should accept 2 parameters: remote schema uri and node-style callback. See example in [Asynchronous compilation](#asynchronous-compilation).
##### Options to modify validated data
@@ -1157,54 +1058,42 @@ Defaults:
##### Asynchronous validation options
- _async_: determines how Ajv compiles asynchronous schemas (see [Asynchronous validation](#asynchronous-validation)) to functions. Option values:
- - `"*"` / `"co*"` (default) - compile to generator function ("co*" - wrapped with `co.wrap`). If generators are not supported and you don't provide `processCode` option (or `transpile` option if you use [ajv-async](https://github.com/epoberezkin/ajv-async) package), the exception will be thrown when async schema is compiled.
- - `"es7"` - compile to es7 async function. Unless your platform supports them you need to provide `processCode` or `transpile` option. According to [compatibility table](http://kangax.github.io/compat-table/es7/)) async functions are supported by:
- - Firefox 52,
- - Chrome 55,
- - Node.js 7 (with `--harmony-async-await`),
- - MS Edge 13 (with flag).
- - `undefined`/`true` - auto-detect async mode. It requires [ajv-async](https://github.com/epoberezkin/ajv-async) package. If `transpile` option is not passed, ajv-async will choose the first of supported/installed async/transpile modes in this order:
- - "es7" (native async functions),
- - "co*" (native generators with co.wrap),
- - "es7"/"nodent",
- - "co*"/"regenerator" during the creation of the Ajv instance.
-
- If none of the options is available the exception will be thrown.
-- _transpile_: Requires [ajv-async](https://github.com/epoberezkin/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values:
+ - `"*"` / `"co*"` - compile to generator function ("co*" - wrapped with `co.wrap`). If generators are not supported and you don't provide `transpile` option, the exception will be thrown when Ajv instance is created.
+ - `"es7"` - compile to es7 async function. Unless your platform supports them you need to provide `transpile` option. Currently only MS Edge 13 with flag supports es7 async functions according to [compatibility table](http://kangax.github.io/compat-table/es7/)).
+ - `true` - if transpile option is not passed Ajv will choose the first supported/installed async/transpile modes in this order: "co*" (native generator with co.wrap), "es7"/"nodent", "co*"/"regenerator" during the creation of the Ajv instance. If none of the options is available the exception will be thrown.
+ - `undefined`- Ajv will choose the first available async mode in the same way as with `true` option but when the first asynchronous schema is compiled.
+- _transpile_: determines whether Ajv transpiles compiled asynchronous validation function. Option values:
- `"nodent"` - transpile with [nodent](https://github.com/MatAtBread/nodent). If nodent is not installed, the exception will be thrown. nodent can only transpile es7 async functions; it will enforce this mode.
- `"regenerator"` - transpile with [regenerator](https://github.com/facebook/regenerator). If regenerator is not installed, the exception will be thrown.
- - a function - this function should accept the code of validation function as a string and return transpiled code. This option allows you to use any other transpiler you prefer. If you are passing a function, you can simply pass it to `processCode` option without using ajv-async.
+ - a function - this function should accept the code of validation function as a string and return transpiled code. This option allows you to use any other transpiler you prefer.
##### Advanced options
-- _meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default). If an object is passed, it will be used as the default meta-schema for schemas that have no `$schema` keyword. This default meta-schema MUST have `$schema` keyword.
+- _meta_: add [meta-schema](http://json-schema.org/documentation.html) so it can be used by other schemas (true by default). With option `v5: true` [v5 meta-schema](https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#) will be added as well. If an object is passed, it will be used as the default meta-schema for schemas that have no `$schema` keyword. This default meta-schema MUST have `$schema` keyword.
- _validateSchema_: validate added/compiled schemas against meta-schema (true by default). `$schema` property in the schema can either be http://json-schema.org/schema or http://json-schema.org/draft-04/schema or absent (draft-4 meta-schema will be used) or can be a reference to the schema previously added with `addMetaSchema` method. Option values:
- `true` (default) - if the validation fails, throw the exception.
- `"log"` - if the validation fails, log error.
- `false` - skip schema validation.
-- _addUsedSchema_: by default methods `compile` and `validate` add schemas to the instance if they have `$id` (or `id`) property that doesn't start with "#". If `$id` is present and it is not unique the exception will be thrown. Set this option to `false` to skip adding schemas to the instance and the `$id` uniqueness check when these methods are used. This option does not affect `addSchema` method.
+- _addUsedSchema_: by default methods `compile` and `validate` add schemas to the instance if they have `id` property that doesn't start with "#". If `id` is present and it is not unique the exception will be thrown. Set this option to `false` to skip adding schemas to the instance and the `id` uniqueness check when these methods are used. This option does not affect `addSchema` method.
- _inlineRefs_: Affects compilation of referenced schemas. Option values:
- `true` (default) - the referenced schemas that don't have refs in them are inlined, regardless of their size - that substantially improves performance at the cost of the bigger size of compiled schema functions.
- `false` - to not inline referenced schemas (they will be compiled as separate functions).
- integer number - to limit the maximum number of keywords of the schema that will be inlined.
- _passContext_: pass validation context to custom keyword functions. If this option is `true` and you pass some context to the compiled validation function with `validate.call(context, data)`, the `context` will be available as `this` in your custom keywords. By default `this` is Ajv instance.
- _loopRequired_: by default `required` keyword is compiled into a single expression (or a sequence of statements in `allErrors` mode). In case of a very large number of properties in this keyword it may result in a very big validation function. Pass integer to set the number of properties above which `required` keyword will be validated in a loop - smaller validation function size but also worse performance.
-- _ownProperties_: by default Ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.
+- _ownProperties_: by default ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.
- _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/epoberezkin/ajv/issues/84)). If you need to use fractional dividers set this option to some positive integer N to have `multipleOf` validated using this formula: `Math.abs(Math.round(division) - division) < 1e-N` (it is slower but allows for float arithmetics deviations).
- _errorDataPath_: set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`.
-- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n)).
- _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call).
-- _processCode_: an optional function to process generated code before it is passed to Function constructor. It can be used to either beautify (the validating function is generated without line-breaks) or to transpile code. Starting from version 5.0.0 this option replaced options:
- - `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass `require('js-beautify').js_beautify`.
- - `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/epoberezkin/ajv-async) package. See [Asynchronous validation](#asynchronous-validation) for more information.
+- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n)).
+- _beautify_: format the generated function with [js-beautify](https://github.com/beautify-web/js-beautify) (the validating function is generated without line-breaks). `npm install js-beautify` to use this option. `true` or js-beautify options can be passed.
- _cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`, `del(key)` and `clear()`.
-- _serialize_: an optional function to serialize schema to cache key. Pass `false` to use schema itself as a key (e.g., if WeakMap used as a cache). By default [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used.
## Validation errors
-In case of validation failure, Ajv assigns the array of errors to `errors` property of validation function (or to `errors` property of Ajv instance when `validate` or `validateSchema` methods were called). In case of [asynchronous validation](#asynchronous-validation), the returned promise is rejected with exception `Ajv.ValidationError` that has `errors` property.
+In case of validation failure Ajv assigns the array of errors to `.errors` property of validation function (or to `.errors` property of Ajv instance in case `validate` or `validateSchema` methods were called). In case of [asynchronous validation](#asynchronous-validation) the returned promise is rejected with the exception of the class `Ajv.ValidationError` that has `.errors` poperty.
### Error objects
@@ -1220,8 +1109,6 @@ Each error is an object with the following properties:
- _parentSchema_: the schema containing the keyword (added with `verbose` option)
- _data_: the data validated by the keyword (added with `verbose` option).
-__Please note__: `propertyNames` keyword schema validation errors have an additional property `propertyName`, `dataPath` points to the object. After schema validation for each property name, if it is invalid an additional error is added with the property `keyword` equal to `"propertyNames"`.
-
### Error parameters
@@ -1230,11 +1117,15 @@ Properties of `params` object in errors depend on the keyword that failed valida
- `maxItems`, `minItems`, `maxLength`, `minLength`, `maxProperties`, `minProperties` - property `limit` (number, the schema of the keyword).
- `additionalItems` - property `limit` (the maximum number of allowed items in case when `items` keyword is an array of schemas and `additionalItems` is false).
- `additionalProperties` - property `additionalProperty` (the property not used in `properties` and `patternProperties` keywords).
+- `patternGroups` (with v5 option) - properties:
+ - `pattern`
+ - `reason` ("minimum"/"maximum"),
+ - `limit` (max/min allowed number of properties matching number)
- `dependencies` - properties:
- `property` (dependent property),
- `missingProperty` (required missing dependency - only the first one is reported currently)
- `deps` (required dependencies, comma separated list as a string),
- - `depsCount` (the number of required dependencies).
+ - `depsCount` (the number of required dependedncies).
- `format` - property `format` (the schema of the keyword).
- `maximum`, `minimum` - properties:
- `limit` (number, the schema of the keyword),
@@ -1243,8 +1134,7 @@ Properties of `params` object in errors depend on the keyword that failed valida
- `multipleOf` - property `multipleOf` (the schema of the keyword)
- `pattern` - property `pattern` (the schema of the keyword)
- `required` - property `missingProperty` (required property that is missing).
-- `propertyNames` - property `propertyName` (an invalid property name).
-- `patternRequired` (in ajv-keywords) - property `missingPattern` (required pattern that did not match any property).
+- `patternRequired` (with v5 option) - property `missingPattern` (required pattern that did not match any property).
- `type` - property `type` (required type(s), a string, can be a comma-separated list)
- `uniqueItems` - properties `i` and `j` (indices of duplicate items).
- `enum` - property `allowedValues` pointing to the array of values (the schema of the keyword).
@@ -1254,14 +1144,10 @@ Properties of `params` object in errors depend on the keyword that failed valida
## Related packages
-- [ajv-async](https://github.com/epoberezkin/ajv-async) - configure async validation mode
-- [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface
-- [ajv-errors](https://github.com/epoberezkin/ajv-errors) - custom error messages
+- [ajv-cli](https://github.com/epoberezkin/ajv-cli) - command line interface for Ajv
- [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) - internationalised error messages
-- [ajv-istanbul](https://github.com/epoberezkin/ajv-istanbul) - instrument generated validation code to measure test coverage of your schemas
-- [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) - custom validation keywords (if/then/else, select, typeof, etc.)
-- [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) - keywords $merge and $patch
-- [ajv-pack](https://github.com/epoberezkin/ajv-pack) - produces a compact module exporting validation functions
+- [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) - keywords $merge and $patch from v5 proposals.
+- [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) - several custom keywords that can be used with Ajv (typeof, instanceof, range, propertyNames)
## Some packages using Ajv
@@ -1272,7 +1158,7 @@ Properties of `params` object in errors depend on the keyword that failed valida
- [har-validator](https://github.com/ahmadnassri/har-validator) - HTTP Archive (HAR) validator
- [jsoneditor](https://github.com/josdejong/jsoneditor) - a web-based tool to view, edit, format, and validate JSON http://jsoneditoronline.org
- [JSON Schema Lint](https://github.com/nickcmaynard/jsonschemalint) - a web tool to validate JSON/YAML document against a single JSON-schema http://jsonschemalint.com
-- [objection](https://github.com/vincit/objection.js) - SQL-friendly ORM for Node.js
+- [objection](https://github.com/vincit/objection.js) - SQL-friendly ORM for node.js
- [table](https://github.com/gajus/table) - formats data into a string table
- [ripple-lib](https://github.com/ripple/ripple-lib) - a JavaScript API for interacting with [Ripple](https://ripple.com) in Node.js and the browser
- [restbase](https://github.com/wikimedia/restbase) - distributed storage with REST API & dispatcher for backend services built to provide a low-latency & high-throughput API for Wikipedia / Wikimedia content
@@ -1281,7 +1167,7 @@ Properties of `params` object in errors depend on the keyword that failed valida
- [rabbitmq-schema](https://github.com/tjmehta/rabbitmq-schema) - a schema definition module for RabbitMQ graphs and messages
- [@query/schema](https://www.npmjs.com/package/@query/schema) - stream filtering with a URI-safe query syntax parsing to JSON Schema
- [chai-ajv-json-schema](https://github.com/peon374/chai-ajv-json-schema) - chai plugin to us JSON-schema with expect in mocha tests
-- [grunt-jsonschema-ajv](https://github.com/SignpostMarv/grunt-jsonschema-ajv) - Grunt plugin for validating files against JSON Schema
+- [grunt-jsonschema-ajv](https://github.com/SignpostMarv/grunt-jsonschema-ajv) - Grunt plugin for validating files against JSON-Schema
- [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) - extract text from bundle into a file
- [electron-builder](https://github.com/electron-userland/electron-builder) - a solution to package and build a ready for distribution Electron app
- [addons-linter](https://github.com/mozilla/addons-linter) - Mozilla Add-ons Linter
@@ -1311,7 +1197,7 @@ Please see [Contributing guidelines](https://github.com/epoberezkin/ajv/blob/mas
See https://github.com/epoberezkin/ajv/releases
-__Please note__: [Changes in version 5.0.0](https://github.com/epoberezkin/ajv/releases/tag/5.0.0).
+__Please note__: [Changes in version 5.0.1-beta](https://github.com/epoberezkin/ajv/releases/tag/5.0.1-beta.0).
[Changes in version 4.6.0](https://github.com/epoberezkin/ajv/releases/tag/4.6.0).
diff --git a/deps/npm/node_modules/ajv/dist/ajv.bundle.js b/deps/npm/node_modules/har-validator/node_modules/ajv/dist/ajv.bundle.js
similarity index 69%
rename from deps/npm/node_modules/ajv/dist/ajv.bundle.js
rename to deps/npm/node_modules/har-validator/node_modules/ajv/dist/ajv.bundle.js
index 25843d30c8535d..387d272a429ae0 100644
--- a/deps/npm/node_modules/ajv/dist/ajv.bundle.js
+++ b/deps/npm/node_modules/har-validator/node_modules/ajv/dist/ajv.bundle.js
@@ -1,55 +1,224 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Ajv = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;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 require=="function"&&require;for(var o=0;o%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
-// For the source: https://gist.github.com/dperini/729294
-// For test cases: https://mathiasbynens.be/demo/url-regex
-// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
-// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
-var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
-var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
-var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$|^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
-var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
+var URI = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?$/i;
+var UUID = /^(?:urn\:uuid\:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
+var JSON_POINTER = /^(?:\/(?:[^~\/]|~0|~1)*)*$|^\#(?:\/(?:[a-z0-9_\-\.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
+var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:\#|(?:\/(?:[^~\/]|~0|~1)*)*)$/;
module.exports = formats;
function formats(mode) {
mode = mode == 'full' ? 'full' : 'fast';
- return util.copy(formats[mode]);
+ var formatDefs = util.copy(formats[mode]);
+ for (var fName in formats.compare) {
+ formatDefs[fName] = {
+ validate: formatDefs[fName],
+ compare: formats.compare[fName]
+ };
+ }
+ return formatDefs;
}
@@ -276,14 +360,11 @@ formats.fast = {
time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i,
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i,
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
- uri: /^(?:[a-z][a-z0-9+-.]*)(?::|\/)\/?[^\s]*$/i,
- 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/\/)?[^\s]*$/i,
- 'uri-template': URITEMPLATE,
- url: URL,
+ uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i,
// email (sources from jsen validator):
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
- email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
+ email: /^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
hostname: HOSTNAME,
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
@@ -305,10 +386,7 @@ formats.full = {
time: time,
'date-time': date_time,
uri: uri,
- 'uri-reference': URIREF,
- 'uri-template': URITEMPLATE,
- url: URL,
- email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
+ email: /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
hostname: hostname,
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
@@ -319,6 +397,13 @@ formats.full = {
};
+formats.compare = {
+ date: compareDate,
+ time: compareTime,
+ 'date-time': compareDateTime
+};
+
+
function date(str) {
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
var matches = str.match(DATE);
@@ -357,16 +442,14 @@ function hostname(str) {
}
-var NOT_URI_FRAGMENT = /\/|:/;
+var NOT_URI_FRAGMENT = /\/|\:/;
function uri(str) {
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
}
-var Z_ANCHOR = /[^\\]\\Z/;
function regex(str) {
- if (Z_ANCHOR.test(str)) return false;
try {
new RegExp(str);
return true;
@@ -375,13 +458,54 @@ function regex(str) {
}
}
-},{"./util":12}],7:[function(require,module,exports){
+
+function compareDate(d1, d2) {
+ if (!(d1 && d2)) return;
+ if (d1 > d2) return 1;
+ if (d1 < d2) return -1;
+ if (d1 === d2) return 0;
+}
+
+
+function compareTime(t1, t2) {
+ if (!(t1 && t2)) return;
+ t1 = t1.match(TIME);
+ t2 = t2.match(TIME);
+ if (!(t1 && t2)) return;
+ t1 = t1[1] + t1[2] + t1[3] + (t1[4]||'');
+ t2 = t2[1] + t2[2] + t2[3] + (t2[4]||'');
+ if (t1 > t2) return 1;
+ if (t1 < t2) return -1;
+ if (t1 === t2) return 0;
+}
+
+
+function compareDateTime(dt1, dt2) {
+ if (!(dt1 && dt2)) return;
+ dt1 = dt1.split(DATE_TIME_SEPARATOR);
+ dt2 = dt2.split(DATE_TIME_SEPARATOR);
+ var res = compareDate(dt1[0], dt2[0]);
+ if (res === undefined) return;
+ return res || compareTime(dt1[1], dt2[1]);
+}
+
+},{"./util":11}],6:[function(require,module,exports){
'use strict';
var resolve = require('./resolve')
, util = require('./util')
- , errorClasses = require('./error_classes')
- , stableStringify = require('fast-json-stable-stringify');
+ , stableStringify = require('json-stable-stringify')
+ , async = require('../async');
+
+var beautify;
+
+function loadBeautify(){
+ if (beautify === undefined) {
+ var name = 'js-beautify';
+ try { beautify = require(name).js_beautify; }
+ catch(e) { beautify = false; }
+ }
+}
var validateGenerator = require('../dotjs/validate');
@@ -391,10 +515,10 @@ var validateGenerator = require('../dotjs/validate');
var co = require('co');
var ucs2length = util.ucs2length;
-var equal = require('fast-deep-equal');
+var equal = require('./equal');
// this error is thrown by async schemas to return validation errors via exception
-var ValidationError = errorClasses.Validation;
+var ValidationError = require('./validation_error');
module.exports = compile;
@@ -419,7 +543,8 @@ function compile(schema, root, localRefs, baseId) {
, patternsHash = {}
, defaults = []
, defaultsHash = {}
- , customRules = [];
+ , customRules = []
+ , keepSourceCode = opts.sourceCode !== false;
root = root || { schema: schema, refVal: refVal, refs: refs };
@@ -441,7 +566,7 @@ function compile(schema, root, localRefs, baseId) {
cv.refVal = v.refVal;
cv.root = v.root;
cv.$async = v.$async;
- if (opts.sourceCode) cv.source = v.source;
+ if (keepSourceCode) cv.sourceCode = v.sourceCode;
}
return v;
} finally {
@@ -461,6 +586,7 @@ function compile(schema, root, localRefs, baseId) {
return compile.call(self, _schema, _root, localRefs, baseId);
var $async = _schema.$async === true;
+ if ($async && !opts.transpile) async.setup(opts);
var sourceCode = validateGenerator({
isTop: true,
@@ -471,7 +597,6 @@ function compile(schema, root, localRefs, baseId) {
schemaPath: '',
errSchemaPath: '#',
errorPath: '""',
- MissingRefError: errorClasses.MissingRef,
RULES: RULES,
validate: validateGenerator,
util: util,
@@ -482,7 +607,6 @@ function compile(schema, root, localRefs, baseId) {
useCustomRule: useCustomRule,
opts: opts,
formats: formats,
- logger: self.logger,
self: self
});
@@ -490,10 +614,20 @@ function compile(schema, root, localRefs, baseId) {
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ sourceCode;
- if (opts.processCode) sourceCode = opts.processCode(sourceCode);
- // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
- var validate;
+ if (opts.beautify) {
+ loadBeautify();
+ /* istanbul ignore else */
+ if (beautify) sourceCode = beautify(sourceCode, opts.beautify);
+ else console.error('"npm install js-beautify" to use beautify option');
+ }
+ // console.log('\n\n\n *** \n', sourceCode);
+ var validate, validateCode
+ , transpile = opts._transpileFunc;
try {
+ validateCode = $async && transpile
+ ? transpile(sourceCode)
+ : sourceCode;
+
var makeValidate = new Function(
'self',
'RULES',
@@ -506,7 +640,7 @@ function compile(schema, root, localRefs, baseId) {
'equal',
'ucs2length',
'ValidationError',
- sourceCode
+ validateCode
);
validate = makeValidate(
@@ -525,7 +659,7 @@ function compile(schema, root, localRefs, baseId) {
refVal[0] = validate;
} catch(e) {
- self.logger.error('Error compiling schema, function code:', sourceCode);
+ console.error('Error compiling schema, function code:', validateCode);
throw e;
}
@@ -535,9 +669,9 @@ function compile(schema, root, localRefs, baseId) {
validate.refVal = refVal;
validate.root = isRoot ? validate : _root;
if ($async) validate.$async = true;
+ if (keepSourceCode) validate.sourceCode = sourceCode;
if (opts.sourceCode === true) {
validate.source = {
- code: sourceCode,
patterns: patterns,
defaults: defaults
};
@@ -566,7 +700,7 @@ function compile(schema, root, localRefs, baseId) {
refCode = addLocalRef(ref);
var v = resolve.call(self, localCompile, root, ref);
- if (v === undefined) {
+ if (!v) {
var localSchema = localRefs && localRefs[ref];
if (localSchema) {
v = resolve.inlineRef(localSchema, opts.inlineRefs)
@@ -575,9 +709,7 @@ function compile(schema, root, localRefs, baseId) {
}
}
- if (v === undefined) {
- removeLocalRef(ref);
- } else {
+ if (v) {
replaceLocalRef(ref, v);
return resolvedRef(v, refCode);
}
@@ -590,17 +722,13 @@ function compile(schema, root, localRefs, baseId) {
return 'refVal' + refId;
}
- function removeLocalRef(ref) {
- delete refs[ref];
- }
-
function replaceLocalRef(ref, v) {
var refId = refs[ref];
refVal[refId] = v;
}
function resolvedRef(refVal, code) {
- return typeof refVal == 'object' || typeof refVal == 'boolean'
+ return typeof refVal == 'object'
? { code: code, schema: refVal, inline: true }
: { code: code, $async: refVal && refVal.$async };
}
@@ -639,7 +767,7 @@ function compile(schema, root, localRefs, baseId) {
var valid = validateSchema(schema);
if (!valid) {
var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
- if (self._opts.validateSchema == 'log') self.logger.error(message);
+ if (self._opts.validateSchema == 'log') console.error(message);
else throw new Error(message);
}
}
@@ -658,12 +786,8 @@ function compile(schema, root, localRefs, baseId) {
validate = inline.call(self, it, rule.keyword, schema, parentSchema);
} else {
validate = rule.definition.validate;
- if (!validate) return;
}
- if (validate === undefined)
- throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
-
var index = customRules.length;
customRules[index] = validate;
@@ -740,7 +864,7 @@ function defaultCode(i) {
function refValCode(i, refVal) {
- return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
+ return refVal[i] ? 'var refVal' + i + ' = refVal[' + i + '];' : '';
}
@@ -757,14 +881,13 @@ function vars(arr, statement) {
return code;
}
-},{"../dotjs/validate":35,"./error_classes":5,"./resolve":8,"./util":12,"co":40,"fast-deep-equal":41,"fast-json-stable-stringify":42}],8:[function(require,module,exports){
+},{"../async":1,"../dotjs/validate":36,"./equal":4,"./resolve":7,"./util":11,"./validation_error":12,"co":41,"json-stable-stringify":42}],7:[function(require,module,exports){
'use strict';
var url = require('url')
- , equal = require('fast-deep-equal')
+ , equal = require('./equal')
, util = require('./util')
- , SchemaObject = require('./schema_obj')
- , traverse = require('json-schema-traverse');
+ , SchemaObject = require('./schema_obj');
module.exports = resolve;
@@ -808,7 +931,7 @@ function resolve(compile, root, ref) {
if (schema instanceof SchemaObject) {
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
- } else if (schema !== undefined) {
+ } else if (schema) {
v = inlineRef(schema, this._opts.inlineRefs)
? schema
: compile.call(this, schema, root, undefined, baseId);
@@ -829,7 +952,7 @@ function resolveSchema(root, ref) {
/* jshint validthis: true */
var p = url.parse(ref, false, true)
, refPath = _getFullPath(p)
- , baseId = getFullPath(this._getId(root.schema));
+ , baseId = getFullPath(root.schema.id);
if (refPath !== baseId) {
var id = normalizeId(refPath);
var refVal = this._refs[id];
@@ -850,7 +973,7 @@ function resolveSchema(root, ref) {
}
}
if (!root.schema) return;
- baseId = getFullPath(this._getId(root.schema));
+ baseId = getFullPath(root.schema.id);
}
return getJsonPointer.call(this, p, baseId, root.schema, root);
}
@@ -864,8 +987,7 @@ function resolveRecursive(root, ref, parsedRef) {
var schema = res.schema;
var baseId = res.baseId;
root = res.root;
- var id = this._getId(schema);
- if (id) baseId = resolveUrl(baseId, id);
+ if (schema.id) baseId = resolveUrl(baseId, schema.id);
return getJsonPointer.call(this, parsedRef, baseId, schema, root);
}
}
@@ -884,24 +1006,20 @@ function getJsonPointer(parsedRef, baseId, schema, root) {
if (part) {
part = util.unescapeFragment(part);
schema = schema[part];
- if (schema === undefined) break;
- var id;
- if (!PREVENT_SCOPE_CHANGE[part]) {
- id = this._getId(schema);
- if (id) baseId = resolveUrl(baseId, id);
- if (schema.$ref) {
- var $ref = resolveUrl(baseId, schema.$ref);
- var res = resolveSchema.call(this, root, $ref);
- if (res) {
- schema = res.schema;
- root = res.root;
- baseId = res.baseId;
- }
+ if (!schema) break;
+ if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id);
+ if (schema.$ref) {
+ var $ref = resolveUrl(baseId, schema.$ref);
+ var res = resolveSchema.call(this, root, $ref);
+ if (res) {
+ schema = res.schema;
+ root = res.root;
+ baseId = res.baseId;
}
}
}
}
- if (schema !== undefined && schema !== root.schema)
+ if (schema && schema != root.schema)
return { schema: schema, root: root, baseId: baseId };
}
@@ -991,46 +1109,48 @@ function resolveUrl(baseId, id) {
/* @this Ajv */
function resolveIds(schema) {
- var schemaId = normalizeId(this._getId(schema));
- var baseIds = {'': schemaId};
- var fullPaths = {'': getFullPath(schemaId, false)};
+ /* eslint no-shadow: 0 */
+ /* jshint validthis: true */
+ var id = normalizeId(schema.id);
var localRefs = {};
- var self = this;
+ _resolveIds.call(this, schema, getFullPath(id, false), id);
+ return localRefs;
- traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
- if (jsonPtr === '') return;
- var id = self._getId(sch);
- var baseId = baseIds[parentJsonPtr];
- var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
- if (keyIndex !== undefined)
- fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
-
- if (typeof id == 'string') {
- id = baseId = normalizeId(baseId ? url.resolve(baseId, id) : id);
-
- var refVal = self._refs[id];
- if (typeof refVal == 'string') refVal = self._refs[refVal];
- if (refVal && refVal.schema) {
- if (!equal(sch, refVal.schema))
- throw new Error('id "' + id + '" resolves to more than one schema');
- } else if (id != normalizeId(fullPath)) {
- if (id[0] == '#') {
- if (localRefs[id] && !equal(sch, localRefs[id]))
+ /* @this Ajv */
+ function _resolveIds(schema, fullPath, baseId) {
+ /* jshint validthis: true */
+ if (Array.isArray(schema)) {
+ for (var i=0; i',
+ $result = 'result' + $lvl;
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -1412,29 +1548,20 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
} else {
$schemaValue = $schema;
}
- var $isMax = $keyword == 'maximum',
- $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
- $schemaExcl = it.schema[$exclusiveKeyword],
- $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data,
- $op = $isMax ? '<' : '>',
- $notOp = $isMax ? '>' : '<',
- $errorKeyword = undefined;
if ($isDataExcl) {
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
$exclusive = 'exclusive' + $lvl,
- $exclType = 'exclType' + $lvl,
- $exclIsNumber = 'exclIsNumber' + $lvl,
$opExpr = 'op' + $lvl,
$opStr = '\' + ' + $opExpr + ' + \'';
out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
$schemaValueExcl = 'schemaExcl' + $lvl;
- out += ' var ' + ($exclusive) + '; var ' + ($exclType) + ' = typeof ' + ($schemaValueExcl) + '; if (' + ($exclType) + ' != \'boolean\' && ' + ($exclType) + ' != \'undefined\' && ' + ($exclType) + ' != \'number\') { ';
+ out += ' if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && ' + ($schemaValueExcl) + ' !== undefined) { ' + ($valid) + ' = false; ';
var $errorKeyword = $exclusiveKeyword;
var $$outStack = $$outStack || [];
$$outStack.push(out);
out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
+ out += ' { keyword: \'' + ($errorKeyword || '_formatExclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
if (it.opts.messages !== false) {
out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
}
@@ -1456,49 +1583,183 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
} else {
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
- out += ' } else if ( ';
+ out += ' } ';
+ if ($breakOnError) {
+ $closingBraces += '}';
+ out += ' else { ';
+ }
if ($isData) {
- out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
+ out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
+ $closingBraces += '}';
}
- out += ' ' + ($exclType) + ' == \'number\' ? ( (' + ($exclusive) + ' = ' + ($schemaValue) + ' === undefined || ' + ($schemaValueExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ') ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValueExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) : ( (' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
- } else {
- var $exclIsNumber = typeof $schemaExcl == 'number',
- $opStr = $op;
- if ($exclIsNumber && $isData) {
- var $opExpr = '\'' + $opStr + '\'';
- out += ' if ( ';
- if ($isData) {
- out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
- }
- out += ' ( ' + ($schemaValue) + ' === undefined || ' + ($schemaExcl) + ' ' + ($op) + '= ' + ($schemaValue) + ' ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaExcl) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' ) || ' + ($data) + ' !== ' + ($data) + ') { ';
+ if ($isDataFormat) {
+ out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
+ $closingBraces += '}';
+ }
+ out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
+ if ($isData) {
+ out += '' + ($schemaValue);
+ } else {
+ out += '' + (it.util.toQuotedString($schema));
+ }
+ out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; var ' + ($exclusive) + ' = ' + ($schemaValueExcl) + ' === true; if (' + ($valid) + ' === undefined) { ' + ($valid) + ' = ' + ($exclusive) + ' ? ' + ($result) + ' ' + ($op) + ' 0 : ' + ($result) + ' ' + ($op) + '= 0; } if (!' + ($valid) + ') var op' + ($lvl) + ' = ' + ($exclusive) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
+ } else {
+ var $exclusive = $schemaExcl === true,
+ $opStr = $op;
+ if (!$exclusive) $opStr += '=';
+ var $opExpr = '\'' + $opStr + '\'';
+ if ($isData) {
+ out += ' if (' + ($schemaValue) + ' === undefined) ' + ($valid) + ' = true; else if (typeof ' + ($schemaValue) + ' != \'string\') ' + ($valid) + ' = false; else { ';
+ $closingBraces += '}';
+ }
+ if ($isDataFormat) {
+ out += ' if (!' + ($compare) + ') ' + ($valid) + ' = true; else { ';
+ $closingBraces += '}';
+ }
+ out += ' var ' + ($result) + ' = ' + ($compare) + '(' + ($data) + ', ';
+ if ($isData) {
+ out += '' + ($schemaValue);
} else {
- if ($exclIsNumber && $schema === undefined) {
- $exclusive = true;
- $errorKeyword = $exclusiveKeyword;
- $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
- $schemaValue = $schemaExcl;
- $notOp += '=';
+ out += '' + (it.util.toQuotedString($schema));
+ }
+ out += ' ); if (' + ($result) + ' === undefined) ' + ($valid) + ' = false; if (' + ($valid) + ' === undefined) ' + ($valid) + ' = ' + ($result) + ' ' + ($op);
+ if (!$exclusive) {
+ out += '=';
+ }
+ out += ' 0;';
+ }
+ out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { ';
+ var $errorKeyword = $keyword;
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ($errorKeyword || '_formatLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { comparison: ' + ($opExpr) + ', limit: ';
+ if ($isData) {
+ out += '' + ($schemaValue);
+ } else {
+ out += '' + (it.util.toQuotedString($schema));
+ }
+ out += ' , exclusive: ' + ($exclusive) + ' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should be ' + ($opStr) + ' "';
+ if ($isData) {
+ out += '\' + ' + ($schemaValue) + ' + \'';
} else {
- if ($exclIsNumber) $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
- if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
- $exclusive = true;
- $errorKeyword = $exclusiveKeyword;
- $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
- $notOp += '=';
- } else {
- $exclusive = false;
- $opStr += '=';
- }
+ out += '' + (it.util.escapeQuotes($schema));
}
- var $opExpr = '\'' + $opStr + '\'';
- out += ' if ( ';
+ out += '"\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: ';
if ($isData) {
- out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
+ out += 'validate.schema' + ($schemaPath);
+ } else {
+ out += '' + (it.util.toQuotedString($schema));
+ }
+ out += ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
+ } else {
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
+ }
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ out += '}';
+ return out;
+}
+
+},{}],14:[function(require,module,exports){
+'use strict';
+module.exports = function generate__limit(it, $keyword) {
+ var out = ' ';
+ var $lvl = it.level;
+ var $dataLvl = it.dataLevel;
+ var $schema = it.schema[$keyword];
+ var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
+ var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
+ var $breakOnError = !it.opts.allErrors;
+ var $errorKeyword;
+ var $data = 'data' + ($dataLvl || '');
+ var $isData = it.opts.v5 && $schema && $schema.$data,
+ $schemaValue;
+ if ($isData) {
+ out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
+ $schemaValue = 'schema' + $lvl;
+ } else {
+ $schemaValue = $schema;
+ }
+ var $isMax = $keyword == 'maximum',
+ $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum',
+ $schemaExcl = it.schema[$exclusiveKeyword],
+ $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data,
+ $op = $isMax ? '<' : '>',
+ $notOp = $isMax ? '>' : '<';
+ if ($isDataExcl) {
+ var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
+ $exclusive = 'exclusive' + $lvl,
+ $opExpr = 'op' + $lvl,
+ $opStr = '\' + ' + $opExpr + ' + \'';
+ out += ' var schemaExcl' + ($lvl) + ' = ' + ($schemaValueExcl) + '; ';
+ $schemaValueExcl = 'schemaExcl' + $lvl;
+ out += ' var exclusive' + ($lvl) + '; if (typeof ' + ($schemaValueExcl) + ' != \'boolean\' && typeof ' + ($schemaValueExcl) + ' != \'undefined\') { ';
+ var $errorKeyword = $exclusiveKeyword;
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ($errorKeyword || '_exclusiveLimit') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'' + ($exclusiveKeyword) + ' should be boolean\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
+ } else {
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
}
- out += ' ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') { ';
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ out += ' } else if( ';
+ if ($isData) {
+ out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
+ }
+ out += ' ((exclusive' + ($lvl) + ' = ' + ($schemaValueExcl) + ' === true) ? ' + ($data) + ' ' + ($notOp) + '= ' + ($schemaValue) + ' : ' + ($data) + ' ' + ($notOp) + ' ' + ($schemaValue) + ') || ' + ($data) + ' !== ' + ($data) + ') { var op' + ($lvl) + ' = exclusive' + ($lvl) + ' ? \'' + ($op) + '\' : \'' + ($op) + '=\';';
+ } else {
+ var $exclusive = $schemaExcl === true,
+ $opStr = $op;
+ if (!$exclusive) $opStr += '=';
+ var $opExpr = '\'' + $opStr + '\'';
+ out += ' if ( ';
+ if ($isData) {
+ out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'number\') || ';
+ }
+ out += ' ' + ($data) + ' ' + ($notOp);
+ if ($exclusive) {
+ out += '=';
}
+ out += ' ' + ($schemaValue) + ' || ' + ($data) + ' !== ' + ($data) + ') {';
}
- $errorKeyword = $errorKeyword || $keyword;
+ var $errorKeyword = $keyword;
var $$outStack = $$outStack || [];
$$outStack.push(out);
out = ''; /* istanbul ignore else */
@@ -1509,7 +1770,7 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
if ($isData) {
out += '\' + ' + ($schemaValue);
} else {
- out += '' + ($schemaValue) + '\'';
+ out += '' + ($schema) + '\'';
}
}
if (it.opts.verbose) {
@@ -1543,9 +1804,9 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
return out;
}
-},{}],14:[function(require,module,exports){
+},{}],15:[function(require,module,exports){
'use strict';
-module.exports = function generate__limitItems(it, $keyword, $ruleType) {
+module.exports = function generate__limitItems(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -1555,7 +1816,7 @@ module.exports = function generate__limitItems(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -1621,9 +1882,9 @@ module.exports = function generate__limitItems(it, $keyword, $ruleType) {
return out;
}
-},{}],15:[function(require,module,exports){
+},{}],16:[function(require,module,exports){
'use strict';
-module.exports = function generate__limitLength(it, $keyword, $ruleType) {
+module.exports = function generate__limitLength(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -1633,7 +1894,7 @@ module.exports = function generate__limitLength(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -1704,9 +1965,9 @@ module.exports = function generate__limitLength(it, $keyword, $ruleType) {
return out;
}
-},{}],16:[function(require,module,exports){
+},{}],17:[function(require,module,exports){
'use strict';
-module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
+module.exports = function generate__limitProperties(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -1716,7 +1977,7 @@ module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $errorKeyword;
var $data = 'data' + ($dataLvl || '');
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -1782,9 +2043,9 @@ module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
return out;
}
-},{}],17:[function(require,module,exports){
+},{}],18:[function(require,module,exports){
'use strict';
-module.exports = function generate_allOf(it, $keyword, $ruleType) {
+module.exports = function generate_allOf(it, $keyword) {
var out = ' ';
var $schema = it.schema[$keyword];
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
@@ -1827,9 +2088,9 @@ module.exports = function generate_allOf(it, $keyword, $ruleType) {
return out;
}
-},{}],18:[function(require,module,exports){
+},{}],19:[function(require,module,exports){
'use strict';
-module.exports = function generate_anyOf(it, $keyword, $ruleType) {
+module.exports = function generate_anyOf(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -1868,7 +2129,7 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) {
}
}
it.compositeRule = $it.compositeRule = $wasComposite;
- out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
+ out += ' ' + ($closingBraces) + ' if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ('anyOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
if (it.opts.messages !== false) {
@@ -1881,15 +2142,7 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) {
} else {
out += ' {} ';
}
- out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError(vErrors); ';
- } else {
- out += ' validate.errors = vErrors; return false; ';
- }
- }
- out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
+ out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
if (it.opts.allErrors) {
out += ' } ';
}
@@ -1902,9 +2155,9 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) {
return out;
}
-},{}],19:[function(require,module,exports){
+},{}],20:[function(require,module,exports){
'use strict';
-module.exports = function generate_const(it, $keyword, $ruleType) {
+module.exports = function generate_constant(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -1914,7 +2167,7 @@ module.exports = function generate_const(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
var $valid = 'valid' + $lvl;
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -1930,7 +2183,7 @@ module.exports = function generate_const(it, $keyword, $ruleType) {
$$outStack.push(out);
out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
- out += ' { keyword: \'' + ('const') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
+ out += ' { keyword: \'' + ('constant') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
if (it.opts.messages !== false) {
out += ' , message: \'should be equal to constant\' ';
}
@@ -1953,98 +2206,12 @@ module.exports = function generate_const(it, $keyword, $ruleType) {
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
out += ' }';
- if ($breakOnError) {
- out += ' else { ';
- }
- return out;
-}
-
-},{}],20:[function(require,module,exports){
-'use strict';
-module.exports = function generate_contains(it, $keyword, $ruleType) {
- var out = ' ';
- var $lvl = it.level;
- var $dataLvl = it.dataLevel;
- var $schema = it.schema[$keyword];
- var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
- var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
- var $breakOnError = !it.opts.allErrors;
- var $data = 'data' + ($dataLvl || '');
- var $valid = 'valid' + $lvl;
- var $errs = 'errs__' + $lvl;
- var $it = it.util.copy(it);
- var $closingBraces = '';
- $it.level++;
- var $nextValid = 'valid' + $it.level;
- var $idx = 'i' + $lvl,
- $dataNxt = $it.dataLevel = it.dataLevel + 1,
- $nextData = 'data' + $dataNxt,
- $currentBaseId = it.baseId,
- $nonEmptySchema = it.util.schemaHasRules($schema, it.RULES.all);
- out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
- if ($nonEmptySchema) {
- var $wasComposite = it.compositeRule;
- it.compositeRule = $it.compositeRule = true;
- $it.schema = $schema;
- $it.schemaPath = $schemaPath;
- $it.errSchemaPath = $errSchemaPath;
- out += ' var ' + ($nextValid) + ' = false; for (var ' + ($idx) + ' = 0; ' + ($idx) + ' < ' + ($data) + '.length; ' + ($idx) + '++) { ';
- $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
- var $passData = $data + '[' + $idx + ']';
- $it.dataPathArr[$dataNxt] = $idx;
- var $code = it.validate($it);
- $it.baseId = $currentBaseId;
- if (it.util.varOccurences($code, $nextData) < 2) {
- out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
- } else {
- out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
- }
- out += ' if (' + ($nextValid) + ') break; } ';
- it.compositeRule = $it.compositeRule = $wasComposite;
- out += ' ' + ($closingBraces) + ' if (!' + ($nextValid) + ') {';
- } else {
- out += ' if (' + ($data) + '.length == 0) {';
- }
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ('contains') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should contain a valid item\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
- }
- out += ' } ';
- } else {
- out += ' {} ';
- }
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
- } else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
- }
- out += ' } else { ';
- if ($nonEmptySchema) {
- out += ' errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } ';
- }
- if (it.opts.allErrors) {
- out += ' } ';
- }
- out = it.util.cleanUpCode(out);
return out;
}
},{}],21:[function(require,module,exports){
'use strict';
-module.exports = function generate_custom(it, $keyword, $ruleType) {
+module.exports = function generate_custom(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2056,7 +2223,7 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
var $data = 'data' + ($dataLvl || '');
var $valid = 'valid' + $lvl;
var $errs = 'errs__' + $lvl;
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -2066,8 +2233,7 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
}
var $rule = this,
$definition = 'definition' + $lvl,
- $rDef = $rule.definition,
- $closingBraces = '';
+ $rDef = $rule.definition;
var $compile, $inline, $macro, $ruleValidate, $validateCode;
if ($isData && $rDef.$data) {
$validateCode = 'keywordValidate' + $lvl;
@@ -2075,7 +2241,6 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
out += ' var ' + ($definition) + ' = RULES.custom[\'' + ($keyword) + '\'].definition; var ' + ($validateCode) + ' = ' + ($definition) + '.validate;';
} else {
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
- if (!$ruleValidate) return;
$schemaValue = 'validate.schema' + $schemaPath;
$validateCode = $ruleValidate.code;
$compile = $rDef.compile;
@@ -2091,13 +2256,8 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
out += '' + ($ruleErrs) + ' = null;';
}
out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';';
- if ($isData && $rDef.$data) {
- $closingBraces += '}';
- out += ' if (' + ($schemaValue) + ' === undefined) { ' + ($valid) + ' = true; } else { ';
- if ($validateSchema) {
- $closingBraces += '}';
- out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') { ';
- }
+ if ($validateSchema) {
+ out += ' ' + ($valid) + ' = ' + ($definition) + '.validateSchema(' + ($schemaValue) + '); if (' + ($valid) + ') {';
}
if ($inline) {
if ($rDef.statements) {
@@ -2107,7 +2267,6 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
}
} else if ($macro) {
var $it = it.util.copy(it);
- var $closingBraces = '';
$it.level++;
var $nextValid = 'valid' + $it.level;
$it.schema = $ruleValidate.validate;
@@ -2157,9 +2316,11 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
}
}
if ($rDef.modifying) {
- out += ' if (' + ($parentData) + ') ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
+ out += ' ' + ($data) + ' = ' + ($parentData) + '[' + ($parentDataProperty) + '];';
+ }
+ if ($validateSchema) {
+ out += ' }';
}
- out += '' + ($closingBraces);
if ($rDef.valid) {
if ($breakOnError) {
out += ' if (true) { ';
@@ -2272,7 +2433,7 @@ module.exports = function generate_custom(it, $keyword, $ruleType) {
},{}],22:[function(require,module,exports){
'use strict';
-module.exports = function generate_dependencies(it, $keyword, $ruleType) {
+module.exports = function generate_dependencies(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2287,8 +2448,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
$it.level++;
var $nextValid = 'valid' + $it.level;
var $schemaDeps = {},
- $propertyDeps = {},
- $ownProperties = it.opts.ownProperties;
+ $propertyDeps = {};
for ($property in $schema) {
var $sch = $schema[$property];
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
@@ -2299,115 +2459,100 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
out += 'var missing' + ($lvl) + ';';
for (var $property in $propertyDeps) {
$deps = $propertyDeps[$property];
- if ($deps.length) {
- out += ' if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
- if ($ownProperties) {
- out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
+ out += ' if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
+ if ($breakOnError) {
+ out += ' && ( ';
+ var arr1 = $deps;
+ if (arr1) {
+ var _$property, $i = -1,
+ l1 = arr1.length - 1;
+ while ($i < l1) {
+ _$property = arr1[$i += 1];
+ if ($i) {
+ out += ' || ';
+ }
+ var $prop = it.util.getProperty(_$property);
+ out += ' ( ' + ($data) + ($prop) + ' === undefined && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop)) + ') ) ';
+ }
}
- if ($breakOnError) {
- out += ' && ( ';
- var arr1 = $deps;
- if (arr1) {
- var $propertyKey, $i = -1,
- l1 = arr1.length - 1;
- while ($i < l1) {
- $propertyKey = arr1[$i += 1];
- if ($i) {
- out += ' || ';
- }
- var $prop = it.util.getProperty($propertyKey),
- $useData = $data + $prop;
- out += ' ( ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
+ out += ')) { ';
+ var $propertyPath = 'missing' + $lvl,
+ $missingProperty = '\' + ' + $propertyPath + ' + \'';
+ if (it.opts._errorDataPathProperty) {
+ it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
+ }
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should have ';
+ if ($deps.length == 1) {
+ out += 'property ' + (it.util.escapeQuotes($deps[0]));
+ } else {
+ out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
}
+ out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
}
- out += ')) { ';
- var $propertyPath = 'missing' + $lvl,
- $missingProperty = '\' + ' + $propertyPath + ' + \'';
- if (it.opts._errorDataPathProperty) {
- it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + ' + ' + $propertyPath;
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
}
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should have ';
- if ($deps.length == 1) {
- out += 'property ' + (it.util.escapeQuotes($deps[0]));
- } else {
- out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
- }
- out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
- }
- out += ' } ';
- } else {
- out += ' {} ';
- }
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
} else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
}
} else {
- out += ' ) { ';
- var arr2 = $deps;
- if (arr2) {
- var $propertyKey, i2 = -1,
- l2 = arr2.length - 1;
- while (i2 < l2) {
- $propertyKey = arr2[i2 += 1];
- var $prop = it.util.getProperty($propertyKey),
- $missingProperty = it.util.escapeQuotes($propertyKey),
- $useData = $data + $prop;
- if (it.opts._errorDataPathProperty) {
- it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
- }
- out += ' if ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ') { var err = '; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should have ';
- if ($deps.length == 1) {
- out += 'property ' + (it.util.escapeQuotes($deps[0]));
- } else {
- out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
- }
- out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ } else {
+ out += ' ) { ';
+ var arr2 = $deps;
+ if (arr2) {
+ var $reqProperty, i2 = -1,
+ l2 = arr2.length - 1;
+ while (i2 < l2) {
+ $reqProperty = arr2[i2 += 1];
+ var $prop = it.util.getProperty($reqProperty),
+ $missingProperty = it.util.escapeQuotes($reqProperty);
+ if (it.opts._errorDataPathProperty) {
+ it.errorPath = it.util.getPath($currentErrorPath, $reqProperty, it.opts.jsonPointers);
+ }
+ out += ' if (' + ($data) + ($prop) + ' === undefined) { var err = '; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('dependencies') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { property: \'' + (it.util.escapeQuotes($property)) + '\', missingProperty: \'' + ($missingProperty) + '\', depsCount: ' + ($deps.length) + ', deps: \'' + (it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", "))) + '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should have ';
+ if ($deps.length == 1) {
+ out += 'property ' + (it.util.escapeQuotes($deps[0]));
+ } else {
+ out += 'properties ' + (it.util.escapeQuotes($deps.join(", ")));
}
- out += ' } ';
- } else {
- out += ' {} ';
+ out += ' when property ' + (it.util.escapeQuotes($property)) + ' is present\' ';
}
- out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
}
+ out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
}
}
- out += ' } ';
- if ($breakOnError) {
- $closingBraces += '}';
- out += ' else { ';
- }
+ }
+ out += ' } ';
+ if ($breakOnError) {
+ $closingBraces += '}';
+ out += ' else { ';
}
}
it.errorPath = $currentErrorPath;
@@ -2415,11 +2560,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
for (var $property in $schemaDeps) {
var $sch = $schemaDeps[$property];
if (it.util.schemaHasRules($sch, it.RULES.all)) {
- out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined ';
- if ($ownProperties) {
- out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') ';
- }
- out += ') { ';
+ out += ' ' + ($nextValid) + ' = true; if (' + ($data) + (it.util.getProperty($property)) + ' !== undefined) { ';
$it.schema = $sch;
$it.schemaPath = $schemaPath + it.util.getProperty($property);
$it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
@@ -2441,7 +2582,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
},{}],23:[function(require,module,exports){
'use strict';
-module.exports = function generate_enum(it, $keyword, $ruleType) {
+module.exports = function generate_enum(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2451,7 +2592,7 @@ module.exports = function generate_enum(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
var $valid = 'valid' + $lvl;
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -2508,7 +2649,7 @@ module.exports = function generate_enum(it, $keyword, $ruleType) {
},{}],24:[function(require,module,exports){
'use strict';
-module.exports = function generate_format(it, $keyword, $ruleType) {
+module.exports = function generate_format(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2523,7 +2664,7 @@ module.exports = function generate_format(it, $keyword, $ruleType) {
}
return out;
}
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -2534,10 +2675,8 @@ module.exports = function generate_format(it, $keyword, $ruleType) {
var $unknownFormats = it.opts.unknownFormats,
$allowUnknown = Array.isArray($unknownFormats);
if ($isData) {
- var $format = 'format' + $lvl,
- $isObject = 'isObject' + $lvl,
- $formatType = 'formatType' + $lvl;
- out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var ' + ($isObject) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; var ' + ($formatType) + ' = ' + ($isObject) + ' && ' + ($format) + '.type || \'string\'; if (' + ($isObject) + ') { ';
+ var $format = 'format' + $lvl;
+ out += ' var ' + ($format) + ' = formats[' + ($schemaValue) + ']; var isObject' + ($lvl) + ' = typeof ' + ($format) + ' == \'object\' && !(' + ($format) + ' instanceof RegExp) && ' + ($format) + '.validate; if (isObject' + ($lvl) + ') { ';
if (it.async) {
out += ' var async' + ($lvl) + ' = ' + ($format) + '.async; ';
}
@@ -2546,14 +2685,14 @@ module.exports = function generate_format(it, $keyword, $ruleType) {
out += ' (' + ($schemaValue) + ' !== undefined && typeof ' + ($schemaValue) + ' != \'string\') || ';
}
out += ' (';
- if ($unknownFormats != 'ignore') {
+ if ($unknownFormats === true || $allowUnknown) {
out += ' (' + ($schemaValue) + ' && !' + ($format) + ' ';
if ($allowUnknown) {
out += ' && self._opts.unknownFormats.indexOf(' + ($schemaValue) + ') == -1 ';
}
out += ') || ';
}
- out += ' (' + ($format) + ' && ' + ($formatType) + ' == \'' + ($ruleType) + '\' && !(typeof ' + ($format) + ' == \'function\' ? ';
+ out += ' (' + ($format) + ' && !(typeof ' + ($format) + ' == \'function\' ? ';
if (it.async) {
out += ' (async' + ($lvl) + ' ? ' + (it.yieldAwait) + ' ' + ($format) + '(' + ($data) + ') : ' + ($format) + '(' + ($data) + ')) ';
} else {
@@ -2563,33 +2702,24 @@ module.exports = function generate_format(it, $keyword, $ruleType) {
} else {
var $format = it.formats[$schema];
if (!$format) {
- if ($unknownFormats == 'ignore') {
- it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
- if ($breakOnError) {
- out += ' if (true) { ';
+ if ($unknownFormats === true || ($allowUnknown && $unknownFormats.indexOf($schema) == -1)) {
+ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
+ } else {
+ if (!$allowUnknown) {
+ console.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
+ if ($unknownFormats !== 'ignore') console.warn('In the next major version it will throw exception. See option unknownFormats for more information');
}
- return out;
- } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
if ($breakOnError) {
out += ' if (true) { ';
}
return out;
- } else {
- throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
}
}
var $isObject = typeof $format == 'object' && !($format instanceof RegExp) && $format.validate;
- var $formatType = $isObject && $format.type || 'string';
if ($isObject) {
var $async = $format.async === true;
$format = $format.validate;
}
- if ($formatType != $ruleType) {
- if ($breakOnError) {
- out += ' if (true) { ';
- }
- return out;
- }
if ($async) {
if (!it.async) throw new Error('async format in sync schema');
var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
@@ -2659,7 +2789,7 @@ module.exports = function generate_format(it, $keyword, $ruleType) {
},{}],25:[function(require,module,exports){
'use strict';
-module.exports = function generate_items(it, $keyword, $ruleType) {
+module.exports = function generate_items(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2790,7 +2920,11 @@ module.exports = function generate_items(it, $keyword, $ruleType) {
if ($breakOnError) {
out += ' if (!' + ($nextValid) + ') break; ';
}
- out += ' }';
+ out += ' } ';
+ if ($breakOnError) {
+ out += ' if (' + ($nextValid) + ') { ';
+ $closingBraces += '}';
+ }
}
if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
@@ -2801,7 +2935,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) {
},{}],26:[function(require,module,exports){
'use strict';
-module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
+module.exports = function generate_multipleOf(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2810,7 +2944,7 @@ module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -2843,7 +2977,7 @@ module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
if ($isData) {
out += '\' + ' + ($schemaValue);
} else {
- out += '' + ($schemaValue) + '\'';
+ out += '' + ($schema) + '\'';
}
}
if (it.opts.verbose) {
@@ -2879,7 +3013,7 @@ module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
},{}],27:[function(require,module,exports){
'use strict';
-module.exports = function generate_not(it, $keyword, $ruleType) {
+module.exports = function generate_not(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -2964,7 +3098,7 @@ module.exports = function generate_not(it, $keyword, $ruleType) {
},{}],28:[function(require,module,exports){
'use strict';
-module.exports = function generate_oneOf(it, $keyword, $ruleType) {
+module.exports = function generate_oneOf(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -3006,7 +3140,10 @@ module.exports = function generate_oneOf(it, $keyword, $ruleType) {
}
}
it.compositeRule = $it.compositeRule = $wasComposite;
- out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { var err = '; /* istanbul ignore else */
+ out += '' + ($closingBraces) + 'if (!' + ($valid) + ') { ';
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ('oneOf') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
if (it.opts.messages !== false) {
@@ -3019,13 +3156,16 @@ module.exports = function generate_oneOf(it, $keyword, $ruleType) {
} else {
out += ' {} ';
}
- out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ var __err = out;
+ out = $$outStack.pop();
if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
if (it.async) {
- out += ' throw new ValidationError(vErrors); ';
+ out += ' throw new ValidationError([' + (__err) + ']); ';
} else {
- out += ' validate.errors = vErrors; return false; ';
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
}
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
out += '} else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; }';
if (it.opts.allErrors) {
@@ -3036,7 +3176,7 @@ module.exports = function generate_oneOf(it, $keyword, $ruleType) {
},{}],29:[function(require,module,exports){
'use strict';
-module.exports = function generate_pattern(it, $keyword, $ruleType) {
+module.exports = function generate_pattern(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -3045,7 +3185,7 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -3112,7 +3252,60 @@ module.exports = function generate_pattern(it, $keyword, $ruleType) {
},{}],30:[function(require,module,exports){
'use strict';
-module.exports = function generate_properties(it, $keyword, $ruleType) {
+module.exports = function generate_patternRequired(it, $keyword) {
+ var out = ' ';
+ var $lvl = it.level;
+ var $dataLvl = it.dataLevel;
+ var $schema = it.schema[$keyword];
+ var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
+ var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
+ var $breakOnError = !it.opts.allErrors;
+ var $data = 'data' + ($dataLvl || '');
+ var $valid = 'valid' + $lvl;
+ var $key = 'key' + $lvl,
+ $matched = 'patternMatched' + $lvl,
+ $closingBraces = '',
+ $ownProperties = it.opts.ownProperties;
+ out += 'var ' + ($valid) + ' = true;';
+ var arr1 = $schema;
+ if (arr1) {
+ var $pProperty, i1 = -1,
+ l1 = arr1.length - 1;
+ while (i1 < l1) {
+ $pProperty = arr1[i1 += 1];
+ out += ' var ' + ($matched) + ' = false; for (var ' + ($key) + ' in ' + ($data) + ') { ';
+ if ($ownProperties) {
+ out += ' if (!Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($key) + ')) continue; ';
+ }
+ out += ' ' + ($matched) + ' = ' + (it.usePattern($pProperty)) + '.test(' + ($key) + '); if (' + ($matched) + ') break; } ';
+ var $missingPattern = it.util.escapeQuotes($pProperty);
+ out += ' if (!' + ($matched) + ') { ' + ($valid) + ' = false; var err = '; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('patternRequired') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingPattern: \'' + ($missingPattern) + '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should have property matching pattern \\\'' + ($missingPattern) + '\\\'\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ';
+ if ($breakOnError) {
+ $closingBraces += '}';
+ out += ' else { ';
+ }
+ }
+ }
+ out += '' + ($closingBraces);
+ return out;
+}
+
+},{}],31:[function(require,module,exports){
+'use strict';
+module.exports = function generate_properties(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -3128,10 +3321,8 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$it.level++;
var $nextValid = 'valid' + $it.level;
var $key = 'key' + $lvl,
- $idx = 'idx' + $lvl,
$dataNxt = $it.dataLevel = it.dataLevel + 1,
- $nextData = 'data' + $dataNxt,
- $dataProperties = 'dataProperties' + $lvl;
+ $nextData = 'data' + $dataNxt;
var $schemaKeys = Object.keys($schema || {}),
$pProperties = it.schema.patternProperties || {},
$pPropertyKeys = Object.keys($pProperties),
@@ -3145,19 +3336,15 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$currentBaseId = it.baseId;
var $required = it.schema.required;
if ($required && !(it.opts.v5 && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required);
- if (it.opts.patternGroups) {
+ if (it.opts.v5) {
var $pgProperties = it.schema.patternGroups || {},
$pgPropertyKeys = Object.keys($pgProperties);
}
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
- if ($ownProperties) {
- out += ' var ' + ($dataProperties) + ' = undefined;';
- }
if ($checkAdditional) {
+ out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
if ($ownProperties) {
- out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
- } else {
- out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
+ out += ' if (!Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($key) + ')) continue; ';
}
if ($someProperties) {
out += ' var isAdditional' + ($lvl) + ' = !(false ';
@@ -3187,7 +3374,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
}
}
}
- if (it.opts.patternGroups && $pgPropertyKeys.length) {
+ if (it.opts.v5 && $pgPropertyKeys && $pgPropertyKeys.length) {
var arr3 = $pgPropertyKeys;
if (arr3) {
var $pgProperty, $i = -1,
@@ -3327,11 +3514,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
out += ' ' + ($code) + ' ';
} else {
if ($requiredHash && $requiredHash[$propertyKey]) {
- out += ' if ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ') { ' + ($nextValid) + ' = false; ';
+ out += ' if (' + ($useData) + ' === undefined) { ' + ($nextValid) + ' = false; ';
var $currentErrorPath = it.errorPath,
$currErrSchemaPath = $errSchemaPath,
$missingProperty = it.util.escapeQuotes($propertyKey);
@@ -3376,17 +3559,9 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
out += ' } else { ';
} else {
if ($breakOnError) {
- out += ' if ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ') { ' + ($nextValid) + ' = true; } else { ';
+ out += ' if (' + ($useData) + ' === undefined) { ' + ($nextValid) + ' = true; } else { ';
} else {
- out += ' if (' + ($useData) + ' !== undefined ';
- if ($ownProperties) {
- out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ' ) { ';
+ out += ' if (' + ($useData) + ' !== undefined) { ';
}
}
out += ' ' + ($code) + ' } ';
@@ -3399,51 +3574,48 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
}
}
}
- if ($pPropertyKeys.length) {
- var arr5 = $pPropertyKeys;
- if (arr5) {
- var $pProperty, i5 = -1,
- l5 = arr5.length - 1;
- while (i5 < l5) {
- $pProperty = arr5[i5 += 1];
- var $sch = $pProperties[$pProperty];
- if (it.util.schemaHasRules($sch, it.RULES.all)) {
- $it.schema = $sch;
- $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
- $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
- if ($ownProperties) {
- out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
- } else {
- out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
- }
- out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
- $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
- var $passData = $data + '[' + $key + ']';
- $it.dataPathArr[$dataNxt] = $key;
- var $code = it.validate($it);
- $it.baseId = $currentBaseId;
- if (it.util.varOccurences($code, $nextData) < 2) {
- out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
- } else {
- out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
- }
- if ($breakOnError) {
- out += ' if (!' + ($nextValid) + ') break; ';
- }
- out += ' } ';
- if ($breakOnError) {
- out += ' else ' + ($nextValid) + ' = true; ';
- }
- out += ' } ';
- if ($breakOnError) {
- out += ' if (' + ($nextValid) + ') { ';
- $closingBraces += '}';
- }
+ var arr5 = $pPropertyKeys;
+ if (arr5) {
+ var $pProperty, i5 = -1,
+ l5 = arr5.length - 1;
+ while (i5 < l5) {
+ $pProperty = arr5[i5 += 1];
+ var $sch = $pProperties[$pProperty];
+ if (it.util.schemaHasRules($sch, it.RULES.all)) {
+ $it.schema = $sch;
+ $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
+ $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
+ out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
+ if ($ownProperties) {
+ out += ' if (!Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($key) + ')) continue; ';
+ }
+ out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
+ $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
+ var $passData = $data + '[' + $key + ']';
+ $it.dataPathArr[$dataNxt] = $key;
+ var $code = it.validate($it);
+ $it.baseId = $currentBaseId;
+ if (it.util.varOccurences($code, $nextData) < 2) {
+ out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
+ } else {
+ out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
+ }
+ if ($breakOnError) {
+ out += ' if (!' + ($nextValid) + ') break; ';
+ }
+ out += ' } ';
+ if ($breakOnError) {
+ out += ' else ' + ($nextValid) + ' = true; ';
+ }
+ out += ' } ';
+ if ($breakOnError) {
+ out += ' if (' + ($nextValid) + ') { ';
+ $closingBraces += '}';
}
}
}
}
- if (it.opts.patternGroups && $pgPropertyKeys.length) {
+ if (it.opts.v5) {
var arr6 = $pgPropertyKeys;
if (arr6) {
var $pgProperty, i6 = -1,
@@ -3456,11 +3628,9 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$it.schema = $sch;
$it.schemaPath = it.schemaPath + '.patternGroups' + it.util.getProperty($pgProperty) + '.schema';
$it.errSchemaPath = it.errSchemaPath + '/patternGroups/' + it.util.escapeFragment($pgProperty) + '/schema';
- out += ' var pgPropCount' + ($lvl) + ' = 0; ';
+ out += ' var pgPropCount' + ($lvl) + ' = 0; for (var ' + ($key) + ' in ' + ($data) + ') { ';
if ($ownProperties) {
- out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
- } else {
- out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
+ out += ' if (!Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($key) + ')) continue; ';
}
out += ' if (' + (it.usePattern($pgProperty)) + '.test(' + ($key) + ')) { pgPropCount' + ($lvl) + '++; ';
$it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
@@ -3580,92 +3750,9 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
return out;
}
-},{}],31:[function(require,module,exports){
-'use strict';
-module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
- var out = ' ';
- var $lvl = it.level;
- var $dataLvl = it.dataLevel;
- var $schema = it.schema[$keyword];
- var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
- var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
- var $breakOnError = !it.opts.allErrors;
- var $data = 'data' + ($dataLvl || '');
- var $errs = 'errs__' + $lvl;
- var $it = it.util.copy(it);
- var $closingBraces = '';
- $it.level++;
- var $nextValid = 'valid' + $it.level;
- if (it.util.schemaHasRules($schema, it.RULES.all)) {
- $it.schema = $schema;
- $it.schemaPath = $schemaPath;
- $it.errSchemaPath = $errSchemaPath;
- var $key = 'key' + $lvl,
- $idx = 'idx' + $lvl,
- $i = 'i' + $lvl,
- $invalidName = '\' + ' + $key + ' + \'',
- $dataNxt = $it.dataLevel = it.dataLevel + 1,
- $nextData = 'data' + $dataNxt,
- $dataProperties = 'dataProperties' + $lvl,
- $ownProperties = it.opts.ownProperties,
- $currentBaseId = it.baseId;
- out += ' var ' + ($errs) + ' = errors; ';
- if ($ownProperties) {
- out += ' var ' + ($dataProperties) + ' = undefined; ';
- }
- if ($ownProperties) {
- out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
- } else {
- out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
- }
- out += ' var startErrs' + ($lvl) + ' = errors; ';
- var $passData = $key;
- var $wasComposite = it.compositeRule;
- it.compositeRule = $it.compositeRule = true;
- var $code = it.validate($it);
- $it.baseId = $currentBaseId;
- if (it.util.varOccurences($code, $nextData) < 2) {
- out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
- } else {
- out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
- }
- it.compositeRule = $it.compositeRule = $wasComposite;
- out += ' if (!' + ($nextValid) + ') { for (var ' + ($i) + '=startErrs' + ($lvl) + '; ' + ($i) + '= it.opts.loopRequired,
- $ownProperties = it.opts.ownProperties;
+ $loopRequired = $isData || $required.length >= it.opts.loopRequired;
if ($breakOnError) {
out += ' var missing' + ($lvl) + '; ';
if ($loopRequired) {
@@ -3848,11 +3930,7 @@ module.exports = function generate_required(it, $keyword, $ruleType) {
if ($isData) {
out += ' if (schema' + ($lvl) + ' === undefined) ' + ($valid) + ' = true; else if (!Array.isArray(schema' + ($lvl) + ')) ' + ($valid) + ' = false; else {';
}
- out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined ';
- if ($ownProperties) {
- out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
- }
- out += '; if (!' + ($valid) + ') break; } ';
+ out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { ' + ($valid) + ' = ' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] !== undefined; if (!' + ($valid) + ') break; } ';
if ($isData) {
out += ' } ';
}
@@ -3894,20 +3972,15 @@ module.exports = function generate_required(it, $keyword, $ruleType) {
out += ' if ( ';
var arr2 = $required;
if (arr2) {
- var $propertyKey, $i = -1,
+ var _$property, $i = -1,
l2 = arr2.length - 1;
while ($i < l2) {
- $propertyKey = arr2[$i += 1];
+ _$property = arr2[$i += 1];
if ($i) {
out += ' || ';
}
- var $prop = it.util.getProperty($propertyKey),
- $useData = $data + $prop;
- out += ' ( ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
- }
- out += ') && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop)) + ') ) ';
+ var $prop = it.util.getProperty(_$property);
+ out += ' ( ' + ($data) + ($prop) + ' === undefined && (missing' + ($lvl) + ' = ' + (it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop)) + ') ) ';
}
}
out += ') { ';
@@ -3983,11 +4056,7 @@ module.exports = function generate_required(it, $keyword, $ruleType) {
}
out += '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + ($vSchema) + ' !== undefined) { ';
}
- out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', ' + ($vSchema) + '[' + ($i) + ']) ';
- }
- out += ') { var err = '; /* istanbul ignore else */
+ out += ' for (var ' + ($i) + ' = 0; ' + ($i) + ' < ' + ($vSchema) + '.length; ' + ($i) + '++) { if (' + ($data) + '[' + ($vSchema) + '[' + ($i) + ']] === undefined) { var err = '; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
if (it.opts.messages !== false) {
@@ -4013,21 +4082,16 @@ module.exports = function generate_required(it, $keyword, $ruleType) {
} else {
var arr3 = $required;
if (arr3) {
- var $propertyKey, i3 = -1,
+ var $reqProperty, i3 = -1,
l3 = arr3.length - 1;
while (i3 < l3) {
- $propertyKey = arr3[i3 += 1];
- var $prop = it.util.getProperty($propertyKey),
- $missingProperty = it.util.escapeQuotes($propertyKey),
- $useData = $data + $prop;
+ $reqProperty = arr3[i3 += 1];
+ var $prop = it.util.getProperty($reqProperty),
+ $missingProperty = it.util.escapeQuotes($reqProperty);
if (it.opts._errorDataPathProperty) {
- it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
- }
- out += ' if ( ' + ($useData) + ' === undefined ';
- if ($ownProperties) {
- out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
+ it.errorPath = it.util.getPath($currentErrorPath, $reqProperty, it.opts.jsonPointers);
}
- out += ') { var err = '; /* istanbul ignore else */
+ out += ' if (' + ($data) + ($prop) + ' === undefined) { var err = '; /* istanbul ignore else */
if (it.createErrors !== false) {
out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
if (it.opts.messages !== false) {
@@ -4060,7 +4124,7 @@ module.exports = function generate_required(it, $keyword, $ruleType) {
},{}],34:[function(require,module,exports){
'use strict';
-module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
+module.exports = function generate_switch(it, $keyword) {
var out = ' ';
var $lvl = it.level;
var $dataLvl = it.dataLevel;
@@ -4070,7 +4134,137 @@ module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
var $breakOnError = !it.opts.allErrors;
var $data = 'data' + ($dataLvl || '');
var $valid = 'valid' + $lvl;
- var $isData = it.opts.$data && $schema && $schema.$data,
+ var $errs = 'errs__' + $lvl;
+ var $it = it.util.copy(it);
+ var $closingBraces = '';
+ $it.level++;
+ var $nextValid = 'valid' + $it.level;
+ var $ifPassed = 'ifPassed' + it.level,
+ $currentBaseId = $it.baseId,
+ $shouldContinue;
+ out += 'var ' + ($ifPassed) + ';';
+ var arr1 = $schema;
+ if (arr1) {
+ var $sch, $caseIndex = -1,
+ l1 = arr1.length - 1;
+ while ($caseIndex < l1) {
+ $sch = arr1[$caseIndex += 1];
+ if ($caseIndex && !$shouldContinue) {
+ out += ' if (!' + ($ifPassed) + ') { ';
+ $closingBraces += '}';
+ }
+ if ($sch.if && it.util.schemaHasRules($sch.if, it.RULES.all)) {
+ out += ' var ' + ($errs) + ' = errors; ';
+ var $wasComposite = it.compositeRule;
+ it.compositeRule = $it.compositeRule = true;
+ $it.createErrors = false;
+ $it.schema = $sch.if;
+ $it.schemaPath = $schemaPath + '[' + $caseIndex + '].if';
+ $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/if';
+ out += ' ' + (it.validate($it)) + ' ';
+ $it.baseId = $currentBaseId;
+ $it.createErrors = true;
+ it.compositeRule = $it.compositeRule = $wasComposite;
+ out += ' ' + ($ifPassed) + ' = ' + ($nextValid) + '; if (' + ($ifPassed) + ') { ';
+ if (typeof $sch.then == 'boolean') {
+ if ($sch.then === false) {
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should pass "switch" keyword validation\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
+ } else {
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
+ }
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ }
+ out += ' var ' + ($nextValid) + ' = ' + ($sch.then) + '; ';
+ } else {
+ $it.schema = $sch.then;
+ $it.schemaPath = $schemaPath + '[' + $caseIndex + '].then';
+ $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/then';
+ out += ' ' + (it.validate($it)) + ' ';
+ $it.baseId = $currentBaseId;
+ }
+ out += ' } else { errors = ' + ($errs) + '; if (vErrors !== null) { if (' + ($errs) + ') vErrors.length = ' + ($errs) + '; else vErrors = null; } } ';
+ } else {
+ out += ' ' + ($ifPassed) + ' = true; ';
+ if (typeof $sch.then == 'boolean') {
+ if ($sch.then === false) {
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('switch') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { caseIndex: ' + ($caseIndex) + ' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should pass "switch" keyword validation\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
+ } else {
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
+ }
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ }
+ out += ' var ' + ($nextValid) + ' = ' + ($sch.then) + '; ';
+ } else {
+ $it.schema = $sch.then;
+ $it.schemaPath = $schemaPath + '[' + $caseIndex + '].then';
+ $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/then';
+ out += ' ' + (it.validate($it)) + ' ';
+ $it.baseId = $currentBaseId;
+ }
+ }
+ $shouldContinue = $sch.continue
+ }
+ }
+ out += '' + ($closingBraces) + 'var ' + ($valid) + ' = ' + ($nextValid) + '; ';
+ out = it.util.cleanUpCode(out);
+ return out;
+}
+
+},{}],35:[function(require,module,exports){
+'use strict';
+module.exports = function generate_uniqueItems(it, $keyword) {
+ var out = ' ';
+ var $lvl = it.level;
+ var $dataLvl = it.dataLevel;
+ var $schema = it.schema[$keyword];
+ var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
+ var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
+ var $breakOnError = !it.opts.allErrors;
+ var $data = 'data' + ($dataLvl || '');
+ var $valid = 'valid' + $lvl;
+ var $isData = it.opts.v5 && $schema && $schema.$data,
$schemaValue;
if ($isData) {
out += ' var schema' + ($lvl) + ' = ' + (it.util.getData($schema.$data, $dataLvl, it.dataPathArr)) + '; ';
@@ -4131,25 +4325,31 @@ module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
return out;
}
-},{}],35:[function(require,module,exports){
+},{}],36:[function(require,module,exports){
'use strict';
-module.exports = function generate_validate(it, $keyword, $ruleType) {
+module.exports = function generate_validate(it, $keyword) {
var out = '';
- var $async = it.schema.$async === true,
- $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'),
- $id = it.self._getId(it.schema);
+ var $async = it.schema.$async === true;
if (it.isTop) {
+ var $top = it.isTop,
+ $lvl = it.level = 0,
+ $dataLvl = it.dataLevel = 0,
+ $data = 'data';
+ it.rootId = it.resolve.fullPath(it.root.schema.id);
+ it.baseId = it.baseId || it.rootId;
if ($async) {
it.async = true;
var $es7 = it.opts.async == 'es7';
it.yieldAwait = $es7 ? 'await' : 'yield';
}
+ delete it.isTop;
+ it.dataPathArr = [undefined];
out += ' var validate = ';
if ($async) {
if ($es7) {
out += ' (async function ';
} else {
- if (it.opts.async != '*') {
+ if (it.opts.async == 'co*') {
out += 'co.wrap';
}
out += '(function* ';
@@ -4157,87 +4357,14 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
} else {
out += ' (function ';
}
- out += ' (data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; ';
- if ($id && (it.opts.sourceCode || it.opts.processCode)) {
- out += ' ' + ('/\*# sourceURL=' + $id + ' */') + ' ';
- }
- }
- if (typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref)) {
- var $keyword = 'false schema';
- var $lvl = it.level;
- var $dataLvl = it.dataLevel;
- var $schema = it.schema[$keyword];
- var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
- var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
- var $breakOnError = !it.opts.allErrors;
- var $errorKeyword;
- var $data = 'data' + ($dataLvl || '');
- var $valid = 'valid' + $lvl;
- if (it.schema === false) {
- if (it.isTop) {
- $breakOnError = true;
- } else {
- out += ' var ' + ($valid) + ' = false; ';
- }
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || 'false schema') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: {} ';
- if (it.opts.messages !== false) {
- out += ' , message: \'boolean schema is false\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
- }
- out += ' } ';
- } else {
- out += ' {} ';
- }
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
- } else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
- }
- } else {
- if (it.isTop) {
- if ($async) {
- out += ' return data; ';
- } else {
- out += ' validate.errors = null; return true; ';
- }
- } else {
- out += ' var ' + ($valid) + ' = true; ';
- }
- }
- if (it.isTop) {
- out += ' }); return validate; ';
- }
- return out;
- }
- if (it.isTop) {
- var $top = it.isTop,
- $lvl = it.level = 0,
- $dataLvl = it.dataLevel = 0,
- $data = 'data';
- it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
- it.baseId = it.baseId || it.rootId;
- delete it.isTop;
- it.dataPathArr = [undefined];
- out += ' var vErrors = null; ';
+ out += ' (data, dataPath, parentData, parentDataProperty, rootData) { \'use strict\'; var vErrors = null; ';
out += ' var errors = 0; ';
- out += ' if (rootData === undefined) rootData = data; ';
+ out += ' if (rootData === undefined) rootData = data;';
} else {
var $lvl = it.level,
$dataLvl = it.dataLevel,
$data = 'data' + ($dataLvl || '');
- if ($id) it.baseId = it.resolve.url(it.baseId, $id);
+ if (it.schema.id) it.baseId = it.resolve.url(it.baseId, it.schema.id);
if ($async && !it.async) throw new Error('async schema in sync schema');
out += ' var errs_' + ($lvl) + ' = errors;';
}
@@ -4245,160 +4372,111 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
$breakOnError = !it.opts.allErrors,
$closingBraces1 = '',
$closingBraces2 = '';
- var $errorKeyword;
var $typeSchema = it.schema.type,
$typeIsArray = Array.isArray($typeSchema);
- if ($typeIsArray && $typeSchema.length == 1) {
- $typeSchema = $typeSchema[0];
- $typeIsArray = false;
- }
- if (it.schema.$ref && $refKeywords) {
- if (it.opts.extendRefs == 'fail') {
- throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
- } else if (it.opts.extendRefs !== true) {
- $refKeywords = false;
- it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
- }
- }
- if ($typeSchema) {
- if (it.opts.coerceTypes) {
- var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
- }
- var $rulesGroup = it.RULES.types[$typeSchema];
- if ($coerceToTypes || $typeIsArray || $rulesGroup === true || ($rulesGroup && !$shouldUseGroup($rulesGroup))) {
- var $schemaPath = it.schemaPath + '.type',
- $errSchemaPath = it.errSchemaPath + '/type';
+ if ($typeSchema && it.opts.coerceTypes) {
+ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
+ if ($coerceToTypes) {
var $schemaPath = it.schemaPath + '.type',
$errSchemaPath = it.errSchemaPath + '/type',
$method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
- out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
- if ($coerceToTypes) {
- var $dataType = 'dataType' + $lvl,
- $coerced = 'coerced' + $lvl;
- out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
- if (it.opts.coerceTypes == 'array') {
- out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' = \'array\'; ';
- }
- out += ' var ' + ($coerced) + ' = undefined; ';
- var $bracesCoercion = '';
- var arr1 = $coerceToTypes;
- if (arr1) {
- var $type, $i = -1,
- l1 = arr1.length - 1;
- while ($i < l1) {
- $type = arr1[$i += 1];
- if ($i) {
- out += ' if (' + ($coerced) + ' === undefined) { ';
- $bracesCoercion += '}';
- }
- if (it.opts.coerceTypes == 'array' && $type != 'array') {
- out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; } ';
- }
- if ($type == 'string') {
- out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
- } else if ($type == 'number' || $type == 'integer') {
- out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
- if ($type == 'integer') {
- out += ' && !(' + ($data) + ' % 1)';
- }
- out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
- } else if ($type == 'boolean') {
- out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
- } else if ($type == 'null') {
- out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
- } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
- out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
- }
+ out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
+ var $dataType = 'dataType' + $lvl,
+ $coerced = 'coerced' + $lvl;
+ out += ' var ' + ($dataType) + ' = typeof ' + ($data) + '; ';
+ if (it.opts.coerceTypes == 'array') {
+ out += ' if (' + ($dataType) + ' == \'object\' && Array.isArray(' + ($data) + ')) ' + ($dataType) + ' = \'array\'; ';
+ }
+ out += ' var ' + ($coerced) + ' = undefined; ';
+ var $bracesCoercion = '';
+ var arr1 = $coerceToTypes;
+ if (arr1) {
+ var $type, $i = -1,
+ l1 = arr1.length - 1;
+ while ($i < l1) {
+ $type = arr1[$i += 1];
+ if ($i) {
+ out += ' if (' + ($coerced) + ' === undefined) { ';
+ $bracesCoercion += '}';
}
- }
- out += ' ' + ($bracesCoercion) + ' if (' + ($coerced) + ' === undefined) { ';
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
- if ($typeIsArray) {
- out += '' + ($typeSchema.join(","));
- } else {
- out += '' + ($typeSchema);
+ if (it.opts.coerceTypes == 'array' && $type != 'array') {
+ out += ' if (' + ($dataType) + ' == \'array\' && ' + ($data) + '.length == 1) { ' + ($coerced) + ' = ' + ($data) + ' = ' + ($data) + '[0]; ' + ($dataType) + ' = typeof ' + ($data) + '; } ';
}
- out += '\' } ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should be ';
- if ($typeIsArray) {
- out += '' + ($typeSchema.join(","));
- } else {
- out += '' + ($typeSchema);
+ if ($type == 'string') {
+ out += ' if (' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\') ' + ($coerced) + ' = \'\' + ' + ($data) + '; else if (' + ($data) + ' === null) ' + ($coerced) + ' = \'\'; ';
+ } else if ($type == 'number' || $type == 'integer') {
+ out += ' if (' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' === null || (' + ($dataType) + ' == \'string\' && ' + ($data) + ' && ' + ($data) + ' == +' + ($data) + ' ';
+ if ($type == 'integer') {
+ out += ' && !(' + ($data) + ' % 1)';
}
- out += '\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ out += ')) ' + ($coerced) + ' = +' + ($data) + '; ';
+ } else if ($type == 'boolean') {
+ out += ' if (' + ($data) + ' === \'false\' || ' + ($data) + ' === 0 || ' + ($data) + ' === null) ' + ($coerced) + ' = false; else if (' + ($data) + ' === \'true\' || ' + ($data) + ' === 1) ' + ($coerced) + ' = true; ';
+ } else if ($type == 'null') {
+ out += ' if (' + ($data) + ' === \'\' || ' + ($data) + ' === 0 || ' + ($data) + ' === false) ' + ($coerced) + ' = null; ';
+ } else if (it.opts.coerceTypes == 'array' && $type == 'array') {
+ out += ' if (' + ($dataType) + ' == \'string\' || ' + ($dataType) + ' == \'number\' || ' + ($dataType) + ' == \'boolean\' || ' + ($data) + ' == null) ' + ($coerced) + ' = [' + ($data) + ']; ';
}
- out += ' } ';
- } else {
- out += ' {} ';
}
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
+ }
+ out += ' ' + ($bracesCoercion) + ' if (' + ($coerced) + ' === undefined) { ';
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
+ if ($typeIsArray) {
+ out += '' + ($typeSchema.join(","));
} else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ out += '' + ($typeSchema);
}
- out += ' } else { ';
- var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
- $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
- out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
- if (!$dataLvl) {
- out += 'if (' + ($parentData) + ' !== undefined)';
- }
- out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } ';
- } else {
- var $$outStack = $$outStack || [];
- $$outStack.push(out);
- out = ''; /* istanbul ignore else */
- if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
+ out += '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should be ';
if ($typeIsArray) {
out += '' + ($typeSchema.join(","));
} else {
out += '' + ($typeSchema);
}
- out += '\' } ';
- if (it.opts.messages !== false) {
- out += ' , message: \'should be ';
- if ($typeIsArray) {
- out += '' + ($typeSchema.join(","));
- } else {
- out += '' + ($typeSchema);
- }
- out += '\' ';
- }
- if (it.opts.verbose) {
- out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
- }
- out += ' } ';
- } else {
- out += ' {} ';
+ out += '\' ';
}
- var __err = out;
- out = $$outStack.pop();
- if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
- if (it.async) {
- out += ' throw new ValidationError([' + (__err) + ']); ';
- } else {
- out += ' validate.errors = [' + (__err) + ']; return false; ';
- }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
} else {
- out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
}
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
}
- out += ' } ';
+ out += ' } else { ';
+ var $parentData = $dataLvl ? 'data' + (($dataLvl - 1) || '') : 'parentData',
+ $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
+ out += ' ' + ($data) + ' = ' + ($coerced) + '; ';
+ if (!$dataLvl) {
+ out += 'if (' + ($parentData) + ' !== undefined)';
+ }
+ out += ' ' + ($parentData) + '[' + ($parentDataProperty) + '] = ' + ($coerced) + '; } } ';
+ }
+ }
+ var $refKeywords;
+ if (it.schema.$ref && ($refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref'))) {
+ if (it.opts.extendRefs == 'fail') {
+ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '"');
+ } else if (it.opts.extendRefs == 'ignore') {
+ $refKeywords = false;
+ console.log('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
+ } else if (it.opts.extendRefs !== true) {
+ console.log('$ref: all keywords used in schema at path "' + it.errSchemaPath + '". It will change in the next major version, see issue #260. Use option { extendRefs: true } to keep current behaviour');
}
}
if (it.schema.$ref && !$refKeywords) {
@@ -4414,9 +4492,6 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
$closingBraces2 += '}';
}
} else {
- if (it.opts.v5 && it.schema.patternGroups) {
- it.logger.warn('keyword "patternGroups" is deprecated and disabled. Use option patternGroups: true to enable.');
- }
var arr2 = it.RULES;
if (arr2) {
var $rulesGroup, i2 = -1,
@@ -4478,12 +4553,9 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
while (i5 < l5) {
$rule = arr5[i5 += 1];
if ($shouldUseRule($rule)) {
- var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
- if ($code) {
- out += ' ' + ($code) + ' ';
- if ($breakOnError) {
- $closingBraces1 += '}';
- }
+ out += ' ' + ($rule.code(it, $rule.keyword)) + ' ';
+ if ($breakOnError) {
+ $closingBraces1 += '}';
}
}
}
@@ -4495,6 +4567,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
if ($rulesGroup.type) {
out += ' } ';
if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
+ var $typeChecked = true;
out += ' else { ';
var $schemaPath = it.schemaPath + '.type',
$errSchemaPath = it.errSchemaPath + '/type';
@@ -4502,7 +4575,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
$$outStack.push(out);
out = ''; /* istanbul ignore else */
if (it.createErrors !== false) {
- out += ' { keyword: \'' + ($errorKeyword || 'type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
+ out += ' { keyword: \'' + ('type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
if ($typeIsArray) {
out += '' + ($typeSchema.join(","));
} else {
@@ -4553,12 +4626,57 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
}
}
}
+ if ($typeSchema && !$typeChecked && !$coerceToTypes) {
+ var $schemaPath = it.schemaPath + '.type',
+ $errSchemaPath = it.errSchemaPath + '/type',
+ $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
+ out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { ';
+ var $$outStack = $$outStack || [];
+ $$outStack.push(out);
+ out = ''; /* istanbul ignore else */
+ if (it.createErrors !== false) {
+ out += ' { keyword: \'' + ('type') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { type: \'';
+ if ($typeIsArray) {
+ out += '' + ($typeSchema.join(","));
+ } else {
+ out += '' + ($typeSchema);
+ }
+ out += '\' } ';
+ if (it.opts.messages !== false) {
+ out += ' , message: \'should be ';
+ if ($typeIsArray) {
+ out += '' + ($typeSchema.join(","));
+ } else {
+ out += '' + ($typeSchema);
+ }
+ out += '\' ';
+ }
+ if (it.opts.verbose) {
+ out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
+ }
+ out += ' } ';
+ } else {
+ out += ' {} ';
+ }
+ var __err = out;
+ out = $$outStack.pop();
+ if (!it.compositeRule && $breakOnError) { /* istanbul ignore if */
+ if (it.async) {
+ out += ' throw new ValidationError([' + (__err) + ']); ';
+ } else {
+ out += ' validate.errors = [' + (__err) + ']; return false; ';
+ }
+ } else {
+ out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
+ }
+ out += ' }';
+ }
if ($breakOnError) {
out += ' ' + ($closingBraces2) + ' ';
}
if ($top) {
if ($async) {
- out += ' if (errors === 0) return data; ';
+ out += ' if (errors === 0) return true; ';
out += ' else throw new ValidationError(vErrors); ';
} else {
out += ' validate.errors = vErrors; ';
@@ -4569,32 +4687,25 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
}
out = it.util.cleanUpCode(out);
- if ($top) {
- out = it.util.finalCleanUpCode(out, $async);
+ if ($top && $breakOnError) {
+ out = it.util.cleanUpVarErrors(out, $async);
}
function $shouldUseGroup($rulesGroup) {
- var rules = $rulesGroup.rules;
- for (var i = 0; i < rules.length; i++)
- if ($shouldUseRule(rules[i])) return true;
+ for (var i = 0; i < $rulesGroup.rules.length; i++)
+ if ($shouldUseRule($rulesGroup.rules[i])) return true;
}
function $shouldUseRule($rule) {
- return it.schema[$rule.keyword] !== undefined || ($rule.implements && $ruleImplementsSomeKeyword($rule));
- }
-
- function $ruleImplementsSomeKeyword($rule) {
- var impl = $rule.implements;
- for (var i = 0; i < impl.length; i++)
- if (it.schema[impl[i]] !== undefined) return true;
+ return it.schema[$rule.keyword] !== undefined || ($rule.keyword == 'properties' && (it.schema.additionalProperties === false || typeof it.schema.additionalProperties == 'object' || (it.schema.patternProperties && Object.keys(it.schema.patternProperties).length) || (it.opts.v5 && it.schema.patternGroups && Object.keys(it.schema.patternGroups).length)));
}
return out;
}
-},{}],36:[function(require,module,exports){
+},{}],37:[function(require,module,exports){
'use strict';
-var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
+var IDENTIFIER = /^[a-z_$][a-z0-9_$\-]*$/i;
var customRuleCode = require('./dotjs/custom');
module.exports = {
@@ -4608,7 +4719,6 @@ module.exports = {
* @this Ajv
* @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords).
* @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
- * @return {Ajv} this for method chaining
*/
function addKeyword(keyword, definition) {
/* jshint validthis: true */
@@ -4635,7 +4745,7 @@ function addKeyword(keyword, definition) {
_addRule(keyword, dataType, definition);
}
- var $data = definition.$data === true && this._opts.$data;
+ var $data = definition.$data === true && this._opts.v5;
if ($data && !definition.validate)
throw new Error('$data support: "validate" function is not defined');
@@ -4645,7 +4755,7 @@ function addKeyword(keyword, definition) {
metaSchema = {
anyOf: [
metaSchema,
- { '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/$data.json#' }
+ { '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#/definitions/$data' }
]
};
}
@@ -4675,8 +4785,7 @@ function addKeyword(keyword, definition) {
keyword: keyword,
definition: definition,
custom: true,
- code: customRuleCode,
- implements: definition.implements
+ code: customRuleCode
};
ruleGroup.rules.push(rule);
RULES.custom[keyword] = rule;
@@ -4686,9 +4795,7 @@ function addKeyword(keyword, definition) {
function checkDataType(dataType) {
if (!RULES.types[dataType]) throw new Error('Unknown type ' + dataType);
}
-
- return this;
-}
+}
/**
@@ -4708,7 +4815,6 @@ function getKeyword(keyword) {
* Remove keyword
* @this Ajv
* @param {String} keyword pre-defined or custom keyword.
- * @return {Ajv} this for method chaining
*/
function removeKeyword(keyword) {
/* jshint validthis: true */
@@ -4725,119 +4831,46 @@ function removeKeyword(keyword) {
}
}
}
- return this;
}
-},{"./dotjs/custom":21}],37:[function(require,module,exports){
-'use strict';
-
-var META_SCHEMA_ID = 'http://json-schema.org/draft-06/schema';
-
-module.exports = function (ajv) {
- var defaultMeta = ajv._opts.defaultMeta;
- var metaSchemaRef = typeof defaultMeta == 'string'
- ? { $ref: defaultMeta }
- : ajv.getSchema(META_SCHEMA_ID)
- ? { $ref: META_SCHEMA_ID }
- : {};
-
- ajv.addKeyword('patternGroups', {
- // implemented in properties.jst
- metaSchema: {
- type: 'object',
- additionalProperties: {
- type: 'object',
- required: [ 'schema' ],
- properties: {
- maximum: {
- type: 'integer',
- minimum: 0
- },
- minimum: {
- type: 'integer',
- minimum: 0
- },
- schema: metaSchemaRef
- },
- additionalProperties: false
- }
- }
- });
- ajv.RULES.all.properties.implements.push('patternGroups');
-};
-
-},{}],38:[function(require,module,exports){
+},{"./dotjs/custom":21}],38:[function(require,module,exports){
module.exports={
- "$schema": "http://json-schema.org/draft-06/schema#",
- "$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/$data.json#",
- "description": "Meta-schema for $data reference (JSON-schema extension proposal)",
- "type": "object",
- "required": [ "$data" ],
- "properties": {
- "$data": {
- "type": "string",
- "anyOf": [
- { "format": "relative-json-pointer" },
- { "format": "json-pointer" }
- ]
- }
- },
- "additionalProperties": false
-}
-
-},{}],39:[function(require,module,exports){
-module.exports={
- "$schema": "http://json-schema.org/draft-06/schema#",
- "$id": "http://json-schema.org/draft-06/schema#",
- "title": "Core schema meta-schema",
+ "id": "http://json-schema.org/draft-04/schema#",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
- "nonNegativeInteger": {
+ "positiveInteger": {
"type": "integer",
"minimum": 0
},
- "nonNegativeIntegerDefault0": {
- "allOf": [
- { "$ref": "#/definitions/nonNegativeInteger" },
- { "default": 0 }
- ]
+ "positiveIntegerDefault0": {
+ "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
},
"simpleTypes": {
- "enum": [
- "array",
- "boolean",
- "integer",
- "null",
- "number",
- "object",
- "string"
- ]
+ "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
- "uniqueItems": true,
- "default": []
+ "minItems": 1,
+ "uniqueItems": true
}
},
- "type": ["object", "boolean"],
+ "type": "object",
"properties": {
- "$id": {
+ "id": {
"type": "string",
- "format": "uri-reference"
+ "format": "uri"
},
"$schema": {
"type": "string",
"format": "uri"
},
- "$ref": {
- "type": "string",
- "format": "uri-reference"
- },
"title": {
"type": "string"
},
@@ -4845,33 +4878,38 @@ module.exports={
"type": "string"
},
"default": {},
- "examples": {
- "type": "array",
- "items": {}
- },
"multipleOf": {
"type": "number",
- "exclusiveMinimum": 0
+ "minimum": 0,
+ "exclusiveMinimum": true
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
- "type": "number"
+ "type": "boolean",
+ "default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
- "type": "number"
+ "type": "boolean",
+ "default": false
},
- "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
- "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
+ "maxLength": { "$ref": "#/definitions/positiveInteger" },
+ "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
- "additionalItems": { "$ref": "#" },
+ "additionalItems": {
+ "anyOf": [
+ { "type": "boolean" },
+ { "$ref": "#" }
+ ],
+ "default": {}
+ },
"items": {
"anyOf": [
{ "$ref": "#" },
@@ -4879,17 +4917,22 @@ module.exports={
],
"default": {}
},
- "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
- "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
+ "maxItems": { "$ref": "#/definitions/positiveInteger" },
+ "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
- "contains": { "$ref": "#" },
- "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
- "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
+ "maxProperties": { "$ref": "#/definitions/positiveInteger" },
+ "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
- "additionalProperties": { "$ref": "#" },
+ "additionalProperties": {
+ "anyOf": [
+ { "type": "boolean" },
+ { "$ref": "#" }
+ ],
+ "default": {}
+ },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
@@ -4914,8 +4957,6 @@ module.exports={
]
}
},
- "propertyNames": { "$ref": "#" },
- "const": {},
"enum": {
"type": "array",
"minItems": 1,
@@ -4932,16 +4973,403 @@ module.exports={
}
]
},
- "format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
+ "dependencies": {
+ "exclusiveMaximum": [ "maximum" ],
+ "exclusiveMinimum": [ "minimum" ]
+ },
+ "default": {}
+}
+
+},{}],39:[function(require,module,exports){
+module.exports={
+ "id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "description": "Core schema meta-schema (v5 proposals)",
+ "definitions": {
+ "schemaArray": {
+ "type": "array",
+ "minItems": 1,
+ "items": { "$ref": "#" }
+ },
+ "positiveInteger": {
+ "type": "integer",
+ "minimum": 0
+ },
+ "positiveIntegerDefault0": {
+ "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
+ },
+ "simpleTypes": {
+ "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
+ },
+ "stringArray": {
+ "type": "array",
+ "items": { "type": "string" },
+ "minItems": 1,
+ "uniqueItems": true
+ },
+ "$data": {
+ "type": "object",
+ "required": [ "$data" ],
+ "properties": {
+ "$data": {
+ "type": "string",
+ "anyOf": [
+ { "format": "relative-json-pointer" },
+ { "format": "json-pointer" }
+ ]
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "format": "uri"
+ },
+ "$schema": {
+ "type": "string",
+ "format": "uri"
+ },
+ "title": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "default": {},
+ "multipleOf": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 0,
+ "exclusiveMinimum": true
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "maximum": {
+ "anyOf": [
+ { "type": "number" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "exclusiveMaximum": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "default": false
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "minimum": {
+ "anyOf": [
+ { "type": "number" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "exclusiveMinimum": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "default": false
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "maxLength": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveInteger" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "minLength": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveIntegerDefault0" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "pattern": {
+ "anyOf": [
+ {
+ "type": "string",
+ "format": "regex"
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "additionalItems": {
+ "anyOf": [
+ { "type": "boolean" },
+ { "$ref": "#" },
+ { "$ref": "#/definitions/$data" }
+ ],
+ "default": {}
+ },
+ "items": {
+ "anyOf": [
+ { "$ref": "#" },
+ { "$ref": "#/definitions/schemaArray" }
+ ],
+ "default": {}
+ },
+ "maxItems": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveInteger" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "minItems": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveIntegerDefault0" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "uniqueItems": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "default": false
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "maxProperties": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveInteger" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "minProperties": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveIntegerDefault0" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "required": {
+ "anyOf": [
+ { "$ref": "#/definitions/stringArray" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "additionalProperties": {
+ "anyOf": [
+ { "type": "boolean" },
+ { "$ref": "#" },
+ { "$ref": "#/definitions/$data" }
+ ],
+ "default": {}
+ },
+ "definitions": {
+ "type": "object",
+ "additionalProperties": { "$ref": "#" },
+ "default": {}
+ },
+ "properties": {
+ "type": "object",
+ "additionalProperties": { "$ref": "#" },
+ "default": {}
+ },
+ "patternProperties": {
+ "type": "object",
+ "additionalProperties": { "$ref": "#" },
+ "default": {}
+ },
+ "dependencies": {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ { "$ref": "#" },
+ { "$ref": "#/definitions/stringArray" }
+ ]
+ }
+ },
+ "enum": {
+ "anyOf": [
+ {
+ "type": "array",
+ "minItems": 1,
+ "uniqueItems": true
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "type": {
+ "anyOf": [
+ { "$ref": "#/definitions/simpleTypes" },
+ {
+ "type": "array",
+ "items": { "$ref": "#/definitions/simpleTypes" },
+ "minItems": 1,
+ "uniqueItems": true
+ }
+ ]
+ },
+ "allOf": { "$ref": "#/definitions/schemaArray" },
+ "anyOf": { "$ref": "#/definitions/schemaArray" },
+ "oneOf": { "$ref": "#/definitions/schemaArray" },
+ "not": { "$ref": "#" },
+ "format": {
+ "anyOf": [
+ { "type": "string" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "formatMaximum": {
+ "anyOf": [
+ { "type": "string" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "formatMinimum": {
+ "anyOf": [
+ { "type": "string" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "formatExclusiveMaximum": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "default": false
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "formatExclusiveMinimum": {
+ "anyOf": [
+ {
+ "type": "boolean",
+ "default": false
+ },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "constant": {
+ "anyOf": [
+ {},
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "contains": { "$ref": "#" },
+ "patternGroups": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object",
+ "required": [ "schema" ],
+ "properties": {
+ "maximum": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveInteger" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "minimum": {
+ "anyOf": [
+ { "$ref": "#/definitions/positiveIntegerDefault0" },
+ { "$ref": "#/definitions/$data" }
+ ]
+ },
+ "schema": { "$ref": "#" }
+ },
+ "additionalProperties": false
+ },
+ "default": {}
+ },
+ "switch": {
+ "type": "array",
+ "items": {
+ "required": [ "then" ],
+ "properties": {
+ "if": { "$ref": "#" },
+ "then": {
+ "anyOf": [
+ { "type": "boolean" },
+ { "$ref": "#" }
+ ]
+ },
+ "continue": { "type": "boolean" }
+ },
+ "additionalProperties": false,
+ "dependencies": {
+ "continue": [ "if" ]
+ }
+ }
+ }
+ },
+ "dependencies": {
+ "exclusiveMaximum": [ "maximum" ],
+ "exclusiveMinimum": [ "minimum" ],
+ "formatMaximum": [ "format" ],
+ "formatMinimum": [ "format" ],
+ "formatExclusiveMaximum": [ "formatMaximum" ],
+ "formatExclusiveMinimum": [ "formatMinimum" ]
+ },
"default": {}
}
},{}],40:[function(require,module,exports){
+'use strict';
+
+var META_SCHEMA_ID = 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json';
+
+module.exports = {
+ enable: enableV5,
+ META_SCHEMA_ID: META_SCHEMA_ID
+};
+
+
+function enableV5(ajv) {
+ var inlineFunctions = {
+ 'switch': require('./dotjs/switch'),
+ 'constant': require('./dotjs/constant'),
+ '_formatLimit': require('./dotjs/_formatLimit'),
+ 'patternRequired': require('./dotjs/patternRequired')
+ };
+
+ if (ajv._opts.meta !== false) {
+ var metaSchema = require('./refs/json-schema-v5.json');
+ ajv.addMetaSchema(metaSchema, META_SCHEMA_ID);
+ }
+ _addKeyword('constant');
+ ajv.addKeyword('contains', { type: 'array', macro: containsMacro });
+
+ _addKeyword('formatMaximum', 'string', inlineFunctions._formatLimit);
+ _addKeyword('formatMinimum', 'string', inlineFunctions._formatLimit);
+ ajv.addKeyword('formatExclusiveMaximum');
+ ajv.addKeyword('formatExclusiveMinimum');
+
+ ajv.addKeyword('patternGroups'); // implemented in properties.jst
+ _addKeyword('patternRequired', 'object');
+ _addKeyword('switch');
+
+
+ function _addKeyword(keyword, types, inlineFunc) {
+ var definition = {
+ inline: inlineFunc || inlineFunctions[keyword],
+ statements: true,
+ errors: 'full'
+ };
+ if (types) definition.type = types;
+ ajv.addKeyword(keyword, definition);
+ }
+}
+
+
+function containsMacro(schema) {
+ return {
+ not: { items: { not: schema } }
+ };
+}
+
+},{"./dotjs/_formatLimit":13,"./dotjs/constant":20,"./dotjs/patternRequired":30,"./dotjs/switch":34,"./refs/json-schema-v5.json":39}],41:[function(require,module,exports){
/**
* slice() reference.
@@ -5176,62 +5604,20 @@ function isGeneratorFunction(obj) {
* @api private
*/
-function isObject(val) {
- return Object == val.constructor;
-}
-
-},{}],41:[function(require,module,exports){
-'use strict';
-
-module.exports = function equal(a, b) {
- if (a === b) return true;
-
- var arrA = Array.isArray(a)
- , arrB = Array.isArray(b)
- , i;
-
- if (arrA && arrB) {
- if (a.length != b.length) return false;
- for (i = 0; i < a.length; i++)
- if (!equal(a[i], b[i])) return false;
- return true;
- }
-
- if (arrA != arrB) return false;
-
- if (a && b && typeof a === 'object' && typeof b === 'object') {
- var keys = Object.keys(a);
- if (keys.length !== Object.keys(b).length) return false;
-
- var dateA = a instanceof Date
- , dateB = b instanceof Date;
- if (dateA && dateB) return a.getTime() == b.getTime();
- if (dateA != dateB) return false;
-
- var regexpA = a instanceof RegExp
- , regexpB = b instanceof RegExp;
- if (regexpA && regexpB) return a.toString() == b.toString();
- if (regexpA != regexpB) return false;
-
- for (i = 0; i < keys.length; i++)
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
-
- for (i = 0; i < keys.length; i++)
- if(!equal(a[keys[i]], b[keys[i]])) return false;
-
- return true;
- }
-
- return false;
-};
-
+function isObject(val) {
+ return Object == val.constructor;
+}
+
},{}],42:[function(require,module,exports){
-'use strict';
+var json = typeof JSON !== 'undefined' ? JSON : require('jsonify');
-module.exports = function (data, opts) {
+module.exports = function (obj, opts) {
if (!opts) opts = {};
if (typeof opts === 'function') opts = { cmp: opts };
+ var space = opts.space || '';
+ if (typeof space === 'number') space = Array(space+1).join(' ');
var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
+ var replacer = opts.replacer || function(key, value) { return value; };
var cmp = opts.cmp && (function (f) {
return function (node) {
@@ -5244,132 +5630,506 @@ module.exports = function (data, opts) {
})(opts.cmp);
var seen = [];
- return (function stringify (node) {
+ return (function stringify (parent, key, node, level) {
+ var indent = space ? ('\n' + new Array(level + 1).join(space)) : '';
+ var colonSeparator = space ? ': ' : ':';
+
if (node && node.toJSON && typeof node.toJSON === 'function') {
node = node.toJSON();
}
- if (node === undefined) return;
- if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
- if (typeof node !== 'object') return JSON.stringify(node);
+ node = replacer.call(parent, key, node);
- var i, out;
- if (Array.isArray(node)) {
- out = '[';
- for (i = 0; i < node.length; i++) {
- if (i) out += ',';
- out += stringify(node[i]) || 'null';
+ if (node === undefined) {
+ return;
+ }
+ if (typeof node !== 'object' || node === null) {
+ return json.stringify(node);
+ }
+ if (isArray(node)) {
+ var out = [];
+ for (var i = 0; i < node.length; i++) {
+ var item = stringify(node, i, node[i], level+1) || json.stringify(null);
+ out.push(indent + space + item);
}
- return out + ']';
+ return '[' + out.join(',') + indent + ']';
}
+ else {
+ if (seen.indexOf(node) !== -1) {
+ if (cycles) return json.stringify('__cycle__');
+ throw new TypeError('Converting circular structure to JSON');
+ }
+ else seen.push(node);
- if (node === null) return 'null';
-
- if (seen.indexOf(node) !== -1) {
- if (cycles) return JSON.stringify('__cycle__');
- throw new TypeError('Converting circular structure to JSON');
- }
+ var keys = objectKeys(node).sort(cmp && cmp(node));
+ var out = [];
+ for (var i = 0; i < keys.length; i++) {
+ var key = keys[i];
+ var value = stringify(node, key, node[key], level+1);
- var seenIndex = seen.push(node) - 1;
- var keys = Object.keys(node).sort(cmp && cmp(node));
- out = '';
- for (i = 0; i < keys.length; i++) {
- var key = keys[i];
- var value = stringify(node[key]);
+ if(!value) continue;
- if (!value) continue;
- if (out) out += ',';
- out += JSON.stringify(key) + ':' + value;
+ var keyValue = json.stringify(key)
+ + colonSeparator
+ + value;
+ ;
+ out.push(indent + space + keyValue);
+ }
+ seen.splice(seen.indexOf(node), 1);
+ return '{' + out.join(',') + indent + '}';
}
- seen.splice(seenIndex, 1);
- return '{' + out + '}';
- })(data);
+ })({ '': obj }, '', obj, 0);
};
-},{}],43:[function(require,module,exports){
-'use strict';
+var isArray = Array.isArray || function (x) {
+ return {}.toString.call(x) === '[object Array]';
+};
-var traverse = module.exports = function (schema, opts, cb) {
- if (typeof opts == 'function') {
- cb = opts;
- opts = {};
- }
- _traverse(opts, cb, schema, '', schema);
+var objectKeys = Object.keys || function (obj) {
+ var has = Object.prototype.hasOwnProperty || function () { return true };
+ var keys = [];
+ for (var key in obj) {
+ if (has.call(obj, key)) keys.push(key);
+ }
+ return keys;
};
+},{"jsonify":43}],43:[function(require,module,exports){
+exports.parse = require('./lib/parse');
+exports.stringify = require('./lib/stringify');
+
+},{"./lib/parse":44,"./lib/stringify":45}],44:[function(require,module,exports){
+var at, // The index of the current character
+ ch, // The current character
+ escapee = {
+ '"': '"',
+ '\\': '\\',
+ '/': '/',
+ b: '\b',
+ f: '\f',
+ n: '\n',
+ r: '\r',
+ t: '\t'
+ },
+ text,
+
+ error = function (m) {
+ // Call error when something is wrong.
+ throw {
+ name: 'SyntaxError',
+ message: m,
+ at: at,
+ text: text
+ };
+ },
-traverse.keywords = {
- additionalItems: true,
- items: true,
- contains: true,
- additionalProperties: true,
- propertyNames: true,
- not: true
-};
+ next = function (c) {
+ // If a c parameter is provided, verify that it matches the current character.
+ if (c && c !== ch) {
+ error("Expected '" + c + "' instead of '" + ch + "'");
+ }
-traverse.arrayKeywords = {
- items: true,
- allOf: true,
- anyOf: true,
- oneOf: true
-};
+ // Get the next character. When there are no more characters,
+ // return the empty string.
-traverse.propsKeywords = {
- definitions: true,
- properties: true,
- patternProperties: true,
- dependencies: true
-};
+ ch = text.charAt(at);
+ at += 1;
+ return ch;
+ },
-traverse.skipKeywords = {
- enum: true,
- const: true,
- required: true,
- maximum: true,
- minimum: true,
- exclusiveMaximum: true,
- exclusiveMinimum: true,
- multipleOf: true,
- maxLength: true,
- minLength: true,
- pattern: true,
- format: true,
- maxItems: true,
- minItems: true,
- uniqueItems: true,
- maxProperties: true,
- minProperties: true
-};
+ number = function () {
+ // Parse a number value.
+ var number,
+ string = '';
+
+ if (ch === '-') {
+ string = '-';
+ next('-');
+ }
+ while (ch >= '0' && ch <= '9') {
+ string += ch;
+ next();
+ }
+ if (ch === '.') {
+ string += '.';
+ while (next() && ch >= '0' && ch <= '9') {
+ string += ch;
+ }
+ }
+ if (ch === 'e' || ch === 'E') {
+ string += ch;
+ next();
+ if (ch === '-' || ch === '+') {
+ string += ch;
+ next();
+ }
+ while (ch >= '0' && ch <= '9') {
+ string += ch;
+ next();
+ }
+ }
+ number = +string;
+ if (!isFinite(number)) {
+ error("Bad number");
+ } else {
+ return number;
+ }
+ },
+
+ string = function () {
+ // Parse a string value.
+ var hex,
+ i,
+ string = '',
+ uffff;
+
+ // When parsing for string values, we must look for " and \ characters.
+ if (ch === '"') {
+ while (next()) {
+ if (ch === '"') {
+ next();
+ return string;
+ } else if (ch === '\\') {
+ next();
+ if (ch === 'u') {
+ uffff = 0;
+ for (i = 0; i < 4; i += 1) {
+ hex = parseInt(next(), 16);
+ if (!isFinite(hex)) {
+ break;
+ }
+ uffff = uffff * 16 + hex;
+ }
+ string += String.fromCharCode(uffff);
+ } else if (typeof escapee[ch] === 'string') {
+ string += escapee[ch];
+ } else {
+ break;
+ }
+ } else {
+ string += ch;
+ }
+ }
+ }
+ error("Bad string");
+ },
+ white = function () {
-function _traverse(opts, cb, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
- if (schema && typeof schema == 'object' && !Array.isArray(schema)) {
- cb(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
- for (var key in schema) {
- var sch = schema[key];
- if (Array.isArray(sch)) {
- if (key in traverse.arrayKeywords) {
- for (var i=0; i= '0' && ch <= '9' ? number() : word();
}
- }
+};
+
+// Return the json_parse function. It will have access to all of the above
+// functions and variables.
+
+module.exports = function (source, reviver) {
+ var result;
+
+ text = source;
+ at = 0;
+ ch = ' ';
+ result = value();
+ white();
+ if (ch) {
+ error("Syntax error");
+ }
+
+ // If there is a reviver function, we recursively walk the new structure,
+ // passing each name/value pair to the reviver function for possible
+ // transformation, starting with a temporary root object that holds the result
+ // in an empty key. If there is not a reviver function, we simply return the
+ // result.
+
+ return typeof reviver === 'function' ? (function walk(holder, key) {
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }({'': result}, '')) : result;
+};
+
+},{}],45:[function(require,module,exports){
+var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+function quote(string) {
+ // If the string contains no control characters, no quote characters, and no
+ // backslash characters, then we can safely slap some quotes around it.
+ // Otherwise we must also replace the offending characters with safe escape
+ // sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
}
+function str(key, holder) {
+ // Produce a string from holder[key].
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
-function escapeJsonPtr(str) {
- return str.replace(/~/g, '~0').replace(/\//g, '~1');
+ // If the value has a toJSON method, call it to obtain a replacement value.
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+ // If we were called with a replacer function, then call the replacer to
+ // obtain a replacement value.
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+ // What happens next depends on the value's type.
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+ // JSON numbers must be finite. Encode non-finite numbers as null.
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+ // If the value is a boolean or null, convert it to a string. Note:
+ // typeof null does not produce 'null'. The case is included here in
+ // the remote chance that this gets fixed someday.
+ return String(value);
+
+ case 'object':
+ if (!value) return 'null';
+ gap += indent;
+ partial = [];
+
+ // Array.isArray
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+ // Join all of the elements together, separated with commas, and
+ // wrap them in brackets.
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+ // If the replacer is an array, use it to select the members to be
+ // stringified.
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ k = rep[i];
+ if (typeof k === 'string') {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+ else {
+ // Otherwise, iterate through all of the keys in the object.
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+ // Join all of the member texts together, separated with commas,
+ // and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
}
-},{}],44:[function(require,module,exports){
+module.exports = function (value, replacer, space) {
+ var i;
+ gap = '';
+ indent = '';
+
+ // If the space parameter is a number, make an indent string containing that
+ // many spaces.
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+ }
+ // If the space parameter is a string, it will be used as the indent string.
+ else if (typeof space === 'string') {
+ indent = space;
+ }
+
+ // If there is a replacer, it must be a function or an array.
+ // Otherwise, throw an error.
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function'
+ && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+ // Make a fake root object containing our value under the key of ''.
+ // Return the result of stringifying the value.
+ return str('', {'': value});
+};
+
+},{}],46:[function(require,module,exports){
(function (global){
/*! https://mths.be/punycode v1.4.1 by @mathias */
;(function(root) {
@@ -5906,7 +6666,7 @@ function escapeJsonPtr(str) {
}(this));
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],45:[function(require,module,exports){
+},{}],47:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -5992,7 +6752,7 @@ var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
-},{}],46:[function(require,module,exports){
+},{}],48:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -6079,13 +6839,13 @@ var objectKeys = Object.keys || function (obj) {
return res;
};
-},{}],47:[function(require,module,exports){
+},{}],49:[function(require,module,exports){
'use strict';
exports.decode = exports.parse = require('./decode');
exports.encode = exports.stringify = require('./encode');
-},{"./decode":45,"./encode":46}],48:[function(require,module,exports){
+},{"./decode":47,"./encode":48}],50:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -6819,7 +7579,7 @@ Url.prototype.parseHost = function() {
if (host) this.hostname = host;
};
-},{"./util":49,"punycode":44,"querystring":47}],49:[function(require,module,exports){
+},{"./util":51,"punycode":46,"querystring":49}],51:[function(require,module,exports){
'use strict';
module.exports = {
@@ -6844,44 +7604,31 @@ var compileSchema = require('./compile')
, resolve = require('./compile/resolve')
, Cache = require('./cache')
, SchemaObject = require('./compile/schema_obj')
- , stableStringify = require('fast-json-stable-stringify')
+ , stableStringify = require('json-stable-stringify')
, formats = require('./compile/formats')
, rules = require('./compile/rules')
- , $dataMetaSchema = require('./$data')
- , patternGroups = require('./patternGroups')
+ , v5 = require('./v5')
, util = require('./compile/util')
+ , async = require('./async')
, co = require('co');
module.exports = Ajv;
-Ajv.prototype.validate = validate;
-Ajv.prototype.compile = compile;
-Ajv.prototype.addSchema = addSchema;
-Ajv.prototype.addMetaSchema = addMetaSchema;
-Ajv.prototype.validateSchema = validateSchema;
-Ajv.prototype.getSchema = getSchema;
-Ajv.prototype.removeSchema = removeSchema;
-Ajv.prototype.addFormat = addFormat;
-Ajv.prototype.errorsText = errorsText;
+Ajv.prototype.compileAsync = async.compile;
-Ajv.prototype._addSchema = _addSchema;
-Ajv.prototype._compile = _compile;
-
-Ajv.prototype.compileAsync = require('./compile/async');
var customKeyword = require('./keyword');
Ajv.prototype.addKeyword = customKeyword.add;
Ajv.prototype.getKeyword = customKeyword.get;
Ajv.prototype.removeKeyword = customKeyword.remove;
+Ajv.ValidationError = require('./compile/validation_error');
-var errorClasses = require('./compile/error_classes');
-Ajv.ValidationError = errorClasses.Validation;
-Ajv.MissingRefError = errorClasses.MissingRef;
-Ajv.$dataMetaSchema = $dataMetaSchema;
-
-var META_SCHEMA_ID = 'http://json-schema.org/draft-06/schema';
+var META_SCHEMA_ID = 'http://json-schema.org/draft-04/schema';
+var SCHEMA_URI_FORMAT = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/\/)?[^\s]*$/i;
+function SCHEMA_URI_FORMAT_FUNC(str) {
+ return SCHEMA_URI_FORMAT.test(str);
+}
var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes' ];
-var META_SUPPORT_DATA = ['/properties'];
/**
* Creates validator instance.
@@ -6891,455 +7638,386 @@ var META_SUPPORT_DATA = ['/properties'];
*/
function Ajv(opts) {
if (!(this instanceof Ajv)) return new Ajv(opts);
+ var self = this;
+
opts = this._opts = util.copy(opts) || {};
- setLogger(this);
this._schemas = {};
this._refs = {};
this._fragments = {};
this._formats = formats(opts.format);
- var schemaUriFormat = this._schemaUriFormat = this._formats['uri-reference'];
- this._schemaUriFormatFunc = function (str) { return schemaUriFormat.test(str); };
-
this._cache = opts.cache || new Cache;
this._loadingSchemas = {};
this._compilations = [];
this.RULES = rules();
- this._getId = chooseGetId(opts);
+
+ // this is done on purpose, so that methods are bound to the instance
+ // (without using bind) so that they can be used without the instance
+ this.validate = validate;
+ this.compile = compile;
+ this.addSchema = addSchema;
+ this.addMetaSchema = addMetaSchema;
+ this.validateSchema = validateSchema;
+ this.getSchema = getSchema;
+ this.removeSchema = removeSchema;
+ this.addFormat = addFormat;
+ this.errorsText = errorsText;
+
+ this._addSchema = _addSchema;
+ this._compile = _compile;
opts.loopRequired = opts.loopRequired || Infinity;
+ if (opts.async || opts.transpile) async.setup(opts);
+ if (opts.beautify === true) opts.beautify = { indent_size: 2 };
if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
- if (opts.serialize === undefined) opts.serialize = stableStringify;
- this._metaOpts = getMetaSchemaOptions(this);
-
- if (opts.formats) addInitialFormats(this);
- addDraft6MetaSchema(this);
- if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
- addInitialSchemas(this);
- if (opts.patternGroups) patternGroups(this);
-}
-
-
-
-/**
- * Validate data using schema
- * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
- * @this Ajv
- * @param {String|Object} schemaKeyRef key, ref or schema object
- * @param {Any} data to be validated
- * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
- */
-function validate(schemaKeyRef, data) {
- var v;
- if (typeof schemaKeyRef == 'string') {
- v = this.getSchema(schemaKeyRef);
- if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
- } else {
- var schemaObj = this._addSchema(schemaKeyRef);
- v = schemaObj.validate || this._compile(schemaObj);
+ this._metaOpts = getMetaSchemaOptions();
+
+ if (opts.formats) addInitialFormats();
+ addDraft4MetaSchema();
+ if (opts.v5) v5.enable(this);
+ if (typeof opts.meta == 'object') addMetaSchema(opts.meta);
+ addInitialSchemas();
+
+
+ /**
+ * Validate data using schema
+ * Schema will be compiled and cached (using serialized JSON as key. [json-stable-stringify](https://github.com/substack/json-stable-stringify) is used to serialize.
+ * @param {String|Object} schemaKeyRef key, ref or schema object
+ * @param {Any} data to be validated
+ * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
+ */
+ function validate(schemaKeyRef, data) {
+ var v;
+ if (typeof schemaKeyRef == 'string') {
+ v = getSchema(schemaKeyRef);
+ if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
+ } else {
+ var schemaObj = _addSchema(schemaKeyRef);
+ v = schemaObj.validate || _compile(schemaObj);
+ }
+
+ var valid = v(data);
+ if (v.$async === true)
+ return self._opts.async == '*' ? co(valid) : valid;
+ self.errors = v.errors;
+ return valid;
+ }
+
+
+ /**
+ * Create validating function for passed schema.
+ * @param {Object} schema schema object
+ * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
+ * @return {Function} validating function
+ */
+ function compile(schema, _meta) {
+ var schemaObj = _addSchema(schema, undefined, _meta);
+ return schemaObj.validate || _compile(schemaObj);
+ }
+
+
+ /**
+ * Adds schema to the instance.
+ * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
+ * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
+ * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
+ * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
+ */
+ function addSchema(schema, key, _skipValidation, _meta) {
+ if (Array.isArray(schema)){
+ for (var i=0; i} errors optional array of validation errors, if not passed errors from the instance are used.
+ * @param {Object} options optional options with properties `separator` and `dataVar`.
+ * @return {String} human readable string with all errors descriptions
+ */
+ function errorsText(errors, options) {
+ errors = errors || self.errors;
+ if (!errors) return 'No errors';
+ options = options || {};
+ var separator = options.separator === undefined ? ', ' : options.separator;
+ var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
-/* @this Ajv */
-function _compile(schemaObj, root) {
- if (schemaObj.compiling) {
- schemaObj.validate = callValidate;
- callValidate.schema = schemaObj.schema;
- callValidate.errors = null;
- callValidate.root = root ? root : callValidate;
- if (schemaObj.schema.$async === true)
- callValidate.$async = true;
- return callValidate;
+ var text = '';
+ for (var i=0; i} errors optional array of validation errors, if not passed errors from the instance are used.
- * @param {Object} options optional options with properties `separator` and `dataVar`.
- * @return {String} human readable string with all errors descriptions
- */
-function errorsText(errors, options) {
- errors = errors || this.errors;
- if (!errors) return 'No errors';
- options = options || {};
- var separator = options.separator === undefined ? ', ' : options.separator;
- var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
-
- var text = '';
- for (var i=0; i=1&&t<=12&&a>=1&&a<=m[t]}function o(e,r){var t=e.match(v);if(!t)return!1;var a=t[1],s=t[2],o=t[3],i=t[5];return a<=23&&s<=59&&o<=59&&(!r||i)}function i(e){var r=e.split(b);return 2==r.length&&s(r[0])&&o(r[1],!0)}function n(e){return e.length<=255&&y.test(e)}function l(e){return w.test(e)&&g.test(e)}function c(e){try{return new RegExp(e),!0}catch(e){return!1}}function h(e,r){if(e&&r)return e>r?1:er?1:e=0?{index:a,compiling:!0}:(a=this._compilations.length,this._compilations[a]={schema:e,root:r,baseId:t},{index:a,compiling:!1})}function i(e,r,t){var a=n.call(this,e,r,t);a>=0&&this._compilations.splice(a,1)}function n(e,r,t){for(var a=0;a=55296&&r<=56319&&s=r)throw new Error("Cannot access property/index "+a+" levels up, current level is "+r);return t[r-a]}if(a>r)throw new Error("Cannot access data "+a+" levels up, current level is "+r);if(o="data"+(r-a||""),!s)return o}for(var n=o,c=s.split("/"),h=0;h",S="result"+s,$=e.opts.v5&&i&&i.$data;if($?(a+=" var schema"+s+" = "+e.util.getData(i.$data,o,e.dataPathArr)+"; ",g="schema"+s):g=i,w){var x=e.util.getData(b.$data,o,e.dataPathArr),_="exclusive"+s,O="op"+s,R="' + "+O+" + '";a+=" var schemaExcl"+s+" = "+x+"; ",x="schemaExcl"+s,a+=" if (typeof "+x+" != 'boolean' && "+x+" !== undefined) { "+u+" = false; ";var t=E,I=I||[];I.push(a),a="",!1!==e.createErrors?(a+=" { keyword: '"+(t||"_formatExclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: '"+E+" should be boolean' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),a+=" } "):a+=" {} ";var A=a;a=I.pop(),a+=!e.compositeRule&&c?e.async?" throw new ValidationError(["+A+"]); ":" validate.errors = ["+A+"]; return false; ":" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",c&&(p+="}",a+=" else { "),$&&(a+=" if ("+g+" === undefined) "+u+" = true; else if (typeof "+g+" != 'string') "+u+" = false; else { ",p+="}"),d&&(a+=" if (!"+y+") "+u+" = true; else { ",p+="}"),a+=" var "+S+" = "+y+"("+h+", ",a+=$?""+g:""+e.util.toQuotedString(i),a+=" ); if ("+S+" === undefined) "+u+" = false; var "+_+" = "+x+" === true; if ("+u+" === undefined) { "+u+" = "+_+" ? "+S+" "+j+" 0 : "+S+" "+j+"= 0; } if (!"+u+") var op"+s+" = "+_+" ? '"+j+"' : '"+j+"=';"}else{var _=!0===b,R=j;_||(R+="=");var O="'"+R+"'";$&&(a+=" if ("+g+" === undefined) "+u+" = true; else if (typeof "+g+" != 'string') "+u+" = false; else { ",p+="}"),d&&(a+=" if (!"+y+") "+u+" = true; else { ",p+="}"),a+=" var "+S+" = "+y+"("+h+", ",a+=$?""+g:""+e.util.toQuotedString(i),a+=" ); if ("+S+" === undefined) "+u+" = false; if ("+u+" === undefined) "+u+" = "+S+" "+j,_||(a+="="),a+=" 0;"}a+=p+"if (!"+u+") { ";var t=r,I=I||[];I.push(a),a="",!1!==e.createErrors?(a+=" { keyword: '"+(t||"_formatLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { comparison: "+O+", limit: ",a+=$?""+g:""+e.util.toQuotedString(i),a+=" , exclusive: "+_+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be "+R+' "',a+=$?"' + "+g+" + '":""+e.util.escapeQuotes(i),a+="\"' "),e.opts.verbose&&(a+=" , schema: ",a+=$?"validate.schema"+n:""+e.util.toQuotedString(i),a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),a+=" } "):a+=" {} ";var A=a;return a=I.pop(),a+=!e.compositeRule&&c?e.async?" throw new ValidationError(["+A+"]); ":" validate.errors = ["+A+"]; return false; ":" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+="}"}},{}],14:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a,s=" ",o=e.level,i=e.dataLevel,n=e.schema[r],l=e.schemaPath+e.util.getProperty(r),c=e.errSchemaPath+"/"+r,h=!e.opts.allErrors,u="data"+(i||""),f=e.opts.v5&&n&&n.$data;f?(s+=" var schema"+o+" = "+e.util.getData(n.$data,i,e.dataPathArr)+"; ",a="schema"+o):a=n;var d="maximum"==r,p=d?"exclusiveMaximum":"exclusiveMinimum",m=e.schema[p],v=e.opts.v5&&m&&m.$data,y=d?"<":">",g=d?">":"<";if(v){var P=e.util.getData(m.$data,i,e.dataPathArr),E="exclusive"+o,b="op"+o,w="' + "+b+" + '";s+=" var schemaExcl"+o+" = "+P+"; ",P="schemaExcl"+o,s+=" var exclusive"+o+"; if (typeof "+P+" != 'boolean' && typeof "+P+" != 'undefined') { ";var t=p,j=j||[];j.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(t||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(s+=" , message: '"+p+" should be boolean' "),e.opts.verbose&&(s+=" , schema: validate.schema"+l+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var S=s;s=j.pop(),s+=!e.compositeRule&&h?e.async?" throw new ValidationError(["+S+"]); ":" validate.errors = ["+S+"]; return false; ":" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else if( ",f&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" ((exclusive"+o+" = "+P+" === true) ? "+u+" "+g+"= "+a+" : "+u+" "+g+" "+a+") || "+u+" !== "+u+") { var op"+o+" = exclusive"+o+" ? '"+y+"' : '"+y+"=';"}else{var E=!0===m,w=y;E||(w+="=");var b="'"+w+"'";s+=" if ( ",f&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+" "+g,E&&(s+="="),s+=" "+a+" || "+u+" !== "+u+") {"}var t=r,j=j||[];j.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(t||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { comparison: "+b+", limit: "+a+", exclusive: "+E+" } ",!1!==e.opts.messages&&(s+=" , message: 'should be "+w+" ",s+=f?"' + "+a:n+"'"),e.opts.verbose&&(s+=" , schema: ",s+=f?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var S=s;return s=j.pop(),s+=!e.compositeRule&&h?e.async?" throw new ValidationError(["+S+"]); ":" validate.errors = ["+S+"]; return false; ":" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",h&&(s+=" else { "),s}},{}],15:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a,s=" ",o=e.level,i=e.dataLevel,n=e.schema[r],l=e.schemaPath+e.util.getProperty(r),c=e.errSchemaPath+"/"+r,h=!e.opts.allErrors,u="data"+(i||""),f=e.opts.v5&&n&&n.$data;f?(s+=" var schema"+o+" = "+e.util.getData(n.$data,i,e.dataPathArr)+"; ",a="schema"+o):a=n;var d="maxItems"==r?">":"<";s+="if ( ",f&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+".length "+d+" "+a+") { ";var t=r,p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(t||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxItems"==r?"more":"less",s+=" than ",s+=f?"' + "+a+" + '":""+n,s+=" items' "),e.opts.verbose&&(s+=" , schema: ",s+=f?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),s+=!e.compositeRule&&h?e.async?" throw new ValidationError(["+m+"]); ":" validate.errors = ["+m+"]; return false; ":" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",h&&(s+=" else { "),s}},{}],16:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a,s=" ",o=e.level,i=e.dataLevel,n=e.schema[r],l=e.schemaPath+e.util.getProperty(r),c=e.errSchemaPath+"/"+r,h=!e.opts.allErrors,u="data"+(i||""),f=e.opts.v5&&n&&n.$data;f?(s+=" var schema"+o+" = "+e.util.getData(n.$data,i,e.dataPathArr)+"; ",a="schema"+o):a=n;var d="maxLength"==r?">":"<";s+="if ( ",f&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=!1===e.opts.unicode?" "+u+".length ":" ucs2length("+u+") ",s+=" "+d+" "+a+") { ";var t=r,p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(t||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT be ",s+="maxLength"==r?"longer":"shorter",s+=" than ",s+=f?"' + "+a+" + '":""+n,s+=" characters' "),e.opts.verbose&&(s+=" , schema: ",s+=f?"validate.schema"+l:""+n,
+s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),s+=!e.compositeRule&&h?e.async?" throw new ValidationError(["+m+"]); ":" validate.errors = ["+m+"]; return false; ":" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",h&&(s+=" else { "),s}},{}],17:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a,s=" ",o=e.level,i=e.dataLevel,n=e.schema[r],l=e.schemaPath+e.util.getProperty(r),c=e.errSchemaPath+"/"+r,h=!e.opts.allErrors,u="data"+(i||""),f=e.opts.v5&&n&&n.$data;f?(s+=" var schema"+o+" = "+e.util.getData(n.$data,i,e.dataPathArr)+"; ",a="schema"+o):a=n;var d="maxProperties"==r?">":"<";s+="if ( ",f&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" Object.keys("+u+").length "+d+" "+a+") { ";var t=r,p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(t||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxProperties"==r?"more":"less",s+=" than ",s+=f?"' + "+a+" + '":""+n,s+=" properties' "),e.opts.verbose&&(s+=" , schema: ",s+=f?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),s+=!e.compositeRule&&h?e.async?" throw new ValidationError(["+m+"]); ":" validate.errors = ["+m+"]; return false; ":" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",h&&(s+=" else { "),s}},{}],18:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.schema[r],s=e.schemaPath+e.util.getProperty(r),o=e.errSchemaPath+"/"+r,i=!e.opts.allErrors,n=e.util.copy(e),l="";n.level++;var c="valid"+n.level,h=n.baseId,u=!0,f=a;if(f)for(var d,p=-1,m=f.length-1;p "+$+") { ";var _=c+"["+$+"]";f.schema=S,f.schemaPath=i+"["+$+"]",f.errSchemaPath=n+"/"+$,f.errorPath=e.util.getPathExpr(e.errorPath,$,e.opts.jsonPointers,!0),f.dataPathArr[v]=$;var O=e.validate(f);f.baseId=g,e.util.varOccurences(O,y)<2?t+=" "+e.util.varReplace(O,y,_)+" ":t+=" var "+y+" = "+_+"; "+O+" ",t+=" } ",l&&(t+=" if ("+p+") { ",d+="}")}if("object"==typeof P&&e.util.schemaHasRules(P,e.RULES.all)){f.schema=P,f.schemaPath=e.schemaPath+".additionalItems",f.errSchemaPath=e.errSchemaPath+"/additionalItems",t+=" "+p+" = true; if ("+c+".length > "+o.length+") { for (var "+m+" = "+o.length+"; "+m+" < "+c+".length; "+m+"++) { ",f.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);var _=c+"["+m+"]";f.dataPathArr[v]=m;var O=e.validate(f);f.baseId=g,e.util.varOccurences(O,y)<2?t+=" "+e.util.varReplace(O,y,_)+" ":t+=" var "+y+" = "+_+"; "+O+" ",l&&(t+=" if (!"+p+") break; "),t+=" } } ",l&&(t+=" if ("+p+") { ",d+="}")}}else if(e.util.schemaHasRules(o,e.RULES.all)){f.schema=o,f.schemaPath=i,f.errSchemaPath=n,t+=" for (var "+m+" = 0; "+m+" < "+c+".length; "+m+"++) { ",f.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0);var _=c+"["+m+"]";f.dataPathArr[v]=m;var O=e.validate(f);f.baseId=g,e.util.varOccurences(O,y)<2?t+=" "+e.util.varReplace(O,y,_)+" ":t+=" var "+y+" = "+_+"; "+O+" ",l&&(t+=" if (!"+p+") break; "),t+=" } ",l&&(t+=" if ("+p+") { ",d+="}")}return l&&(t+=" "+d+" if ("+u+" == errors) {"),t=e.util.cleanUpCode(t)}},{}],26:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a=" ",s=e.level,o=e.dataLevel,i=e.schema[r],n=e.schemaPath+e.util.getProperty(r),l=e.errSchemaPath+"/"+r,c=!e.opts.allErrors,h="data"+(o||""),u=e.opts.v5&&i&&i.$data;u?(a+=" var schema"+s+" = "+e.util.getData(i.$data,o,e.dataPathArr)+"; ",t="schema"+s):t=i,a+="var division"+s+";if (",u&&(a+=" "+t+" !== undefined && ( typeof "+t+" != 'number' || "),a+=" (division"+s+" = "+h+" / "+t+", ",a+=e.opts.multipleOfPrecision?" Math.abs(Math.round(division"+s+") - division"+s+") > 1e-"+e.opts.multipleOfPrecision+" ":" division"+s+" !== parseInt(division"+s+") ",a+=" ) ",u&&(a+=" ) "),a+=" ) { ";var f=f||[];f.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { multipleOf: "+t+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be multiple of ",a+=u?"' + "+t:i+"'"),e.opts.verbose&&(a+=" , schema: ",a+=u?"validate.schema"+n:""+i,a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),a+=" } "):a+=" {} ";var d=a;return a=f.pop(),a+=!e.compositeRule&&c?e.async?" throw new ValidationError(["+d+"]); ":" validate.errors = ["+d+"]; return false; ":" var err = "+d+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+="} ",c&&(a+=" else { "),a}},{}],27:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),h="errs__"+a,u=e.util.copy(e);u.level++;var f="valid"+u.level;if(e.util.schemaHasRules(o,e.RULES.all)){u.schema=o,u.schemaPath=i,u.errSchemaPath=n,t+=" var "+h+" = errors; ";var d=e.compositeRule;e.compositeRule=u.compositeRule=!0,u.createErrors=!1;var p;u.opts.allErrors&&(p=u.opts.allErrors,u.opts.allErrors=!1),t+=" "+e.validate(u)+" ",u.createErrors=!0,p&&(u.opts.allErrors=p),e.compositeRule=u.compositeRule=d,t+=" if ("+f+") { ";var m=m||[];m.push(t),t="",!1!==e.createErrors?(t+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: {} ",!1!==e.opts.messages&&(t+=" , message: 'should NOT be valid' "),e.opts.verbose&&(t+=" , schema: validate.schema"+i+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var v=t;t=m.pop(),t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+v+"]); ":" validate.errors = ["+v+"]; return false; ":" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+=" } else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.opts.allErrors&&(t+=" } ")}else t+=" var err = ",!1!==e.createErrors?(t+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: {} ",!1!==e.opts.messages&&(t+=" , message: 'should NOT be valid' "),e.opts.verbose&&(t+=" , schema: validate.schema"+i+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ",t+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l&&(t+=" if (false) { ");return t}},{}],28:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),h="valid"+a,u="errs__"+a,f=e.util.copy(e),d="";f.level++;var p="valid"+f.level;t+="var "+u+" = errors;var prevValid"+a+" = false;var "+h+" = false;";var m=f.baseId,v=e.compositeRule;e.compositeRule=f.compositeRule=!0;var y=o;if(y)for(var g,P=-1,E=y.length-1;P5)t+=" || validate.schema"+i+"["+m+"] ";else{var q=g;if(q)for(var D,L=-1,Q=q.length-1;L= "+pe+"; ",n=e.errSchemaPath+"/patternGroups/minimum",t+=" if (!"+h+") { ";var G=G||[];G.push(t),t="",!1!==e.createErrors?(t+=" { keyword: 'patternGroups' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { reason: '"+ye+"', limit: "+ve+", pattern: '"+e.util.escapeQuotes(M)+"' } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have "+ge+" than "+ve+' properties matching pattern "'+e.util.escapeQuotes(M)+"\"' "),e.opts.verbose&&(t+=" , schema: validate.schema"+i+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var K=t;t=G.pop(),t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+K+"]); ":" validate.errors = ["+K+"]; return false; ":" var err = "+K+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+=" } ",void 0!==me&&(t+=" else ")}if(void 0!==me){var ve=me,ye="maximum",ge="more";t+=" "+h+" = pgPropCount"+a+" <= "+me+"; ",n=e.errSchemaPath+"/patternGroups/maximum",t+=" if (!"+h+") { ";var G=G||[];G.push(t),t="",!1!==e.createErrors?(t+=" { keyword: 'patternGroups' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { reason: '"+ye+"', limit: "+ve+", pattern: '"+e.util.escapeQuotes(M)+"' } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have "+ge+" than "+ve+' properties matching pattern "'+e.util.escapeQuotes(M)+"\"' "),e.opts.verbose&&(t+=" , schema: validate.schema"+i+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var K=t;t=G.pop(),t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+K+"]); ":" validate.errors = ["+K+"]; return false; ":" var err = "+K+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+=" } "}n=J,l&&(t+=" if ("+h+") { ",d+="}")}}}}return l&&(t+=" "+d+" if ("+u+" == errors) {"),t=e.util.cleanUpCode(t)}},{}],32:[function(e,r,t){"use strict";r.exports=function(e,r){var t,a,s=" ",o=e.level,i=e.dataLevel,n=e.schema[r],l=e.errSchemaPath+"/"+r,c=!e.opts.allErrors,h="data"+(i||""),u="valid"+o;if("#"==n||"#/"==n)e.isRoot?(t=e.async,a="validate"):(t=!0===e.root.schema.$async,a="root.refVal[0]");else{var f=e.resolveRef(e.baseId,n,e.isRoot);if(void 0===f){var d="can't resolve reference "+n+" from id "+e.baseId;if("fail"==e.opts.missingRefs){console.log(d);var p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { ref: '"+e.util.escapeQuotes(n)+"' } ",!1!==e.opts.messages&&(s+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(n)+"' "),e.opts.verbose&&(s+=" , schema: "+e.util.toQuotedString(n)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),s+=" } "):s+=" {} ";var m=s;s=p.pop(),s+=!e.compositeRule&&c?e.async?" throw new ValidationError(["+m+"]); ":" validate.errors = ["+m+"]; return false; ":" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c&&(s+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs){var v=new Error(d);throw v.missingRef=e.resolve.url(e.baseId,n),v.missingSchema=e.resolve.normalizeId(e.resolve.fullPath(v.missingRef)),v}console.log(d),c&&(s+=" if (true) { ")}}else if(f.inline){var y=e.util.copy(e);y.level++;var g="valid"+y.level;y.schema=f.schema,y.schemaPath="",y.errSchemaPath=n;var P=e.validate(y).replace(/validate\.schema/g,f.code);s+=" "+P+" ",c&&(s+=" if ("+g+") { ")}else t=!0===f.$async,a=f.code}if(a){var p=p||[];p.push(s),s="",s+=e.opts.passContext?" "+a+".call(this, ":" "+a+"( ",s+=" "+h+", (dataPath || '')",'""'!=e.errorPath&&(s+=" + "+e.errorPath);s+=" , "+(i?"data"+(i-1||""):"parentData")+" , "+(i?e.dataPathArr[i]:"parentDataProperty")+", rootData) ";var E=s;if(s=p.pop(),t){if(!e.async)throw new Error("async schema referenced by sync schema");s+=" try { ",c&&(s+="var "+u+" ="),s+=" "+e.yieldAwait+" "+E+"; } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; } ",c&&(s+=" if ("+u+") { ")}else s+=" if (!"+E+") { if (vErrors === null) vErrors = "+a+".errors; else vErrors = vErrors.concat("+a+".errors); errors = vErrors.length; } ",c&&(s+=" else { ")}return s}},{}],33:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),h="valid"+a,u=e.opts.v5&&o&&o.$data;u&&(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ");var f="schema"+a;if(!u)if(o.length=e.opts.loopRequired;if(l)if(t+=" var missing"+a+"; ",E){u||(t+=" var "+f+" = validate.schema"+i+"; ");var b="i"+a,w="schema"+a+"["+b+"]",j="' + "+w+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(P,w,e.opts.jsonPointers)),t+=" var "+h+" = true; ",u&&(t+=" if (schema"+a+" === undefined) "+h+" = true; else if (!Array.isArray(schema"+a+")) "+h+" = false; else {"),t+=" for (var "+b+" = 0; "+b+" < "+f+".length; "+b+"++) { "+h+" = "+c+"["+f+"["+b+"]] !== undefined; if (!"+h+") break; } ",u&&(t+=" } "),t+=" if (!"+h+") { ";var S=S||[];S.push(t),t="",!1!==e.createErrors?(t+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { missingProperty: '"+j+"' } ",!1!==e.opts.messages&&(t+=" , message: '",t+=e.opts._errorDataPathProperty?"is a required property":"should have required property \\'"+j+"\\'",t+="' "),e.opts.verbose&&(t+=" , schema: validate.schema"+i+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var $=t;t=S.pop(),t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+$+"]); ":" validate.errors = ["+$+"]; return false; ":" var err = "+$+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+=" } else { "}else{t+=" if ( ";var x=d;if(x)for(var _,b=-1,O=x.length-1;b 1) { var i = "+h+".length, j; outer: for (;i--;) { for (j = i; j--;) { if (equal("+h+"[i], "+h+"[j])) { "+u+" = false; break outer; } } } } ",f&&(a+=" } "),a+=" if (!"+u+") { ";var d=d||[];d.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(a+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(a+=" , schema: ",a+=f?"validate.schema"+n:""+i,a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),a+=" } "):a+=" {} ";var p=a;a=d.pop(),a+=!e.compositeRule&&c?e.async?" throw new ValidationError(["+p+"]); ":" validate.errors = ["+p+"]; return false; ":" var err = "+p+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",c&&(a+=" else { ")}else c&&(a+=" if (true) { ");return a}},{}],36:[function(e,r,t){"use strict";r.exports=function(e,r){function t(r){return void 0!==e.schema[r.keyword]||"properties"==r.keyword&&(!1===e.schema.additionalProperties||"object"==typeof e.schema.additionalProperties||e.schema.patternProperties&&Object.keys(e.schema.patternProperties).length||e.opts.v5&&e.schema.patternGroups&&Object.keys(e.schema.patternGroups).length)}var a="",s=!0===e.schema.$async;if(e.isTop){var o=e.isTop,i=e.level=0,n=e.dataLevel=0,l="data";if(e.rootId=e.resolve.fullPath(e.root.schema.id),e.baseId=e.baseId||e.rootId,s){e.async=!0;var c="es7"==e.opts.async;e.yieldAwait=c?"await":"yield"}delete e.isTop,e.dataPathArr=[void 0],a+=" var validate = ",s?c?a+=" (async function ":("co*"==e.opts.async&&(a+="co.wrap"),a+="(function* "):a+=" (function ",a+=" (data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; var vErrors = null; ",a+=" var errors = 0; ",a+=" if (rootData === undefined) rootData = data;"}else{var i=e.level,n=e.dataLevel,l="data"+(n||"");if(e.schema.id&&(e.baseId=e.resolve.url(e.baseId,e.schema.id)),s&&!e.async)throw new Error("async schema in sync schema");a+=" var errs_"+i+" = errors;"}var h="valid"+i,u=!e.opts.allErrors,f="",d="",p=e.schema.type,m=Array.isArray(p);if(p&&e.opts.coerceTypes){var v=e.util.coerceToTypes(e.opts.coerceTypes,p);if(v){var y=e.schemaPath+".type",g=e.errSchemaPath+"/type",P=m?"checkDataTypes":"checkDataType";a+=" if ("+e.util[P](p,l,!0)+") { ";var E="dataType"+i,b="coerced"+i;a+=" var "+E+" = typeof "+l+"; ","array"==e.opts.coerceTypes&&(a+=" if ("+E+" == 'object' && Array.isArray("+l+")) "+E+" = 'array'; "),a+=" var "+b+" = undefined; ";var w="",j=v;if(j)for(var S,$=-1,x=j.length-1;$2&&(r=f.call(arguments,1)),t(r)})})}function i(e){return Promise.all(e.map(s,this))}function n(e){for(var r=new e.constructor,t=Object.keys(e),a=[],o=0;o="0"&&s<="9";)r+=s,c();if("."===s)for(r+=".";c()&&s>="0"&&s<="9";)r+=s;if("e"===s||"E"===s)for(r+=s,c(),"-"!==s&&"+"!==s||(r+=s,c());s>="0"&&s<="9";)r+=s,c();if(e=+r,isFinite(e))return e;l("Bad number")},u=function(){var e,r,t,a="";if('"'===s)for(;c();){if('"'===s)return c(),a;if("\\"===s)if(c(),"u"===s){for(t=0,r=0;r<4&&(e=parseInt(c(),16),isFinite(e));r+=1)t=16*t+e;a+=String.fromCharCode(t)}else{if("string"!=typeof n[s])break;a+=n[s]}else a+=s}l("Bad string")},f=function(){for(;s&&s<=" ";)c()},d=function(){switch(s){case"t":return c("t"),c("r"),c("u"),c("e"),!0;case"f":return c("f"),c("a"),c("l"),c("s"),c("e"),!1;case"n":return c("n"),c("u"),c("l"),c("l"),null}l("Unexpected '"+s+"'")},p=function(){var e=[];if("["===s){if(c("["),f(),"]"===s)return c("]"),e;for(;s;){if(e.push(i()),f(),"]"===s)return c("]"),e;c(","),f()}}l("Bad array")},m=function(){var e,r={};if("{"===s){if(c("{"),f(),"}"===s)return c("}"),r;for(;s;){if(e=u(),f(),c(":"),Object.hasOwnProperty.call(r,e)&&l('Duplicate key "'+e+'"'),r[e]=i(),f(),"}"===s)return c("}"),r;c(","),f()}}l("Bad object")};i=function(){switch(f(),s){case"{":return m();case"[":return p();case'"':return u();case"-":return h();default:return s>="0"&&s<="9"?h():d()}},r.exports=function(e,r){var t;return o=e,a=0,s=" ",t=i(),f(),s&&l("Syntax error"),"function"==typeof r?function e(t,a){var s,o,i=t[a];if(i&&"object"==typeof i)for(s in i)Object.prototype.hasOwnProperty.call(i,s)&&(o=e(i,s),void 0!==o?i[s]=o:delete i[s]);return r.call(t,a,i)}({"":t},""):t}},{}],45:[function(e,r,t){function a(e){return l.lastIndex=0,l.test(e)?'"'+e.replace(l,function(e){var r=c[e];return"string"==typeof r?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function s(e,r){var t,l,c,h,u,f=o,d=r[e];switch(d&&"object"==typeof d&&"function"==typeof d.toJSON&&(d=d.toJSON(e)),"function"==typeof n&&(d=n.call(r,e,d)),typeof d){case"string":return a(d);case"number":return isFinite(d)?String(d):"null";case"boolean":case"null":return String(d);case"object":if(!d)return"null";if(o+=i,u=[],"[object Array]"===Object.prototype.toString.apply(d)){for(h=d.length,t=0;t1&&(a=t[0]+"@",e=t[1]),e=e.replace(q,"."),a+i(e.split("."),r).join(".")}function l(e){for(var r,t,a=[],s=0,o=e.length;s=55296&&r<=56319&&s65535&&(e-=65536,r+=C(e>>>10&1023|55296),e=56320|1023&e),r+=C(e)}).join("")}function h(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:j}function u(e,r){return e+22+75*(e<26)-((0!=r)<<5)}function f(e,r,t){var a=0;for(e=t?Q(e/_):e>>1,e+=Q(e/r);e>L*$>>1;a+=j)e=Q(e/L);return Q(a+(L+1)*e/(e+x))}function d(e){var r,t,a,s,i,n,l,u,d,p,m=[],v=e.length,y=0,g=R,P=O;for(t=e.lastIndexOf(I),t<0&&(t=0),a=0;a=128&&o("not-basic"),m.push(e.charCodeAt(a));for(s=t>0?t+1:0;s=v&&o("invalid-input"),u=h(e.charCodeAt(s++)),(u>=j||u>Q((w-y)/n))&&o("overflow"),y+=u*n,d=l<=P?S:l>=P+$?$:l-P,!(uQ(w/p)&&o("overflow"),n*=p;r=m.length+1,P=f(y-i,r,0==i),Q(y/r)>w-g&&o("overflow"),g+=Q(y/r),y%=r,m.splice(y++,0,g)}return c(m)}function p(e){var r,t,a,s,i,n,c,h,d,p,m,v,y,g,P,E=[];for(e=l(e),v=e.length,r=R,t=0,i=O,n=0;n=r&&mQ((w-t)/y)&&o("overflow"),t+=(c-r)*y,r=c,n=0;nw&&o("overflow"),m==r){for(h=t,d=j;p=d<=i?S:d>=i+$?$:d-i,!(h= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=j-S,Q=Math.floor,C=String.fromCharCode;if(E={version:"1.4.1",ucs2:{decode:l,encode:c},decode:d,encode:p,toASCII:v,toUnicode:m},"function"==typeof e&&"object"==typeof e.amd&&e.amd)e("punycode",function(){return E});else if(y&&g)if(t.exports==y)g.exports=E;else for(b in E)E.hasOwnProperty(b)&&(y[b]=E[b]);else s.punycode=E}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],47:[function(e,r,t){"use strict";function a(e,r){return Object.prototype.hasOwnProperty.call(e,r)}r.exports=function(e,r,t,o){r=r||"&",t=t||"=";var i={};if("string"!=typeof e||0===e.length)return i;e=e.split(r);var n=1e3;o&&"number"==typeof o.maxKeys&&(n=o.maxKeys);var l=e.length;n>0&&l>n&&(l=n);for(var c=0;c=0?(h=p.substr(0,m),u=p.substr(m+1)):(h=p,u=""),f=decodeURIComponent(h),d=decodeURIComponent(u),a(i,f)?s(i[f])?i[f].push(d):i[f]=[i[f],d]:i[f]=d}return i};var s=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],48:[function(e,r,t){"use strict";function a(e,r){if(e.map)return e.map(r);for(var t=[],a=0;a",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(d),m=["'"].concat(p),v=["%","/","?",";","#"].concat(m),y=["/","?","#"],g={javascript:!0,"javascript:":!0},P={javascript:!0,"javascript:":!0},E={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");a.prototype.parse=function(e,r,t){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var a=e.indexOf("?"),s=-1!==a&&a127?A+="x":A+=I[k];if(!A.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var D=O.slice(0,j),L=O.slice(j+1),Q=I.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);Q&&(D.push(Q[1]),L.unshift(Q[2])),L.length&&(i="/"+L.join(".")+i),this.hostname=D.join(".");break}}}this.hostname=this.hostname.length>255?"":this.hostname.toLowerCase(),_||(this.hostname=l.toASCII(this.hostname));var C=this.port?":"+this.port:"";this.host=(this.hostname||"")+C,this.href+=this.host,_&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==i[0]&&(i="/"+i))}if(!g[d])for(var j=0,R=m.length;j0)&&t.host.split("@");j&&(t.auth=j.shift(),t.host=t.hostname=j.shift())}return t.search=e.search,t.query=e.query,c.isNull(t.pathname)&&c.isNull(t.search)||(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=t.format(),t}if(!b.length)return t.pathname=null,t.path=t.search?"/"+t.search:null,t.href=t.format(),t;for(var S=b.slice(-1)[0],$=(t.host||e.host||b.length>1)&&("."===S||".."===S)||""===S,x=0,_=b.length;_>=0;_--)S=b[_],"."===S?b.splice(_,1):".."===S?(b.splice(_,1),x++):x&&(b.splice(_,1),x--);if(!y&&!g)for(;x--;x)b.unshift("..");!y||""===b[0]||b[0]&&"/"===b[0].charAt(0)||b.unshift(""),$&&"/"!==b.join("/").substr(-1)&&b.push("");var O=""===b[0]||b[0]&&"/"===b[0].charAt(0);if(w){t.hostname=t.host=O?"":b.length?b.shift():"";var j=!!(t.host&&t.host.indexOf("@")>0)&&t.host.split("@");j&&(t.auth=j.shift(),t.host=t.hostname=j.shift())}return y=y||t.host&&b.length,y&&!O&&b.unshift(""),b.length?t.pathname=b.join("/"):(t.pathname=null,t.path=null),c.isNull(t.pathname)&&c.isNull(t.search)||(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=e.auth||t.auth,t.slashes=t.slashes||e.slashes,t.href=t.format(),t},a.prototype.parseHost=function(){var e=this.host,r=u.exec(e);r&&(r=r[0],":"!==r&&(this.port=r.substr(1)),e=e.substr(0,e.length-r.length)),e&&(this.hostname=e)}},{"./util":51,punycode:46,querystring:49}],51:[function(e,r,t){"use strict";r.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],ajv:[function(e,r,t){"use strict";function a(e){return g.test(e)}function s(r){function t(e,r){var t;if("string"==typeof e){if(!(t=S(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var a=R(e);t=a.validate||I(a)}var s=t(r);return!0===t.$async?"*"==D._opts.async?m(s):s:(D.errors=t.errors,s)}function v(e,r){var t=R(e,void 0,r);return t.validate||I(t)}function E(e,r,t,a){if(Array.isArray(e))for(var s=0;s=t}function i(e,t,n){var r=t.input.slice(t.start);return n&&(r=r.replace(p,"$1 $3")),e.test(r)}function s(e,t,n,r){var i=new e.constructor(e.options,e.input,t);if(n)for(var s in n)i[s]=n[s];var o=e,a=i;return["inFunction","inAsyncFunction","inAsync","inGenerator","inModule"].forEach(function(e){e in o&&(a[e]=o[e])}),r&&(i.options.preserveParens=!0),i.nextToken(),i}function o(e,t){var n=function(){};e.extend("initialContext",function(r){return function(){return this.options.ecmaVersion<7&&(n=function(t){e.raise(t.start,"async/await keywords only available when ecmaVersion>=7")}),this.reservedWords=new RegExp(this.reservedWords.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")),this.reservedWordsStrict=new RegExp(this.reservedWordsStrict.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")),this.reservedWordsStrictBind=new RegExp(this.reservedWordsStrictBind.toString().replace(/await|async/g,"").replace("|/","/").replace("/|","/").replace("||","|")),this.inAsyncFunction=t.inAsyncFunction,t.awaitAnywhere&&t.inAsyncFunction&&e.raise(node.start,"The options awaitAnywhere and inAsyncFunction are mutually exclusive"),r.apply(this,arguments)}}),e.extend("shouldParseExportStatement",function(e){return function(){return!("name"!==this.type.label||"async"!==this.value||!i(c,this))||e.apply(this,arguments)}}),e.extend("parseStatement",function(e){return function(n,r){var s=this.start,o=this.startLoc;if("name"===this.type.label)if(i(c,this,!0)){var a=this.inAsyncFunction;try{this.inAsyncFunction=!0,this.next();var l=this.parseStatement(n,r);return l.async=!0,l.start=s,l.loc&&(l.loc.start=o),l.range&&(l.range[0]=s),l}finally{this.inAsyncFunction=a}}else if("object"==typeof t&&t.asyncExits&&i(u,this)){this.next();var l=this.parseStatement(n,r);return l.async=!0,l.start=s,l.loc&&(l.loc.start=o),l.range&&(l.range[0]=s),l}return e.apply(this,arguments)}}),e.extend("parseIdent",function(e){return function(t){var n=e.apply(this,arguments);return this.inAsyncFunction&&"await"===n.name&&0===arguments.length&&this.raise(n.start,"'await' is reserved within async functions"),n}}),e.extend("parseExprAtom",function(e){return function(i){var o,u=this.start,c=this.startLoc,p=e.apply(this,arguments);if("Identifier"===p.type)if("async"!==p.name||r(this,p.end)){if("await"===p.name){var h=this.startNodeAt(p.start,p.loc&&p.loc.start);if(this.inAsyncFunction)return o=this.parseExprSubscripts(),h.operator="await",h.argument=o,h=this.finishNodeAt(h,"AwaitExpression",o.end,o.loc&&o.loc.end),n(h),h;if(this.input.slice(p.end).match(l))return t.awaitAnywhere||"module"!==this.options.sourceType?p:this.raise(p.start,"'await' is reserved within modules");if("object"==typeof t&&t.awaitAnywhere&&(u=this.start,o=s(this,u-4).parseExprSubscripts(),o.end<=u))return o=s(this,u).parseExprSubscripts(),h.operator="await",h.argument=o,h=this.finishNodeAt(h,"AwaitExpression",o.end,o.loc&&o.loc.end),this.pos=o.end,this.end=o.end,this.endLoc=o.endLoc,this.next(),n(h),h;if(!t.awaitAnywhere&&"module"===this.options.sourceType)return this.raise(p.start,"'await' is reserved within modules")}}else{var f=this.inAsyncFunction;try{this.inAsyncFunction=!0;var d=this,y=!1,m={parseFunctionBody:function(e,t){try{var n=y;return y=!0,d.parseFunctionBody.apply(this,arguments)}finally{y=n}},raise:function(){try{return d.raise.apply(this,arguments)}catch(e){throw y?e:a}}};if(o=s(this,this.start,m,!0).parseExpression(),"SequenceExpression"===o.type&&(o=o.expressions[0]),"CallExpression"===o.type&&(o=o.callee),"FunctionExpression"===o.type||"FunctionDeclaration"===o.type||"ArrowFunctionExpression"===o.type)return o=s(this,this.start,m).parseExpression(),"SequenceExpression"===o.type&&(o=o.expressions[0]),"CallExpression"===o.type&&(o=o.callee),o.async=!0,o.start=u,o.loc&&(o.loc.start=c),o.range&&(o.range[0]=u),this.pos=o.end,this.end=o.end,this.endLoc=o.endLoc,this.next(),n(o),o}catch(e){if(e!==a)throw e}finally{this.inAsyncFunction=f}}return p}}),e.extend("finishNodeAt",function(e){return function(t,n,r,i){return t.__asyncValue&&(delete t.__asyncValue,t.value.async=!0),e.apply(this,arguments)}}),e.extend("finishNode",function(e){return function(t,n){return t.__asyncValue&&(delete t.__asyncValue,t.value.async=!0),e.apply(this,arguments)}});e.extend("parsePropertyName",function(e){return function(t){var i=(t.key&&t.key.name,e.apply(this,arguments));return"Identifier"!==i.type||"async"!==i.name||r(this,i.end)||this.input.slice(i.end).match(l)||(h.test(this.input.slice(i.end))?(i=e.apply(this,arguments),t.__asyncValue=!0):(n(t),"set"===t.kind&&this.raise(i.start,"'set (value)' cannot be be async"),i=e.apply(this,arguments),"Identifier"===i.type&&"set"===i.name&&this.raise(i.start,"'set (value)' cannot be be async"),t.__asyncValue=!0)),i}}),e.extend("parseClassMethod",function(e){return function(t,n,r){var i;n.__asyncValue&&("constructor"===n.kind&&this.raise(n.start,"class constructor() cannot be be async"),i=this.inAsyncFunction,this.inAsyncFunction=!0);var s=e.apply(this,arguments);return this.inAsyncFunction=i,s}}),e.extend("parseMethod",function(e){return function(t){var n;this.__currentProperty&&this.__currentProperty.__asyncValue&&(n=this.inAsyncFunction,this.inAsyncFunction=!0);var r=e.apply(this,arguments);return this.inAsyncFunction=n,r}}),e.extend("parsePropertyValue",function(e){return function(t,n,r,i,s,o){var a=this.__currentProperty;this.__currentProperty=t;var u;t.__asyncValue&&(u=this.inAsyncFunction,this.inAsyncFunction=!0);var c=e.apply(this,arguments);return this.inAsyncFunction=u,this.__currentProperty=a,c}})}var a={},u=/^async[\t ]+(return|throw)/,c=/^async[\t ]+function/,l=/^\s*[():;]/,p=/([^\n])\/\*(\*(?!\/)|[^\n*])*\*\/([^\n])/g,h=/\s*(get|set)\s*\(/;t.exports=o},{}],3:[function(e,t,n){function r(e,t){return e.lineStart>=t}function i(e,t,n){var r=t.input.slice(t.start);return n&&(r=r.replace(c,"$1 $3")),e.test(r)}function s(e,t,n){var r=new e.constructor(e.options,e.input,t);if(n)for(var i in n)r[i]=n[i];var s=e,o=r;return["inFunction","inAsync","inGenerator","inModule"].forEach(function(e){e in s&&(o[e]=s[e])}),r.nextToken(),r}function o(e,t){t&&"object"==typeof t||(t={}),e.extend("parse",function(n){return function(){return this.inAsync=t.inAsyncFunction,t.awaitAnywhere&&t.inAsyncFunction&&e.raise(node.start,"The options awaitAnywhere and inAsyncFunction are mutually exclusive"),n.apply(this,arguments)}}),e.extend("parseStatement",function(e){return function(n,r){var s=this.start,o=this.startLoc;if("name"===this.type.label&&t.asyncExits&&i(a,this)){this.next();var u=this.parseStatement(n,r);return u.async=!0,u.start=s,u.loc&&(u.loc.start=o),u.range&&(u.range[0]=s),u}return e.apply(this,arguments)}}),e.extend("parseIdent",function(e){return function(n){return"module"===this.options.sourceType&&this.options.ecmaVersion>=8&&t.awaitAnywhere?e.call(this,!0):e.apply(this,arguments)}}),e.extend("parseExprAtom",function(e){var n={};return function(r){var i,o=this.start,a=(this.startLoc,e.apply(this,arguments));if("Identifier"===a.type&&"await"===a.name&&!this.inAsync&&t.awaitAnywhere){var u=this.startNodeAt(a.start,a.loc&&a.loc.start);o=this.start;var c={raise:function(){try{return pp.raise.apply(this,arguments)}catch(e){throw n}}};try{if(i=s(this,o-4,c).parseExprSubscripts(),i.end<=o)return i=s(this,o,c).parseExprSubscripts(),u.argument=i,u=this.finishNodeAt(u,"AwaitExpression",i.end,i.loc&&i.loc.end),this.pos=i.end,this.end=i.end,this.endLoc=i.endLoc,this.next(),u}catch(e){if(e===n)return a;throw e}}return a}});var n={undefined:!0,get:!0,set:!0,static:!0,async:!0,constructor:!0};e.extend("parsePropertyName",function(e){return function(t){var i=t.key&&t.key.name,s=e.apply(this,arguments);"get"===this.value&&(t.__maybeStaticAsyncGetter=!0);return n[this.value]?s:("Identifier"!==s.type||"async"!==s.name&&"async"!==i||r(this,s.end)||this.input.slice(s.end).match(u)?delete t.__maybeStaticAsyncGetter:"set"===t.kind||"set"===s.name?this.raise(s.start,"'set (value)' cannot be be async"):(this.__isAsyncProp=!0,s=e.apply(this,arguments),"Identifier"===s.type&&"set"===s.name&&this.raise(s.start,"'set (value)' cannot be be async")),s)}}),e.extend("parseClassMethod",function(e){return function(t,n,r){var i=e.apply(this,arguments);return n.__maybeStaticAsyncGetter&&(delete n.__maybeStaticAsyncGetter,"get"!==n.key.name&&(n.kind="get")),i}}),e.extend("parseFunctionBody",function(e){return function(t,n){var r=this.inAsync;this.__isAsyncProp&&(t.async=!0,this.inAsync=!0,delete this.__isAsyncProp);var i=e.apply(this,arguments);return this.inAsync=r,i}})}var a=/^async[\t ]+(return|throw)/,u=/^\s*[):;]/,c=/([^\n])\/\*(\*(?!\/)|[^\n*])*\*\/([^\n])/g;t.exports=o},{}],4:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function i(e){return 3*e.length/4-r(e)}function s(e){var t,n,i,s,o,a,u=e.length;o=r(e),a=new p(3*u/4-o),i=o>0?u-4:u;var c=0;for(t=0,n=0;t>16&255,a[c++]=s>>8&255,a[c++]=255&s;return 2===o?(s=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,a[c++]=255&s):1===o&&(s=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,a[c++]=s>>8&255,a[c++]=255&s),a}function o(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function a(e,t,n){for(var r,i=[],s=t;su?u:o+16383));return 1===r?(t=e[n-1],i+=c[t>>2],i+=c[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=c[t>>10],i+=c[t>>4&63],i+=c[t<<2&63],i+="="),s.push(i),s.join("")}n.byteLength=i,n.toByteArray=s,n.fromByteArray=u;for(var c=[],l=[],p="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,d=h.length;fH)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=i.prototype,t}function i(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return u(e)}return s(e,t,n)}function s(e,t,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?p(e,t,n):"string"==typeof e?c(e,t):h(e)}function o(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function a(e,t,n){return o(e),e<=0?r(e):void 0!==t?"string"==typeof n?r(e).fill(t,n):r(e).fill(t):r(e)}function u(e){return o(e),r(e<0?0:0|f(e))}function c(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var n=0|y(e,t),s=r(n),o=s.write(e,t);return o!==n&&(s=s.slice(0,o)),s}function l(e){for(var t=e.length<0?0:0|f(e.length),n=r(t),i=0;i=H)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+H.toString(16)+" bytes");return 0|e}function d(e){return+e!=e&&(e=0),i.alloc(+e)}function y(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(r)return V(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,n);case"utf8":case"utf-8":return C(this,t,n);case"ascii":return P(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function v(e,t,n,r,s){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof t&&(t=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,s);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,s);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,i){function s(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}var c;if(i){var l=-1;for(c=n;ca&&(n=a-u),c=n;c>=0;c--){for(var p=!0,h=0;hi&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o239?4:s>223?3:s>191?2:1;if(i+a<=n){var u,c,l,p;switch(a){case 1:s<128&&(o=s);break;case 2:u=e[i+1],128==(192&u)&&(p=(31&s)<<6|63&u)>127&&(o=p);break;case 3:u=e[i+1],c=e[i+2],128==(192&u)&&128==(192&c)&&(p=(15&s)<<12|(63&u)<<6|63&c)>2047&&(p<55296||p>57343)&&(o=p);break;case 4:u=e[i+1],c=e[i+2],l=e[i+3],128==(192&u)&&128==(192&c)&&128==(192&l)&&(p=(15&s)<<18|(63&u)<<12|(63&c)<<6|63&l)>65535&&p<1114112&&(o=p)}}null===o?(o=65533,a=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=a}return L(r)}function L(e){var t=e.length;if(t<=Z)return String.fromCharCode.apply(String,e);for(var n="",r=0;r